I am trying the code in this tutorial http://www.ogre3d.org/tikiwiki/Get+XZ+coordinates and here is my code.
Code: Select all
MeshManager::getSingleton().createPlane(
"ground", ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME,
mPlane,
1500, 1500,
20, 20,
true,
1,
5, 5,
Vector3::UNIT_Z
);
Entity *planeEntity= mSceneMgr->createEntity("Ground", "ground");
mSceneMgr->getRootSceneNode()->createChildSceneNode()->attachObject(planeEntity); Code: Select all
mCamera = mSceneMgr->createCamera("Camera");
mCamera->setPosition(Ogre::Vector3(0, 700, 800));
mCamera->lookAt(Ogre::Vector3(0, 0, 0));
mCamera->setNearClipDistance(5);Code: Select all
Ray mRay = mTrayMgr->getCursorRay(mCamera);
std::pair<bool, Real> result = mRay.intersects(mPlane);
if (result.first)
{
Vector3 point= mRay.getPoint(result.second);
}