I try to realize a collision system with some Ogre::Ray but it seems that it doesn't work ...
Here's is the code :
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;
}
}
}
This code is putting in the function : framerenderingqueued :)
but my mesh stays below the terrain
Someone can help me? :) Thanks