- Timestamp:
- 05/03/05 02:44:23 (20 years ago)
- Location:
- trunk/VUT
- Files:
-
- 2 added
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/VUT/work/TestCullingTerrain/TerrainContentGenerator.cpp
r74 r75 6 6 */ 7 7 #include "TerrainContentGenerator.h" 8 8 #include <windows.h> 9 9 /********************************************/ 10 10 /* TerrainContentGenerator implementation */ 11 11 /********************************************/ 12 12 //----------------------------------------------------------------------- 13 TerrainContentGenerator::TerrainContentGenerator( SceneManager *sm, RayQueryExecutor *rayQueryEx)13 TerrainContentGenerator::TerrainContentGenerator(SceneManager *sm) 14 14 { 15 15 mSceneMgr = sm; 16 mRayQueryExecutor = rayQueryEx;16 mRayQueryExecutor = new RayQueryExecutor(sm); 17 17 18 mMinPos = Vector3(- 200.0f, -70.0f, 200.0f);19 mMaxPos = Vector3( 200.0f, 70.0f, 200.0f);18 mMinPos = Vector3(-500.0f, 5000.0f, -500.0f); 19 mMaxPos = Vector3(500.0f, 5000.0f, 500.0f); 20 20 21 21 mMinAngle = 0; … … 25 25 } 26 26 //----------------------------------------------------------------------- 27 void TerrainContentGenerator::generateScene( int numObjects)27 TerrainContentGenerator::~TerrainContentGenerator() 28 28 { 29 srand (time (0)); 29 delete mRayQueryExecutor; 30 } 31 //----------------------------------------------------------------------- 32 void TerrainContentGenerator::generateScene(int numObjects, const String &meshName) 33 { 34 srand (time(0)); 30 35 31 36 Vector3 rotationRatio; 32 37 Vector3 translationRatio; 33 38 34 for(int i=0; i < numObjects; i++)39 for(int i=0; i < numObjects; ++i) 35 40 { 36 41 rotationRatio.x = rand() / (float) RAND_MAX; … … 42 47 translationRatio.z = rand() / (float) RAND_MAX; 43 48 44 generateSceneObject(translationRatio, rotationRatio, i, "sphere.mesh");49 generateSceneObject(translationRatio, rotationRatio, i, meshName); 45 50 } 46 51 } … … 53 58 Vector3 position = mMinPos + translationRatio * (mMaxPos - mMinPos); 54 59 55 position.y = 5000;56 57 60 Vector3 queryResult; 58 61 59 if(mRayQueryExecutor->executeRayQuery(&queryResult, position, Vector3::NEGATIVE_UNIT_Y)) 62 char msg[100]; 63 sprintf(msg, "pos: %3.3f %3.3f %3.3f\n", position.x, position.y, position.z); 64 65 if (mRayQueryExecutor->executeRayQuery(&queryResult, position, Vector3::NEGATIVE_UNIT_Y)) 60 66 { 61 67 char name[16]; 62 sprintf( 63 68 sprintf(name, "%s%d", entName.c_str(), mCount++); 69 OutputDebugString("Creating new object "); OutputDebugString(msg); 64 70 Entity *ent = mSceneMgr->createEntity(name, entName); 65 71 SceneNode *currentObject = mSceneMgr->getRootSceneNode()-> … … 67 73 currentObject->attachObject(ent); 68 74 currentObject->setScale(0.1f, 0.1f, 0.1f); 75 currentObject->setPosition(position); 76 } 77 else 78 { 79 OutputDebugString(msg); 69 80 } 70 81 } -
trunk/VUT/work/TestCullingTerrain/TerrainContentGenerator.h
r74 r75 24 24 { 25 25 public: 26 TerrainContentGenerator(SceneManager *sm, RayQueryExecutor *rayQueryEx); 26 TerrainContentGenerator(SceneManager *sm); 27 ~TerrainContentGenerator(); 27 28 /** Generates a the scene hierarchy with random values . 28 29 @param number of objects to generate 30 @param the name of the mesh to be generated 29 31 */ 30 void generateScene(int numObjects );32 void generateScene(int numObjects, const String &meshName); 31 33 /** Generates a new scene object 32 34 @param tranlationRatio ratio between minimal and maximal possible translation -
trunk/VUT/work/TestCullingTerrain/TestCullingTerrainApplication.cpp
r74 r75 25 25 TestCullingTerrainApplication::~TestCullingTerrainApplication() 26 26 { 27 delete mRayQueryExecutor;28 27 delete mTerrainContentGenerator; 29 28 } 30 31 29 //----------------------------------------------------------------------- 32 30 void TestCullingTerrainApplication::createCamera( void ) … … 44 42 } 45 43 //----------------------------------------------------------------------- 46 void TestCullingTerrainApplication::createScene( void ) 47 { 48 mRayQueryExecutor = new RayQueryExecutor(mSceneMgr); 49 mTerrainContentGenerator = new TerrainContentGenerator(mSceneMgr, mRayQueryExecutor); 50 44 void TestCullingTerrainApplication::createScene() 45 { 51 46 // Set ambient light 52 47 mSceneMgr->setAmbientLight(ColourValue(0.5, 0.5, 0.5)); … … 93 88 mCamera->setPosition(707,2500,528); 94 89 mCamera->setOrientation(Quaternion(-0.3486, 0.0122, 0.9365, 0.0329)); 95 90 96 91 // CEGUI setup 97 92 setupGui(); 98 93 99 mTerrainContentGenerator->generateScene(100); 94 mTerrainContentGenerator = new TerrainContentGenerator(mSceneMgr); 95 mTerrainContentGenerator->generateScene(300, "robot.mesh"); 100 96 } 101 97 //----------------------------------------------------------------------- 102 98 void TestCullingTerrainApplication::setupGui( void ) 103 99 { 104 mGUIRenderer = new CEGUI::OgreCEGUIRenderer(mWindow, Ogre::RENDER_QUEUE_OVERLAY, false, 3000, ST_EXTERIOR_CLOSE); 100 mGUIRenderer = new CEGUI::OgreCEGUIRenderer(mWindow, Ogre::RENDER_QUEUE_OVERLAY, 101 false, 3000, ST_EXTERIOR_CLOSE); 105 102 mGUISystem = new CEGUI::System(mGUIRenderer); 106 103 … … 111 108 (CEGUI::utf8*)"TaharezLook", (CEGUI::utf8*)"MouseArrow"); 112 109 113 CEGUI::MouseCursor::getSingleton().show( 110 CEGUI::MouseCursor::getSingleton().show(); 114 111 } 115 112 //----------------------------------------------------------------------- 116 113 void TestCullingTerrainApplication::createFrameListener(void) 117 114 { 118 mFrameListener= new MouseQueryListener(mWindow, mCamera, mSceneMgr, mGUIRenderer , mRayQueryExecutor);115 mFrameListener= new MouseQueryListener(mWindow, mCamera, mSceneMgr, mGUIRenderer); 119 116 mFrameListener->showDebugOverlay(true); 120 117 mRoot->addFrameListener(mFrameListener); … … 130 127 /***********************************************/ 131 128 //----------------------------------------------------------------------- 132 MouseQueryListener::MouseQueryListener(RenderWindow* win, Camera* cam, SceneManager *sceneManager, CEGUI::Renderer *renderer, RayQueryExecutor *rqe) 133 : ExampleFrameListener(win, cam, false, true), mGUIRenderer(renderer), mShutdownRequested(false), mRayQueryExecutor(rqe) 134 { 135 129 MouseQueryListener::MouseQueryListener(RenderWindow* win, Camera* cam, 130 SceneManager *sceneManager, 131 CEGUI::Renderer *renderer): 132 ExampleFrameListener(win, cam, false, true), mGUIRenderer(renderer), 133 mShutdownRequested(false) 134 { 136 135 // Setup default variables 137 136 mCurrentObject = NULL; … … 153 152 154 153 mRayQueryExecutor = new RayQueryExecutor(mSceneMgr); 155 154 156 155 // show overlay 157 156 Overlay* pOver = OverlayManager::getSingleton().getByName("Example/VisibilityDemoOverlay"); … … 184 183 { 185 184 // Update CEGUI with the mouse motion 186 CEGUI::System::getSingleton().injectMouseMove(e->getRelX() * mGUIRenderer->getWidth(), e->getRelY() * mGUIRenderer->getHeight()); 185 CEGUI::System::getSingleton().injectMouseMove(e->getRelX() * mGUIRenderer->getWidth(), 186 e->getRelY() * mGUIRenderer->getHeight()); 187 187 } 188 188 //----------------------------------------------------------------------- … … 202 202 { 203 203 char name[16]; 204 sprintf( name, "Robot%d", mCount++);204 sprintf(name, "Robot%d", mCount++); 205 205 206 206 Entity *ent = mSceneMgr->createEntity(name, "robot.mesh"); 207 207 mCurrentObject = mSceneMgr->getRootSceneNode()-> 208 createChildSceneNode( String(name) + "Node", queryResult); 209 mCurrentObject->attachObject( ent ); 210 mCurrentObject->setScale( 0.1f, 0.1f, 0.1f ); 208 createChildSceneNode(String(name) + "Node", queryResult); 209 mCurrentObject->attachObject(ent); 210 mCurrentObject->setScale(0.1f, 0.1f, 0.1f); 211 211 212 } 212 213 … … 216 217 else if (e->getButtonID() & InputEvent::BUTTON1_MASK) 217 218 { 218 CEGUI::MouseCursor::getSingleton().hide( 219 CEGUI::MouseCursor::getSingleton().hide(); 219 220 mRMouseDown = true; 220 221 } // else if … … 227 228 if (e->getButtonID() & InputEvent::BUTTON0_MASK) 228 229 { 229 CEGUI::MouseCursor::getSingleton().show( 230 CEGUI::MouseCursor::getSingleton().show(); 230 231 mLMouseDown = false; 231 232 } … … 233 234 else if (e->getButtonID() & InputEvent::BUTTON1_MASK) 234 235 { 235 CEGUI::MouseCursor::getSingleton().show( 236 CEGUI::MouseCursor::getSingleton().show(); 236 237 mRMouseDown = false; 237 238 } 238 239 } 239 240 //----------------------------------------------------------------------- 240 void MouseQueryListener::mouseDragged 241 void MouseQueryListener::mouseDragged(MouseEvent *e) 241 242 { 242 243 // If we are dragging the left mouse button. 243 if ( mLMouseDown)244 if (mLMouseDown) 244 245 { 245 246 Vector3 queryResult; … … 252 253 } 253 254 // If we are dragging the right mouse button. 254 if ( mRMouseDown)255 if (mRMouseDown) 255 256 { 256 257 mCamera->yaw( -e->getRelX() * mRotateSpeed ); … … 271 272 mCamera->getPosition().z); 272 273 } 273 274 274 275 return ExampleFrameListener::frameStarted(evt); 275 276 } … … 371 372 catch( Ogre::Exception& e ) 372 373 { 373 MessageBox( NULL, e.getFullDescription().c_str(), "An exception has occured!", MB_OK | MB_ICONERROR | MB_TASKMODAL); 374 MessageBox( NULL, e.getFullDescription().c_str(), 375 "An exception has occured!", MB_OK | MB_ICONERROR | MB_TASKMODAL); 374 376 } 375 377 -
trunk/VUT/work/TestCullingTerrain/TestCullingTerrainApplication.h
r74 r75 30 30 31 31 MouseQueryListener(RenderWindow* win, Camera* cam, SceneManager *sceneManager, 32 CEGUI::Renderer *renderer , RayQueryExecutor *rqe);32 CEGUI::Renderer *renderer); 33 33 34 34 … … 103 103 CEGUI::OgreCEGUIRenderer *mGUIRenderer; 104 104 CEGUI::System *mGUISystem; 105 RayQueryExecutor *mRayQueryExecutor; 106 TerrainContentGenerator *mTerrainContentGenerator; 105 // RayQueryExecutor *mRayQueryExecutor; 107 106 108 107 Vector3 mMinTranslation; … … 112 111 Vector3 mMaxAngle; 113 112 113 TerrainContentGenerator *mTerrainContentGenerator; 114 114 115 private: 115 116 void chooseSceneManager(void);
Note: See TracChangeset
for help on using the changeset viewer.