ogre programming intermediate tutorial

9
1 OGRE Programming OGRE Programming Intermediate Intermediate Tutorial Tutorial

Upload: amity-salinas

Post on 01-Jan-2016

40 views

Category:

Documents


5 download

DESCRIPTION

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. - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: OGRE Programming Intermediate Tutorial

1

OGRE ProgrammingOGRE Programming

Intermediate TutorialIntermediate Tutorial

Page 2: OGRE Programming Intermediate Tutorial

2

ContentsContents

2

1. Select any object on the screen using the mouse

2. Restrict what is selectable

Page 3: OGRE Programming Intermediate Tutorial

3

Show the bounding box of a scene node:

mCurrentObject->showBoundingBox(true);

//mCurrentObject is a SceneNode.

Showing the selected object

Page 4: OGRE Programming Intermediate Tutorial

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 QueryProcess of Ray Scene Query

Page 5: OGRE Programming Intermediate Tutorial

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 QueryProcess of Ray Scene Query

Page 6: OGRE Programming Intermediate Tutorial

66

Query MasksMask: 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 Set the ray scene query for the entity whose query flag is QMASKflag is QMASK

mRaySceneQuery->setQueryMask(QMASK);//now, if //now, if ROBOT_MASK & QMASK ROBOT_MASK & QMASK is is non-zeronon-zero, then the , then the corresponding entities are returned in the query results.corresponding entities are returned in the query results.

Page 7: OGRE Programming Intermediate Tutorial

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);

Page 8: OGRE Programming Intermediate Tutorial

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

Page 9: OGRE Programming Intermediate Tutorial

9

References: References:

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