Changeset 130 for trunk/VUT/work
- Timestamp:
- 06/14/05 02:50:05 (20 years ago)
- Location:
- trunk/VUT/work
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/VUT/work/TestCulling/TestCullingApplication.cpp
r115 r130 161 161 } 162 162 //----------------------------------------------------------------------- 163 TerrainMouseQueryListener::~TerrainMouseQueryListener( 164 { 165 } 166 //----------------------------------------------------------------------- 167 void TerrainMouseQueryListener::mouseMoved 163 TerrainMouseQueryListener::~TerrainMouseQueryListener() 164 { 165 } 166 //----------------------------------------------------------------------- 167 void TerrainMouseQueryListener::mouseMoved(MouseEvent *e) 168 168 { 169 169 // Update CEGUI with the mouse motion 170 CEGUI::System::getSingleton().injectMouseMove(e->getRelX() * mGUIRenderer->getWidth(), e->getRelY() * mGUIRenderer->getHeight()); 170 CEGUI::System::getSingleton().injectMouseMove(e->getRelX() * 171 mGUIRenderer->getWidth(), e->getRelY() * mGUIRenderer->getHeight()); 171 172 } 172 173 //----------------------------------------------------------------------- -
trunk/VUT/work/TestCullingTerrain/TerrainMouseQueryListener.cpp
r122 r130 6 6 #include <OgreMemoryMacros.h> 7 7 #include "TerrainMouseQueryListener.h" 8 #include "OgrePlatformQueryManager.h" 9 #include "OgreVisibilityTerrainSceneManager.h" 10 #include "VisibilityInfo.h" 8 11 9 12 // output file for frame info … … 54 57 mTerrainContentGenerator(sceneGenerator), 55 58 mVisibilityThreshold(0), 56 //mCurrentAlgorithm(GtpVisibility::VisibilityEnvironment::COHERENT_HIERARCHICAL_CULLING),57 mCurrentAlgorithm(GtpVisibility::VisibilityEnvironment::FRUSTUM_CULLING),59 mCurrentAlgorithm(GtpVisibility::VisibilityEnvironment::COHERENT_HIERARCHICAL_CULLING), 60 //mCurrentAlgorithm(GtpVisibility::VisibilityEnvironment::FRUSTUM_CULLING), 58 61 mNodeVizMode(NODEVIZ_NONE), 59 62 mVizCameraHeight(Real(2500.0)), … … 81 84 mSunLight(sunLight) 82 85 { 83 mInputDevice = PlatformManager::getSingleton().createInputReader(); 84 mInputDevice->initialise(win, true, true); 85 86 /* 86 //mInputDevice = PlatformManager::getSingleton().createInputReader(); 87 88 //mInputDevice->initialise(win, true, true); 89 mEventProcessor = new EventProcessor(); 90 91 mEventProcessor->initialise(win); 92 mEventProcessor->startProcessingEvents(); 87 93 mEventProcessor->addMouseListener(this); 88 94 mEventProcessor->addMouseMotionListener(this); 89 mEventProcessor->addKeyListener(this); 90 */ 95 96 //mEventProcessor->addKeyListener(this); 97 mInputDevice = mEventProcessor->getInputReader(); 98 91 99 92 100 // create ray query executor, used to place objects in terrain … … 145 153 mSceneMgr->setOption("CullCamera", &mCullCamera); 146 154 mSceneMgr->setOption("ShowVisualization", &mShowVisualization); 155 156 mVisibilityManager = 157 dynamic_cast<VisibilityTerrainSceneManager *>(mSceneMgr)->GetVisibilityManager(); 158 159 dynamic_cast<PlatformQueryManager *>(mVisibilityManager->GetQueryManager())-> 160 SetViewport(mWindow->getViewport(0)); 147 161 } 148 162 //----------------------------------------------------------------------- 149 163 TerrainMouseQueryListener::~TerrainMouseQueryListener() 150 164 { 151 PlatformManager::getSingleton().destroyInputReader(mInputDevice);165 //PlatformManager::getSingleton().destroyInputReader(mInputDevice); 152 166 153 167 delete mRayQueryExecutor; 168 delete mEventProcessor; 154 169 } 155 170 //----------------------------------------------------------------------- … … 170 185 // Setup the ray scene query 171 186 Ray mouseRay = mCamera->getCameraToViewportRay(e->getX(), e->getY()); 172 173 Vector3 queryResult;187 188 //Vector3 queryResult; mRayQueryExecutor->executeRayQuery(&queryResult, mouseRay); 174 189 175 190 // Get results, create a node/entity on the position 176 191 mCurrentObject = mTerrainContentGenerator->GenerateSceneObject( 177 mouseRay.getOrigin(), Vector3 (0,0,0), "robot");192 mouseRay.getOrigin(), Vector3::ZERO, "robot", false); 178 193 179 194 mLMouseDown = true; … … 231 246 bool TerrainMouseQueryListener::frameStarted(const FrameEvent &evt) 232 247 { 233 LogManager::getSingleton().logMessage("frame started");234 248 if (mWindow->isClosed()) 249 { 235 250 return false; 236 237 mInputDevice->capture(); 238 239 //-- IMPORTANT: must be set, otherwise terrain is not rendered correctly 240 int terrainLevelIdx = 0; 241 mSceneMgr->setOption("TerrainLevelIdx", &terrainLevelIdx); 242 243 //-- setup what is needed for immediate mouse/key movement 244 if (mTimeDelay >= 0) 245 mTimeDelay -= evt.timeSinceLastFrame; 246 247 // If this is the first frame, pick a speed 248 if (evt.timeSinceLastFrame == 0) 249 { 250 mMoveScale = 1; 251 mRotScale = 0.1; 252 } 253 // Otherwise scale movement units by time passed since last frame 254 else 255 { 256 // Move about 100 units per second, 257 mMoveScale = mMoveSpeed * evt.timeSinceLastFrame; 258 // Take about 10 seconds for full rotation 259 mRotScale = mRotateSpeed * evt.timeSinceLastFrame; 260 } 261 262 mRotX = 0; 263 mRotY = 0; 264 mTranslateVector = Vector3::ZERO; 265 266 if (!processUnbufferedKeyInput(evt)) 267 { 268 return false; 269 } 270 if (!processUnbufferedMouseInput(evt)) 271 { 272 return false; 273 } 274 275 if (mShowVisualization) 276 { 251 } 252 253 // mInputDevice->capture(); 254 255 //-- IMPORTANT: must be set, otherwise terrain is not rendered correctly 256 int terrainLevelIdx = 0; 257 mSceneMgr->setOption("TerrainLevelIdx", &terrainLevelIdx); 258 259 //-- setup what is needed for immediate mouse/key movement 260 if (mTimeDelay >= 0) 261 { 262 mTimeDelay -= evt.timeSinceLastFrame; 263 } 264 265 // If this is the first frame, pick a speed 266 if (evt.timeSinceLastFrame == 0) 267 { 268 mMoveScale = 1; 269 mRotScale = 0.1; 270 } 271 // Otherwise scale movement units by time passed since last frame 272 else 273 { 274 // Move about 100 units per second, 275 mMoveScale = mMoveSpeed * evt.timeSinceLastFrame; 276 // Take about 10 seconds for full rotation 277 mRotScale = mRotateSpeed * evt.timeSinceLastFrame; 278 } 279 280 mRotX = 0; 281 mRotY = 0; 282 mTranslateVector = Vector3::ZERO; 283 284 if (!processUnbufferedKeyInput(evt)) 285 { 286 return false; 287 } 288 /* if (!processUnbufferedMouseInput(evt)) 289 { 290 return false; 291 }*/ 292 // --- set parameters for visualization 293 if (mShowVisualization) 294 { 277 295 // important for visualization => draw octree bounding boxes 278 296 mSceneMgr->setOption("ShowOctree", &mShowVisualization); 279 // also render nodew content? 280 //mSceneMgr->setOption("RenderNodesForViz", &mRenderNodesForViz); 281 282 // -- setup visualization camera 297 298 // ---- setup visualization camera 299 283 300 mVizCamera->setPosition(0, 0, 0); 284 301 mVizCamera->setOrientation(Quaternion::IDENTITY); … … 289 306 // point down -Z axis 290 307 mVizCamera->pitch(Radian(Degree(270.0))); 291 308 292 309 // rotation arounnd X axis 293 310 mVizCamera->yaw(Math::ATan2(-mCamera->getDerivedDirection().x, … … 298 315 } 299 316 317 //-- set application state 300 318 switch (mAppState) 301 319 { … … 312 330 StringConverter::toString(mFrameInfo.size() - 1)); 313 331 } 314 315 316 317 318 332 333 moveCamera(); 334 Clamp2Terrain(); 335 336 break; 319 337 default: 320 338 break; 321 339 }; 322 340 323 341 return true; 342 } 343 //----------------------------------------------------------------------- 344 void TerrainMouseQueryListener::ApplyVisibilityQuery() 345 { 346 InfoContainer<GtpVisibility::NodeInfo> visibleNodes; 347 InfoContainer<GtpVisibility::MeshInfo> visibleGeometry; 348 349 mVisibilityManager->GetQueryManager()->ComputeCameraVisibility(*mCamera, 350 &visibleNodes, &visibleGeometry, false); 351 352 for (int i=0; i < visibleGeometry.size(); ++i) 353 { 354 std::stringstream d; d << "Geometry visibility: " << visibleGeometry[i].GetVisibiliy(); 355 LogManager::getSingleton().logMessage(d.str()); 356 } 357 for (int i=0; i < visibleNodes.size(); ++i) 358 { 359 std::stringstream d; d << "Node visibility: " << visibleNodes[i].GetVisibiliy(); 360 LogManager::getSingleton().logMessage(d.str()); 361 } 362 324 363 } 325 364 //----------------------------------------------------------------------- … … 365 404 { 366 405 ofstr << StringConverter::toString((*it).position) << " " 367 << StringConverter::toString((*it).orientation) << " "368 << StringConverter::toString((*it).timeElapsed) << "\n";406 << StringConverter::toString((*it).orientation) << " " 407 << StringConverter::toString((*it).timeElapsed) << "\n"; 369 408 } 370 409 ofstr.close(); … … 390 429 mFrameInfo.push_back(info); 391 430 392 /* 393 std::stringstream d; 431 /* std::stringstream d; 394 432 d << StringConverter::toString(info.position) << " " << StringConverter::toString(info.orientation); 395 LogManager::getSingleton().logMessage(d.str()); 396 */ 433 LogManager::getSingleton().logMessage(d.str()); */ 397 434 } 398 435 ifstr.close(); … … 791 828 KEY_PRESSED(KC_F3, 0.3, nextAppState()); 792 829 KEY_PRESSED(KC_F4, 0.3, toggleRecord()); 830 KEY_PRESSED(KC_F5, 0.3, ApplyVisibilityQuery()); 793 831 794 832 KEY_PRESSED(KC_F11, 0.3, takeScreenShot()); -
trunk/VUT/work/TestCullingTerrain/TerrainMouseQueryListener.h
r121 r130 9 9 #include <OgreException.h> 10 10 #include "VisibilityEnvironment.h" 11 #include "VisibilityManager.h" 11 12 #include "OgreTerrainContentGenerator.h" 12 13 … … 113 114 void toggleRecord(); 114 115 116 void ApplyVisibilityQuery(); 117 118 void switchMouseMode() 119 { 120 mUseBufferedInputMouse = !mUseBufferedInputMouse; 121 mInputDevice->setBufferedInput(mUseBufferedInputKeys, mUseBufferedInputMouse); 122 } 115 123 protected: 116 124 … … 201 209 202 210 Light *mSunLight; 211 GtpVisibility::VisibilityManager *mVisibilityManager; 212 EventProcessor* mEventProcessor; 213 214 bool mUseBufferedInputKeys, mUseBufferedInputMouse, mInputTypeSwitchingOn; 215 203 216 }; 204 217 -
trunk/VUT/work/TestCullingTerrain/TestCullingTerrain.vcproj
r115 r130 75 75 PreprocessorDefinitions="_WINDOWS;_STLP_USE_DYNAMIC_LIB;OGRE_LIBRARY_IMPORTS;_RELEASE;WIN32;_STLP_RELEASE;GTP_VISIBILITY_MODIFIED_OGRE" 76 76 RuntimeLibrary="2" 77 RuntimeTypeInfo="TRUE" 77 78 UsePrecompiledHeader="0" 78 79 WarningLevel="3" -
trunk/VUT/work/TestCullingTerrain/TestCullingTerrainApplication.h
r115 r130 57 57 58 58 TerrainMouseQueryListener *mTerrainFrameListener; 59 59 60 60 private: 61 61 void chooseSceneManager(void);
Note: See TracChangeset
for help on using the changeset viewer.