-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathGetSkeletonTransforms.py
More file actions
34 lines (25 loc) · 1.1 KB
/
GetSkeletonTransforms.py
File metadata and controls
34 lines (25 loc) · 1.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
from pxr import Usd, UsdGeom, UsdPhysics, UsdShade, UsdSkel, Sdf, Gf, Tf
import omni.kit
# Get stage.
stage = omni.usd.get_context().get_stage()
# Get selection.
selection = omni.usd.get_context().get_selection()
paths = selection.get_selected_prim_paths()
skel_cache = UsdSkel.Cache()
#time_code = omni.timeline.get_timeline_interface().get_current_time() * stage.GetTimeCodesPerSecond()
time_code = Usd.TimeCode.Default()
for path in paths:
# Get prim.
prim = stage.GetPrimAtPath(path)
if prim.IsValid() and prim.GetTypeName() == 'Skeleton':
# Get transform from cache.
skel_query = skel_cache.GetSkelQuery(UsdSkel.Skeleton(prim))
transforms = skel_query.ComputeJointLocalTransforms(time_code)
# joints name.
jointNames = skel_query.GetJointOrder()
# joints matrix to translate, rotations, scales.
translates, rotations, scales = UsdSkel.DecomposeTransforms(transforms)
print(jointNames)
print(" Translates : " + str(translates))
print(" Rotations : " + str(rotations))
print(" Scales : " + str(scales))