mirror of
https://github.com/scummvm/scummvm.git
synced 2026-06-20 05:45:29 +00:00
EMI: Draw attached actors w/ joint-relative rotation
This commit is contained in:
+11
-1
@@ -2042,9 +2042,19 @@ Math::Vector3d Actor::getWorldPos() const {
|
||||
Math::Quaternion Actor::getRotationQuat() const {
|
||||
if (g_grim->getGameType() == GType_MONKEY4) {
|
||||
Math::Quaternion ret = Math::Quaternion::fromEuler(_yaw, _pitch, _roll);
|
||||
|
||||
if (isAttached()) {
|
||||
Actor *attachedActor = Actor::getPool().getObject(_attachedActor);
|
||||
ret = ret * attachedActor->getRotationQuat();
|
||||
const Math::Quaternion &attachedQuat = attachedActor->getRotationQuat();
|
||||
|
||||
EMICostume *cost = static_cast<EMICostume *>(attachedActor->getCurrentCostume());
|
||||
if (cost && cost->_emiSkel && cost->_emiSkel->_obj) {
|
||||
Joint *j = cost->_emiSkel->_obj->getJointNamed(_attachedJoint);
|
||||
const Math::Quaternion &jointQuat = j->_finalQuat;
|
||||
ret = ret * jointQuat * attachedQuat;
|
||||
} else {
|
||||
ret = ret * attachedQuat;
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
} else {
|
||||
|
||||
@@ -67,6 +67,7 @@ void AnimationEmi::animate(Skeleton *skel, float delta) {
|
||||
curBone._target = skel->getJointNamed(curBone._boneName);
|
||||
|
||||
Math::Matrix4 &relFinal = curBone._target->_finalMatrix;
|
||||
Math::Quaternion &quatFinal = curBone._target->_finalQuat;
|
||||
|
||||
if (curBone._rotations) {
|
||||
int keyfIdx = 0;
|
||||
@@ -92,6 +93,7 @@ void AnimationEmi::animate(Skeleton *skel, float delta) {
|
||||
quat = curBone._rotations[keyfIdx]._quat.slerpQuat(curBone._rotations[keyfIdx - 1]._quat, interpVal);
|
||||
}
|
||||
quat.toMatrix(relFinal);
|
||||
quatFinal = quat;
|
||||
relFinal.setPosition(relPos);
|
||||
}
|
||||
|
||||
|
||||
@@ -86,6 +86,7 @@ void Skeleton::initBones() {
|
||||
void Skeleton::resetAnim() {
|
||||
for (int i = 0; i < _numJoints; ++i) {
|
||||
_joints[i]._finalMatrix = _joints[i]._relMatrix;
|
||||
_joints[i]._finalQuat = _joints[i]._quat;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -94,6 +95,7 @@ void Skeleton::commitAnim() {
|
||||
const Joint *parent = getParentJoint(&_joints[m]);
|
||||
if (parent) {
|
||||
_joints[m]._finalMatrix = parent->_finalMatrix * _joints[m]._finalMatrix;
|
||||
_joints[m]._finalQuat = parent->_finalQuat * _joints[m]._finalQuat;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -47,6 +47,7 @@ struct Joint {
|
||||
Math::Matrix4 _absMatrix;
|
||||
Math::Matrix4 _relMatrix;
|
||||
Math::Matrix4 _finalMatrix;
|
||||
Math::Quaternion _finalQuat;
|
||||
};
|
||||
|
||||
class Skeleton : public Object {
|
||||
|
||||
Reference in New Issue
Block a user