1 / 9

OGRE Programming Intermediate Tutorial

OGRE Programming Intermediate Tutorial. Contents. Select any object on the screen using the mouse Restrict what is selectable. 2. Showing the selected object. Show the bounding box of a scene node: mCurrentObject->showBoundingBox(true); //mCurrentObject is a SceneNode.

Download Presentation

OGRE Programming Intermediate Tutorial

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. OGRE Programming Intermediate Tutorial

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

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

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

  5. Process of Ray Scene Query 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) { …… } } 5

  6. 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. 6

  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. 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. References: http://www.ogre3d.org/wiki/index.php/Intermediate_Tutorial_3

More Related