University of Southern CaliforniaUSC
USC ICT TwitterUSC ICT FacebookUSC ICT YouTube

Trying to parse a .skm file | General SmartBody Discussion | Forum

Avatar

Please consider registering
guest

sp_LogInOut Log In sp_Registration Register

Register | Lost password?
Advanced Search

— Forum Scope —




— Match —





— Forum Options —





Minimum search word length is 3 characters - maximum search word length is 84 characters

sp_Feed Topic RSS sp_TopicIcon
Trying to parse a .skm file
September 10, 2015
6:50 pm
Avatar
Member
Members
Forum Posts: 3
Member Since:
September 10, 2015
sp_UserOfflineSmall Offline

Hello,

I'm trying to parse a .skm and display it as an animation in the Blender animation software. The character is loaded in Blender using the .dae file. .skm files are parsed using a python script.

- the .dae file is located in the Smartbody repository at the following path:
data/mesh/ChrBrad/ChrBrad.dae

- the .skm file id located in the Smartbody repository at the following path:
data/ChrMaarten/motion/ChrBrad@Entrance.skm

Orientations are obtained from 3 coordinated in .skm file according to the following routine:
elif channel == 'Quat':
  x = float(valueArray[counter+values_offset])
  counter += 1
  y = float(valueArray[counter+values_offset])
  counter += 1
  z = float(valueArray[counter+values_offset])
  counter += 1
  w = math.sqrt((x*x+y*y+z*z))

channelDict[bone][2] = mathutils.Quaternion(mathutils.Vector((x,y,z)),w) #instanciate quaternion from axis-angle

Quaternions are later applied in the local frame to Brad's armature, resulting in the pose depicted in the picture referenced by the link below. The pose is not correct and I am wondering what might be the problem. Would you have any idea?

[pic]: http://www.tiikoni.com/tis/view/?id=b0546a8

September 11, 2015
6:06 pm
Avatar
Admin
Forum Posts: 983
Member Since:
December 1, 2011
sp_UserOfflineSmall Offline

Did you also parse the prerot line in the .sk which adds a rotational offset to each joint in axis/angle format?

prerot  axis 0.585462 -0.560775 -0.585462 ang 121.434761 

 

Ari

September 12, 2015
2:30 pm
Avatar
Member
Members
Forum Posts: 3
Member Since:
September 10, 2015
sp_UserOfflineSmall Offline

Thank you for your answer,

Did you also parse the prerot line in the .sk which adds a rotational offset to each joint in axis/angle format?

No, I directly applied the orientation in the .skm the the .dae skeleton imported in Blender, hoping that I could avoid writing an importer for the .sk.

Following your advice, I wrote an importer for .sk files in Blender. I could parse the bone hierarchy and bone length correctly but I have trouble parsing the prerot information. I actually need to know if prerot describes the bone orientation in absolute (relative to root bone) or relative coordinates (relative to parent bone). Also, if prerot relates to absolute orientation, should this orientation's pivot be the root origin or the bone head? 

Alexis

September 12, 2015
11:59 pm
Avatar
Admin
Forum Posts: 983
Member Since:
December 1, 2011
sp_UserOfflineSmall Offline

It's a local rotation. The final orientation will be the joint quaternion x joint prerotation quaternion.

 

Ari

September 13, 2015
12:46 pm
Avatar
Member
Members
Forum Posts: 3
Member Since:
September 10, 2015
sp_UserOfflineSmall Offline

OK, I didn't account for the fact that angles in .sk files are specified in degrees. Thank you for the quick reply.

I'm now facing a Blender-related issue : In Blender, local frames's y axis always follows the bone's principal direction. I will therefore need to use intermediate empties (with .sk compliant local frames) to drive the blender bones.

I do not have so much time for implementation but will get back to you ASAP.

Alexis.