首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网络游戏 >

人物模型走路的有关问题,是OGRE,SDK里的例子,一段代码不太懂,求教

2012-03-21 
人物模型走路的问题,是OGRE,SDK里的例子,一段代码不太懂,求教C/C++ codeif (mKeyDirection ! Vector3::ZE

人物模型走路的问题,是OGRE,SDK里的例子,一段代码不太懂,求教

C/C++ code
if (mKeyDirection != Vector3::ZERO && mBaseAnimID != ANIM_DANCE)        {            // calculate actually goal direction in world based on player's key directions            mGoalDirection += mKeyDirection.z * mCameraNode->getOrientation().zAxis();            mGoalDirection += mKeyDirection.x * mCameraNode->getOrientation().xAxis();            mGoalDirection.y = 0;            mGoalDirection.normalise();            Quaternion toGoal = mBodyNode->getOrientation().zAxis().getRotationTo(mGoalDirection);            // calculate how much the character has to turn to face goal direction            Real yawToGoal = toGoal.getYaw().valueDegrees();            // this is how much the character CAN turn this frame            Real yawAtSpeed = yawToGoal / Math::Abs(yawToGoal) * deltaTime * TURN_SPEED;            // reduce "turnability" if we're in midair            if (mBaseAnimID == ANIM_JUMP_LOOP) yawAtSpeed *= 0.2f;            // turn as much as we can, but not more than we need to            if (yawToGoal < 0) yawToGoal = std::min<Real>(0, std::max<Real>(yawToGoal, yawAtSpeed)); //yawToGoal = Math::Clamp<Real>(yawToGoal, yawAtSpeed, 0);            else if (yawToGoal > 0) yawToGoal = std::max<Real>(0, std::min<Real>(yawToGoal, yawAtSpeed)); //yawToGoal = Math::Clamp<Real>(yawToGoal, 0, yawAtSpeed);                        mBodyNode->yaw(Degree(yawToGoal));            // move in current body direction (not the goal direction)            mBodyNode->translate(0, 0, deltaTime * RUN_SPEED * mAnims[mBaseAnimID]->getWeight(),                Node::TS_LOCAL);        }

第一第二句是什么意思呢,为什么要和摄像机NODE有关系,zAxis()是什么意思呢
mGoalDirection += mKeyDirection.z * mCameraNode->getOrientation().zAxis();
mGoalDirection += mKeyDirection.x * mCameraNode->getOrientation().xAxis();


如果向下面这样写可以吗
直走
SinbadTranslate += sinbadNode->getLocalAxes() * Ogre::Vector3(0,0,-1);
sinbadNode->translate(SinbadTranslate * evt.timeSinceLastFrame * 50.0f);
转弯
float rotX = CInputManager::GetInstance()->returnMouse()->getMouseState().X.rel * evt.timeSinceLastFrame * -1;
character->turnAround(rotX/5);




[解决办法]
摄像机方向,就是你前进的方向。当然跟摄像机有关

热点排行