Welcome to mirror list, hosted at ThFree Co, Russian Federation.

io_import_scene_unreal_psk.py - git.blender.org/blender-addons.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: d8fdcccc13c128bd832c07adc52a42ed06d3c2bd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
# ##### BEGIN GPL LICENSE BLOCK #####
#
#  This program is free software; you can redistribute it and/or
#  modify it under the terms of the GNU General Public License
#  as published by the Free Software Foundation; either version 2
#  of the License, or (at your option) any later version.
#
#  This program is distributed in the hope that it will be useful,
#  but WITHOUT ANY WARRANTY; without even the implied warranty of
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#  GNU General Public License for more details.
#
#  You should have received a copy of the GNU General Public License
#  along with this program; if not, write to the Free Software Foundation,
#  Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
# ##### END GPL LICENSE BLOCK #####

bl_info = {
    "name": "Import Unreal Skeleton Mesh (.psk)",
    "author": "Darknet",
    "version": (2, 1),
    "blender": (2, 6, 2),
    "location": "File > Import > Skeleton Mesh (.psk)",
    "description": "Import Skeleleton Mesh",
    "warning": "",
    "wiki_url": "http://wiki.blender.org/index.php/Extensions:2.5/Py/"
        "Scripts/Import-Export/Unreal_psk_psa",
    "tracker_url": "https://projects.blender.org/tracker/index.php?"\
        "func=detail&aid=21366",
    "category": "Import-Export"}

"""
Version': '2.0' ported by Darknet

Unreal Tournament PSK file to Blender mesh converter V1.0
Author: 
-Darknet (Redesign and reworked)
-D.M. Sturgeon (camg188 at the elYsium forum)
-#2011-01-20 MARIUSZ SZKARADEK GLOGOW POLAND 

Imports a *psk file to a new mesh

-No UV Texutre
-No Weight
-No Armature Bones
-No Material ID
"""

import bpy
import bmesh
import mathutils
import math
from string import *
from struct import *
import struct
from math import *
from bpy.props import *
from bpy_extras.io_utils import unpack_list, unpack_face_list

Quaternion = mathutils.Quaternion

bpy.types.Scene.unrealbonesize = FloatProperty(
    name="Bone Length",
    description="Bone Length from head to tail distance",
    default=1,min=0.001,max=1000)

#output log in to txt file
DEBUGLOG = False

scale = 1.0
bonesize = 1.0
skala = 1
flipyz = False   
flipuv = True

"""
def unpack_list(list_of_tuples):
    l = []
    for t in list_of_tuples:
        l.extend(t)
    return l
"""	
#pack read words	
def word(long): 
   s=''
   for j in range(0,long): 
       lit =  struct.unpack('c',plik.read(1))[0]
       #print(">",lit)
       #print(">",bytes.decode(lit))
       if ord(lit)!=0:
           #print(lit)
           s+=bytes.decode(lit)
           if len(s)>100:
               break
   return s
#pack read data   
def b(n):
    return struct.unpack(n*'b', plik.read(n))
def B(n):
    return struct.unpack(n*'B', plik.read(n))
def h(n):
    return struct.unpack(n*'h', plik.read(n*2))
def H(n):
    return struct.unpack(n*'H', plik.read(n*2))
def i(n):
    return struct.unpack(n*'i', plik.read(n*4))
def f(n):
    return struct.unpack(n*'f', plik.read(n*4))

#work in progress
#bmesh
#tess function prefix
def drawmesh():
    global DEBUGLOG, plik,vertexes,uvcoord,faceslist,num_faces,facemat,facesmooth,m
    global vertexes_ids,bonesdata,meshesdata,groups,num_materials,skala,flipyz,flipuv,mat_faceslist
    global vertices,faces
    print(faces[0])
    print("[CREATING MESH:]")
    me_ob = bpy.data.meshes.new('testmesh')
    #create mesh
    print("-Vertices count:",len(vertices))
    me_ob.vertices.add(len(vertices))
    print("-Faces count:",len(faces))
    me_ob.tessfaces.add(len(faces))
    print("-Creating vertices points...")
    me_ob.vertices.foreach_set("co", unpack_list(vertices))
    print("-Creating faces idx...")
    me_ob.tessfaces.foreach_set("vertices_raw",unpack_list( faces))
    for face in me_ob.tessfaces:
        print(dir(face))
        face.use_smooth = facesmooth[face.index]
        #face.material_index = facemat[face.index]#not yet working
    print("-Creating UV Texture...")
    me_ob.tessface_uv_textures.new('uvtexture')
    #uvtex = me_ob.tessface_uv_textures[0]
    for uv in me_ob.tessface_uv_textures:
        for face in me_ob.tessfaces:
            #uv.data[face.index].uv1.x = 
            
            #print(uv.data[face.index].uv1)
            #uv.data[face.index].uv1 = Vector(uvcoord[faces[face.index]][0],uvcoord[face.index][1])
            print(face.vertices_raw[0],face.vertices_raw[1],face.vertices_raw[2])
            uv.data[face.index].uv1 = mathutils.Vector((uvcoord[face.vertices_raw[0]][0],uvcoord[face.vertices_raw[0]][1]))
            uv.data[face.index].uv2 = mathutils.Vector((uvcoord[face.vertices_raw[1]][0],uvcoord[face.vertices_raw[1]][1]))
            uv.data[face.index].uv3 = mathutils.Vector((uvcoord[face.vertices_raw[2]][0],uvcoord[face.vertices_raw[2]][1]))

    ob = bpy.data.objects.new("TestObject",me_ob)
    #create vertex group
    for bone_id in range(len(bonesdata)):
        bonedata = bonesdata[str(bone_id)]
        namebone = bonedata[0]#.strip()[-25:]
        #print("NAME:",namebone)
        ob.vertex_groups.new(namebone)
    me_ob.update()
    bpy.context.scene.objects.link(ob) 
def drawmesh4():
    global DEBUGLOG, plik,vertexes,uvcoord,faceslist,num_faces,facemat,facesmooth,m
    global vertexes_ids,bonesdata,meshesdata,groups,num_materials,skala,flipyz,flipuv,mat_faceslist
    global vertices,faces
    print("CREATING MESH")
    me_ob = bpy.data.meshes.new('testmesh')
    print("CREATING BMESH")
    bm = bmesh.new()   # create an empty BMesh    
    #print(dir(bm))
    bm.from_mesh(me_ob)   # fill it in from a Mesh
        
    #print("CREATING:")
    
    #vertices
    #print("-VERTICES")
    #for v_co in vertices:
        #bm.verts.new(v_co)
    
    #faces
    #print("-FACES")
    for f_idx in faces:
        #face idx
        bm.faces.new([bm.verts[i] for i in f_idx])
    
    print("-FACE SMOOTHS")
    for face in bm.faces:
        face.smooth = facesmooth[face.index]    
    
    bm.to_mesh(me_ob) #write mesh
    ob = bpy.data.objects.new("TestObject",me_ob) 
    me_ob.update() #update object
    bpy.context.scene.objects.link(ob) #link to scene
    
    #print(dir(bm))
    
    #create vertex group
    for bone_id in range(len(bonesdata)):
        bonedata = bonesdata[str(bone_id)]
        namebone = bonedata[0]#.strip()[-25:]
        #print("NAME:",namebone)
        ob.vertex_groups.new(namebone)
        
    #print("CREATING > Assign Weights")
    
    
    materialname = "pskmat"
    psktexname = "psktex"
    
    me_ob.uv_textures.new()
    for matcount in range(1):
        matdata = bpy.data.materials.new(materialname + str(1))
        me_ob.materials.append(matdata)
    
    
    print(dir(me_ob))
    #me_ob.tessface_uv_textures.new(name=psktexname)
    #me_ob.uv_textures.new(name=psktexname)
    #me_ob.uv_textures[0].active =True
    
    #print((me_ob.uv_textures[0].name))
    #print(dir(me_ob.uv_textures[0]))
    #for uv in me_ob.uv_textures:
        #print(dir(uv.data[0]))
        
    """
    print("NEW TEXTURE")
    me_ob.uv_textures.new()
    
    print("CREATING UV")
    for uv in me_ob.uv_textures:
        #print(len(uv.data))
        for face in bm.faces:
            print(dir(face.verts[0]))
            #print(dir(uv.data[face.index].image))
            #print(dir(uv.data[face.index]))
    
    print("CREATING > Vertex Group")
    """
    bpy.context.scene.update()
def drawmesh3():
    global DEBUGLOG, plik,vertexes,uvcoord,faceslist,num_faces,facemat,facesmooth,m
    global vertexes_ids,bonesdata,meshesdata,groups,num_materials,skala,flipyz,flipuv,mat_faceslist
    global vertices,faces
    print("CREATING MESH")
    me_ob = bpy.data.meshes.new('testmesh')
    print("CREATING BMESH")
    bm = bmesh.new()   # create an empty BMesh    
    #print(dir(bm))
    bm.from_mesh(me_ob)   # fill it in from a Mesh
        
    print("CREATING:")
    
    #vertices
    print("-VERTICES")
    for v_co in vertices:
        bm.verts.new(v_co)
    
    #faces
    print("-FACES")
    for f_idx in faces:
        #face idx
        bm.faces.new([bm.verts[i] for i in f_idx])
    
    print("-FACE SMOOTHS")
    for face in bm.faces:
        face.smooth = facesmooth[face.index]    
    
    bm.to_mesh(me_ob) #write mesh
    ob = bpy.data.objects.new("TestObject",me_ob) 
    me_ob.update() #update object
    bpy.context.scene.objects.link(ob) #link to scene
    
    #print(dir(bm))
    
    #create vertex group
    for bone_id in range(len(bonesdata)):
        bonedata = bonesdata[str(bone_id)]
        namebone = bonedata[0]#.strip()[-25:]
        #print("NAME:",namebone)
        ob.vertex_groups.new(namebone)
        
    #print("CREATING > Assign Weights")
    
    
    materialname = "pskmat"
    psktexname = "psktex"
    
    me_ob.uv_textures.new()
    for matcount in range(1):
        matdata = bpy.data.materials.new(materialname + str(1))
        me_ob.materials.append(matdata)
    
    
    print(dir(me_ob))
    me_ob.tessface_uv_textures.new(name=psktexname)
    #me_ob.uv_textures.new(name=psktexname)
    #me_ob.uv_textures[0].active =True
    
    #print((me_ob.uv_textures[0].name))
    #print(dir(me_ob.uv_textures[0]))
    #for uv in me_ob.uv_textures:
        #print(dir(uv.data[0]))
        
    """
    print("NEW TEXTURE")
    me_ob.uv_textures.new()
    
    print("CREATING UV")
    for uv in me_ob.uv_textures:
        #print(len(uv.data))
        for face in bm.faces:
            print(dir(face.verts[0]))
            #print(dir(uv.data[face.index].image))
            #print(dir(uv.data[face.index]))
    
    print("CREATING > Vertex Group")
    """
    bpy.context.scene.update()    
def drawmesh1():
    global DEBUGLOG, plik,vertexes,uvcoord,faceslist,num_faces,facemat,facesmooth,m
    global vertexes_ids,bonesdata,meshesdata,groups,num_materials,skala,flipyz,flipuv,mat_faceslist
    global vertices,faces
    print(faces[0])
    me_ob = bpy.data.meshes.new('testmesh')
    #obmesh = bpy.data.objects.new('testdata',me_ob)
    #uvtex = me_ob.uv_textures.new(name="pskuvtexture")
    #uvtex = me_ob.tessface_uv_textures.new(name="pskuvtexture")
    
    #material = bpy.data.materials.new('pskmat')
    #me_ob.materials.append(material)
    #uvtex = me_ob.uv_textures.new('pskuvtexture')
    
    #create mesh
    #me_ob.from_pydata(vertexes,[],faceslist)#create the faces and vertices
	
    me_ob.vertices.add(len(vertices))
    me_ob.tessfaces.add(len(faces))
    me_ob.vertices.foreach_set("co", unpack_list(vertices))
    me_ob.tessfaces.foreach_set("vertices_raw",unpack_list( faces))
    
    
    
    #bm = bmesh.new()   # create an empty BMesh    
    #print(dir(bm))
    #bm.from_mesh(me_ob)   # fill it in from a Mesh
    
    
    #for v_co in vertices:
        #bm.verts.new(v_co)
    #for f_idx in faces:
        #bm.faces.new([bm.verts[i] for i in f_idx])
    
    
    #bm.to_mesh(me_ob)
    ob = bpy.data.objects.new("TestObject",me_ob)
    me_ob.update()
    bpy.context.scene.objects.link(ob) 
    
    #set face smooth list boolean
    #for face in bm.faces:
        #face.smooth = facesmooth[face.index]
    #bm.uv_textures.new()
    #print(dir(bm))
    #bm.verts.foreach_set("co", vertices)
    #bm.faces.add(len(faces))
    #bm.faces.foreach_set("vertices_raw", faces)
    
    #print(dir(me_ob))
    #print(dir(bm))
    
    #print(dir(uvtex.data[0].image))
    #for countm in range(len(me_ob.uv_textures)):
        #me_ob.update()
        #uvtex = me_ob.uv_textures[countm] #add one uv texture
        #me_ob.update()
        #for i, face in enumerate(bm.faces):
            #print(dir(face))
        
        
        
        
    #texture
    #texture = bpy.data.textures.new(name="texture",type='IMAGE')
    #material
    #matdata = bpy.data.materials.new(name="pskmat")
    #mtex = matdata.texture_slots.add()
    #mtex.texture = texture
    #mtex.texture_coords = 'UV'
    #mtex.use_map_color_diffuse = True
    #mtex.use_map_alpha = True
    #uvtex = me_ob.uv_textures[0]
    
    #print(dir(uvtex.data[0]))
    #print(dir(uvtex.data[0].image))
    #print(dir(texture))
    
    #for i, face in enumerate(bm.faces):
        #print(face.material_index)
        #face.material_index = faceuv[i][1]
        #blender_tface = uvtex.data[i].image #face
    """
    
    #mesh vertex group #not done
	#create vertex group
    for bone_id in range(len(bonesdata)):
       bonedata = bonesdata[str(bone_id)]
       namebone = bonedata[0]#.strip()[-25:]
       obmesh.vertex_groups.new(namebone)
    #assgin group
    for m in range(len(groups)):
            data = groups[m]
            w = float(data[0])
            v_id = data[1]
            gr = data[2]
            gr = bonenames[gr]
    
    #for vgroup in obmesh.vertex_groups:
        #print(vgroup.name,":",vgroup.index)
    
        for vgp in RWghts:
            #bone index
            if vgp[1] == vgroup.index:
                #print(vgp)
                #[vertex id],weight
                vgroup.add([vgp[0]], vgp[2], 'ADD')
    """
    
    
    # Finish up, write the bmesh back to the mesh
    #bm.to_mesh(me_ob)
    
    
    
    #print((uvtex.name))
    #print((uvtex.data))
    #print(dir(uvtex))
    #print(dir(uvtex.data[0].image))
    #print(type(uvtex.data[0].image))
    
    
    
    #bpy.context.scene.objects.link(obmesh)    
    bpy.context.scene.update()	
#Create Armature
def check_armature():
    global DEBUGLOG, plik,vertexes,uvcoord,faceslist,num_faces,facemat,facesmooth,m
    global vertexes_ids,bonesdata,meshesdata,groups,num_materials,skala,flipyz,flipuv,amt
    
    #create Armature
    bpy.ops.object.mode_set(mode='OBJECT')
    for i in bpy.context.scene.objects: i.select = False #deselect all objects

    bpy.ops.object.add(
     type='ARMATURE', 
     enter_editmode=True,
     location=(0,0,0))
    ob = bpy.context.object
    ob.show_x_ray = True
    ob.name = "ARM"
    amt = ob.data
    amt.name = 'Amt'
    amt.show_axes = True
    bpy.ops.object.mode_set(mode='EDIT')
    bpy.context.scene.update()
#Create bones
def make_bone():    
    global DEBUGLOG, plik,vertexes,uvcoord,faceslist,num_faces,facemat,facesmooth,m
    global vertexes_ids,bonesdata,meshesdata,groups,num_materials,skala,flipyz,flipuv,amt
    global bonenames
    bonenames = []
    
    print ('make bone')
    
    for bone_id in range(len(bonesdata)):
       bonedata = bonesdata[str(bone_id)]
       namebone = bonedata[0]#.strip()[-25:]
       newbone = amt.edit_bones.new(namebone)
       #those are need to show in the scene
       newbone.head = (0,0,0)
       newbone.tail = (0,0,1)
       bonenames.append(namebone)
    bpy.context.scene.update()
#Make bone parent
def make_bone_parent():    
    global DEBUGLOG, plik,vertexes,uvcoord,faceslist,num_faces,facemat,facesmooth,m
    global vertexes_ids,bonesdata,meshesdata,groups,num_materials,skala,flipyz,flipuv,amt    
    global children
    children = {}
    
    print ('make bone parent')
    for bone_id in range(len(bonesdata)):
        bonedata = bonesdata[str(bone_id)]
        namebone  = bonenames[bone_id]
        nameparent = bonenames[bonedata[1][2]]
        #print(nameparent)
        if nameparent != None:#make sure it has name
           parentbone = amt.edit_bones[nameparent]
           bonecurrnet = amt.edit_bones[namebone]
           bonecurrnet.parent = parentbone
    bpy.context.scene.update()

#make bone martix set    
def bones_matrix():    
    global DEBUGLOG, plik,vertexes,uvcoord,faceslist,num_faces,facemat,facesmooth,m
    global vertexes_ids,bonesdata,meshesdata,groups,num_materials,skala,flipyz,flipuv,amt
    
    for bone_id in range(len(bonesdata)):
        bonedata = bonesdata[str(bone_id)]
        namebone = bonedata[0]#.strip()[-25:]
        nameparent = bonenames[bonedata[1][2]]
        pos = bonedata[2][4:7] 
        rot = bonedata[2][0:4] 
        qx,qy,qz,qw = rot[0],rot[1],rot[2],rot[3]
        #print("Quaternion:",qx,qy,qz,qw)
        if bone_id==0:
            rot =  mathutils.Quaternion((qw,-qx,-qy,-qz))
        if bone_id!=0:
            rot =  mathutils.Quaternion((qw,qx,qy,qz))
        matrix = mathutils.Matrix()
        rot = rot.to_matrix().inverted()
        #print(rot)
        matrix[0][:3] = rot[0]
        matrix[1][:3] = rot[1]
        matrix[2][:3] = rot[2]
        matrix[3][:3] = pos
        if bone_id>0:
            bonedata.append(matrix*bonesdata[str(bonedata[1][2])][3])
        else:
            bonedata.append(matrix)
    bpy.context.scene.update()

#not working    
def make_bone_position():
    print ('make bone position')
    bpy.ops.object.mode_set(mode='EDIT')
    for bone_id in range(len(bonesdata)):
        bonedata = bonesdata[str(bone_id)]
        namebone = bonedata[0]#.strip()[-25:]
        bone = amt.edit_bones[namebone]
        bone.transform(bonedata[3], scale=True, roll=True)
        bvec = bone.tail- bone.head
        bvec.normalize()
        bone.tail = bone.head + 0.1 * bvec
        #bone.tail = bone.head + 1 * bvec
    bpy.context.scene.update()    
        
#not working  
def make_bone_position1():    
    print ('make bone position')
    bpy.ops.object.mode_set(mode='EDIT')
    for bone_id in range(len(bonesdata)):
        bonedata = bonesdata[str(bone_id)]
        namebone = bonedata[0]#.strip()[-25:]
        pos = bonedata[2][4:7] 
        pos1 = pos[0]*skala  
        pos2 = pos[1]*skala  
        pos3 = pos[2]*skala 
        if flipyz == False:
            pos = [pos1,pos2,pos3]
        if flipyz == True:
            pos = [pos1,-pos3,pos2]
        rot = bonedata[2][0:4] 
        qx,qy,qz,qw = rot[0],rot[1],rot[2],rot[3]
        if bone_id==0:
            rot = mathutils.Quaternion((qw,-qx,-qy,-qz))
        if bone_id!=0:
            rot = mathutils.Quaternion((qw,qx,qy,qz))
        #rot = rot.toMatrix().invert() 	
        rot = rot.to_matrix().inverted() 	
        bone = amt.edit_bones[namebone]
        #print("BONES:",amt.bones[0])
        
        if bone_id!=0:
            bone.head = bone.parent.head+mathutils.Vector(pos) * bone.parent.matrix
            #print(dir(rot))
            #print("rot:",rot)
            #print("matrix:",bone.parent.matrix)
            
            tempM = rot.to_4x4()*bone.parent.matrix
            #bone.matrix = tempM
            bone.transform(tempM, scale=False, roll=True)
            #bone.matrix_local = tempM
        else:
            bone.head = mathutils.Vector(pos)
            #bone.matrix = rot
            bone.transform(rot, scale=False, roll=True)
            #bone.matrix_local = rot
        bvec = bone.tail- bone.head
        bvec.normalize()
        bone.tail = bone.head + 0.1 * bvec
        #bone.tail = bone.head + 1 * bvec
    

#http://www.blender.org/forum/viewtopic.php?t=13340&sid=8b17d5de07b17960021bbd72cac0495f            
def fixRollZ(b):
    v = (b.tail-b.head)/b.length
    b.roll -= math.degrees(math.atan2(v[0]*v[2]*(1 - v[1]),v[0]*v[0] + v[1]*v[2]*v[2])) 
def fixRoll(b):
    v = (b.tail-b.head)/b.length
    if v[2]*v[2] > .5:
        #align X-axis
        b.roll += math.degrees(math.atan2(v[0]*v[2]*(1 - v[1]),v[2]*v[2] + v[1]*v[0]*v[0]))
    else:
        #align Z-axis
        b.roll -= math.degrees(math.atan2(v[0]*v[2]*(1 - v[1]),v[0]*v[0] + v[1]*v[2]*v[2])) 
""" #did not port this yet unstable but work in some ways
def make_bone_position3():    
            for bone in md5_bones:
                #print(dir(bone))
                bpy.ops.object.mode_set(mode='EDIT')
                newbone = ob_new.data.edit_bones.new(bone.name)
                #parent the bone
                print("DRI:",dir(newbone))
                parentbone = None
                print("bone name:",bone.name)
                #note bone location is set in the real space or global not local
                bonesize = bpy.types.Scene.unrealbonesize
                if bone.name != bone.parent:

                    pos_x = bone.bindpos[0]
                    pos_y = bone.bindpos[1]
                    pos_z = bone.bindpos[2]
                    
                    #print( "LINKING:" , bone.parent ,"j")
                    parentbone = ob_new.data.edit_bones[bone.parent]
                    newbone.parent = parentbone
                    
                    rotmatrix = bone.bindmat.to_matrix().to_4x4().to_3x3()  # XXX, redundant matrix conversion?
                    newbone.transform(bone.bindmat.to_matrix().to_4x4(),True,True)
                    #parent_head = parentbone.matrix.to_quaternion().inverse() * parentbone.head
                    #parent_tail = parentbone.matrix.to_quaternion().inverse() * parentbone.tail
                    #location=Vector(pos_x,pos_y,pos_z)
                    #set_position = (parent_tail - parent_head) + location
                    #print("tmp head:",set_position)

                    #pos_x = set_position.x
                    #pos_y = set_position.y
                    #pos_z = set_position.z
                    
                 
                    newbone.head.x = parentbone.head.x + pos_x
                    newbone.head.y = parentbone.head.y + pos_y
                    newbone.head.z = parentbone.head.z + pos_z
                    #print("head:",newbone.head)
                    newbone.tail.x = parentbone.head.x + (pos_x + bonesize * rotmatrix[0][1])
                    newbone.tail.y = parentbone.head.y + (pos_y + bonesize * rotmatrix[1][1])
                    newbone.tail.z = parentbone.head.z + (pos_z + bonesize * rotmatrix[2][1])
                    #newbone.roll = fixRoll(newbone)
                else:
                    #print("rotmatrix:",dir(bone.bindmat.to_matrix().resize_4x4()))
                    #rotmatrix = bone.bindmat.to_matrix().resize_4x4().to_3x3()  # XXX, redundant matrix conversion?
                    rotmatrix = bone.bindmat.to_matrix().to_3x3()  # XXX, redundant matrix conversion?
                    #newbone.transform(bone.bindmat.to_matrix(),True,True)
                    newbone.head.x = bone.bindpos[0]
                    newbone.head.y = bone.bindpos[1]
                    newbone.head.z = bone.bindpos[2]
                    newbone.tail.x = bone.bindpos[0] + bonesize * rotmatrix[0][1]
                    newbone.tail.y = bone.bindpos[1] + bonesize * rotmatrix[1][1]
                    newbone.tail.z = bone.bindpos[2] + bonesize * rotmatrix[2][1]
                    #newbone.roll = fixRoll(newbone)
                    #print("no parent")    
""" 
    

#import psk file
def pskimport(filename,importmesh,importbone,bDebugLogPSK,importmultiuvtextures):
    global DEBUGLOG, plik,vertexes,uvcoord,faceslist,num_faces,facemat,facesmooth,m
    global vertexes_ids,bonesdata,meshesdata,groups,num_materials,skala,flipyz,flipuv,amt,vertices,faces
    points = []
    vertexes = []
    vertices = []
    uvcoord = []
    faceslist = []
    datafaces = []
    faces = []
    facemat = []
    facesmooth = []
    groups = []
    vertexes_ids = []
    bonesdata = {}
    meshesdata ={}
	
    DEBUGLOG = bDebugLogPSK
    print ("--------------------------------------------------")
    print ("---------SCRIPT EXECUTING PYTHON IMPORTER---------")
    print ("--------------------------------------------------")
    print (" DEBUG Log:",bDebugLogPSK)
    print ("Importing file: ", filename)
    
    plik = open(filename,'rb')
    word(20),i(3)
    
    #------POINTS------
    print ('reading points')
    word(20)
    data = i(3)
    num_points = data[2]    
    for m in range(num_points):
        v=f(3)
        v1 =v[0]*skala
        v2 =v[1]*skala
        v3 =v[2]*skala
        if flipyz == False:
            points.append([v1,v2,v3])
        if flipyz == True:
            points.append([v1,-v3,v2])
        vertexes_ids.append([])
    
    #------VERTEXES----
    print ('reading vertexes')
    word(20)
    data = i(3)
    num_vertexes = data[2]
    for m in range(num_vertexes):
        data1 = H(2)
        vertexes.append(points[data1[0]])
        vertices.append(points[data1[0]])
        #vertices.extend(points[data1[0]])
        #vertices.extend([(points[data1[0]][0],points[data1[0]][1],points[data1[0]][2] )])
        #vertices.extend([(points[data1[0]][0],points[data1[0]][1],points[data1[0]][2] )])
        #print(points[data1[0]])
        if flipuv == False:
            uvcoord.append([f(1)[0],1-f(1)[0]])
        if flipuv == True:
            uvcoord.append([f(1)[0],f(1)[0]])
        vertexes_ids[data1[0]].append(m)
        b(2),h(1)
    
    
    #------FACES-------
    print ('reading faces')
    word(20)
    data = i(3)
    num_faces = data[2]
    for m in range(num_faces):
        v0=H(1)[0]
        v1=H(1)[0]
        v2=H(1)[0]
        faceslist.append([v1,v0,v2])
        faces.extend([(v1,v0,v2,0)])
        #faces.append([v1,v0,v2])
        #print((v1,v0,v2,0))
        mat_ids = B(2) 
        facemat.append(mat_ids)
        if str(mat_ids[0]) not in meshesdata:
            meshesdata[str(mat_ids[0])] = []          
        meshesdata[str(mat_ids[0])].append(m)
        facesmooth.append(i(1)[0])
        #datafaces.append([v1,v0,v2],mat_ids
    
    #------MATERIALS---
    print ('making materials')
    word(20)
    data = i(3)
    num_materials = data[2]
    for m in range(num_materials):
        name = word(64)
        print ('read materials from',name)
        matdata = bpy.data.materials.new(name)
        #try:
            #mat = Material.Get(namemodel+'-'+str(m))
            #mat = Material.Get(name)
        #except:
            #mat = Material.New(namemodel+'-'+str(m))
            #mat = Material.New(name)
        i(6)
        #make_materials(name,mat)
    
    #-------BONES------
    print ('reading bones')
    #check_armature()
    check_armature()
    word(20)
    data = i(3)
    num_bones = data[2]
    for m in range(num_bones):
        #print(str(m)) #index
        bonesdata[str(m)] = []
        bonename = word(64)
        bonename = bonename#.strip() 
        bonename = bonename.strip() 
        #print(bonename)#bone name
        bonesdata[str(m)].append(bonename)
        bonesdata[str(m)].append(i(3))
        bonesdata[str(m)].append(f(11))
    make_bone()
    make_bone_parent()
    bones_matrix()
    make_bone_position1()

    
     #-------SKINNING---
    print ('making skinning')
    word(20)
    data = i(3)
    num_groups = data[2]
    
    for m in range(num_groups):
        w = f(1)[0]
        v_id  = i(1)[0]         
        gr = i(1)[0]
        groups.append([w,v_id,gr]) 
    #create Mesh
    drawmesh()

    print ("IMPORTER PSK Blender 2.6 completed")
#End of def pskimport#########################

def getInputFilename(self,filename,importmesh,importbone,bDebugLogPSK,importmultiuvtextures):
    checktype = filename.split('\\')[-1].split('.')[1]
    print ("------------",filename)
    if checktype.lower() != 'psk':
        print ("  Selected file = ",filename)
        raise (IOError, "The selected input file is not a *.psk file")
        #self.report({'INFO'}, ("Selected file:"+ filename))
    else:
        pskimport(filename,importmesh,importbone,bDebugLogPSK,importmultiuvtextures)
#import panel
class IMPORT_OT_psk(bpy.types.Operator):
    '''Load a skeleton mesh psk File'''
    bl_idname = "import_scene.psk"
    bl_label = "Import PSK"
    bl_space_type = "PROPERTIES"
    bl_region_type = "WINDOW"
    bl_options = {'UNDO'}

    # List of operator properties, the attributes will be assigned
    # to the class instance from the operator settings before calling.
    filepath = StringProperty(
            subtype='FILE_PATH',
            )
    filter_glob = StringProperty(
            default="*.psk",
            options={'HIDDEN'},
            )
    importmesh = BoolProperty(
            name="Mesh",
            description="Import mesh only. (not yet build.)",
            default=True,
            )
    importbone = BoolProperty(
            name="Bones",
            description="Import bones only. Current not working yet",
            default=True,
            )
    importmultiuvtextures = BoolProperty(
            name="Single UV Texture(s)",
            description="Single or Multi uv textures",
            default=True,
            )
    bDebugLogPSK = BoolProperty(
            name="Debug Log.txt",
            description="Log the output of raw format. It will save in " \
                        "current file dir. Note this just for testing",
            default=False,
            )
    unrealbonesize = FloatProperty(
            name="Bone Length",
            description="Bone Length from head to tail distance",
            default=1,
            min=0.001,
            max=1000,
            )

    def execute(self, context):
        bpy.types.Scene.unrealbonesize = self.unrealbonesize
        getInputFilename(self,self.filepath,self.importmesh,self.importbone,self.bDebugLogPSK,self.importmultiuvtextures)
        return {'FINISHED'}

    def invoke(self, context, event):
        wm = context.window_manager
        wm.fileselect_add(self)
        return {'RUNNING_MODAL'}  
#import panel psk	
class OBJECT_OT_PSKPath(bpy.types.Operator):
    bl_idname = "object.pskpath"
    bl_label = "PSK Path"
    __doc__ = ""

    filepath = StringProperty(
            subtype='FILE_PATH',
            )
    filter_glob = StringProperty(
            default="*.psk",
            options={'HIDDEN'},
            )
    importmesh = BoolProperty(
            name="Mesh",
            description="Import mesh only. (not yet build.)",
            default=True,
            )
    importbone = BoolProperty(
            name="Bones",
            description="Import bones only. Current not working yet",
            default=True,
            )
    importmultiuvtextures = BoolProperty(
            name="Single UV Texture(s)",
            description="Single or Multi uv textures",
            default=True,
            )
    bDebugLogPSK = BoolProperty(
            name="Debug Log.txt",
            description="Log the output of raw format. It will save in " \
                        "current file dir. Note this just for testing",
            default=False,
            )
    unrealbonesize = FloatProperty(
            name="Bone Length",
            description="Bone Length from head to tail distance",
            default=1,
            min=0.001,
            max=1000,
            )
    
    def execute(self, context):
        #context.scene.importpskpath = self.properties.filepath
        bpy.types.Scene.unrealbonesize = self.unrealbonesize
        getInputFilename(self,self.filepath,self.importmesh,self.importbone,self.bDebugLogPSK,self.importmultiuvtextures)
        return {'FINISHED'}
        
    def invoke(self, context, event):
        #bpy.context.window_manager.fileselect_add(self)
        wm = context.window_manager
        wm.fileselect_add(self)
        return {'RUNNING_MODAL'}
#import panel psa		
class OBJECT_OT_PSAPath(bpy.types.Operator):
    bl_idname = "object.psapath"
    bl_label = "PSA Path"
    __doc__ = ""

    filepath = StringProperty(name="PSA File Path", description="Filepath used for importing the PSA file", maxlen= 1024, default= "")
    filter_glob = StringProperty(
            default="*.psa",
            options={'HIDDEN'},
            )
    def execute(self, context):
        context.scene.importpsapath = self.properties.filepath
        return {'FINISHED'}
        
    def invoke(self, context, event):
        bpy.context.window_manager.fileselect_add(self)
        return {'RUNNING_MODAL'}
		
class OBJECT_OT_Path(bpy.types.Operator):
    bl_idname = "object.path"
    bl_label = "MESH BUILD"
    __doc__ = ""
    # generic transform props
    view_align = BoolProperty(
            name="Align to View",
            default=False,
            )
    location = FloatVectorProperty(
            name="Location",
            subtype='TRANSLATION',
            )
    rotation = FloatVectorProperty(
            name="Rotation",
            subtype='EULER',
            )
    def execute(self, context):
        return {'FINISHED'}
        
    def invoke(self, context, event):
        me = bpy.data.meshes.new("test")
        obmade = bpy.data.objects.new("TestObject",me)
        print("Create Simple Mesh")
        bpy.data.scenes[0].objects.link(obmade)
        for i in bpy.context.scene.objects: i.select = False #deselect all objects
        obmade.select = True
        bpy.context.scene.objects.active = obmade
        
        verts = [(0,0,0),(2,0,0),(2,0,2)]
        edges = [(0,1),(1,2),(2,0)]
        faces = []
        faces.extend([(0,1,2,0)])
        #me.vertices.add(len(verts))
        #print(dir(me))
        me.vertices.add(len(verts))
        me.tessfaces.add(len(faces))
        for face in me.tessfaces:
            print(dir(face))
        
        me.vertices.foreach_set("co", unpack_list(verts))
        me.tessfaces.foreach_set("vertices_raw", unpack_list(faces))
        me.edges.add(len(edges))
        me.edges.foreach_set("vertices", unpack_list(edges))
        
        #print(len(me.tessfaces))
        me.tessface_uv_textures.new("uvtexture")
        #for uv in me.tessface_uv_textures:
            #print(len(uv.data))
            #print(dir(uv.data[0]))
            #print(dir(uv.data[0].uv1))
        return {'RUNNING_MODAL'}
"""
class OBJECT_OT_Path(bpy.types.Operator):
    bl_idname = "object.path"
    bl_label = "MESH BUILD"
    __doc__ = ""
    # generic transform props
    view_align = BoolProperty(
            name="Align to View",
            default=False,
            )
    location = FloatVectorProperty(
            name="Location",
            subtype='TRANSLATION',
            )
    rotation = FloatVectorProperty(
            name="Rotation",
            subtype='EULER',
            )
    def execute(self, context):
        return {'FINISHED'}
        
    def invoke(self, context, event):
        me = bpy.data.meshes.new("test")
        obmade = bpy.data.objects.new("TestObject",me)
        print("Create Simple Mesh")
        bpy.data.scenes[0].objects.link(obmade)
        for i in bpy.context.scene.objects: i.select = False #deselect all objects
        obmade.select = True
        bpy.context.scene.objects.active = obmade
        
        #bpy.ops.object.mode_set(mode='EDIT')
        #me.from_pydata([(0,0,0),(2,0,0),(2,0,2)],[(1,2),(2,3),(3,1)],[(1,2,3)])
        #me.from_pydata([(0,0,0),(2,0,0),(2,0,2)],[(1,2),(2,3),(3,1)],[(1,2,3)])
        verts = [(0,0,0),(2,0,0),(2,0,2)]
        #faces = [([0, 1, 2])]
        
        faces = []
        #faces.extend([(1,2,3,0)])
        faces.extend([(0,1,2,0)])
        #print(faces[0][0])
        #print(dir(me.tessfaces))
        me.vertices.add(len(verts))
        me.vertices.foreach_set("co", unpack_list(verts))
        
        me.tessfaces.add(len(faces))
        #me.tessfaces.foreach_set("vertices_raw", unpack_list(faces))
        me.tessfaces.foreach_set("vertices", unpack_list(faces))
        #me.tessfaces.foreach_set("vertices_raw", (faces))
        print(len(me.tessfaces))
        me.tessface_uv_textures.new("uvtexture")
        for uv in me.tessface_uv_textures:
            print(len(uv.data))
            print(dir(uv.data[0]))
        bm = bmesh.new()
        bm.to_mesh(me)
        #for v_co in verts:
            #bm.verts.new(v_co)
        for f_idx in faces:
            bm.faces.new([bm.verts[i] for i in f_idx])
        #bm.to_mesh(me)
        #ob = bpy.data.objects.new("TestObject",me)
        #me.update()
        
        #print(dir(me))
        #me.uv_textures.new("uvtexture")
        #for uv in me.uv_textures:
            #print(len(uv.data))
        #from bpy_extras import object_utils
        #object_utils.object_data_add(context, me, operator=self)
        #ob = bpy.data.objects.new("TestObject",me)
        #bpy.context.scene.objects.link(ob) 

        return {'RUNNING_MODAL'}		
"""
"""
class OBJECT_OT_Path(bpy.types.Operator):
    bl_idname = "object.path"
    bl_label = "PSA Path"
    __doc__ = ""
    # generic transform props
    view_align = BoolProperty(
            name="Align to View",
            default=False,
            )
    location = FloatVectorProperty(
            name="Location",
            subtype='TRANSLATION',
            )
    rotation = FloatVectorProperty(
            name="Rotation",
            subtype='EULER',
            )
    def execute(self, context):
        return {'FINISHED'}
        
    def invoke(self, context, event):
        me = bpy.data.meshes.new("test")
        #ob = bpy.data.objects.new("TestObject",me)
        print("Create Simple Mesh")
        #bpy.data.scenes[0].objects.link(ob)
        
        #me.from_pydata([(0,0,0),(2,0,0),(2,0,2)],[(1,2),(2,3),(3,1)],[(1,2,3)])
        #me.from_pydata([(0,0,0),(2,0,0),(2,0,2)],[(1,2),(2,3),(3,1)],[(1,2,3)])
        verts = [(0,0,0),(2,0,0),(2,0,2)]
        faces = [(0, 1, 2)]
        #faces = [([1,2,3])]
        
        
        bm = bmesh.new()
 
        for v_co in verts:
            bm.verts.new(v_co)

        for f_idx in faces:
            bm.faces.new([bm.verts[i] for i in f_idx])

        bm.to_mesh(me)
        ob = bpy.data.objects.new("TestObject",me)
        me.update()
        
        print(dir(me))
        me.uv_textures.new("uvtexture")
        for uv in me.uv_textures:
            print(len(uv.data))
        
        
        
        
        #from bpy_extras import object_utils
        #object_utils.object_data_add(context, me, operator=self)
        bpy.context.scene.objects.link(ob) 

        return {'RUNNING_MODAL'}
"""
"""		
class OBJECT_OT_Path(bpy.types.Operator):
    bl_idname = "object.path"
    bl_label = "PSA Path"
    __doc__ = ""
    # generic transform props
    view_align = BoolProperty(
            name="Align to View",
            default=False,
            )
    location = FloatVectorProperty(
            name="Location",
            subtype='TRANSLATION',
            )
    rotation = FloatVectorProperty(
            name="Rotation",
            subtype='EULER',
            )
    #filepath = StringProperty(name="PSA File Path", description="Filepath used for importing the PSA file", maxlen= 1024, default= "")
    #filter_glob = StringProperty(
            #default="*.psa",
            #options={'HIDDEN'},
            #)
    def execute(self, context):
        #context.scene.importpsapath = self.properties.filepath
        return {'FINISHED'}
        
    def invoke(self, context, event):
        me = bpy.data.meshes.new("test")
        #ob = bpy.data.objects.new("TestObject",me)
        print("Create Simple Mesh")
        #bpy.data.scenes[0].objects.link(ob)
        
        #me.from_pydata([(0,0,0),(2,0,0),(2,0,2)],[(1,2),(2,3),(3,1)],[(1,2,3)])
        #me.from_pydata([(0,0,0),(2,0,0),(2,0,2)],[(1,2),(2,3),(3,1)],[(1,2,3)])
        verts = [(0,0,0),(2,0,0),(2,0,2)]
        faces = [(0, 1, 2, 3)]
        #faces = [([1,2,3])]
        
        
        bm = bmesh.new()
 
        for v_co in verts:
            bm.verts.new(v_co)

        #for f_idx in faces:
            #bm.faces.new([bm.verts[i] for i in f_idx])
        bm.to_mesh(me)
        me.update()
        from bpy_extras import object_utils
        object_utils.object_data_add(context, me, operator=self)
        
        #bpy.context.scene.objects.link(me) 
      
        #me.from_pydata(verts,[],faces)
        me.vertices.add(len(verts))
        me.tessfaces.add(len(faces))
        
        me.vertices.foreach_set("co", unpack_list(verts))
        me.tessfaces.foreach_set("vertices_raw", (faces))#not working
        
        me.update()
       
        #bpy.context.window_manager.fileselect_add(self)
        return {'RUNNING_MODAL'}		
"""
#import menu panel tool bar
class VIEW3D_PT_unrealimport_objectmode(bpy.types.Panel):
    bl_space_type = "VIEW_3D"
    bl_region_type = "TOOLS"
    bl_label = "Import PSK/PSA"
    
    @classmethod
    def poll(cls, context):
        return context.active_object

    def draw(self, context):
        layout = self.layout
        rd = context.scene

        row2 = layout.row(align=True)
        row2.operator(OBJECT_OT_PSKPath.bl_idname)                
        row2.operator(OBJECT_OT_PSAPath.bl_idname)        
        row2.operator(OBJECT_OT_Path.bl_idname)        
#import panel
def menu_func(self, context):
    self.layout.operator(IMPORT_OT_psk.bl_idname, text="Skeleton Mesh (.psk)")

def register():
    bpy.utils.register_module(__name__)
    bpy.types.INFO_MT_file_import.append(menu_func)
    
def unregister():
    bpy.utils.unregister_module(__name__)
    bpy.types.INFO_MT_file_import.remove(menu_func)

if __name__ == "__main__":
    register()

#note this only read the data and will not be place in the scene    
#getInputFilename('C:\\blenderfiles\\BotA.psk') 
#getInputFilename('C:\\blenderfiles\\AA.PSK')
#getInputFilename('C:\\blender26x\\blender-2.psk')