Getting Bone Coordinates with Python


https://forum.reallusion.com/Topic434223.aspx
Print Topic | Close Window

By edwardjaywang - 4 Years Ago
Hi,

I am looking to get the coordinates of individual bones in my avatar. My goal is to create a partial visualization of the Wireframe Render State. For my project, I am trying to get the wireframe of my avatar's face as they make various facial expressions.
 
I have been able to write a script to get all the Transform objects of the Bone Nodes(which I assume are the leaf nodes that have 0 children), by traversing the bone tree, starting from the avatar.GetSkeletonComponent.GetSkinBones() iterable object. However, once I get to the leaf nodes at the bottom of the bone hierarchy, I have not been able to find a way to get the X, Y, Z, coordinates and angles that I need to recreate the visual in another medium.

Any help is greatly appreciated. Thank you.
By elMartino - 4 Years Ago
Not entirely sure what exactly you want to do but most likely your facial expressions will also be controlled by morphs and not just bones. Anyhow, how do the bones help you to with the wire frame you want to see? If you want to blend in the wire frame partially I would render your scene twice, once with the wire frame and one time regular and then blend it in the post production with Adobe Premiere or a tool like it. You can just overlay both videos and make it transparent with masks.
By Lord Ashes - 4 Years Ago
Probably something like this may be what you are looking at:


import RLPy

RLPy.RGlobal.Stop()

print("Get Rope Object")
avatar = RLPy.RScene.GetSelectedObjects()[0]

print("Get Bones")
motion_bones = avatar.GetSkeletonComponent().GetMotionBones()

print("Create clip")
clip = avatar.GetSkeletonComponent().AddClip(RLPy.RGlobal.GetTime())

for bone in motion_bones:
   rotX = clip.GetControl("Layer", bone).GetDataBlock().GetControl("Rotation/RotationX")
   rotY = clip.GetControl("Layer", bone).GetDataBlock().GetControl("Rotation/RotationY")
   rotZ = clip.GetControl("Layer", bone).GetDataBlock().GetControl("Rotation/RotationZ")
   print("X:%d,Y:%d,Z:%d"%(rotX,rotY,rotZ))


There is probably equivalent Translation/TranslationX, Translation/TranslationY and Translation/TranslationZ controls (although they may be named differently).

[Update]
I believe the other properties are actually called Position/PositionX, 
Position/PositionZ and Position/PositionZ.