Changeset 1273 for GTP/trunk/App/Demos/Vis/KdTreeDemo
- Timestamp:
- 08/24/06 14:17:44 (18 years ago)
- Location:
- GTP/trunk/App/Demos/Vis/KdTreeDemo
- Files:
-
- 1 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/App/Demos/Vis/KdTreeDemo/OGRE/include/TestKdTree.h
r1220 r1273 56 56 57 57 // scene options 58 String mSceneFiles;58 //String mSceneFiles; 59 59 Real mRotationRadius; 60 60 int mModelSpacing; … … 87 87 88 88 void createMaterials(void); 89 void createSimpleScene(void); 89 90 private: 90 91 std::string cat(std::string name, int x, int z) -
GTP/trunk/App/Demos/Vis/KdTreeDemo/OGRE/include/TestKdTreeAppListener.h
r1258 r1273 49 49 #define VIZ_VIEWPORT_Z_ORDER 10 50 50 51 #define TERRAIN_SCENE "terrain" 52 51 53 using namespace Ogre; 52 54 … … 80 82 { 81 83 SM_KDT, 84 SM_KTE, 82 85 SM_OCM, 83 86 SM_OCT, 87 SM_TER, 84 88 SM_GEN, 85 89 SM_SIZE, … … 121 125 } 122 126 127 String mSceneFiles; 123 128 String mDemoInfileName; 124 129 String mDemoOutfileName; … … 272 277 Degree mRotScale; 273 278 Radian mDeathAngle; 279 // for terrain 280 RaySceneQuery *mRaySceneQuery; 274 281 275 282 // just to stop toggles flipping too fast -
GTP/trunk/App/Demos/Vis/KdTreeDemo/OGRE/src/TestKdTree.cpp
r1258 r1273 181 181 cfDeath.load("testKdTree.cfg"); 182 182 183 m SceneFiles = cfDeath.getSetting("scene");183 mOptions.mSceneFiles = cfDeath.getSetting("scene"); 184 184 185 185 tmp = cfDeath.getSetting("shadows"); … … 236 236 createMaterials(); 237 237 238 // load simple scene (planes & robots) 239 if (mOptions.mSceneFiles == "") 240 { 241 createSimpleScene(); 242 } 243 // load terrain, but only if terrainscenemanager selected 244 else if (mOptions.mSceneFiles == TERRAIN_SCENE) 245 { 246 Plane waterPlane; 247 248 // Set ambient light 249 mSceneMgr->setAmbientLight(ColourValue(0.5, 0.5, 0.5)); 250 251 // Create a light 252 Light* l = mSceneMgr->createLight("MainLight"); 253 // Accept default settings: point light, white diffuse, just set position 254 // NB I could attach the light to a SceneNode if I wanted it to move automatically with 255 // other objects, but I don't 256 l->setPosition(20,80,50); 257 258 // Fog 259 // NB it's VERY important to set this before calling setWorldGeometry 260 // because the vertex program picked will be different 261 //ColourValue fadeColour(0.93, 0.86, 0.76); 262 //mSceneMgr->setFog( FOG_LINEAR, fadeColour, .001, 500, 1000); 263 //mWindow->getViewport(0)->setBackgroundColour(fadeColour); 264 mWindow->getViewport(0)->setBackgroundColour(ColourValue::Blue); 265 266 std::string terrain_cfg("terrain.cfg"); 267 268 mSceneMgr -> setWorldGeometry( terrain_cfg ); 269 270 // Define the required skyplane 271 Plane plane; 272 // 5000 world units from the camera 273 plane.d = 5000; 274 // Above the camera, facing down 275 plane.normal = -Vector3::UNIT_Y; 276 277 // add one robot 278 //Entity *robot = mSceneMgr->createEntity("TheRobot","robot.mesh"); 279 //SceneNode *node = mSceneMgr->getRootSceneNode()->createChildSceneNode("TheRobotNode"); 280 //node->attachObject(robot); 281 // add stuff minus gound plane 282 mSelectEntities &= ~ENT_PLN; 283 createSimpleScene(); 284 285 // Set a nice viewpoint 286 mCamNode->setPosition(707,2500,528); 287 mCamNode->setOrientation(Quaternion(-0.3486, 0.0122, 0.9365, 0.0329)); 288 } 289 // load scene from file 290 else 291 { 292 // don't load the other stuff 293 loadScene(mOptions.mSceneFiles); 294 // top view 295 mTopCam->setPosition(Vector3(1232, 3990, -1477)); 296 // walkthrough view 297 mCamNode->setPosition(Vector3(827.885, 184.435, -524.984)); 298 mCamNode->setOrientation(Quaternion(0.98935, 0.0348082, -0.141246, 0.00496945)); 299 300 mSceneMgr->setSkyBox(true, "Examples/CloudyNoonSkyBox", 5000, true); 301 } 302 } 303 304 void KdTreeApp::createSimpleScene() 305 { 238 306 Entity *deaths; 239 307 SceneNode *nodes; … … 245 313 Real planeSixth = mPlaneDim / 6; 246 314 247 // load scene from file 248 if (mSceneFiles != "") 249 { 250 // don't load the other stuff 251 loadScene(mSceneFiles); 252 // top view 253 mTopCam->setPosition(Vector3(1232, 3990, -1477)); 254 // walkthrough view 255 mCamNode->setPosition(Vector3(827.885, 184.435, -524.984)); 256 mCamNode->setOrientation(Quaternion(0.98935, 0.0348082, -0.141246, 0.00496945)); 257 258 mSceneMgr->setSkyBox(true, "Examples/CloudyNoonSkyBox", 5000, true); 259 } 260 else 261 { 262 mCamNode->setPosition(Vector3(1280,600,1666)); 263 mCamNode->setOrientation(Quaternion(0.936893, -0.124586, 0.323813, 0.04306)); 264 //mCamera->lookAt(Vector3(-20,30,10)); 265 266 SceneNode *anchor = mSceneMgr->getRootSceneNode()->createChildSceneNode("AnchorNode"); 267 //SceneNode *grndan = anchor->createChildSceneNode("GroundAnchor"); 268 SceneNode *grndan = mSceneMgr->getRootSceneNode(); 269 270 if (mSelectEntities & ENT_GRID) 315 mCamNode->setPosition(Vector3(1280,600,1666)); 316 mCamNode->setOrientation(Quaternion(0.936893, -0.124586, 0.323813, 0.04306)); 317 318 SceneNode *anchor = mSceneMgr->getRootSceneNode()->createChildSceneNode("AnchorNode"); 319 //SceneNode *grndan = anchor->createChildSceneNode("GroundAnchor"); 320 SceneNode *grndan = mSceneMgr->getRootSceneNode(); 321 322 if (mSelectEntities & ENT_GRID) 323 { 324 for (j = 0, z = -(mModelCount / 2 * mModelSpacing); j < mModelCount; j++, z += mModelSpacing) 271 325 { 272 for ( j = 0, z = -(mModelCount / 2 * mModelSpacing); j < mModelCount; j++, z += mModelSpacing)326 for (i = 0, x = -(mModelCount / 2 * mModelSpacing); i < mModelCount; i++, x += mModelSpacing) 273 327 { 274 for (i = 0, x = -(mModelCount / 2 * mModelSpacing); i < mModelCount; i++, x += mModelSpacing) 275 { 276 deaths = mSceneMgr->createEntity(cat(entName, i, j).c_str(),"robot.mesh"); 277 if (mShadowsEnabled) 278 deaths->setCastShadows(true); 279 nodes = /*mSceneMgr->getRootSceneNode()*/anchor->createChildSceneNode(cat(nodeName, i, j).c_str(), Vector3(x, 0 , z)); 280 nodes->attachObject(deaths); 281 } 282 } 283 } 284 285 if (mSelectEntities & ENT_RND) 286 { 287 entName = "randomdeath"; 288 nodeName = "RandomDeathNode"; 289 for (i = 0; i < mRandomCount; i++) 290 { 291 Vector3 pos( 292 Math::RangeRandom(-planeHalf,-planeSixth), 293 0, 294 Math::RangeRandom(-planeThreeEights, planeThreeEights)); 295 deaths = mSceneMgr->createEntity(cat(entName,666,i),"robot.mesh"); 328 deaths = mSceneMgr->createEntity(cat(entName, i, j).c_str(),"robot.mesh"); 296 329 if (mShadowsEnabled) 297 330 deaths->setCastShadows(true); 298 nodes = /*mSceneMgr->getRootSceneNode()*/anchor->createChildSceneNode(cat(nodeName,666,i), pos, 299 Quaternion(Radian(Math::RangeRandom(-Math::PI, Math::PI)), Vector3::UNIT_Y)); 331 nodes = /*mSceneMgr->getRootSceneNode()*/anchor->createChildSceneNode(cat(nodeName, i, j).c_str(), Vector3(x, 0 , z)); 300 332 nodes->attachObject(deaths); 301 333 } 302 334 } 303 304 if (mSelectEntities & ENT_SPC) 335 } 336 337 if (mSelectEntities & ENT_RND) 338 { 339 entName = "randomdeath"; 340 nodeName = "RandomDeathNode"; 341 for (i = 0; i < mRandomCount; i++) 305 342 { 306 entName = "randomspaceship"; 307 nodeName = "RandomSpaceshipNode"; 308 for (i = 0; i < mRandomCount; i++) 309 { 310 Vector3 pos( 311 //Math::RangeRandom(-planeHalf,-planeSixth), 312 Math::RangeRandom(planeSixth,planeHalf), 313 Math::RangeRandom(planeHalf * 0.1, planeHalf), 314 Math::RangeRandom(-planeThreeEights, planeThreeEights)); 315 deaths = mSceneMgr->createEntity(cat(entName,666,i),"razor.mesh"); 316 if (mShadowsEnabled) 317 deaths->setCastShadows(true); 318 nodes = /*mSceneMgr->getRootSceneNode()*/anchor->createChildSceneNode(cat(nodeName,666,i), pos, 319 Quaternion(Radian(Math::RangeRandom(-Math::PI, Math::PI)), Vector3::UNIT_Y)); 320 nodes->attachObject(deaths); 321 } 343 Vector3 pos( 344 Math::RangeRandom(-planeHalf,-planeSixth), 345 0, 346 Math::RangeRandom(-planeThreeEights, planeThreeEights)); 347 deaths = mSceneMgr->createEntity(cat(entName,666,i),"robot.mesh"); 348 if (mShadowsEnabled) 349 deaths->setCastShadows(true); 350 nodes = /*mSceneMgr->getRootSceneNode()*/anchor->createChildSceneNode(cat(nodeName,666,i), pos, 351 Quaternion(Radian(Math::RangeRandom(-Math::PI, Math::PI)), Vector3::UNIT_Y)); 352 nodes->attachObject(deaths); 322 353 } 323 324 if (mSelectEntities & ENT_MOV) 354 } 355 356 if (mSelectEntities & ENT_SPC) 357 { 358 entName = "randomspaceship"; 359 nodeName = "RandomSpaceshipNode"; 360 for (i = 0; i < mRandomCount; i++) 325 361 { 326 Entity *movingDeath = mSceneMgr->createEntity("movingDeath","robot.mesh"); 362 Vector3 pos( 363 //Math::RangeRandom(-planeHalf,-planeSixth), 364 Math::RangeRandom(planeSixth,planeHalf), 365 Math::RangeRandom(planeHalf * 0.1, planeHalf), 366 Math::RangeRandom(-planeThreeEights, planeThreeEights)); 367 deaths = mSceneMgr->createEntity(cat(entName,666,i),"razor.mesh"); 327 368 if (mShadowsEnabled) 328 movingDeath->setCastShadows( true ); 329 330 SceneNode *deathPivotNode = mSceneMgr->getRootSceneNode()->createChildSceneNode("deathPivotNode"); 331 mMoveNode = deathPivotNode->createChildSceneNode("movingNode", Vector3(0, 0, mRotationRadius)/*, 332 Quaternion(Radian(Math::HALF_PI), Vector3::UNIT_Y)*/); 333 mMoveNode->attachObject(movingDeath); 334 335 Entity *ent_ball = mSceneMgr->createEntity("ball","sphere.mesh"); 336 SceneNode *node_pivot = mMoveNode->createChildSceneNode("pivotNode"); 337 SceneNode *node_ball = node_pivot->createChildSceneNode("orbitNode", Vector3(120, 40, 0)); 338 node_ball->attachObject(ent_ball); 339 node_ball->scale(0.1, 0.1, 0.1); 340 341 342 //mFollowCam->setAutoTracking(true, mMoveNode); 369 deaths->setCastShadows(true); 370 nodes = /*mSceneMgr->getRootSceneNode()*/anchor->createChildSceneNode(cat(nodeName,666,i), pos, 371 Quaternion(Radian(Math::RangeRandom(-Math::PI, Math::PI)), Vector3::UNIT_Y)); 372 nodes->attachObject(deaths); 343 373 } 344 345 if (mSelectEntities & ENT_PLN) 346 { 347 Plane ground(Vector3::UNIT_Y, 0); 348 MeshManager::getSingleton().createPlane("ground", ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, 349 ground, mPlaneDim * 4 / 3, mPlaneDim, 20, 20, true, 1, 20, 20, Vector3::UNIT_Z); 350 Entity *ent_ground = mSceneMgr->createEntity("GroundEntity", "ground"); 351 ent_ground->setCastShadows(false); 352 ent_ground->setMaterialName("Examples/RustySteel");//("Examples/Rockwall"); 353 SceneNode *node_ground = /*mSceneMgr->getRootSceneNode()*/grndan->createChildSceneNode("GroundNode", Vector3(0, 0, 0)); 354 node_ground->attachObject(ent_ground); 355 356 //MeshManager::getSingleton().createPlane("ground2", ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, 357 // ground, mPlaneDim/2, mPlaneDim, 10, 20, true, 1, 10, 20, Vector3::UNIT_Z); 358 //ent_ground = mSceneMgr->createEntity("GroundEntity2", "ground2"); 359 //ent_ground->setCastShadows(false); 360 //ent_ground->setMaterialName("Examples/RustySteel"); 361 //node_ground = /*mSceneMgr->getRootSceneNode()*/grndan->createChildSceneNode("GroundNode2", Vector3(-mPlaneDim/4, 0, 0)); 362 //node_ground->attachObject(ent_ground); 363 } 364 365 // Lights 366 mSceneMgr->setAmbientLight(ColourValue(0.1,0.1,0.1)); 367 Light *light = mSceneMgr->createLight("light"); 374 } 375 376 if (mSelectEntities & ENT_MOV) 377 { 378 Entity *movingDeath = mSceneMgr->createEntity("movingDeath","robot.mesh"); 368 379 if (mShadowsEnabled) 369 { 370 mSceneMgr->setShadowTechnique(SHADOWTYPE_STENCIL_ADDITIVE); 371 light->setType(Light::LT_POINT); 372 light->setPosition(Vector3(x, 300, z + 200)); 373 } 374 else 375 { 376 light->setType(Light::LT_DIRECTIONAL); 377 light->setDirection(-1,-1,-1); 378 } 379 light->setDiffuseColour(ColourValue::White); 380 light->setSpecularColour(ColourValue(1, 1, 0.2)); 381 382 // Skybox 383 mSceneMgr->setSkyBox(true, "Examples/SpaceSkyBox", mPlaneDim * 2); 384 } 385 386 /* Some math tests 387 Plane planeX(Vector3::UNIT_X, Vector3(10,10,10)); 388 Plane planeY(Vector3::UNIT_Y, Vector3(10,10,10)); 389 Plane planeZ(Vector3::UNIT_Z, Vector3(10,10,10)); 390 Vector3 vect(20,20,20); 391 Vector3 interX = planeX.projectVector(vect); 392 Vector3 interY = planeY.projectVector(vect); 393 Vector3 interZ = planeZ.projectVector(vect); 394 std::stringstream ssX, ssY, ssZ; 395 ssX << "The intersection of " << planeX << " and " << vect << " is at: " << interX; 396 ssY << "The intersection of " << planeY << " and " << vect << " is at: " << interY; 397 ssZ << "The intersection of " << planeZ << " and " << vect << " is at: " << interZ; 398 LogManager::getSingleton().logMessage(ssX.str()); 399 LogManager::getSingleton().logMessage(ssY.str()); 400 LogManager::getSingleton().logMessage(ssZ.str()); 401 */ 380 movingDeath->setCastShadows( true ); 381 382 SceneNode *deathPivotNode = mSceneMgr->getRootSceneNode()->createChildSceneNode("deathPivotNode"); 383 mMoveNode = deathPivotNode->createChildSceneNode("movingNode", Vector3(0, 0, mRotationRadius)/*, 384 Quaternion(Radian(Math::HALF_PI), Vector3::UNIT_Y)*/); 385 mMoveNode->attachObject(movingDeath); 386 387 Entity *ent_ball = mSceneMgr->createEntity("ball","sphere.mesh"); 388 SceneNode *node_pivot = mMoveNode->createChildSceneNode("pivotNode"); 389 SceneNode *node_ball = node_pivot->createChildSceneNode("orbitNode", Vector3(120, 40, 0)); 390 node_ball->attachObject(ent_ball); 391 node_ball->scale(0.1, 0.1, 0.1); 392 393 394 //mFollowCam->setAutoTracking(true, mMoveNode); 395 } 396 397 if (mSelectEntities & ENT_PLN) 398 { 399 Plane ground(Vector3::UNIT_Y, 0); 400 MeshManager::getSingleton().createPlane("ground", ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, 401 ground, mPlaneDim * 4 / 3, mPlaneDim, 20, 20, true, 1, 20, 20, Vector3::UNIT_Z); 402 Entity *ent_ground = mSceneMgr->createEntity("GroundEntity", "ground"); 403 ent_ground->setCastShadows(false); 404 ent_ground->setMaterialName("Examples/RustySteel");//("Examples/Rockwall"); 405 SceneNode *node_ground = /*mSceneMgr->getRootSceneNode()*/grndan->createChildSceneNode("GroundNode", Vector3(0, 0, 0)); 406 node_ground->attachObject(ent_ground); 407 408 //MeshManager::getSingleton().createPlane("ground2", ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, 409 // ground, mPlaneDim/2, mPlaneDim, 10, 20, true, 1, 10, 20, Vector3::UNIT_Z); 410 //ent_ground = mSceneMgr->createEntity("GroundEntity2", "ground2"); 411 //ent_ground->setCastShadows(false); 412 //ent_ground->setMaterialName("Examples/RustySteel"); 413 //node_ground = /*mSceneMgr->getRootSceneNode()*/grndan->createChildSceneNode("GroundNode2", Vector3(-mPlaneDim/4, 0, 0)); 414 //node_ground->attachObject(ent_ground); 415 } 416 417 // Lights 418 mSceneMgr->setAmbientLight(ColourValue(0.1,0.1,0.1)); 419 Light *light = mSceneMgr->createLight("light"); 420 if (mShadowsEnabled) 421 { 422 mSceneMgr->setShadowTechnique(SHADOWTYPE_STENCIL_ADDITIVE); 423 light->setType(Light::LT_POINT); 424 light->setPosition(Vector3(x, 300, z + 200)); 425 } 426 else 427 { 428 light->setType(Light::LT_DIRECTIONAL); 429 light->setDirection(-1,-1,-1); 430 } 431 light->setDiffuseColour(ColourValue::White); 432 light->setSpecularColour(ColourValue(1, 1, 0.2)); 433 434 // Skybox 435 mSceneMgr->setSkyBox(true, "Examples/SpaceSkyBox", mPlaneDim * 2); 402 436 } 403 437 … … 418 452 "MySceneManager"); 419 453 // set params for kdtree scene manager 420 if (mOptions.mSceneManager == KdTreeAppListener::SM_KDT) 454 if (mOptions.mSceneManager == KdTreeAppListener::SM_KDT || 455 mOptions.mSceneManager == KdTreeAppListener::SM_KTE) 421 456 { 422 457 mSceneMgr->setOption("BuildMethod", &mOptions.mBuildMethod); … … 530 565 531 566 // create play button 532 mat = MaterialManager::getSingleton().create("KdTree/DemoPlayButton", "General"); 567 mat = MaterialManager::getSingleton().getByName("KdTree/DemoPlayButton"); 568 if (mat.isNull()) 569 mat = MaterialManager::getSingleton().create("KdTree/DemoPlayButton", "General"); 533 570 mat->setLightingEnabled(false); 534 571 tech = mat->getTechnique(0); … … 540 577 541 578 // create record button 542 mat = MaterialManager::getSingleton().create("KdTree/DemoRecordButton", "General"); 579 mat = MaterialManager::getSingleton().getByName("KdTree/DemoRecordButton"); 580 if (mat.isNull()) 581 mat = MaterialManager::getSingleton().create("KdTree/DemoRecordButton", "General"); 543 582 mat->setLightingEnabled(false); 544 583 tech = mat->getTechnique(0); -
GTP/trunk/App/Demos/Vis/KdTreeDemo/OGRE/src/TestKdTreeAppListener.cpp
r1265 r1273 18 18 const String KdTreeAppListener::BUILDMETHOD[] = { "RE", "PQ" }; 19 19 const String KdTreeAppListener::BUILDMETHODCAPTION[] = { "Recursive", "Priority Queue" }; 20 const String KdTreeAppListener::SCENEMANAGER[] = { "KDT", " OCM", "OCT", "GEN" };20 const String KdTreeAppListener::SCENEMANAGER[] = { "KDT", "KTE", "OCM", "OCT", "TER", "GEN" }; 21 21 const String KdTreeAppListener::SCENEMANAGERNAME[] = 22 22 { 23 23 "KdTreeSceneManager", 24 "KdTreeTerrainSceneManager", 24 25 "OcclusionCullingSceneManager", 25 26 "OctreeSceneManager", 27 "TerrainSceneManager", 26 28 "DefaultSceneManager" 27 29 }; … … 128 130 mRotScale(0.0f), 129 131 mDeathAngle(0.0f), 132 mRaySceneQuery(0), 130 133 // just to stop toggles flipping too fast 131 134 mTimeUntilNextToggle(0.0f), … … 159 162 mTopCam = sm->getCamera("TopCam"); 160 163 mCamNode = sm->getSceneNode("PlayerCamNode"); 164 165 mRaySceneQuery = mSceneMgr->createRayQuery(Ray(mCamNode->getPosition(), Vector3::NEGATIVE_UNIT_Y)); 161 166 162 167 mDebugOverlay = OverlayManager::getSingleton().getByName("Core/DebugOverlay"); … … 404 409 if (mSceneMgr->getTypeName() == "OctreeSceneManager") 405 410 mSceneMgr->setOption("ShowOctree", &show); 406 else if (mSceneMgr->getTypeName() == "KdTreeSceneManager") 411 else if ( 412 mSceneMgr->getTypeName() == "KdTreeSceneManager" || 413 mSceneMgr->getTypeName() == "KdTreeTerrainSceneManager") 407 414 mSceneMgr->setOption("ShowKdTree", &show); 408 415 … … 965 972 if (!mFreeMove) 966 973 { 967 Vector3 pos = mCamNode->getPosition(); 968 RaySceneQuery * rsquery = mSceneMgr->createRayQuery(Ray(pos, Vector3::NEGATIVE_UNIT_Y)); 969 RaySceneQueryResult& rsresult = rsquery->execute(); 970 971 RaySceneQueryResult::iterator it = rsresult.begin(); 972 RaySceneQueryResult::iterator end = rsresult.end(); 973 974 while (it != end && it->movable) 975 { 976 if (it->movable->getName() != "PlayerCam") 974 if (mOptions.mSceneFiles == TERRAIN_SCENE) 975 { 976 static Vector3 pos; 977 static Ray updateRay; 978 pos = mCamNode->getPosition(); 979 updateRay.setOrigin(pos); 980 updateRay.setDirection(Vector3::NEGATIVE_UNIT_Y); 981 mRaySceneQuery->setRay(updateRay); 982 RaySceneQueryResult& qryResult = mRaySceneQuery->execute(); 983 RaySceneQueryResult::iterator i = qryResult.begin(); 984 if (i != qryResult.end() && i->worldFragment) 977 985 { 978 mCamNode->setPosition(pos.x, it->movable->getWorldBoundingBox().getCenter().y + 2, pos.z);979 break;986 SceneQuery::WorldFragment* wf = i->worldFragment; 987 mCamNode->setPosition(pos.x, wf->singleIntersection.y + 10, pos.z); 980 988 } 981 it++; 982 } 983 OGRE_DELETE(rsquery); 989 } 990 else 991 { 992 static Vector3 pos; 993 static Ray updateRay; 994 pos = mCamNode->getPosition(); 995 updateRay.setOrigin(pos); 996 updateRay.setDirection(Vector3::NEGATIVE_UNIT_Y); 997 mRaySceneQuery->setRay(updateRay); 998 RaySceneQueryResult& qryResult = mRaySceneQuery->execute(); 999 RaySceneQueryResult::iterator i = qryResult.begin(); 1000 while (i != qryResult.end() && i->movable) 1001 { 1002 if (i->movable->getName() != "PlayerCam") 1003 { 1004 MovableObject *mov = i->movable; 1005 mCamNode->setPosition(pos.x, mov->getWorldBoundingBox().getCenter().y + 2, pos.z); 1006 break; 1007 } 1008 i++; 1009 } 1010 } 984 1011 } 985 1012 }
Note: See TracChangeset
for help on using the changeset viewer.