Skip to content
Snippets Groups Projects
Commit b39de231 authored by John Phan's avatar John Phan
Browse files

No commit message

No commit message
parent 23fc6a34
No related branches found
No related tags found
No related merge requests found
...@@ -55,11 +55,14 @@ import re ...@@ -55,11 +55,14 @@ import re
from string import * from string import *
from struct import * from struct import *
from math import * from math import *
from bpy.props import *
#from bpy.props import *
import mathutils import mathutils
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 #output log in to txt file
DEBUGLOG = False DEBUGLOG = False
...@@ -333,11 +336,11 @@ def pskimport(infile,importmesh,importbone,bDebugLogPSK,importmultiuvtextures): ...@@ -333,11 +336,11 @@ def pskimport(infile,importmesh,importbone,bDebugLogPSK,importmultiuvtextures):
#w,x,y,z #w,x,y,z
if (counter == 0):#main parent if (counter == 0):#main parent
print("no parent bone") print("no parent bone")
createbone.bindmat = mathutils.Quaternion((indata[7],indata[4],indata[5],indata[6])) createbone.bindmat = mathutils.Quaternion((indata[7],indata[4],indata[5],indata[6]))#default
#createbone.bindmat = mathutils.Quaternion((indata[7],-indata[4],-indata[5],-indata[6])) #createbone.bindmat = mathutils.Quaternion((indata[7],-indata[4],-indata[5],-indata[6]))
else:#parent else:#parent
print("parent bone") print("parent bone")
createbone.bindmat = mathutils.Quaternion((indata[7],-indata[4],-indata[5],-indata[6])) createbone.bindmat = mathutils.Quaternion((indata[7],-indata[4],-indata[5],-indata[6]))#default
#createbone.bindmat = mathutils.Quaternion((indata[7],indata[4],indata[5],indata[6])) #createbone.bindmat = mathutils.Quaternion((indata[7],indata[4],indata[5],indata[6]))
md5_bones.append(createbone) md5_bones.append(createbone)
...@@ -421,20 +424,23 @@ def pskimport(infile,importmesh,importbone,bDebugLogPSK,importmultiuvtextures): ...@@ -421,20 +424,23 @@ def pskimport(infile,importmesh,importbone,bDebugLogPSK,importmultiuvtextures):
bpy.ops.object.mode_set(mode='EDIT') bpy.ops.object.mode_set(mode='EDIT')
newbone = ob_new.data.edit_bones.new(bone.name) newbone = ob_new.data.edit_bones.new(bone.name)
#parent the bone #parent the bone
print("DRI:",dir(newbone))
parentbone = None parentbone = None
print("bone name:",bone.name) print("bone name:",bone.name)
#note bone location is set in the real space or global not local #note bone location is set in the real space or global not local
bonesize = bpy.types.Scene.unrealbonesize
if bone.name != bone.parent: if bone.name != bone.parent:
pos_x = bone.bindpos[0] pos_x = bone.bindpos[0]
pos_y = bone.bindpos[1] pos_y = bone.bindpos[1]
pos_z = bone.bindpos[2] pos_z = bone.bindpos[2]
#print( "LINKING:" , bone.parent ,"j") #print( "LINKING:" , bone.parent ,"j")
parentbone = ob_new.data.edit_bones[bone.parent] parentbone = ob_new.data.edit_bones[bone.parent]
newbone.parent = parentbone newbone.parent = parentbone
rotmatrix = bone.bindmat.to_matrix().to_4x4().to_3x3() # XXX, redundant matrix conversion? 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_head = parentbone.head * parentbone.matrix.to_quaternion().inverse()
#parent_tail = parentbone.tail * parentbone.matrix.to_quaternion().inverse() #parent_tail = parentbone.tail * parentbone.matrix.to_quaternion().inverse()
#location=Vector(pos_x,pos_y,pos_z) #location=Vector(pos_x,pos_y,pos_z)
...@@ -444,7 +450,8 @@ def pskimport(infile,importmesh,importbone,bDebugLogPSK,importmultiuvtextures): ...@@ -444,7 +450,8 @@ def pskimport(infile,importmesh,importbone,bDebugLogPSK,importmultiuvtextures):
#pos_x = set_position.x #pos_x = set_position.x
#pos_y = set_position.y #pos_y = set_position.y
#pos_z = set_position.z #pos_z = set_position.z
newbone.head.x = parentbone.head.x + pos_x newbone.head.x = parentbone.head.x + pos_x
newbone.head.y = parentbone.head.y + pos_y newbone.head.y = parentbone.head.y + pos_y
newbone.head.z = parentbone.head.z + pos_z newbone.head.z = parentbone.head.z + pos_z
...@@ -452,16 +459,19 @@ def pskimport(infile,importmesh,importbone,bDebugLogPSK,importmultiuvtextures): ...@@ -452,16 +459,19 @@ def pskimport(infile,importmesh,importbone,bDebugLogPSK,importmultiuvtextures):
newbone.tail.x = parentbone.head.x + (pos_x + bonesize * rotmatrix[1][0]) newbone.tail.x = parentbone.head.x + (pos_x + bonesize * rotmatrix[1][0])
newbone.tail.y = parentbone.head.y + (pos_y + bonesize * rotmatrix[1][1]) newbone.tail.y = parentbone.head.y + (pos_y + bonesize * rotmatrix[1][1])
newbone.tail.z = parentbone.head.z + (pos_z + bonesize * rotmatrix[1][2]) newbone.tail.z = parentbone.head.z + (pos_z + bonesize * rotmatrix[1][2])
#newbone.roll = fixRoll(newbone)
else: else:
#print("rotmatrix:",dir(bone.bindmat.to_matrix().resize_4x4())) #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().resize_4x4().to_3x3() # XXX, redundant matrix conversion?
rotmatrix = bone.bindmat.to_matrix().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.x = bone.bindpos[0]
newbone.head.y = bone.bindpos[1] newbone.head.y = bone.bindpos[1]
newbone.head.z = bone.bindpos[2] newbone.head.z = bone.bindpos[2]
newbone.tail.x = bone.bindpos[0] + bonesize * rotmatrix[1][0] newbone.tail.x = bone.bindpos[0] + bonesize * rotmatrix[1][0]
newbone.tail.y = bone.bindpos[1] + bonesize * rotmatrix[1][1] newbone.tail.y = bone.bindpos[1] + bonesize * rotmatrix[1][1]
newbone.tail.z = bone.bindpos[2] + bonesize * rotmatrix[1][2] newbone.tail.z = bone.bindpos[2] + bonesize * rotmatrix[1][2]
#newbone.roll = fixRoll(newbone)
#print("no parent") #print("no parent")
bpy.context.scene.update() bpy.context.scene.update()
...@@ -738,8 +748,6 @@ def getInputFilename(self,filename,importmesh,importbone,bDebugLogPSK,importmult ...@@ -738,8 +748,6 @@ def getInputFilename(self,filename,importmesh,importbone,bDebugLogPSK,importmult
else: else:
pskimport(filename,importmesh,importbone,bDebugLogPSK,importmultiuvtextures) pskimport(filename,importmesh,importbone,bDebugLogPSK,importmultiuvtextures)
from bpy.props import *
class IMPORT_OT_psk(bpy.types.Operator): class IMPORT_OT_psk(bpy.types.Operator):
'''Load a skeleton mesh psk File''' '''Load a skeleton mesh psk File'''
bl_idname = "import_scene.psk" bl_idname = "import_scene.psk"
...@@ -755,8 +763,10 @@ class IMPORT_OT_psk(bpy.types.Operator): ...@@ -755,8 +763,10 @@ class IMPORT_OT_psk(bpy.types.Operator):
importbone = BoolProperty(name="Bones", description="Import bones only. Current not working yet.", 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) 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) 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): def execute(self, context):
bpy.types.Scene.unrealbonesize = self.unrealbonesize
getInputFilename(self,self.filepath,self.importmesh,self.importbone,self.bDebugLogPSK,self.importmultiuvtextures) getInputFilename(self,self.filepath,self.importmesh,self.importbone,self.bDebugLogPSK,self.importmultiuvtextures)
return {'FINISHED'} return {'FINISHED'}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment