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

git.blender.org/blender-addons.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2011-07-25 13:09:46 +0400
committerCampbell Barton <ideasman42@gmail.com>2011-07-25 13:09:46 +0400
commitd71455d4c1534a1949f6fb0e6ab0fcb1ceb7c2f8 (patch)
tree1ab3c49dd272c80edf473f5fa4ffd8250ec848bc /io_import_scene_unreal_psk.py
parent48c9da843c40ff8a97b462d8539185b662ba1567 (diff)
switch vector multiplication order & some style changes.
Diffstat (limited to 'io_import_scene_unreal_psk.py')
-rw-r--r--io_import_scene_unreal_psk.py90
1 files changed, 60 insertions, 30 deletions
diff --git a/io_import_scene_unreal_psk.py b/io_import_scene_unreal_psk.py
index edc7cd02..fe4b4e75 100644
--- a/io_import_scene_unreal_psk.py
+++ b/io_import_scene_unreal_psk.py
@@ -382,7 +382,7 @@ def pskimport(infile,importmesh,importbone,bDebugLogPSK,importmultiuvtextures):
bpy.context.scene.objects.active = ob_new
#set mode to able to edit the bone
bpy.ops.object.mode_set(mode='EDIT')
-
+
#newbone = ob_new.data.edit_bones.new('test')
#newbone.tail.y = 1
print("creating bone(s)")
@@ -391,8 +391,8 @@ def pskimport(infile,importmesh,importbone,bDebugLogPSK,importmultiuvtextures):
bpy.ops.object.mode_set(mode='EDIT')
newbone = ob_new.data.edit_bones.new(bone.name)
'''
-
-
+
+
armdata = bpy.data.armatures.new(objectname)
ob_new = bpy.data.objects.new(meshname, armdata)
#ob_new = bpy.data.objects.new(meshname, 'ARMATURE')
@@ -405,7 +405,7 @@ def pskimport(infile,importmesh,importbone,bDebugLogPSK,importmultiuvtextures):
bpy.context.scene.objects.active = ob_new
#set mode to able to edit the bone
bpy.ops.object.mode_set(mode='EDIT')
-
+
#newbone = ob_new.data.edit_bones.new('test')
#newbone.tail.y = 1
print("creating bone(s)")
@@ -420,7 +420,7 @@ def pskimport(infile,importmesh,importbone,bDebugLogPSK,importmultiuvtextures):
#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]
@@ -431,12 +431,12 @@ def pskimport(infile,importmesh,importbone,bDebugLogPSK,importmultiuvtextures):
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.head * parentbone.matrix.to_quaternion().inverse()
- #parent_tail = parentbone.tail * parentbone.matrix.to_quaternion().inverse()
+ #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
@@ -462,7 +462,7 @@ def pskimport(infile,importmesh,importbone,bDebugLogPSK,importmultiuvtextures):
newbone.tail.y = bone.bindpos[1] + bonesize * rotmatrix[1][1]
newbone.tail.z = bone.bindpos[2] + bonesize * rotmatrix[1][2]
#newbone.roll = fixRoll(newbone)
- #print("no parent")
+ #print("no parent")
bpy.context.scene.update()
@@ -549,13 +549,13 @@ def pskimport(infile,importmesh,importbone,bDebugLogPSK,importmultiuvtextures):
me_ob.update_tag()
"""
- Material setup coding.
- First the mesh has to be create first to get the uv texture setup working.
- -Create material(s) list in the psk pack data from the list.(to do list)
- -Append the material to the from create the mesh object.
- -Create Texture(s)
- -fae loop for uv assign and assign material index
-
+ Material setup coding.
+ First the mesh has to be create first to get the uv texture setup working.
+ -Create material(s) list in the psk pack data from the list.(to do list)
+ -Append the material to the from create the mesh object.
+ -Create Texture(s)
+ -fae loop for uv assign and assign material index
+
"""
bpy.ops.object.mode_set(mode='OBJECT')
#===================================================================================================
@@ -566,7 +566,7 @@ def pskimport(infile,importmesh,importbone,bDebugLogPSK,importmultiuvtextures):
print ("-------------------------")
materialname = "pskmat"
materials = []
-
+
for matcount in range(materialcount):
#if texturedata != None:
matdata = bpy.data.materials.new(materialname + str(matcount))
@@ -582,7 +582,7 @@ def pskimport(infile,importmesh,importbone,bDebugLogPSK,importmultiuvtextures):
#matdata.texture_coords = 'UV'
#matdata.active_texture = texturedata
materials.append(matdata)
-
+
for material in materials:
#add material to the mesh list of materials
me_ob.materials.append(material)
@@ -622,7 +622,7 @@ def pskimport(infile,importmesh,importbone,bDebugLogPSK,importmultiuvtextures):
for countm in range(materialcount):
psktexname="psk" + str(countm)
me_ob.uv_textures.new(name=psktexname)
- #psktexname="psk" + str(countm)
+ #psktexname="psk" + str(countm)
#me_ob.uv_textures.new(name=psktexname)
for countm in range(len(me_ob.uv_textures)):
me_ob.update()
@@ -672,8 +672,8 @@ def pskimport(infile,importmesh,importbone,bDebugLogPSK,importmultiuvtextures):
#for face in me_ob.faces:
#print(dir(face))
-
-
+
+
'''
matdata = bpy.data.materials.new(materialname)
#color is 0 - 1 not in 0 - 255
@@ -717,7 +717,7 @@ def pskimport(infile,importmesh,importbone,bDebugLogPSK,importmultiuvtextures):
#print(vgp)
#[vertex id],weight
vgroup.add([vgp[0]], vgp[2], 'ADD')
-
+
#check if there is a material to set to
if len(materials) > 0:
obmesh.active_material = materials[0] #material setup tmp
@@ -744,16 +744,46 @@ class IMPORT_OT_psk(bpy.types.Operator):
bl_label = "Import PSK"
bl_space_type = "PROPERTIES"
bl_region_type = "WINDOW"
-
+
# List of operator properties, the attributes will be assigned
# to the class instance from the operator settings before calling.
- filepath = StringProperty(name="File Path", description="Filepath used for importing the psk file", maxlen= 1024, 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)
+ filepath = StringProperty(
+ name="File Path",
+ description="Filepath used for importing the psk file",
+ maxlen= 1024,
+ 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