0
我試圖實現與一些食人魔::雷碰撞系統,但它似乎不工作...路口與地形
這裏的是代碼:
Ogre::Vector3 robotPos = mRobotNode->getPosition();
Ogre::Ray robotRay(Ogre::Vector3(robotPos.x,5000.0f,robotPos.z),Ogre::Vector3::NEGATIVE_UNIT_Y);
mRaySceneQuery->setRay(robotRay);
mRaySceneQuery->setSortByDistance(false);
Ogre::RaySceneQueryResult &result = mRaySceneQuery->execute();
Ogre::RaySceneQueryResult::iterator itr;
for(itr = result.begin();itr != result.end(); itr++)
{
if(itr->worldFragment)
{
Ogre::Real terrainHeight = itr->worldFragment->singleIntersection.y;
if(terrainHeight!=robotPos.y)
{
mRobotNode->setPosition(Ogre::Vector3(robotPos.x,terrainHeight,robotPos.z));
mCameraNode->setPosition(Ogre::Vector3(robotPos.x,terrainHeight,robotPos.z));
break;
}
}
}
此代碼是投入功能:framerenderingqueued :)
,但我的網住宿的地形
有人可以幫我在下面? :)謝謝