|
|
它在listener的framestarted中有这样一段代码
Quaternion rot(mAnimationRotation, Vector3::UNIT_Y);
Vector3 startoffset = mSceneNode->getOrientation() * -mSneakStartOffset;
Vector3 endoffset = mSneakEndOffset;
Vector3 offset = rot * startoffset;
Vector3 currEnd = mSceneNode->getOrientation() * endoffset + mSceneNode->getPosition();
mSceneNode->setPosition(currEnd + offset);
mSceneNode->rotate(rot);
大致意思我明白,因为动画是位移动画,所以移动后我们要重新改变节点的位置,因为动画第一帧开始又跳回了最初位置,所以得想办法把节点移动到合适的位置,这个位置正好让开始帧所处位置和动画最后一帧位置处相同,并且这个代码同时还旋转了角色的方向。
这里的数学运算实在看不懂,尤其是mSceneNode->setPosition(currEnd + offset);这句的+offset如何理解,还有这句,mSceneNode->rotate(rot);这句和刚才的那句应该是有关联的,他们是如何互相作用的。
这个东西把握折磨很久了,痛苦中。 [em4] |
|