17 auto hierarchicalScene = this->inHierarchicalScene()->constDataPtr();
19 float inputTimeStart = hierarchicalScene->mTimeStart;
20 float inputTimeEnd = hierarchicalScene->mTimeEnd;
24 auto& d_hinge = topo->hingeJoints();
26 c_hinge.assign(d_hinge);
28 std::vector<std::vector<Real>*> animRot;
29 std::vector<std::vector<Real>*> animTime;
31 animRot.resize(c_hinge.size());
32 animTime.resize(c_hinge.size());
35 auto hinge_DriveObjName = this->varDriverName()->getValue();
38 for (
size_t i = 0; i < hinge_DriveObjName.size(); i++)
40 auto name = hinge_DriveObjName[i];
41 auto bone = hierarchicalScene->getObjectByName(name);
44 animRot[i] = bone->m_Rotation_Values;
45 animTime[i] = bone->m_Rotation_Times;
49 move += this->inDeltaTime()->getValue() * this->varSpeed()->getValue();
54 float currentFrameinAnim = fmod(
move, inputTimeEnd - inputTimeStart) + inputTimeStart;
56 for (
size_t hingeId = 0; hingeId < animTime.size(); hingeId++)
58 if (!animTime[hingeId])
61 auto animTimeZ = animTime[hingeId][2];
63 if (currentFrameinAnim < animTimeZ[0])
68 if (currentFrameinAnim > animTimeZ[animTimeZ.size()-1])
71 keyFrame = animTimeZ.size()-1;
74 for (
size_t j = 0; j < animTimeZ.size(); j++)
76 if (currentFrameinAnim > animTimeZ[j] && currentFrameinAnim <= animTimeZ[j + 1])
78 float v = (currentFrameinAnim - animTimeZ[j]) / (animTimeZ[j + 1] - animTimeZ[j]);
88 float angleDivede = -1.0;
110 auto lerp = [](
float a,
float b,
float t) {
111 return a + t * (b - a);
118 for (
size_t hingeId = 0; hingeId < animRot.size(); hingeId++)
120 if (!animRot[hingeId])
122 auto animX = animRot[hingeId][0];
123 auto animY = animRot[hingeId][1];
124 auto animZ = animRot[hingeId][2];
128 angle = animZ[keyFrame] *
M_PI / 180 / angleDivede;
131 angle =
lerp(animZ[keyFrame], animZ[keyFrame + 1], weight) *
M_PI / 180 / angleDivede;
134 c_hinge[hingeId].setRange(angle, angle + epsilonAngle);
139 d_hinge.assign(c_hinge);