Changeset 1170 for GTP/trunk/App/Demos/Vis/KdTreeDemo/OGRE
- Timestamp:
- 07/28/06 17:06:01 (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/App/Demos/Vis/KdTreeDemo/OGRE/include/TestKdTreeAppListener.h
r1165 r1170 54 54 Real mRotationPeriod; 55 55 bool mShowTree; 56 bool mFreeMove; 56 57 57 58 int mSeqNum; … … 122 123 } 123 124 125 mFreeMove = false; 124 126 mShowTree = false; 125 127 mCullCamera = false; … … 210 212 caption = OverlayManager::getSingleton().getOverlayElement("KdTree/BuildMethod")->getCaption(); 211 213 OverlayManager::getSingleton().getOverlayElement("KdTree/BuildMethod")->setCaption(caption + value); 214 215 String rm; 216 if (mSceneMgr->getOption("RenderMethod", &rm)) 217 value = " " + rm; 218 else 219 value = na; 220 caption = OverlayManager::getSingleton().getOverlayElement("KdTree/RenderMethod")->getCaption(); 221 OverlayManager::getSingleton().getOverlayElement("KdTree/RenderMethod")->setCaption(caption + value); 222 223 value = na; 224 if (mFreeMove) 225 value = " Free"; 226 else 227 value = " Ground"; 228 caption = OverlayManager::getSingleton().getOverlayElement("KdTree/Movement")->getCaption(); 229 OverlayManager::getSingleton().getOverlayElement("KdTree/Movement")->setCaption(caption + value); 212 230 } 213 231 … … 264 282 static String sKT = "[5][6] KT: "; 265 283 static String sKI = "[7][8] KI: "; 266 static String sBM = "[Space] Build Method: "; 267 268 static String bmRec = "Recursive"; 269 static String bmPQ = "PriorityQueue"; 284 static String sBM = "[Y] Build Method: "; 285 static String sRM = "[X] Render Method: "; 286 static String sMov = "[Q] Movement: "; 287 288 static String bmOptions[] = { "Recursive", "PriorityQueue" }; 289 static int bmOptionsSize = sizeof(bmOptions) / sizeof(String); 290 static int bmCurrent = 0; 291 292 //static String rmOptions[] = { "Recursive", "Stack", "StopAndWait", "CHC" }; 293 static String rmOptions[] = { "Recursive", "Stack" }; 294 static int rmOptionsSize = sizeof(rmOptions) / sizeof (String); 295 static int rmCurrent = 0; 270 296 271 297 if ((mInputDevice->isKeyDown(KC_1) || mInputDevice->isKeyDown(KC_2)) && mTimeUntilNextToggle <= 0) … … 374 400 } 375 401 376 if (mInputDevice->isKeyDown(KC_ SPACE) && mTimeUntilNextToggle <= 0)402 if (mInputDevice->isKeyDown(KC_Z) && mTimeUntilNextToggle <= 0) 377 403 { 378 404 String bm; 379 405 if (mSceneMgr->getOption("BuildMethod", &bm)) 380 406 { 381 if (bm == bmRec) 382 bm = bmPQ; 383 else if (bm == bmPQ) 384 bm = bmRec; 385 if (mSceneMgr->setOption("BuildMethod", &bm)) 386 OverlayManager::getSingleton().getOverlayElement("KdTree/BuildMethod")->setCaption(sBM + bm); 407 bmCurrent = (bmCurrent + 1) % bmOptionsSize; 408 if (mSceneMgr->setOption("BuildMethod", &bmOptions[bmCurrent])) 409 OverlayManager::getSingleton().getOverlayElement("KdTree/BuildMethod")->setCaption(sBM + bmOptions[bmCurrent]); 387 410 } 388 411 else … … 391 414 } 392 415 393 mTimeUntilNextToggle = 0.2; 394 } 416 mTimeUntilNextToggle = 0.5; 417 } 418 419 if (mInputDevice->isKeyDown(KC_X) && mTimeUntilNextToggle <= 0) 420 { 421 String rm; 422 if (mSceneMgr->getOption("RenderMethod", &rm)) 423 { 424 rmCurrent = (rmCurrent + 1) % rmOptionsSize; 425 if (mSceneMgr->setOption("RenderMethod", &rmOptions[rmCurrent])) 426 OverlayManager::getSingleton().getOverlayElement("KdTree/RenderMethod")->setCaption(sRM + rmOptions[rmCurrent]); 427 } 428 else 429 { 430 OverlayManager::getSingleton().getOverlayElement("KdTree/RenderMethod")->setCaption(sRM + "N/A"); 431 } 432 433 mTimeUntilNextToggle = 0.5; 434 } 435 436 if (mInputDevice->isKeyDown(KC_Q) && mTimeUntilNextToggle <= 0) 437 { 438 mFreeMove = !mFreeMove; 439 String move = "N/A"; 440 if (mFreeMove) 441 move = "Free"; 442 else 443 move = "Ground"; 444 445 OverlayManager::getSingleton().getOverlayElement("KdTree/Movement")->setCaption(sMov + move); 446 447 mTimeUntilNextToggle = 0.5; 448 } 449 395 450 396 451 if (mInputDevice->isKeyDown(KC_BACK) && mTimeUntilNextToggle <= 0) … … 667 722 mTopCam->moveRelative(mCullTransVec); 668 723 669 Vector3 pos = mCamera->getPosition(); 670 RaySceneQuery * rsquery = mSceneMgr->createRayQuery(Ray(pos, Vector3::NEGATIVE_UNIT_Y)); 671 RaySceneQueryResult& rsresult = rsquery->execute(); 672 673 RaySceneQueryResult::iterator it = rsresult.begin(); 674 RaySceneQueryResult::iterator end = rsresult.end(); 675 676 while (it != end && it->movable) 677 { 678 if (it->movable->getName() != "PlayerCam") 679 { 680 mCamera->setPosition(pos.x, it->movable->getWorldBoundingBox().getCenter().y + 3, pos.z); 681 break; 682 } 683 it++; 684 } 685 OGRE_DELETE(rsquery); 724 if (!mFreeMove) 725 { 726 Vector3 pos = mCamera->getPosition(); 727 RaySceneQuery * rsquery = mSceneMgr->createRayQuery(Ray(pos, Vector3::NEGATIVE_UNIT_Y)); 728 RaySceneQueryResult& rsresult = rsquery->execute(); 729 730 RaySceneQueryResult::iterator it = rsresult.begin(); 731 RaySceneQueryResult::iterator end = rsresult.end(); 732 733 while (it != end && it->movable) 734 { 735 if (it->movable->getName() != "PlayerCam") 736 { 737 mCamera->setPosition(pos.x, it->movable->getWorldBoundingBox().getCenter().y + 3, pos.z); 738 break; 739 } 740 it++; 741 } 742 OGRE_DELETE(rsquery); 743 } 686 744 } 687 745
Note: See TracChangeset
for help on using the changeset viewer.