Changeset 34
- Timestamp:
- 03/30/05 17:54:55 (20 years ago)
- Location:
- trunk/VUT/OcclusionCullingSceneManager
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/VUT/OcclusionCullingSceneManager/TestCulling/TestCullingApplication.cpp
r33 r34 20 20 #include "windows.h" 21 21 22 RaySceneQuery* raySceneQuery = 0; 23 22 24 /***********************************************/ 23 25 /* TestCullingApplication implementation */ 24 26 /***********************************************/ 25 26 27 TestCullingApplication::~TestCullingApplication() 28 { 29 delete raySceneQuery; 30 } 31 //----------------------------------------------------------------------- 32 void TestCullingApplication::createCamera( void ) 33 { 34 // Create the camera 35 mCamera = mSceneMgr->createCamera("PlayerCam"); 36 37 // Position it at 500 in Z direction 38 mCamera->setPosition(Vector3(128,25,128)); 39 40 // Look back along -Z 41 mCamera->lookAt(Vector3(0,0,-300)); 42 mCamera->setNearClipDistance( 1 ); 43 mCamera->setFarClipDistance( 1000 ); 44 } 27 45 //----------------------------------------------------------------------- 28 46 void TestCullingApplication::createScene(void) 29 47 { 48 Plane waterPlane; 49 // Set ambient light 50 mSceneMgr->setAmbientLight(ColourValue(0.5, 0.5, 0.5)); 51 52 // Create a light 53 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 mWindow->getViewport(0)->setBackgroundColour(fadeColour); 65 66 std::string terrain_cfg("terrain.cfg"); 67 #if OGRE_PLATFORM == OGRE_PLATFORM_APPLE 68 terrain_cfg = mResourcePath + terrain_cfg; 69 #endif 70 mSceneMgr -> setWorldGeometry( terrain_cfg ); 71 // Infinite far plane? 72 if (mRoot->getRenderSystem()->getCapabilities()->hasCapability(RSC_INFINITE_FAR_PLANE)) 73 { 74 mCamera->setFarClipDistance(0); 75 } 76 77 // Define the required skyplane 78 Plane plane; 79 // 5000 world units from the camera 80 plane.d = 5000; 81 // Above the camera, facing down 82 plane.normal = -Vector3::UNIT_Y; 83 84 // Set a nice viewpoint 85 mCamera->setPosition(707,2500,528); 86 mCamera->setOrientation(Quaternion(-0.3486, 0.0122, 0.9365, 0.0329)); 87 88 raySceneQuery = mSceneMgr->createRayQuery( 89 Ray(mCamera->getPosition(), Vector3::NEGATIVE_UNIT_Y)); 90 30 91 // Create a skybox 31 mSceneMgr->setSkyBox(true, "Examples/SpaceSkyBox"); 32 mShip = mSceneMgr->createEntity("razor", "razor.mesh"); 33 mShipNode = mSceneMgr->getRootSceneNode()->createChildSceneNode(); 34 mShipNode->attachObject(mShip); 35 36 mSceneMgr->setAmbientLight(ColourValue(0.5, 0.5, 0.5)); 92 // mSceneMgr->setSkyBox(true, "Examples/SpaceSkyBox"); 37 93 38 94 // CEGUI setup 39 mGUIRenderer = new CEGUI::OgreCEGUIRenderer(mWindow, Ogre::RENDER_QUEUE_OVERLAY, false, 3000, ST_GENERIC); 95 setupGui(); 96 } 97 //----------------------------------------------------------------------- 98 void TestCullingApplication::setupGui( void ) 99 { 100 mGUIRenderer = new CEGUI::OgreCEGUIRenderer(mWindow, Ogre::RENDER_QUEUE_OVERLAY, false, 3000, ST_EXTERIOR_CLOSE); 40 101 mGUISystem = new CEGUI::System(mGUIRenderer); 41 102 … … 57 118 void TestCullingApplication::createFrameListener(void) 58 119 { 59 mFrameListener= new MouseQueryListener(mWindow, mCamera, mSceneMgr, mGUIRenderer , mShipNode);120 mFrameListener= new MouseQueryListener(mWindow, mCamera, mSceneMgr, mGUIRenderer); 60 121 mFrameListener->showDebugOverlay(true); 61 122 mRoot->addFrameListener(mFrameListener); … … 73 134 74 135 //----------------------------------------------------------------------- 75 MouseQueryListener::MouseQueryListener(RenderWindow* win, Camera* cam, SceneManager *sceneManager, CEGUI::Renderer *renderer ,76 SceneNode* shipNode) 77 : ExampleFrameListener(win, cam, false, true), mGUIRenderer(renderer), mShipNode(shipNode)//,mShutdownRequested(false)136 MouseQueryListener::MouseQueryListener(RenderWindow* win, Camera* cam, SceneManager *sceneManager, CEGUI::Renderer *renderer) 137 : ExampleFrameListener(win, cam, false, true), mGUIRenderer(renderer), 138 mShutdownRequested(false) 78 139 { 79 140 80 141 // Setup default variables 81 mCurrentObject = NULL;142 // mCurrentObject = NULL; 82 143 mLMouseDown = false; 83 144 mRMouseDown = false; … … 144 205 CEGUI::MouseCursor::getSingleton().show( ); 145 206 mLMouseDown = false; 146 } // if207 } 147 208 // Right mouse button up 148 209 else if (e->getButtonID() & InputEvent::BUTTON1_MASK) … … 150 211 CEGUI::MouseCursor::getSingleton().show( ); 151 212 mRMouseDown = false; 152 } // else if153 } // mouseReleased213 } 214 } 154 215 //----------------------------------------------------------------------- 155 216 void MouseQueryListener::mouseDragged (MouseEvent *e) 156 217 { 157 // If we are dragging the left mouse button. 158 if ( mLMouseDown ) 159 { 160 mShipNode->translate(-e->getRelX() * 200, -e->getRelY() * 200, 0.0); 161 } // if 162 163 // If we are dragging the right mouse button. 164 else if ( mRMouseDown ) 165 { 166 mCamera->yaw( -e->getRelX() * mRotateSpeed ); 167 mCamera->pitch( -e->getRelY() * mRotateSpeed ); 168 } // else if 169 } // mouseDragged 218 /* 219 // If we are dragging the left mouse button. 220 if ( mLMouseDown ) 221 { 222 mShipNode->translate(-e->getRelX() * 200, -e->getRelY() * 200, 0.0); 223 } 224 */ 225 226 // If we are dragging the right mouse button. 227 if ( mRMouseDown ) 228 { 229 mCamera->yaw( -e->getRelX() * mRotateSpeed ); 230 mCamera->pitch( -e->getRelY() * mRotateSpeed ); 231 } 232 } 233 //----------------------------------------------------------------------- 234 bool MouseQueryListener::frameStarted(const FrameEvent &evt) 235 { 236 // clamp to terrain 237 static Ray updateRay; 238 updateRay.setOrigin(mCamera->getPosition()); 239 updateRay.setDirection(Vector3::NEGATIVE_UNIT_Y); 240 raySceneQuery->setRay(updateRay); 241 RaySceneQueryResult& qryResult = raySceneQuery->execute(); 242 RaySceneQueryResult::iterator i = qryResult.begin(); 243 244 if (i != qryResult.end() && i->worldFragment) 245 { 246 SceneQuery::WorldFragment* wf = i->worldFragment; 247 mCamera->setPosition(mCamera->getPosition().x, 248 i->worldFragment->singleIntersection.y + 10, 249 mCamera->getPosition().z); 250 } 251 252 return ExampleFrameListener::frameStarted(evt); 253 } 170 254 //----------------------------------------------------------------------- 171 255 bool MouseQueryListener::frameEnded(const FrameEvent& evt) … … 252 336 TestCullingApplication app; 253 337 254 try { 338 try 339 { 255 340 app.go(); 256 } catch( Ogre::Exception& e ) { 341 } 342 catch( Ogre::Exception& e ) 343 { 257 344 MessageBox( NULL, e.getFullDescription().c_str(), "An exception has occured!", MB_OK | MB_ICONERROR | MB_TASKMODAL); 258 345 } -
trunk/VUT/OcclusionCullingSceneManager/TestCulling/TestCullingApplication.h
r33 r34 29 29 public: 30 30 31 MouseQueryListener(RenderWindow* win, Camera* cam, SceneManager *sceneManager, CEGUI::Renderer *renderer, 32 SceneNode* shipNode); 31 MouseQueryListener(RenderWindow* win, Camera* cam, SceneManager *sceneManager, CEGUI::Renderer *renderer); 33 32 34 33 … … 37 36 } 38 37 38 bool frameStarted(const FrameEvent& evt); 39 39 bool frameEnded(const FrameEvent& evt); 40 40 41 /* MouseListener callbacks. */ 41 42 virtual void mouseClicked(MouseEvent* e) { } … … 67 68 bool mLMouseDown, mRMouseDown; // True if the mouse buttons are down 68 69 SceneManager *mSceneMgr; // A pointer to the scene manager 69 SceneNode *mCurrentObject; // The newly created object70 71 SceneNode* mShipNode;70 71 CEGUI::Renderer *mGUIRenderer; // cegui renderer 72 72 73 bool mShutdownRequested; 73 74 int mCurrentAlgorithm; … … 79 80 OverlayElement *mQueryCulledNodesInfo; 80 81 OverlayElement *mTraversedNodesInfo; 81 82 82 }; 83 83 … … 86 86 { 87 87 public: 88 /*TestCullingApplication() 89 { 90 }*/ 88 ~TestCullingApplication(); 91 89 92 90 protected: 93 91 void createScene(void); 94 92 void createFrameListener(void); 93 void setupGui(void); 94 virtual void createCamera(void); 95 95 96 96 CEGUI::OgreCEGUIRenderer *mGUIRenderer; … … 100 100 void chooseSceneManager(void); 101 101 102 Entity* mShip; 103 SceneNode* mShipNode; 104 105 /* String mQuakePk3; 106 String mQuakeLevel; 107 108 // Override resource sources (include Quake3 archives) 109 void setupResources(void) 110 { 111 112 // Load Quake3 locations from a file 113 ConfigFile cf; 114 115 cf.load("quake3settings.cfg"); 116 117 mQuakePk3 = cf.getSetting("Pak0Location"); 118 mQuakeLevel = cf.getSetting("Map"); 119 120 ExampleApplication::setupResources(); 121 ResourceManager::addCommonArchiveEx(mQuakePk3, "Zip"); 122 123 }*/ 102 //Entity* mShip; 103 //SceneNode* mShipNode; 124 104 }; 125 105 -
trunk/VUT/OcclusionCullingSceneManager/include/OgreOcclusionCullingTerrainSceneManager.h
r33 r34 26 26 ~OcclusionCullingTerrainSceneManager(); 27 27 28 void _renderVisibleObjects(void); 29 void _findVisibleObjects(Camera* cam, bool onlyShadowCasters); 30 void _updateSceneGraph(Camera* cam); 28 //void _renderVisibleObjects(void); 29 //void _findVisibleObjects(Camera* cam, bool onlyShadowCasters); 30 31 //void _updateSceneGraph(Camera* cam); 31 32 32 33 /** Sets the given option for the SceneManager … … 35 36 "Algorithm", int *; 36 37 */ 38 37 39 virtual bool setOption( const String &, const void * ); 38 40 /** Gets the given option for the Scene Manager. -
trunk/VUT/OcclusionCullingSceneManager/src/OgreOcclusionCullingSceneManagerDll.cpp
r33 r34 27 27 #include "OgreOcclusionCullingSceneManager.h" 28 28 #include "OgreOcclusionCullingDotSceneManager.h" 29 #include "OgreHeightmapTerrainPageSource.h" 29 30 #include <OgreRoot.h> 30 31 31 //#include "OgreHeightmapTerrainPageSource.h"32 32 //#include <windows.h> 33 33 … … 36 36 OcclusionCullingSceneManager *occlusionPlugin; 37 37 OcclusionCullingTerrainSceneManager *occlusionTerrainPlugin; 38 38 HeightmapTerrainPageSource* heightmapTerrainPageSource; 39 39 40 //----------------------------------------------------------------------- 40 41 extern "C" void dllStartPlugin(void) … … 43 44 occlusionPlugin = new OcclusionCullingSceneManager(); 44 45 occlusionTerrainPlugin = new OcclusionCullingTerrainSceneManager(); 45 46 heightmapTerrainPageSource = new HeightmapTerrainPageSource(); 47 48 occlusionTerrainPlugin->registerPageSource("Heightmap", heightmapTerrainPageSource); 49 46 50 // Register 47 51 Root::getSingleton().setSceneManager( ST_GENERIC, occlusionPlugin ); … … 52 56 extern "C" void dllStopPlugin(void) 53 57 { 58 delete heightmapTerrainPageSource; 54 59 delete occlusionPlugin; 55 60 delete occlusionTerrainPlugin; -
trunk/VUT/OcclusionCullingSceneManager/src/OgreOcclusionCullingSceneTraverser.cpp
r33 r34 41 41 mDistanceQueue->push(root); 42 42 mCurrentTestIdx = 0; 43 43 44 mCurrentAlgorithm = RENDER_CULL_FRUSTUM; 44 45 switch(mCurrentAlgorithm) 45 46 { … … 144 145 node->setNodeVisible(false); 145 146 146 if( cam->isVisible(node->_getWorldAABB()))147 if(!cam->isVisible(node->_getWorldAABB())) 147 148 { 148 149 // update node's visited flag … … 151 152 traverseNode(cam, node); 152 153 } 153 else 154 //else 155 if(cam->isVisible(node->_getWorldAABB())) 156 { 157 mNumQueryCulledNodes ++; 158 }else 154 159 { 155 160 mNumFrustumCulledNodes ++; … … 230 235 { 231 236 mNumTraversedNodes ++; 232 237 233 238 if(node->numAttachedObjects() > 0) 234 239 { … … 252 257 //HACK (too slow) 253 258 mSceneManager->_renderSceneNode(cam, node); 259 //MessageBox( NULL, "myplugin registered", "this is my plugin", MB_OK | MB_ICONERROR | MB_TASKMODAL); 254 260 } 255 261 //----------------------------------------------------------------------- -
trunk/VUT/OcclusionCullingSceneManager/src/OgreOcclusionCullingTerrainSceneManager.cpp
r33 r34 15 15 { 16 16 mOcclusionCullingSceneTraverser = new OcclusionCullingSceneTraverser(this, mDestRenderSystem); 17 mDisplayNodes = true; 18 //mShowBoundingBoxes = true; 19 mShowBoxes = true; 17 20 } 18 21 //----------------------------------------------------------------------- … … 22 25 } 23 26 //----------------------------------------------------------------------- 24 void OcclusionCullingTerrainSceneManager::_renderVisibleObjects(void)27 /*void OcclusionCullingTerrainSceneManager::_renderVisibleObjects(void) 25 28 { 26 29 mOcclusionCullingSceneTraverser->renderScene(mCameraInProgress, mSceneRoot); … … 38 41 39 42 TerrainSceneManager::_updateSceneGraph(cam); 40 } 43 }*/ 41 44 //----------------------------------------------------------------------- 42 45 bool OcclusionCullingTerrainSceneManager::setOption( const String & key, const void * val )
Note: See TracChangeset
for help on using the changeset viewer.