Presentation is loading. Please wait.

Presentation is loading. Please wait.

1 OGRE Programming Intermediate Tutorial. 2Contents 2 1.Select any object on the screen using the mouse 2.Restrict what is selectable.

Similar presentations


Presentation on theme: "1 OGRE Programming Intermediate Tutorial. 2Contents 2 1.Select any object on the screen using the mouse 2.Restrict what is selectable."— Presentation transcript:

1 1 OGRE Programming Intermediate Tutorial

2 2Contents 2 1.Select any object on the screen using the mouse 2.Restrict what is selectable

3 3  Show the bounding box of a scene node: mCurrentObject->showBoundingBox(true); //mCurrentObject is a SceneNode. Showing the selected object

4 4 1.Setup the ray for the ray scene query 2.Set the sorting type for the results 3.Execute the ray scene query 4.Retrieve intersection results 5.Based on the results, perform the specific task Process of Ray Scene Query

5 55 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 )); mRaySceneQuery->setRay(mouseRay); mRaySceneQuery->setSortByDistance(true); // Perform the scene query RaySceneQueryResult &result = mRaySceneQuery->execute(); RaySceneQueryResult::iterator itr = result.begin(); for (itr = result.begin(); itr != result.end(); itr++) { if (itr->movable && itr->movable->getName().substr(0, 5) != " tile[ ") { mCurrentObject = itr->movable->getParentSceneNode(); break; } // if else if (itr->worldFragment) { …… } Process of Ray Scene Query

6 66 Query Masks  Mask: bitwise value.  The mask can be used to restrict the objects which are selectable.  Set the mask for an entity: ent->setQueryFlags(ROBOT_MASK);  Set the ray scene query for the entity whose query flag is QMASK mRaySceneQuery->setQueryMask(QMASK); //now, if ROBOT_MASK & QMASK is non-zero, then the corresponding entities are returned in the query results.

7 7 Query Type Masks  The query never returns the billboardset normally. Why?  The SceneQuery has another mask: QueryTypeMask.  It limits the selection type specified as the flag.  By default, it returns only objects of entity type. To return BillboardSets or ParticleSystems: mRaySceneQuery->setQueryTypeMask( SceneManager::FX_TYPE_MASK);

8 8 QueryTypeMask Six types of QueryTypeMask defined in the SceneManager class as static members: WORLD_GEOMETRY_TYPE_MASK //Returns world geometry. ENTITY_TYPE_MASK //Returns entities. FX_TYPE_MASK //Returns billboardsets / particle systems. STATICGEOMETRY_TYPE_MASK //Returns static geometry. LIGHT_TYPE_MASK //Returns lights. USER_TYPE_MASK_LIMIT //User type mask limit. The default QueryTypeMask : ENTITY_TYPE_MASK

9 9 References: http://www.ogre3d.org/wiki/index.php/Intermediate_Tutorial_3


Download ppt "1 OGRE Programming Intermediate Tutorial. 2Contents 2 1.Select any object on the screen using the mouse 2.Restrict what is selectable."

Similar presentations


Ads by Google