- Timestamp:
- 11/16/05 11:09:15 (19 years ago)
- Location:
- trunk/VUT
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/VUT/work/TestCullingTerrain/TerrainFrameListener.cpp
r415 r417 141 141 mDemoFps(0), 142 142 mUseDemoFps(false), 143 mUseArbQueries(false) 143 mUseArbQueries(false), 144 mUseBufferedInputMouse(false) 144 145 { 145 146 //mInputDevice = PlatformManager::getSingleton().createInputReader(); … … 156 157 mInputDevice = mEventProcessor->getInputReader(); 157 158 159 mInputDevice->setBufferedInput(true, mUseBufferedInputMouse); 160 158 161 // create ray query executor, used to place objects in terrain 159 162 mRayQueryExecutor = new RayQueryExecutor(mSceneMgr); … … 216 219 void TerrainFrameListener::mousePressed(MouseEvent* e) 217 220 { 218 219 220 221 222 223 224 221 // Left mouse button down 222 if (e->getButtonID() & InputEvent::BUTTON0_MASK) 223 { 224 CEGUI::MouseCursor::getSingleton().hide(); 225 226 // Setup the ray scene query 227 Ray mouseRay = mCamera->getCameraToViewportRay(e->getX(), e->getY()); 225 228 226 //Vector3 queryResult; mRayQueryExecutor->executeRayQuery(&queryResult, mouseRay); 227 228 Real val = Math::RangeRandom(0, 360); // random rotation 229 230 // get results, create a node/entity on the position 231 mCurrentObject = mTerrainContentGenerator->GenerateSceneObject( 232 mouseRay.getOrigin()/*queryResult*/, Vector3(val, 0, 0), 233 msObjectCaptions[mCurrentObjectType]); 234 235 mLMouseDown = true; 236 } 237 // Right mouse button down 238 else if (e->getButtonID() & InputEvent::BUTTON1_MASK) 239 { 229 //Vector3 queryResult; mRayQueryExecutor->executeRayQuery(&queryResult, mouseRay); 230 Real val = Math::RangeRandom(0, 360); // random rotation 231 232 // get results, create a node/entity on the position 233 mCurrentObject = mTerrainContentGenerator->GenerateSceneObject( 234 mouseRay.getOrigin(), Vector3(val, 0, 0), 235 msObjectCaptions[mCurrentObjectType]); 236 237 mLMouseDown = true; 238 } 239 // Right mouse button down 240 /*else if (e->getButtonID() & InputEvent::BUTTON1_MASK) 241 { 240 242 CEGUI::MouseCursor::getSingleton().hide(); 241 243 mRMouseDown = true; 242 } 244 }*/ 243 245 } 244 246 //----------------------------------------------------------------------- … … 289 291 //----------------------------------------------------------------------- 290 292 void TerrainFrameListener::mouseDragged(MouseEvent *e) 291 { 292 // If we are dragging the left mouse button. 293 if (mLMouseDown) 294 { 295 if (!mCurrentObject) 296 return; 297 298 Vector3 queryResult; 299 Ray mouseRay = mCamera->getCameraToViewportRay(e->getX(), e->getY()); 300 301 if (mRayQueryExecutor->executeRayQuery(&queryResult, mouseRay)) 302 { 303 // apply offset so object is ON terrain 304 queryResult.y += msObjectTerrainOffsets[mCurrentObjectType]; 305 mCurrentObject->setPosition(queryResult); 306 } 307 } 308 // If we are dragging the right mouse button. 309 if (mRMouseDown) 310 { 311 //mCamera->yaw(-e->getRelX() * mRotateSpeed); 312 //mCamera->pitch(-e->getRelY() * mRotateSpeed); 313 mCamNode->yaw(-e->getRelX() * mRotateSpeed); 314 mCamNode->pitch(-e->getRelY() * mRotateSpeed); 315 } 293 { 294 // If we are dragging the left mouse button. 295 if (mLMouseDown) 296 { 297 if (!mCurrentObject) 298 return; 299 300 Vector3 queryResult; 301 Ray mouseRay = mCamera->getCameraToViewportRay(e->getX(), e->getY()); 302 303 if (mRayQueryExecutor->executeRayQuery(&queryResult, mouseRay)) 304 { 305 // apply offset so object is ON terrain 306 queryResult.y += msObjectTerrainOffsets[mCurrentObjectType]; 307 mCurrentObject->setPosition(queryResult); 308 } 309 } 316 310 } 317 311 //----------------------------------------------------------------------- … … 370 364 return false; 371 365 } 372 /* if (!processUnbufferedMouseInput(evt)) 373 { return false; }*/ 366 if (!mUseBufferedInputMouse) 367 { 368 if (!processUnbufferedMouseInput(evt)) 369 { 370 return false; 371 } 372 } 374 373 375 374 //-- set parameters for visualization … … 593 592 } 594 593 594 595 bool TerrainFrameListener::processUnbufferedMouseInput(const FrameEvent& evt) 596 { 597 /* Rotation factors, may not be used if the second mouse button is pressed. */ 598 599 /* If the second mouse button is pressed, then the mouse movement results in 600 sliding the camera, otherwise we rotate. */ 601 if (mInputDevice->getMouseButton(1)) 602 { 603 mTranslateVector.x += mInputDevice->getMouseRelativeX() * 0.13; 604 mTranslateVector.y -= mInputDevice->getMouseRelativeY() * 0.13; 605 } 606 else 607 { 608 mRotX = Degree(-mInputDevice->getMouseRelativeX() * 0.13); 609 mRotY = Degree(-mInputDevice->getMouseRelativeY() * 0.13); 610 } 611 612 return true; 613 } 595 614 //----------------------------------------------------------------------- 596 615 bool TerrainFrameListener::frameEnded(const FrameEvent& evt) … … 1201 1220 toggleUseArbQueries(); 1202 1221 break; 1203 1222 case KC_O: 1223 switchMouseMode(); 1224 break; 1204 1225 //KEY_PRESSED(KC_F3, 0.3, writeFrames()); 1205 1226 //KEY_PRESSED(KC_F4, 0.3, loadFrames()); -
trunk/VUT/work/TestCullingTerrain/TerrainFrameListener.h
r343 r417 111 111 bool frameStarted(const FrameEvent& evt); 112 112 bool frameEnded(const FrameEvent& evt); 113 //bool processUnbufferedKeyInput(const FrameEvent& evt); 114 113 115 114 116 115 /* MouseListener callbacks. */ … … 172 171 bool processUnbufferedKeyInput(const FrameEvent& evt); 173 172 bool processUnbufferedMouseInput(const FrameEvent& evt); 173 174 void switchMouseMode() 175 { 176 mUseBufferedInputMouse = !mUseBufferedInputMouse; 177 mInputDevice->setBufferedInput(true, mUseBufferedInputMouse); 178 } 174 179 175 180 /** Shows the frame / algorithm statistics. … … 393 398 float mPureRenderTimeFps; 394 399 TestCullingTerrainApplication *mApplication; 400 401 bool mUseBufferedInputMouse; 395 402 }; 396 403 -
trunk/VUT/work/TestCullingTerrain/TestCullingTerrainApplication.cpp
r350 r417 231 231 232 232 // Set ambient light 233 mAmbientLight = ColourValue(0.5 233 mAmbientLight = ColourValue(0.5, 0.5, 0.5); 234 234 mSceneMgr->setAmbientLight(mAmbientLight); 235 235 … … 316 316 Vector3 scale(val, val, val); 317 317 const float maxHeight = 75; 318 // to provide much occlusion, 318 319 // In order to provide much occlusion, 319 320 // height is restricted to maxHeight => no objects are created on peaks 320 321 mTerrainContentGenerator->SetMinPos(Vector3(mTerrainMinPos)); 321 322 mTerrainContentGenerator->SetMaxPos(Vector3(mTerrainMaxPos.x, maxHeight, mTerrainMaxPos.z)); 322 std::stringstream d; d << "objscale: " << scale[0]; 323 Ogre::LogManager::getSingleton().logMessage(d.str()); 323 324 //std::stringstream d; d << "objscale: " << scale[0]; 325 //Ogre::LogManager::getSingleton().logMessage(d.str()); 326 324 327 mTerrainContentGenerator->SetScale(scale); 325 328 mTerrainContentGenerator->SetOffset(TerrainFrameListener::msObjectTerrainOffsets[objectType]); -
trunk/VUT/work/iv/IVFrameListener.cpp
r345 r417 258 258 return false; 259 259 } 260 /* if (!processUnbufferedMouseInput(evt)) 261 { return false; }*/ 260 if (!processUnbufferedMouseInput(evt)) 261 { 262 return false; 263 } 262 264 263 265 // --- set parameters for visualization … … 313 315 break; 314 316 }; 317 318 return true; 319 } 320 321 bool IVFrameListener::processUnbufferedMouseInput(const FrameEvent& evt) 322 { 323 /* Rotation factors, may not be used if the second mouse button is pressed. */ 324 325 /* If the second mouse button is pressed, then the mouse movement results in 326 sliding the camera, otherwise we rotate. */ 327 if (mInputDevice->getMouseButton(1)) 328 { 329 mTranslateVector.x += mInputDevice->getMouseRelativeX() * 0.13; 330 mTranslateVector.y -= mInputDevice->getMouseRelativeY() * 0.13; 331 } 332 else 333 { 334 mRotX = Degree(-mInputDevice->getMouseRelativeX() * 0.13); 335 mRotY = Degree(-mInputDevice->getMouseRelativeY() * 0.13); 336 } 337 315 338 316 339 return true;
Note: See TracChangeset
for help on using the changeset viewer.