Changeset 44 for trunk/VUT/OcclusionCullingSceneManager
- Timestamp:
- 04/12/05 18:32:32 (20 years ago)
- Location:
- trunk/VUT/OcclusionCullingSceneManager
- Files:
-
- 4 added
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/VUT/OcclusionCullingSceneManager/TestCulling/TestCulling.vcproj
r33 r44 122 122 UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"> 123 123 <File 124 RelativePath=".\TerrainContentGenerator.cpp"> 125 </File> 126 <File 124 127 RelativePath=".\TestCullingApplication.cpp"> 125 128 </File> … … 129 132 Filter="h;hpp;hxx;hm;inl;inc;xsd" 130 133 UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"> 134 <File 135 RelativePath=".\TerrainContentGenerator.h"> 136 </File> 131 137 <File 132 138 RelativePath=".\TestCullingApplication.h"> -
trunk/VUT/OcclusionCullingSceneManager/TestCulling/TestCullingApplication.cpp
r42 r44 20 20 #include "windows.h" 21 21 22 RaySceneQuery* raySceneQuery = 0;22 //RaySceneQuery* mRaySceneQuery = 0; 23 23 24 24 /***********************************************/ 25 25 /* TestCullingApplication implementation */ 26 26 /***********************************************/ 27 TestCullingApplication::~TestCullingApplication()28 { 29 delete raySceneQuery;30 } 27 /*TestCullingApplication::~TestCullingApplication() 28 { 29 delete mRaySceneQuery; 30 }*/ 31 31 //----------------------------------------------------------------------- 32 32 void TestCullingApplication::createCamera( void ) … … 57 57 l->setPosition(20,80,50); 58 58 59 // Fog59 // --Fog 60 60 // NB it's VERY important to set this before calling setWorldGeometry 61 61 // because the vertex program picked will be different … … 66 66 mWindow->getViewport(0)->setBackgroundColour(fadeColour); 67 67 68 69 70 68 // Create a skybox 69 //mSceneMgr->setSkyBox(true, "Examples/SpaceSkyBox", 500, false); 70 //mSceneMgr->setSkyDome( true, "Examples/CloudySky", 5, 8, 500, false ); 71 71 72 72 std::string terrain_cfg("terrain.cfg"); … … 94 94 mCamera->setOrientation(Quaternion(-0.3486, 0.0122, 0.9365, 0.0329)); 95 95 96 raySceneQuery = mSceneMgr->createRayQuery(97 Ray(mCamera->getPosition(), Vector3::NEGATIVE_UNIT_Y));98 99 Entity *robotEnt = mSceneMgr->createEntity( "Robot", "robot.mesh" );96 //mRaySceneQuery = mSceneMgr->createRayQuery( 97 // Ray(mCamera->getPosition(), Vector3::NEGATIVE_UNIT_Y)); 98 99 /*Entity *robotEnt = mSceneMgr->createEntity( "Robot", "robot.mesh" ); 100 100 SceneNode *robotNode = mSceneMgr->getRootSceneNode()->createChildSceneNode( "RobotNode", Vector3( 750, 25, 600 )); 101 101 robotNode->attachObject( robotEnt ); … … 113 113 ogreNode2->attachObject( ogreEnt2 ); 114 114 ogreNode2->scale(.05,.05,.05); 115 ogreNode->yaw( Degree( 40 ) ); 115 ogreNode->yaw( Degree( 40 ) );*/ 116 116 117 117 // CEGUI setup … … 131 131 132 132 CEGUI::MouseCursor::getSingleton().show( ); 133 134 /* CEGUI::Window* sheet =135 CEGUI::WindowManager::getSingleton().loadWindowLayout(136 (CEGUI::utf8*)"ogregui.layout");137 138 mGUISystem->setGUISheet(sheet);*/139 133 } 140 134 //----------------------------------------------------------------------- … … 155 149 /* MouseQueryListener implementation */ 156 150 /***********************************************/ 157 158 151 //----------------------------------------------------------------------- 159 152 MouseQueryListener::MouseQueryListener(RenderWindow* win, Camera* cam, SceneManager *sceneManager, CEGUI::Renderer *renderer) … … 163 156 164 157 // Setup default variables 165 //mCurrentObject = NULL;158 mCurrentObject = NULL; 166 159 mLMouseDown = false; 167 160 mRMouseDown = false; … … 180 173 mEventProcessor->addKeyListener(this); 181 174 175 mRaySceneQuery = mSceneMgr->createRayQuery( Ray() ); 176 182 177 // show overlay 183 178 Overlay* pOver = OverlayManager::getSingleton().getByName("Example/OcclusionCullingDemoOverlay"); … … 200 195 201 196 pOver->show(); 202 } // MouseQueryListener 197 } 198 //----------------------------------------------------------------------- 199 MouseQueryListener::~MouseQueryListener( ) 200 { 201 delete mRaySceneQuery; 202 } 203 203 //----------------------------------------------------------------------- 204 204 void MouseQueryListener::mouseMoved (MouseEvent *e) … … 214 214 { 215 215 CEGUI::MouseCursor::getSingleton().hide( ); 216 mLMouseDown = true; 217 } // if 216 217 // Setup the ray scene query 218 Ray mouseRay = mCamera->getCameraToViewportRay( e->getX(), e->getY() ); 219 mRaySceneQuery->setRay( mouseRay ); 220 221 // Execute query 222 RaySceneQueryResult &result = mRaySceneQuery->execute(); 223 RaySceneQueryResult::iterator itr = result.begin( ); 224 225 // Get results, create a node/entity on the position 226 if ( itr != result.end() && itr->worldFragment ) 227 { 228 char name[16]; 229 sprintf( name, "Robot%d", mCount++ ); 230 231 Entity *ent = mSceneMgr->createEntity( name, "robot.mesh" ); 232 mCurrentObject = mSceneMgr->getRootSceneNode( )->createChildSceneNode( String(name) + "Node", itr->worldFragment->singleIntersection ); 233 mCurrentObject->attachObject( ent ); 234 mCurrentObject->setScale( 0.1f, 0.1f, 0.1f ); 235 } 236 237 mLMouseDown = true; 238 } 218 239 // Right mouse button down 219 240 else if (e->getButtonID() & InputEvent::BUTTON1_MASK) … … 243 264 void MouseQueryListener::mouseDragged (MouseEvent *e) 244 265 { 245 /* 246 // If we are dragging the left mouse button. 266 // If we are dragging the left mouse button. 247 267 if ( mLMouseDown ) 248 { 249 mShipNode->translate(-e->getRelX() * 200, -e->getRelY() * 200, 0.0); 268 { 269 Ray mouseRay = mCamera->getCameraToViewportRay( e->getX(), e->getY() ); 270 mRaySceneQuery->setRay( mouseRay ); 271 272 RaySceneQueryResult &result = mRaySceneQuery->execute(); 273 RaySceneQueryResult::iterator itr = result.begin( ); 274 275 if ( itr != result.end() && itr->worldFragment ) 276 { 277 mCurrentObject->setPosition( itr->worldFragment->singleIntersection ); 278 } 250 279 } 251 */252 253 280 // If we are dragging the right mouse button. 254 281 if ( mRMouseDown ) … … 262 289 { 263 290 // clamp to terrain 264 static Ray updateRay; 265 updateRay.setOrigin(mCamera->getPosition()); 266 updateRay.setDirection(Vector3::NEGATIVE_UNIT_Y); 267 raySceneQuery->setRay(updateRay); 268 RaySceneQueryResult& qryResult = raySceneQuery->execute(); 269 RaySceneQueryResult::iterator i = qryResult.begin(); 270 271 if (i != qryResult.end() && i->worldFragment) 291 Vector3 camPos = mCamera->getPosition( ); 292 Ray cameraRay( Vector3(camPos.x, 5000.0f, camPos.z), Vector3::NEGATIVE_UNIT_Y ); 293 mRaySceneQuery->setRay( cameraRay ); 294 295 // Perform the scene query 296 RaySceneQueryResult &queryResult = mRaySceneQuery->execute(); 297 RaySceneQueryResult::iterator it = queryResult.begin( ); 298 299 if (it != queryResult.end() && it->worldFragment) 272 300 { 273 SceneQuery::WorldFragment* wf = i ->worldFragment;274 mCamera->setPosition(mCamera->getPosition().x, 275 i->worldFragment->singleIntersection.y + 10,301 SceneQuery::WorldFragment* wf = it->worldFragment; 302 303 mCamera->setPosition(mCamera->getPosition().x, wf->singleIntersection.y + 10, 276 304 mCamera->getPosition().z); 277 305 } … … 290 318 KEY_PRESSED(KC_SPACE, 0.3, changeAlgorithm()); 291 319 292 KEY_PRESSED(KC_SUBTRACT, 0 .3, changeThreshold(-10));320 KEY_PRESSED(KC_SUBTRACT, 0, changeThreshold(-10)); 293 321 KEY_PRESSED(KC_ADD, 0, changeThreshold(10)); 294 322 //KEY_PRESSED(KC_T, 1, change); -
trunk/VUT/OcclusionCullingSceneManager/TestCulling/TestCullingApplication.h
r42 r44 5 5 #include "CEGUIForwardRefs.h" 6 6 #include "ExampleApplication.h" 7 //#include "OgreOcclusionCullingSceneManager.h"8 7 #include "OgreOcclusionCullingSceneTraverser.h" 9 8 … … 32 31 33 32 34 ~MouseQueryListener( ) 35 { 36 } 33 ~MouseQueryListener( ); 37 34 38 35 bool frameStarted(const FrameEvent& evt); … … 82 79 OverlayElement *mHierarchyNodesInfo; 83 80 OverlayElement *mSceneNodesInfo; 81 82 SceneNode *mCurrentObject; // The newly created object 83 int mCount; // The number of robots on the screen 84 RaySceneQuery *mRaySceneQuery; // The ray scene query pointer 84 85 }; 85 86 … … 88 89 { 89 90 public: 90 ~TestCullingApplication();91 //~TestCullingApplication(); 91 92 92 93 protected: … … 101 102 private: 102 103 void chooseSceneManager(void); 103 104 //Entity* mShip;105 //SceneNode* mShipNode;106 104 }; 107 105 -
trunk/VUT/OcclusionCullingSceneManager/src/OgreOcclusionCullingDotSceneManager.cpp
r42 r44 5 5 #include "OgreCamera.h" 6 6 #include "OgreHardwareOcclusionQuery.h" 7 //#include "OgreWireBoundingBox.h"8 7 #include "OgreSolidHalfBoundingBox.h" 9 8 -
trunk/VUT/OcclusionCullingSceneManager/src/OgreOcclusionCullingSceneTraverser.cpp
r42 r44 4 4 #include "OgreCamera.h" 5 5 #include "OgreHardwareOcclusionQuery.h" 6 //#include "OgreWireBoundingBox.h"7 6 #include "OgreSolidHalfBoundingBox.h" 8 7 … … 55 54 break; 56 55 case RENDER_COHERENT: 57 renderCoherentWithQueue(cam); 56 //renderCoherentWithQueue(cam); 57 renderStopAndWait(cam); 58 58 break; 59 59 default: … … 228 228 // change state so the bounding box gets not actually rendered on the screen 229 229 // TODO: in rendervisibleobjects, the rendermode is changed by ogre itself => change this!! 230 setRenderingMode(MODE_QUERY); 231 //setRenderingMode(MODE_RENDER); 230 231 //setRenderingMode(MODE_QUERY); 232 setRenderingMode(MODE_RENDER); 232 233 233 234 // get next available test id … … 247 248 { 248 249 // avoid unnecessary state changes 249 if(mode != mQueryMode)250 {250 //if(mode != mQueryMode) 251 //{ 251 252 bool enabled = (mode == MODE_RENDER); 252 253 … … 257 258 258 259 mQueryMode = mode; 259 }260 //} 260 261 } 261 262 //----------------------------------------------------------------------- -
trunk/VUT/OcclusionCullingSceneManager/src/OgreOcclusionCullingTerrainSceneManager.cpp
r42 r44 5 5 #include "OgreCamera.h" 6 6 #include "OgreHardwareOcclusionQuery.h" 7 //#include "OgreWireBoundingBox.h"8 7 #include "OgreSolidHalfBoundingBox.h" 9 8 … … 19 18 //mDisplayNodes = true; 20 19 //mShowBoundingBoxes = true; 21 mShowBoxes = true;22 //mMaxDepth = 20;20 //mShowBoxes = true; 21 mMaxDepth = 20; 23 22 } 24 23 //----------------------------------------------------------------------- … … 66 65 { 67 66 //char *msg = "now updating scenegraph\n"; OutputDebugString(msg); 67 //mOcclusionCullingTerrainSceneTraverser->preprocess(); 68 68 69 mOcclusionCullingTerrainSceneTraverser->setNumSceneNodes((int)mSceneNodes.size()); 69 70 mOcclusionCullingTerrainSceneTraverser->setRenderSystem(mDestRenderSystem); 70 //mOcclusionCullingTerrainSceneTraverser->preprocess();71 71 72 mOcclusionCullingTerrainSceneTraverser->setNumOctreeNodes(mNumOctreeNodes); 72 73 … … 99 100 NodeList::iterator it = octant->mNodes.begin(); 100 101 101 while ( it != octant->mNodes.end())102 while(it != octant->mNodes.end()) 102 103 { 103 104 OctreeNode *sn = *it; … … 106 107 107 108 // check bounding box visibility of scene nodes 108 if ( cam->isVisible( sn->_getWorldAABB() ))109 if (cam->isVisible(sn->_getWorldAABB())) 109 110 { 110 sn->_addToRenderQueue(cam, getRenderQueue(), false 111 sn->_addToRenderQueue(cam, getRenderQueue(), false); 111 112 //node->_findVisibleObjects(cam, getRenderQueue(), false, mDisplayNodes, false); 112 mVisible.push_back( sn);113 mVisible.push_back(sn); 113 114 114 if ( mDisplayNodes)115 getRenderQueue()->addRenderable( sn);115 if (mDisplayNodes) 116 getRenderQueue()->addRenderable(sn); 116 117 117 118 // check if the scene manager or this node wants the bounding box shown. … … 119 120 sn->_addBoundingBoxToQueue(getRenderQueue()); 120 121 121 if ( mShowBoxes)122 if (mShowBoxes) 122 123 getRenderQueue()->addRenderable(octant->getWireBoundingBox()); 123 124 } -
trunk/VUT/OcclusionCullingSceneManager/src/OgreOcclusionCullingTerrainSceneTraverser.cpp
r42 r44 23 23 24 24 // if we come across some renderable geometry => render it 25 if(octant->numNodes() > 0) 26 { 27 renderOctant(cam, octant); 28 } 29 25 renderOctant(cam, octant); 26 30 27 for(int i=0; i<8; i++) 31 28 { … … 90 87 continue; 91 88 } 92 // 89 //if intersects near plane => skip occlusion query because wrong results possible 93 90 if(intersects) 94 91 { … … 212 209 { 213 210 // if we come across some renderable geometry => render it 214 if(octant->numNodes() > 0) 215 { 216 renderOctant(cam, octant); 217 } 218 211 renderOctant(cam, octant); 212 219 213 octant->setOctreeVisible(true); 220 214 octant = octant->getParent(); … … 224 218 void OcclusionCullingTerrainSceneTraverser::renderOctant( Camera *cam, Octree *octant ) 225 219 { 220 //if(octant->numNodes() > 0) 226 221 if(octant->lastVisited() != octant->lastRendered()) 227 222 { 228 setRenderingMode(MODE_RENDER);223 //setRenderingMode(MODE_RENDER); 229 224 230 225 octant->setLastRendered(octant->lastVisited());
Note: See TracChangeset
for help on using the changeset viewer.