1 //
2 // Copyright 2016 Pixar
3 //
4 // Licensed under the Apache License, Version 2.0 (the "Apache License")
5 // with the following modification; you may not use this file except in
6 // compliance with the Apache License and the following modification to it:
7 // Section 6. Trademarks. is deleted and replaced with:
8 //
9 // 6. Trademarks. This License does not grant permission to use the trade
10 // names, trademarks, service marks, or product names of the Licensor
11 // and its affiliates, except as required to comply with Section 4(c) of
12 // the License and to reproduce the content of the NOTICE file.
13 //
14 // You may obtain a copy of the Apache License at
15 //
16 // http://www.apache.org/licenses/LICENSE-2.0
17 //
18 // Unless required by applicable law or agreed to in writing, software
19 // distributed under the Apache License with the above modification is
20 // distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
21 // KIND, either express or implied. See the Apache License for the specific
22 // language governing permissions and limitations under the Apache License.
23 //
24 #include "pxr/usd/usdSkel/animQuery.h"
25
26 #include "pxr/usd/usd/pyConversions.h"
27 #include "pxr/base/tf/pyContainerConversions.h"
28 #include "pxr/base/tf/pyResultConversions.h"
29 #include "pxr/base/tf/pyUtils.h"
30 #include "pxr/base/tf/wrapTypeHelpers.h"
31
32 #include "pxr/usd/usd/prim.h"
33
34 #include "pxr/base/gf/interval.h"
35
36 #include <boost/python.hpp>
37
38 #include <vector>
39
40
41 using namespace boost::python;
42
43 PXR_NAMESPACE_USING_DIRECTIVE
44
45
46 namespace {
47
48
49 VtMatrix4dArray
_ComputeJointLocalTransforms(const UsdSkelAnimQuery & self,UsdTimeCode time)50 _ComputeJointLocalTransforms(const UsdSkelAnimQuery& self, UsdTimeCode time)
51 {
52 VtMatrix4dArray xforms;
53 self.ComputeJointLocalTransforms(&xforms, time);
54 return xforms;
55 }
56
57
58 boost::python::tuple
_ComputeJointLocalTransformComponents(const UsdSkelAnimQuery & self,UsdTimeCode time)59 _ComputeJointLocalTransformComponents(const UsdSkelAnimQuery& self, UsdTimeCode time)
60 {
61 VtVec3fArray translations;
62 VtQuatfArray rotations;
63 VtVec3hArray scales;
64 self.ComputeJointLocalTransformComponents(&translations, &rotations,
65 &scales, time);
66 return boost::python::make_tuple(translations, rotations, scales);
67 }
68
69
70 VtFloatArray
_ComputeBlendShapeWeights(const UsdSkelAnimQuery & self,UsdTimeCode time)71 _ComputeBlendShapeWeights(const UsdSkelAnimQuery& self, UsdTimeCode time)
72 {
73 VtFloatArray weights;
74 self.ComputeBlendShapeWeights(&weights, time);
75 return weights;
76 }
77
78
79 std::vector<double>
_GetJointTransformTimeSamples(const UsdSkelAnimQuery & self)80 _GetJointTransformTimeSamples(const UsdSkelAnimQuery& self)
81 {
82 std::vector<double> times;
83 self.GetJointTransformTimeSamples(×);
84 return times;
85 }
86
87
88 std::vector<double>
_GetJointTransformTimeSamplesInInterval(const UsdSkelAnimQuery & self,const GfInterval & interval)89 _GetJointTransformTimeSamplesInInterval(const UsdSkelAnimQuery& self,
90 const GfInterval& interval)
91 {
92 std::vector<double> times;
93 self.GetJointTransformTimeSamplesInInterval(interval, ×);
94 return times;
95 }
96
97
98 std::vector<double>
_GetBlendShapeWeightTimeSamples(const UsdSkelAnimQuery & self)99 _GetBlendShapeWeightTimeSamples(const UsdSkelAnimQuery& self)
100 {
101 std::vector<double> times;
102 self.GetBlendShapeWeightTimeSamples(×);
103 return times;
104 }
105
106
107 std::vector<double>
_GetBlendShapeWeightTimeSamplesInInterval(const UsdSkelAnimQuery & self,const GfInterval & interval)108 _GetBlendShapeWeightTimeSamplesInInterval(const UsdSkelAnimQuery& self,
109 const GfInterval& interval)
110 {
111 std::vector<double> times;
112 self.GetBlendShapeWeightTimeSamplesInInterval(interval, ×);
113 return times;
114 }
115
116
117 } // namespace
118
119
wrapUsdSkelAnimQuery()120 void wrapUsdSkelAnimQuery()
121 {
122 using This = UsdSkelAnimQuery;
123
124 class_<This>("AnimQuery", no_init)
125
126 .def(!self)
127 .def(self == self)
128 .def(self != self)
129
130 .def("__str__", &This::GetDescription)
131
132 .def("GetPrim", &This::GetPrim)
133
134 .def("ComputeJointLocalTransforms", &_ComputeJointLocalTransforms,
135 (arg("time")=UsdTimeCode::Default()))
136
137 .def("ComputeJointLocalTransformComponents",
138 &_ComputeJointLocalTransformComponents,
139 (arg("time")=UsdTimeCode::Default()))
140
141 .def("ComputeBlendShapeWeights", &_ComputeBlendShapeWeights,
142 (arg("time")=UsdTimeCode::Default()))
143
144 .def("GetJointTransformTimeSamples", &_GetJointTransformTimeSamples)
145
146 .def("GetJointTransformTimeSamplesInInterval",
147 &_GetJointTransformTimeSamplesInInterval,
148 (arg("interval")))
149
150 .def("JointTransformsMightBeTimeVarying",
151 &This::JointTransformsMightBeTimeVarying)
152
153 .def("GetBlendShapeWeightTimeSamples", &_GetBlendShapeWeightTimeSamples)
154
155 .def("GetBlendShapeWeightTimeSamplesInInterval",
156 &_GetBlendShapeWeightTimeSamplesInInterval,
157 (arg("interval")))
158
159 .def("BlendShapeWeightsMightBeTimeVarying",
160 &This::BlendShapeWeightsMightBeTimeVarying)
161
162 .def("GetJointOrder", &This::GetJointOrder)
163
164 .def("GetBlendShapeOrder", &This::GetBlendShapeOrder)
165 ;
166 }
167