|
| 1 | +#usda 1.0 |
| 2 | + |
| 3 | +# A prototype containing a skeleton and a couple of cubes, one of them skinned. |
| 4 | + |
| 5 | +def Scope "Prototypes" |
| 6 | +{ |
| 7 | + |
| 8 | + uniform token visibility = "invisible" |
| 9 | + |
| 10 | + def SkelRoot "SkeletonRoot" ( |
| 11 | + prepend apiSchemas = ["SkelBindingAPI"] |
| 12 | + ) |
| 13 | + { |
| 14 | + def Skeleton "Skeleton" ( |
| 15 | + prepend apiSchemas = ["SkelBindingAPI"] |
| 16 | + ) |
| 17 | + { |
| 18 | + uniform matrix4d[] bindTransforms = [( (1, 0, 0, 0), (0, 1, 0, 0), (0, 0, 1, 0), (0, 0, 0, 1) )] |
| 19 | + uniform token[] joints = ["Joint1"] |
| 20 | + uniform matrix4d[] restTransforms = [( (1, 0, 0, 0), (0, 1, 0, 0), (0, 0, 1, 0), (0, 0, 0, 1) )] |
| 21 | + } |
| 22 | + |
| 23 | + def Mesh "SkinnedCube" ( |
| 24 | + prepend apiSchemas = ["SkelBindingAPI"] |
| 25 | + ) |
| 26 | + { |
| 27 | + int[] faceVertexCounts = [4, 4, 4, 4, 4, 4] |
| 28 | + int[] faceVertexIndices = [0, 1, 3, 2, 2, 3, 5, 4, 4, 5, 7, 6, 6, 7, 1, 0, 1, 7, 5, 3, 6, 0, 2, 4] |
| 29 | + uniform token subdivisionScheme = "none" |
| 30 | + point3f[] points = [(-0.5, -0.5, 0.5), (0.5, -0.5, 0.5), (-0.5, 0.5, 0.5), (0.5, 0.5, 0.5), (-0.5, 0.5, -0.5), (0.5, 0.5, -0.5), (-0.5, -0.5, -0.5), (0.5, -0.5, -0.5)] |
| 31 | + matrix4d primvars:skel:geomBindTransform = ( (1, 0, 0, 0), (0, 1, 0, 0), (0, 0, 1, 0), (0, 0, 0, 1) ) |
| 32 | + int[] primvars:skel:jointIndices = [0, 0, 0, 0, 0, 0, 0, 0] ( |
| 33 | + elementSize = 1 |
| 34 | + interpolation = "vertex" |
| 35 | + ) |
| 36 | + float[] primvars:skel:jointWeights = [1, 1, 1, 1, 1, 1, 1, 1] ( |
| 37 | + elementSize = 1 |
| 38 | + interpolation = "vertex" |
| 39 | + ) |
| 40 | + rel skel:skeleton = </Prototypes/SkeletonRoot/Skeleton> |
| 41 | + } |
| 42 | + |
| 43 | + # Just regular geometry. Even though it's inside a SkelRoot, it |
| 44 | + # shouldn't be affected by SkelAnimation at all. |
| 45 | + def Mesh "UnskinnedCube" |
| 46 | + { |
| 47 | + int[] faceVertexCounts = [4, 4, 4, 4, 4, 4] |
| 48 | + int[] faceVertexIndices = [0, 1, 3, 2, 2, 3, 5, 4, 4, 5, 7, 6, 6, 7, 1, 0, 1, 7, 5, 3, 6, 0, 2, 4] |
| 49 | + uniform token subdivisionScheme = "none" |
| 50 | + point3f[] points = [(-0.5, -0.5, 0.5), (0.5, -0.5, 0.5), (-0.5, 0.5, 0.5), (0.5, 0.5, 0.5), (-0.5, 0.5, -0.5), (0.5, 0.5, -0.5), (-0.5, -0.5, -0.5), (0.5, -0.5, -0.5)] |
| 51 | + } |
| 52 | + } |
| 53 | + |
| 54 | +} |
| 55 | + |
| 56 | +# Instance of the prototype, with an animation inherited onto it. |
| 57 | + |
| 58 | +def Xform "Instance1" ( |
| 59 | + prepend apiSchemas = ["SkelBindingAPI"] |
| 60 | +) |
| 61 | +{ |
| 62 | + append rel skel:animationSource = </Instance1/InlineAnim> |
| 63 | + |
| 64 | + def SkelAnimation "InlineAnim" |
| 65 | + { |
| 66 | + uniform token[] joints = ["Joint1"] |
| 67 | + quatf[] rotations = [(1, 0, 0, 0)] |
| 68 | + half3[] scales = [(1, 1, 1)] |
| 69 | + float3[] translations = [(0, 0, 1)] |
| 70 | + } |
| 71 | + |
| 72 | + over "SkeletonRoot" ( |
| 73 | + instanceable = true |
| 74 | + prepend references = </Prototypes/SkeletonRoot> |
| 75 | + ) |
| 76 | + { |
| 77 | + } |
| 78 | +} |
| 79 | + |
| 80 | +# Another instance of the prototype, with a different animation inherited onto it. |
| 81 | + |
| 82 | +def SkelAnimation "SeparateAnim" |
| 83 | +{ |
| 84 | + uniform token[] joints = ["Joint1"] |
| 85 | + quatf[] rotations = [(1, 0, 0, 0)] |
| 86 | + half3[] scales = [(1, 1, 1)] |
| 87 | + float3[] translations = [(0, 0, -1)] |
| 88 | +} |
| 89 | + |
| 90 | +def Xform "Group" ( |
| 91 | + prepend apiSchemas = ["SkelBindingAPI"] |
| 92 | +) |
| 93 | +{ |
| 94 | + append rel skel:animationSource = </SeparateAnim> |
| 95 | + |
| 96 | + def Xform "Instance2" |
| 97 | + { |
| 98 | + over "SkeletonRoot" ( |
| 99 | + instanceable = true |
| 100 | + prepend references = </Prototypes/SkeletonRoot> |
| 101 | + ) |
| 102 | + { |
| 103 | + } |
| 104 | + } |
| 105 | +} |
| 106 | + |
| 107 | +# A third instance, this time sharing the animation with the second instance. |
| 108 | + |
| 109 | +def Xform "Instance3" ( |
| 110 | + prepend apiSchemas = ["SkelBindingAPI"] |
| 111 | +) |
| 112 | +{ |
| 113 | + append rel skel:animationSource = </SeparateAnim> |
| 114 | + over "SkeletonRoot" ( |
| 115 | + instanceable = true |
| 116 | + prepend references = </Prototypes/SkeletonRoot> |
| 117 | + ) |
| 118 | + { |
| 119 | + } |
| 120 | +} |
| 121 | + |
| 122 | +# And now an instanceable reference to the third instance. |
| 123 | + |
| 124 | +def Xform "Instance4" ( |
| 125 | + instanceable = true |
| 126 | + prepend references = </Instance3> |
| 127 | +) |
| 128 | +{ |
| 129 | +} |
0 commit comments