Presentation is loading. Please wait.

Presentation is loading. Please wait.

Intermediate Tutorial

Similar presentations


Presentation on theme: "Intermediate Tutorial"— Presentation transcript:

1 Intermediate Tutorial
OGRE Programming Intermediate Tutorial

2 Use the mouse to select x and y coordinates on the terrain
Contents Use RaySceneQueries to keep the camera from falling through the terrain Use the mouse to select x and y coordinates on the terrain 2

3 Ray Scene Query Initialize the RaySceneQuery object:
RaySceneQuery *mRaySceneQuery = mSceneMgr->createRayQuery ( Ray() );

4 Execution of Ray Scene Query
Setup the ray for the ray scene query Execute the ray scene query Retrieve intersection results mRaySceneQuery->setRay(mRay); // Perform the scene query RaySceneQueryResult &result = mRaySceneQuery->execute(); RaySceneQueryResult::iterator itr = result.begin(); // Get the results, set the camera height // We are interested in the first intersection. It is ok to traverse all the results. if (itr != result.end() && itr->worldFragment) { …… }

5 Mouse Ray // Setup the ray scene query, use CEGUI's mouse position
CEGUI::Point mousePos = CEGUI::MouseCursor::getSingleton().getPosition(); Ray mouseRay = mCamera->getCameraToViewportRay( mousePos.d_x / float(arg.state.width), mousePos.d_y / float(arg.state.height) ); Remark: e.g. in bool mouseMoved(const OIS::MouseEvent &arg), arg.state.width and arg.state.height specify the viewport dimension 5

6 Mouse Ray // Use TrayMgr Ray mRay =mTrayMgr->getCursorRay(mCamera);

7 References:


Download ppt "Intermediate Tutorial"

Similar presentations


Ads by Google