- Timestamp:
- 04/19/05 09:12:55 (20 years ago)
- Location:
- trunk/VUT/OcclusionCullingSceneManager
- Files:
-
- 14 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/VUT/OcclusionCullingSceneManager/TestCulling/TestCullingApplication.cpp
r44 r51 20 20 #include "windows.h" 21 21 22 //RaySceneQuery* mRaySceneQuery = 0;23 22 24 23 /***********************************************/ 25 24 /* TestCullingApplication implementation */ 26 25 /***********************************************/ 27 /*TestCullingApplication::~TestCullingApplication() 28 { 29 delete mRaySceneQuery; 30 }*/ 31 //----------------------------------------------------------------------- 32 void TestCullingApplication::createCamera( void ) 26 TestCullingApplication::~TestCullingApplication() 27 { 28 } 29 //----------------------------------------------------------------------- 30 /*void TestCullingApplication::createCamera( void ) 33 31 { 34 32 // Create the camera … … 42 40 mCamera->setNearClipDistance( 1 ); 43 41 mCamera->setFarClipDistance( 1000 ); 44 } 42 }*/ 45 43 //----------------------------------------------------------------------- 46 44 void TestCullingApplication::createScene(void) 47 45 { 48 Plane waterPlane;49 46 // Set ambient light 50 47 mSceneMgr->setAmbientLight(ColourValue(0.5, 0.5, 0.5)); … … 52 49 // Create a light 53 50 Light* l = mSceneMgr->createLight("MainLight"); 54 // Accept default settings: point light, white diffuse, just set position 55 // NB I could attach the light to a SceneNode if I wanted it to move automatically with 56 // other objects, but I don't 57 l->setPosition(20,80,50); 58 59 // --Fog 60 // NB it's VERY important to set this before calling setWorldGeometry 61 // because the vertex program picked will be different 62 ColourValue fadeColour(0.93, 0.86, 0.76); 63 //mSceneMgr->setFog( FOG_LINEAR, fadeColour, .001, 500, 1000); 64 //mSceneMgr->setFog( FOG_EXP, fadeColour, 0.005 ); 65 51 //l->setPosition(20,80,50); 52 53 mMinTranslation = Vector3(-70.0f, -70.0f, 0.0f); 54 mMaxTranslation = Vector3(70.0f, 70.0f, 600.0f); 55 56 mMinAngle = Vector3(0, 0, 0); 57 mMaxAngle = Vector3(360, 360, 360); 58 59 /* 66 60 mWindow->getViewport(0)->setBackgroundColour(fadeColour); 67 61 62 Entity *ogreHeadEnt = mSceneMgr->createEntity("head", "ogrehead.mesh"); 63 mOgreHead = mSceneMgr->getRootSceneNode()->createChildSceneNode( "OgreHeadNode" ); 64 mOgreHead->attachObject(ogreHeadEnt); 65 */ 66 generateScene(4); 68 67 // Create a skybox 69 //mSceneMgr->setSkyBox(true, "Examples/SpaceSkyBox", 500, false); 70 //mSceneMgr->setSkyDome( true, "Examples/CloudySky", 5, 8, 500, false ); 71 72 std::string terrain_cfg("terrain.cfg"); 73 #if OGRE_PLATFORM == OGRE_PLATFORM_APPLE 74 terrain_cfg = mResourcePath + terrain_cfg; 75 #endif 76 mSceneMgr -> setWorldGeometry( terrain_cfg ); 77 // Infinite far plane? 78 if (mRoot->getRenderSystem()->getCapabilities()->hasCapability(RSC_INFINITE_FAR_PLANE)) 79 { 80 mCamera->setFarClipDistance(0); 81 } 82 83 /* // Define the required skyplane 84 Plane plane; 85 // 5000 world units from the camera 86 plane.d = 5000; 87 // Above the camera, facing down 88 plane.normal = -Vector3::UNIT_Y; 89 // Create the plane 10000 units wide, tile the texture 3 times 90 mSceneMgr->setSkyPlane(true, plane, "Examples/SpaceSkyPlane",10000,3);*/ 91 92 // Set a nice viewpoint 93 mCamera->setPosition(707,2500,528); 94 mCamera->setOrientation(Quaternion(-0.3486, 0.0122, 0.9365, 0.0329)); 95 96 //mRaySceneQuery = mSceneMgr->createRayQuery( 97 // Ray(mCamera->getPosition(), Vector3::NEGATIVE_UNIT_Y)); 98 99 /*Entity *robotEnt = mSceneMgr->createEntity( "Robot", "robot.mesh" ); 100 SceneNode *robotNode = mSceneMgr->getRootSceneNode()->createChildSceneNode( "RobotNode", Vector3( 750, 25, 600 )); 101 robotNode->attachObject( robotEnt ); 102 robotNode->scale( .3, .3, .3 ); 103 robotNode->yaw( Degree( 160 ) ); 104 105 Entity *ogreEnt = mSceneMgr->createEntity( "Ogre", "ogrehead.mesh" ); 106 SceneNode *ogreNode = mSceneMgr->getRootSceneNode()->createChildSceneNode( "Ogre", Vector3( 800, 50, 830 ) ); 107 ogreNode->attachObject( ogreEnt ); 108 ogreNode->scale(.2,.2,.2); 109 ogreNode->yaw( Degree( 20 ) ); 110 111 Entity *ogreEnt2 = mSceneMgr->createEntity( "Ogre2", "ogrehead.mesh" ); 112 SceneNode *ogreNode2 = mSceneMgr->getRootSceneNode()->createChildSceneNode( "Ogre2", Vector3( 700, 50, 730 ) ); 113 ogreNode2->attachObject( ogreEnt2 ); 114 ogreNode2->scale(.05,.05,.05); 115 ogreNode->yaw( Degree( 40 ) );*/ 68 //mSceneMgr->setSkyBox(true, "Examples/CloudyNoonSkyBox", 1000, false); 69 ColourValue fadeColour(0.3, 0.9, 0.5); 70 mWindow->getViewport(0)->setBackgroundColour(fadeColour); 116 71 117 72 // CEGUI setup … … 142 97 void TestCullingApplication::chooseSceneManager(void) 143 98 { 144 //mSceneMgr = mRoot->getSceneManager(ST_GENERIC); 145 mSceneMgr = mRoot->getSceneManager(ST_EXTERIOR_CLOSE); 146 } 147 99 mSceneMgr = mRoot->getSceneManager(ST_GENERIC); 100 } 101 //----------------------------------------------------------------------- 102 void TestCullingApplication::generateSceneObject(const Vector3 &translationRatio, 103 const Vector3 &rotationRatio, const int idx, const String& entName) 104 { 105 Vector3 rotation = mMinAngle + rotationRatio * (mMaxAngle - mMinAngle); 106 Vector3 translation = mMinTranslation + translationRatio * (mMaxTranslation - mMinTranslation); 107 108 char name[16]; 109 sprintf( name, "object%d", idx ); 110 111 Entity *ent = mSceneMgr->createEntity( name, entName ); 112 SceneNode *node = mSceneMgr->getRootSceneNode()->createChildSceneNode( String(name) + "Node", translation); 113 node->attachObject(ent); 114 node->scale(0.1,0.1,0.1); 115 116 node->yaw(Degree(rotation.x)); 117 node->pitch(Degree(rotation.y)); 118 node->roll(Degree(rotation.z)); 119 } 120 //----------------------------------------------------------------------- 121 void TestCullingApplication::generateScene( int numObjects ) 122 { 123 srand (time (0)); 124 125 Vector3 rotationRatio; 126 Vector3 translationRatio; 127 128 for(int i=0; i < numObjects; i++) 129 { 130 rotationRatio.x = rand() / (float) RAND_MAX; 131 rotationRatio.y = rand() / (float) RAND_MAX; 132 rotationRatio.z = rand() / (float) RAND_MAX; 133 134 translationRatio.x = rand() / (float) RAND_MAX; 135 translationRatio.y = rand() / (float) RAND_MAX; 136 translationRatio.z = rand() / (float) RAND_MAX; 137 138 generateSceneObject(translationRatio, rotationRatio, i, "sphere.mesh"); 139 } 140 } 148 141 /***********************************************/ 149 142 /* MouseQueryListener implementation */ … … 156 149 157 150 // Setup default variables 158 mCurrentObject= NULL;151 //mOgreHead = NULL; 159 152 mLMouseDown = false; 160 153 mRMouseDown = false; … … 173 166 mEventProcessor->addKeyListener(this); 174 167 175 mRaySceneQuery = mSceneMgr->createRayQuery( Ray() );176 177 168 // show overlay 178 169 Overlay* pOver = OverlayManager::getSingleton().getByName("Example/OcclusionCullingDemoOverlay"); … … 199 190 MouseQueryListener::~MouseQueryListener( ) 200 191 { 201 delete mRaySceneQuery;202 192 } 203 193 //----------------------------------------------------------------------- … … 213 203 if (e->getButtonID() & InputEvent::BUTTON0_MASK) 214 204 { 215 CEGUI::MouseCursor::getSingleton().hide( ); 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; 205 mLMouseDown = true; 238 206 } 239 207 // Right mouse button down … … 267 235 if ( mLMouseDown ) 268 236 { 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 } 237 279 238 } 280 239 // If we are dragging the right mouse button. … … 287 246 //----------------------------------------------------------------------- 288 247 bool MouseQueryListener::frameStarted(const FrameEvent &evt) 289 { 290 // clamp to terrain 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) 300 { 301 SceneQuery::WorldFragment* wf = it->worldFragment; 302 303 mCamera->setPosition(mCamera->getPosition().x, wf->singleIntersection.y + 10, 304 mCamera->getPosition().z); 305 } 306 248 { 307 249 return ExampleFrameListener::frameStarted(evt); 308 250 } -
trunk/VUT/OcclusionCullingSceneManager/TestCulling/TestCullingApplication.h
r44 r51 79 79 OverlayElement *mHierarchyNodesInfo; 80 80 OverlayElement *mSceneNodesInfo; 81 82 SceneNode *mCurrentObject; // The newly created object83 int mCount; // The number of robots on the screen84 RaySceneQuery *mRaySceneQuery; // The ray scene query pointer85 81 }; 86 82 … … 95 91 void createFrameListener(void); 96 92 void setupGui(void); 97 virtual void createCamera(void); 93 /** generates a the scene hierarchy with random values 94 @param number of objects to generate 95 */ 96 void generateScene(int numObjects); 97 98 /** generates a new scene object 99 @param tranlationRatio ratio between minimal and maximal possible translation 100 @param rotationRatio ratio between minimal and maximal possible rotation 101 @idx the index of the new object 102 @entName the name of the object entity 103 */ 104 void generateSceneObject(const Vector3 &translationRatio, const Vector3 &rotationRatio, 105 const int idx, const String &entName); 106 107 //virtual void createCamera(void); 98 108 99 109 CEGUI::OgreCEGUIRenderer *mGUIRenderer; 100 110 CEGUI::System *mGUISystem; 111 112 Vector3 mMinTranslation; 113 Vector3 mMaxTranslation; 114 115 Vector3 mMinAngle; 116 Vector3 mMaxAngle; 101 117 102 118 private: -
trunk/VUT/OcclusionCullingSceneManager/TestCullingTerrain/TestCullingTerrainApplication.cpp
r48 r51 46 46 void TestCullingTerrainApplication::createScene(void) 47 47 { 48 Plane waterPlane;49 48 // Set ambient light 50 49 mSceneMgr->setAmbientLight(ColourValue(0.5, 0.5, 0.5)); … … 61 60 // because the vertex program picked will be different 62 61 ColourValue fadeColour(0.93, 0.86, 0.76); 62 mWindow->getViewport(0)->setBackgroundColour(fadeColour); 63 63 //mSceneMgr->setFog( FOG_LINEAR, fadeColour, .001, 500, 1000); 64 64 //mSceneMgr->setFog( FOG_EXP, fadeColour, 0.005 ); 65 65 66 mWindow->getViewport(0)->setBackgroundColour(fadeColour);66 67 67 68 68 // Create a skybox 69 69 //mSceneMgr->setSkyBox(true, "Examples/SpaceSkyBox", 500, false); 70 70 //mSceneMgr->setSkyDome( true, "Examples/CloudySky", 5, 8, 500, false ); 71 72 /* // Define the required skyplane 73 Plane plane; 74 // 5000 world units from the camera 75 plane.d = 5000; 76 // Above the camera, facing down 77 plane.normal = -Vector3::UNIT_Y; 78 // Create the plane 10000 units wide, tile the texture 3 times 79 mSceneMgr->setSkyPlane(true, plane, "Examples/SpaceSkyPlane",10000,3);*/ 71 80 72 81 std::string terrain_cfg("terrain.cfg"); … … 81 90 } 82 91 83 /* // Define the required skyplane84 Plane plane;85 // 5000 world units from the camera86 plane.d = 5000;87 // Above the camera, facing down88 plane.normal = -Vector3::UNIT_Y;89 // Create the plane 10000 units wide, tile the texture 3 times90 mSceneMgr->setSkyPlane(true, plane, "Examples/SpaceSkyPlane",10000,3);*/91 92 92 // Set a nice viewpoint 93 93 mCamera->setPosition(707,2500,528); 94 94 mCamera->setOrientation(Quaternion(-0.3486, 0.0122, 0.9365, 0.0329)); 95 95 96 //mRaySceneQuery = mSceneMgr->createRayQuery( 97 // Ray(mCamera->getPosition(), Vector3::NEGATIVE_UNIT_Y)); 98 99 /*Entity *robotEnt = mSceneMgr->createEntity( "Robot", "robot.mesh" ); 96 /* 97 Entity *robotEnt = mSceneMgr->createEntity( "Robot", "robot.mesh" ); 100 98 SceneNode *robotNode = mSceneMgr->getRootSceneNode()->createChildSceneNode( "RobotNode", Vector3( 750, 25, 600 )); 101 99 robotNode->attachObject( robotEnt ); -
trunk/VUT/OcclusionCullingSceneManager/include/OgreOcclusionCullingOctreeSceneManager.h
r48 r51 42 42 bool getOptionKeys( StringVector &refKeys ); 43 43 44 /** Renders one octant of an octree, i.e., renders current octant45 node and does not traverse deeper into the tree.46 @remark Note that OctreeNode instances are NOT part of the octree47 hierarchy, instead one octant of an Octree contains many OctreeNode instances.48 @param octree the octree to be rendered49 @param cam current camera50 */51 void _renderOctant(Camera* cam, Octree *octree);52 53 44 protected: 54 45 /** Recursively counts octree size (i.e., number of octree instances) -
trunk/VUT/OcclusionCullingSceneManager/include/OgreOcclusionCullingSceneTraverser.h
r42 r51 170 170 unsigned int mNumFrustumCulledNodes; 171 171 unsigned int mNumRenderedGeometry; 172 unsigned int mNumRenderedNodes; 172 173 173 174 private: -
trunk/VUT/OcclusionCullingSceneManager/include/OgreOcclusionCullingTerrainSceneManager.h
r48 r51 44 44 bool getOptionKeys( StringVector &refKeys ); 45 45 46 /** Renders one octant of an octree, i.e., renders current octant47 node and does not traverse deeper into the tree.48 @remark Note that OctreeNode instances are NOT part of the octree49 hierarchy, instead one octant of an Octree contains many OctreeNode instances.50 @param octree the octree to be rendered51 @param cam current camera52 */53 void _renderOctant(Camera* cam, Octree *octree);54 55 46 protected: 56 47 -
trunk/VUT/OcclusionCullingSceneManager/include/OgreSolidHalfBoundingBox.h
r26 r51 15 15 class SolidHalfBoundingBox : public WireBoundingBox 16 16 { 17 public: 18 19 SolidHalfBoundingBox(bool isFirstHalf); 20 void setupBoundingBox(const AxisAlignedBox& aabb); 21 /** Override this method to prevent parent transforms (rotation,translation,scale) 22 and to make it public. 23 */ 24 void getWorldTransforms( Matrix4* xform ) const; 25 17 26 protected: 18 27 19 28 /** Builds the wireframe line list. 29 @param the axis aligned bounding box for setting up the list. 20 30 */ 21 31 void setupBoundingBoxVertices(const AxisAlignedBox& aab); 22 23 public: 24 25 bool mIsFirstHalf; 26 void setupBoundingBox(const AxisAlignedBox& aabb); 27 SolidHalfBoundingBox(bool isFirstHalf); 32 33 bool mIsFirstHalf; 28 34 }; 29 35 -
trunk/VUT/OcclusionCullingSceneManager/src/OgreOcclusionCullingOctreeSceneManager.cpp
r45 r51 16 16 //mDisplayNodes = true; 17 17 //mShowBoundingBoxes = true; 18 //mShowBoxes = true;18 mShowBoxes = true; 19 19 mMaxDepth = 20; 20 20 } … … 57 57 // must be empty because objects are found and rendered in an interleaved fashion 58 58 // in _renderVisibibleObjects 59 //char *msg = "now finding visible objects\n"; OutputDebugString(msg);60 59 } 61 60 //----------------------------------------------------------------------- … … 92 91 return mOcclusionCullingOctreeSceneTraverser->getOptionKeys ( refKeys ) || OctreeSceneManager::getOptionKeys( refKeys ); 93 92 } 94 //-----------------------------------------------------------------------95 void OcclusionCullingOctreeSceneManager::_renderOctant(Camera *cam, Octree *octant)96 {97 //Add stuff to be rendered;98 NodeList::iterator it = octant->mNodes.begin();99 100 while(it != octant->mNodes.end())101 {102 OctreeNode *sn = *it;103 104 mNumObjects++;105 106 // check bounding box visibility of scene nodes107 if (cam->isVisible(sn->_getWorldAABB()))108 {109 sn->_addToRenderQueue(cam, getRenderQueue(), false);110 //node->_findVisibleObjects(cam, getRenderQueue(), false, mDisplayNodes, false);111 mVisible.push_back(sn);112 113 if (mDisplayNodes)114 getRenderQueue()->addRenderable(sn);115 116 // check if the scene manager or this node wants the bounding box shown.117 if (sn->getShowBoundingBox() || mShowBoundingBoxes)118 sn->_addBoundingBoxToQueue(getRenderQueue());119 120 if (mShowBoxes)121 getRenderQueue()->addRenderable(octant->getWireBoundingBox());122 }123 ++it;124 }125 126 SceneManager::_renderVisibleObjects();127 128 // delete all rendered objects from renderqueue129 _deleteRenderedQueueGroups();130 }131 93 } -
trunk/VUT/OcclusionCullingSceneManager/src/OgreOcclusionCullingOctreeSceneTraverser.cpp
r48 r51 28 28 { 29 29 Octree *nextChild = octant->mChildren[(i & 4) >> 2][(i & 2) >> 1][i & 1]; 30 30 31 /*char msg[100]; 32 sprintf(msg, "node number: %d %d %d\n", (i & 4) >> 2, (i & 2) >> 1, i & 1); 33 OutputDebugString(msg);*/ 34 31 35 if(nextChild) 32 36 mOctreeDistanceQueue->push(nextChild); … … 44 48 45 49 // interesting for visualization purpose 46 //TODO: octree->setNodeVisible(false);50 octant->setOctreeVisible(false); 47 51 octant->_getCullBounds(&box); 48 52 … … 81 85 bool intersects = false; 82 86 83 //if(vis == OctreeCamera::NONE)84 87 if(!cam->isVisible(box, intersects)) 85 88 { … … 100 103 // wait if result not available 101 104 query->pullOcclusionQuery(&visiblePixels); 102 105 //visiblePixels = 1; 103 106 // node visible 104 107 if(visiblePixels > mVisibilityThreshold) … … 108 111 else 109 112 { 113 char msg[100]; 114 Vector3 min = box.getMinimum(); 115 Vector3 max = box.getMaximum(); 116 117 sprintf(msg, "culling box: %3.3f %3.3f %3.3f %3.3f %3.3f %3.3f\n", min.x, min.y, min.z, max.x, max.y, max.z); 118 OutputDebugString(msg); 119 110 120 mNumQueryCulledNodes ++; 111 121 } … … 133 143 unsigned int visiblePixels; 134 144 query->pullOcclusionQuery(&visiblePixels); 135 145 //visiblePixels = 1; 136 146 if(visiblePixels > mVisibilityThreshold) 137 147 { … … 164 174 if(intersects) 165 175 { 166 // update node's visited flag176 // update octant's visited flag 167 177 octant->setLastVisited(mFrameId); 168 178 pullUpVisibility(cam, octant); … … 174 184 // identify previously visible nodes 175 185 bool wasVisible = octant->isOctreeVisible() && (octant->lastVisited() == mFrameId - 1); 176 186 187 /* char msg[100]; 188 if(wasVisible) sprintf(msg, "yes, was visible, %d\n", mFrameId); 189 else sprintf(msg, "no was invisible, %d\n", mFrameId); 190 OutputDebugString(msg);*/ 191 177 192 // identify nodes that we cannot skip queries for 178 193 bool leafOrWasInvisible = !wasVisible || isLeaf(octant); … … 196 211 traverseOctant(cam, octant); 197 212 } 198 else199 {200 mNumFrustumCulledNodes ++;201 }202 213 } 203 214 } … … 218 229 void OcclusionCullingOctreeSceneTraverser::renderOctant( Camera *cam, Octree *octant ) 219 230 { 220 //if(octant->numNodes() > 0)231 if(octant->numNodes() == 0) return; 221 232 if(octant->lastVisited() != octant->lastRendered()) 222 233 { 223 //setRenderingMode(MODE_RENDER); 234 //TODO: does nothing useful 235 setRenderingMode(MODE_RENDER); 236 mNumRenderedNodes ++; 224 237 225 238 octant->setLastRendered(octant->lastVisited()); 226 ((Oc clusionCullingOctreeSceneManager *)mSceneManager)->_renderOctant(cam, octant);227 } 228 else OutputDebugString("already rendered");239 ((OctreeSceneManager *)mSceneManager)->_renderOctant(cam, octant); 240 } 241 //else OutputDebugString("already rendered"); 229 242 } 230 243 //----------------------------------------------------------------------- -
trunk/VUT/OcclusionCullingSceneManager/src/OgreOcclusionCullingSceneManagerDll.cpp
r48 r51 34 34 namespace Ogre { 35 35 36 36 // OcclusionCullingDotSceneManager *occlusionDotPlugin; 37 37 OcclusionCullingOctreeSceneManager *occlusionOctreePlugin; 38 38 OcclusionCullingTerrainSceneManager *occlusionTerrainPlugin; … … 54 54 Root::getSingleton().setSceneManager( ST_GENERIC, occlusionOctreePlugin ); 55 55 Root::getSingleton().setSceneManager( ST_EXTERIOR_CLOSE, occlusionTerrainPlugin ); 56 57 // MessageBox( NULL, "myplugin registered", "this is my plugin", MB_OK | MB_ICONERROR | MB_TASKMODAL);58 56 } 59 57 extern "C" void dllStopPlugin(void) -
trunk/VUT/OcclusionCullingSceneManager/src/OgreOcclusionCullingSceneTraverser.cpp
r44 r51 16 16 mQueryMode(MODE_RENDER), mNumSceneNodes(0), mCurrentAlgorithm(RENDER_COHERENT), 17 17 mNumQueries(0), mNumTraversedNodes(0), mNumQueryCulledNodes(0), mNumFrustumCulledNodes(0), 18 mNumRendered Geometry(0), mSceneManager(sm), mRenderSystem(rsys), mSceneRoot(NULL)18 mNumRenderedNodes(0),mNumRenderedGeometry(0), mSceneManager(sm), mRenderSystem(rsys), mSceneRoot(NULL) 19 19 { 20 20 mHalfBoundingBox[0] = mHalfBoundingBox[1] = 0; … … 39 39 mNumFrustumCulledNodes = 0; 40 40 mNumRenderedGeometry = 0; 41 41 mNumRenderedNodes = 0; 42 42 43 mCurrentTestIdx = 0; 43 44 44 45 initDistanceQueue(cam); 45 46 46 //mCurrentAlgorithm = RENDER_CULL_FRUSTUM; 47 //deleteQueries(); 48 //char *msg = "deleting queries\n"; OutputDebugString(msg); 49 //for(unsigned int i=0; i < 1000; i++) 50 //mOcclusionQueries.push_back(mRenderSystem->createHardwareOcclusionQuery()); 51 //mCurrentAlgorithm = RENDER_CULL_FRUSTUM; 52 47 53 switch(mCurrentAlgorithm) 48 54 { … … 54 60 break; 55 61 case RENDER_COHERENT: 56 //renderCoherentWithQueue(cam); 57 renderStopAndWait(cam); 62 renderCoherentWithQueue(cam); 58 63 break; 59 64 default: … … 209 214 // wait if result not available 210 215 query->pullOcclusionQuery(&visiblePixels); 211 216 212 217 // node visible 213 218 if(visiblePixels > mVisibilityThreshold) … … 229 234 // TODO: in rendervisibleobjects, the rendermode is changed by ogre itself => change this!! 230 235 231 //setRenderingMode(MODE_QUERY);232 setRenderingMode(MODE_RENDER);236 setRenderingMode(MODE_QUERY); 237 //setRenderingMode(MODE_RENDER); 233 238 234 239 // get next available test id … … 251 256 //{ 252 257 bool enabled = (mode == MODE_RENDER); 253 258 //if(mode == MODE_QUERY){ 254 259 mRenderSystem->_setColourBufferWriteEnabled(enabled, 255 260 enabled, enabled, enabled); 256 261 mRenderSystem->_setDepthBufferWriteEnabled(enabled); 257 262 mRenderSystem->setLightingEnabled(enabled); 258 263 //} 259 264 mQueryMode = mode; 260 265 //} … … 346 351 void OcclusionCullingSceneTraverser::deleteQueries( void ) 347 352 { 348 for(unsigned int i=0; i < (unsigned int)mOcclusionQueries.size(); i++)353 for(unsigned int i=0; i < (unsigned int)mOcclusionQueries.size(); ++i) 349 354 delete mOcclusionQueries[i]; 350 355 … … 357 362 for(int half = 0; half < 2; half ++) 358 363 { 359 //static Matrix4 xform[256];360 //TODO: this should be full bou dning box364 static Matrix4 xform[256]; 365 //TODO: this should be full bounding box 361 366 SolidHalfBoundingBox *halfbox = getSolidHalfBoundingBox(half); 362 367 halfbox->setupBoundingBox(*box); 363 364 mRenderSystem->_setWorldMatrix(Matrix4::IDENTITY);365 368 369 //mRenderSystem->_setWorldMatrix(Matrix4::IDENTITY); 370 // Set world transformation 371 /*halfbox->getWorldTransforms(xform); 372 373 int numMatrices = halfbox->getNumWorldTransforms(); 374 if (numMatrices > 1) 375 { 376 mRenderSystem->_setWorldMatrices(xform, numMatrices); 377 } 378 else 379 { 380 mRenderSystem->_setWorldMatrix(*xform); 381 } 382 mRenderSystem->setClipPlanes(halfbox->getClipPlanes()); 383 366 384 static RenderOperation ro; 367 385 … … 369 387 halfbox->getRenderOperation(ro); 370 388 ro.srcRenderable = halfbox; 371 mRenderSystem->_render(ro); 372 373 //mSceneManager->renderSingleObject(getSolidHalfBoundingBox(half),374 //getSolidHalfBoundingBox(half)->getTechnique()->getPass(0), false);389 mRenderSystem->_render(ro);*/ 390 391 mSceneManager->myrenderSingleObject(getSolidHalfBoundingBox(half), 392 getSolidHalfBoundingBox(half)->getTechnique()->getPass(0), false); 375 393 } 376 394 } … … 410 428 { 411 429 mOcclusionQueries.push_back(mRenderSystem->createHardwareOcclusionQuery()); 430 //char *msg = "creating query!!\n"; OutputDebugString(msg); 412 431 } 413 432 -
trunk/VUT/OcclusionCullingSceneManager/src/OgreOcclusionCullingTerrainSceneManager.cpp
r48 r51 18 18 //mDisplayNodes = true; 19 19 //mShowBoundingBoxes = true; 20 //mShowBoxes = true;20 mShowBoxes = true; 21 21 mMaxDepth = 20; 22 22 } … … 95 95 } 96 96 //----------------------------------------------------------------------- 97 void OcclusionCullingTerrainSceneManager::_renderOctant(Camera *cam, Octree *octant)98 {99 //Add stuff to be rendered;100 NodeList::iterator it = octant->mNodes.begin();101 102 while(it != octant->mNodes.end())103 {104 OctreeNode *sn = *it;105 106 mNumObjects++;107 108 // check bounding box visibility of scene nodes109 if (cam->isVisible(sn->_getWorldAABB()))110 {111 sn->_addToRenderQueue(cam, getRenderQueue(), false);112 //node->_findVisibleObjects(cam, getRenderQueue(), false, mDisplayNodes, false);113 mVisible.push_back(sn);114 115 if (mDisplayNodes)116 getRenderQueue()->addRenderable(sn);117 118 // check if the scene manager or this node wants the bounding box shown.119 if (sn->getShowBoundingBox() || mShowBoundingBoxes)120 sn->_addBoundingBoxToQueue(getRenderQueue());121 122 if (mShowBoxes)123 getRenderQueue()->addRenderable(octant->getWireBoundingBox());124 }125 ++it;126 }127 128 SceneManager::_renderVisibleObjects();129 130 // delete all rendered objects from renderqueue131 _deleteRenderedQueueGroups();132 }133 //-----------------------------------------------------------------------134 97 /*unsigned int OcclusionCullingTerrainSceneManager::countNumOctrees(Octree *root) 135 98 { -
trunk/VUT/OcclusionCullingSceneManager/src/OgreSolidHalfBoundingBox.cpp
r26 r51 89 89 setBoundingBox(aabb); 90 90 } 91 // Override this method to prevent parent transforms (rotation,translation,scale) 92 void SolidHalfBoundingBox::getWorldTransforms( Matrix4* xform ) const 93 { 94 // return identity matrix to prevent parent transforms 95 *xform = Matrix4::IDENTITY; 96 } 91 97 } 92 98
Note: See TracChangeset
for help on using the changeset viewer.