mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 03:58:07 +02:00
getRotationInModelFrame -> getRotation
This commit is contained in:
parent
4ae58153e0
commit
4a3fbfcdee
3 changed files with 11 additions and 11 deletions
|
@ -148,7 +148,7 @@ void SkeletonModel::applyHandPositionInModelFrame(int jointIndex, const glm::vec
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
JointState& state = _jointStates[jointIndex];
|
JointState& state = _jointStates[jointIndex];
|
||||||
glm::quat handRotation = state.getRotationInModelFrame();
|
glm::quat handRotation = state.getRotation();
|
||||||
|
|
||||||
// align hand with forearm
|
// align hand with forearm
|
||||||
float sign = (jointIndex == geometry.rightHandJointIndex) ? 1.0f : -1.0f;
|
float sign = (jointIndex == geometry.rightHandJointIndex) ? 1.0f : -1.0f;
|
||||||
|
@ -267,7 +267,7 @@ void SkeletonModel::renderJointConstraints(int jointIndex) {
|
||||||
|
|
||||||
glPushMatrix();
|
glPushMatrix();
|
||||||
glTranslatef(position.x, position.y, position.z);
|
glTranslatef(position.x, position.y, position.z);
|
||||||
glm::quat parentRotation = (joint.parentIndex == -1) ? _rotation : _rotation * _jointStates.at(joint.parentIndex).getRotationInModelFrame();
|
glm::quat parentRotation = (joint.parentIndex == -1) ? _rotation : _rotation * _jointStates.at(joint.parentIndex).getRotation();
|
||||||
glm::vec3 rotationAxis = glm::axis(parentRotation);
|
glm::vec3 rotationAxis = glm::axis(parentRotation);
|
||||||
glRotatef(glm::degrees(glm::angle(parentRotation)), rotationAxis.x, rotationAxis.y, rotationAxis.z);
|
glRotatef(glm::degrees(glm::angle(parentRotation)), rotationAxis.x, rotationAxis.y, rotationAxis.z);
|
||||||
float fanScale = directionSize * 0.75f;
|
float fanScale = directionSize * 0.75f;
|
||||||
|
@ -300,7 +300,7 @@ void SkeletonModel::renderJointConstraints(int jointIndex) {
|
||||||
}
|
}
|
||||||
glPopMatrix();
|
glPopMatrix();
|
||||||
|
|
||||||
renderOrientationDirections(position, _rotation * jointState.getRotationInModelFrame(), directionSize);
|
renderOrientationDirections(position, _rotation * jointState.getRotation(), directionSize);
|
||||||
jointIndex = joint.parentIndex;
|
jointIndex = joint.parentIndex;
|
||||||
|
|
||||||
} while (jointIndex != -1 && geometry.joints.at(jointIndex).isFree);
|
} while (jointIndex != -1 && geometry.joints.at(jointIndex).isFree);
|
||||||
|
|
|
@ -734,7 +734,7 @@ bool Model::getJointRotationInWorldFrame(int jointIndex, glm::quat& rotation) co
|
||||||
if (jointIndex == -1 || jointIndex >= _jointStates.size()) {
|
if (jointIndex == -1 || jointIndex >= _jointStates.size()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
rotation = _rotation * _jointStates[jointIndex].getRotationInModelFrame();
|
rotation = _rotation * _jointStates[jointIndex].getRotation();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -742,7 +742,7 @@ bool Model::getJointCombinedRotation(int jointIndex, glm::quat& rotation) const
|
||||||
if (jointIndex == -1 || jointIndex >= _jointStates.size()) {
|
if (jointIndex == -1 || jointIndex >= _jointStates.size()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
rotation = _rotation * _jointStates[jointIndex].getRotationInModelFrame();
|
rotation = _rotation * _jointStates[jointIndex].getRotation();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -958,7 +958,7 @@ void Model::updateShapePositions() {
|
||||||
const JointState& state = _jointStates[i];
|
const JointState& state = _jointStates[i];
|
||||||
const FBXJoint& joint = state.getFBXJoint();
|
const FBXJoint& joint = state.getFBXJoint();
|
||||||
// shape position and rotation need to be in world-frame
|
// shape position and rotation need to be in world-frame
|
||||||
glm::quat stateRotation = state.getRotationInModelFrame();
|
glm::quat stateRotation = state.getRotation();
|
||||||
glm::vec3 shapeOffset = uniformScale * (stateRotation * joint.shapePosition);
|
glm::vec3 shapeOffset = uniformScale * (stateRotation * joint.shapePosition);
|
||||||
glm::vec3 worldPosition = _translation + _rotation * (state.getPositionInModelFrame() + shapeOffset);
|
glm::vec3 worldPosition = _translation + _rotation * (state.getPositionInModelFrame() + shapeOffset);
|
||||||
Shape* shape = _jointShapes[i];
|
Shape* shape = _jointShapes[i];
|
||||||
|
@ -1269,9 +1269,9 @@ bool Model::setJointPositionInModelFrame(int jointIndex, const glm::vec3& positi
|
||||||
JointState& state = _jointStates[jointIndex];
|
JointState& state = _jointStates[jointIndex];
|
||||||
|
|
||||||
// TODO: figure out what this is trying to do and combine it into one JointState method
|
// TODO: figure out what this is trying to do and combine it into one JointState method
|
||||||
endRotation = state.getRotationInModelFrame();
|
endRotation = state.getRotation();
|
||||||
state.applyRotationDeltaInModelFrame(rotation * glm::inverse(endRotation), true, priority);
|
state.applyRotationDeltaInModelFrame(rotation * glm::inverse(endRotation), true, priority);
|
||||||
endRotation = state.getRotationInModelFrame();
|
endRotation = state.getRotation();
|
||||||
}
|
}
|
||||||
|
|
||||||
// then, we go from the joint upwards, rotating the end as close as possible to the target
|
// then, we go from the joint upwards, rotating the end as close as possible to the target
|
||||||
|
@ -1285,7 +1285,7 @@ bool Model::setJointPositionInModelFrame(int jointIndex, const glm::vec3& positi
|
||||||
}
|
}
|
||||||
glm::vec3 jointPosition = extractTranslation(state.getTransform());
|
glm::vec3 jointPosition = extractTranslation(state.getTransform());
|
||||||
glm::vec3 jointVector = endPosition - jointPosition;
|
glm::vec3 jointVector = endPosition - jointPosition;
|
||||||
glm::quat oldCombinedRotation = state.getRotationInModelFrame();
|
glm::quat oldCombinedRotation = state.getRotation();
|
||||||
glm::quat combinedDelta;
|
glm::quat combinedDelta;
|
||||||
float combinedWeight;
|
float combinedWeight;
|
||||||
if (useRotation) {
|
if (useRotation) {
|
||||||
|
@ -1315,7 +1315,7 @@ bool Model::setJointPositionInModelFrame(int jointIndex, const glm::vec3& positi
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
state.applyRotationDeltaInModelFrame(combinedDelta, true, priority);
|
state.applyRotationDeltaInModelFrame(combinedDelta, true, priority);
|
||||||
glm::quat actualDelta = state.getRotationInModelFrame() * glm::inverse(oldCombinedRotation);
|
glm::quat actualDelta = state.getRotation() * glm::inverse(oldCombinedRotation);
|
||||||
endPosition = actualDelta * jointVector + jointPosition;
|
endPosition = actualDelta * jointVector + jointPosition;
|
||||||
if (useRotation) {
|
if (useRotation) {
|
||||||
endRotation = actualDelta * endRotation;
|
endRotation = actualDelta * endRotation;
|
||||||
|
|
|
@ -43,7 +43,7 @@ public:
|
||||||
void computeTransform(const glm::mat4& parentTransform);
|
void computeTransform(const glm::mat4& parentTransform);
|
||||||
const glm::mat4& getTransform() const { return _transform; }
|
const glm::mat4& getTransform() const { return _transform; }
|
||||||
|
|
||||||
glm::quat getRotationInModelFrame() const { return _rotation; }
|
glm::quat getRotation() const { return _rotation; }
|
||||||
glm::vec3 getPositionInModelFrame() const { return extractTranslation(_transform); }
|
glm::vec3 getPositionInModelFrame() const { return extractTranslation(_transform); }
|
||||||
|
|
||||||
/// \return rotation from bind to model frame
|
/// \return rotation from bind to model frame
|
||||||
|
|
Loading…
Reference in a new issue