Profile Picture

Getting Bone Coordinates with Python

Posted By edwardjaywang 4 Years Ago
You don't have permission to rate!
Author
Message
edwardjaywang
edwardjaywang
Posted 4 Years Ago
View Quick Profile
Senior Member

Senior Member (328 reputation)Senior Member (328 reputation)Senior Member (328 reputation)Senior Member (328 reputation)Senior Member (328 reputation)Senior Member (328 reputation)Senior Member (328 reputation)Senior Member (328 reputation)Senior Member (328 reputation)

Group: Forum Members
Last Active: 4 Years Ago
Posts: 3, Visits: 60
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.
elMartino
elMartino
Posted 4 Years Ago
View Quick Profile
Senior Member

Senior Member (312 reputation)Senior Member (312 reputation)Senior Member (312 reputation)Senior Member (312 reputation)Senior Member (312 reputation)Senior Member (312 reputation)Senior Member (312 reputation)Senior Member (312 reputation)Senior Member (312 reputation)

Group: Forum Members
Last Active: 3 Years Ago
Posts: 9, Visits: 701
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.
Lord Ashes
Lord Ashes
Posted 4 Years Ago
View Quick Profile
Distinguished Member

Distinguished Member (20.8K reputation)Distinguished Member (20.8K reputation)Distinguished Member (20.8K reputation)Distinguished Member (20.8K reputation)Distinguished Member (20.8K reputation)Distinguished Member (20.8K reputation)Distinguished Member (20.8K reputation)Distinguished Member (20.8K reputation)Distinguished Member (20.8K reputation)

Group: Forum Members
Last Active: Last Week
Posts: 1.3K, Visits: 1.6K
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.

"We often compare ourselves to the U.S. and often they come out the best, but they only have the right to bear arms while we have the right to bare breasts"
Bowser and Blue, Busting The Breast
Edited
4 Years Ago by Lord Ashes



Reading This Topic