本文整理汇总了C++中SimpleSceneManager::getNavigator方法的典型用法代码示例。如果您正苦于以下问题:C++ SimpleSceneManager::getNavigator方法的具体用法?C++ SimpleSceneManager::getNavigator怎么用?C++ SimpleSceneManager::getNavigator使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SimpleSceneManager
的用法示例。
在下文中一共展示了SimpleSceneManager::getNavigator方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
//.........这里部分代码省略.........
ExampleParticleSystem->setMaxParticles(5); // 5 rockets max to avoid collisions. they are bad.
ExampleParticleSystem->pushToAffectors(AgeFadeAffector);
ExampleParticleSystem->attachUpdateProducer(TutorialWindow);
//Creating Particle System Drawer
QuadParticleSystemDrawerRefPtr ExampleParticleSystemDrawer = QuadParticleSystemDrawer::create();
ExampleParticleSystemDrawer->setNormalAndUpSource(QuadParticleSystemDrawer::NORMAL_VIEW_DIRECTION,
QuadParticleSystemDrawer::UP_VELOCITY);
QuadParticleSystemDrawerRefPtr ExampleTrailDrawer = QuadParticleSystemDrawer::create();
//ExampleTrailDrawer->setNormalAndUpSource(QuadParticleSystemDrawer::NORMAL_VIEW_DIRECTION,
//QuadParticleSystemDrawer::UP_PARTICLE_NORMAL);
// Attaching affector and generator to the particle system
ExampleParticleSystem->pushToGenerators(ExampleGenerator);
//Particle System Core, setting its system, drawer, and material
ParticleSystemCoreRefPtr ParticleNodeCore = ParticleSystemCore::create();
ParticleNodeCore->setSystem(ExampleParticleSystem);
ParticleNodeCore->setDrawer(ExampleParticleSystemDrawer);
ParticleNodeCore->setMaterial(PSMaterial);
// create Particle System Particle Trail generator
ParticleSystemParticleTrailGeneratorRecPtr ExamplePSTrailGenerator = ParticleSystemParticleTrailGenerator::create();
ExamplePSTrailGenerator->setTrailResolution(0.05f);
ExamplePSTrailGenerator->setTrailLength(1.2);
ExamplePSTrailGenerator->setTrailLengthMethod(ParticleTrailGenerator::TIME);
ExamplePSTrailGenerator->setTrailResolutionMethod(ParticleTrailGenerator::TIME_SPACING);
ExamplePSTrailGenerator->setTrailMaterial(TrailMaterial);
ExamplePSTrailGenerator->setTrailDrawer(ExampleTrailDrawer);
ExamplePSTrailGenerator->setSizeDistribution(createTrailSizeDistribution());
ExamplePSTrailGenerator->setColorDistribution(createColorDistribution());
ExamplePSTrailGenerator->setNormalDistribution(createNormalDistribution());
ExamplePSTrailGenerator->setVelocityDistribution(createNormalDistribution());
// create affectors for particle trails
GravityParticleAffectorRefPtr GravAffector = GravityParticleAffector::create();
GravAffector->setBeacon(ExamplePSTrailGenerator);
AgeFadeParticleAffectorRefPtr TrailAgeFadeAffector = AgeFadeParticleAffector::create();
TrailAgeFadeAffector->setFadeInTime(0.2f);
TrailAgeFadeAffector->setStartAlpha(0.0f);
TrailAgeFadeAffector->setEndAlpha(0.0f);
TrailAgeFadeAffector->setFadeOutTime(1.0f);
TrailAgeFadeAffector->setFadeToAlpha(0.6f);
// now we attach the affector to the particle trail generator's particle system
ExamplePSTrailGenerator->getParticleSystem()->pushToAffectors(TrailAgeFadeAffector);
// attach listener for trail generator to the particle system
ExamplePSTrailGenerator->setSystemToTrail(ExampleParticleSystem);
//Attach the the update producer to the particle system particle trail generator.
ExamplePSTrailGenerator->attachUpdateProducer(TutorialWindow);
// Set up node with the particle system at its core
NodeRefPtr ParticleNode = Node::create();
ParticleNode->setCore(ParticleNodeCore);
ParticleNode->addChild(ExamplePSTrailGenerator);
// Make Main Scene Node
NodeRefPtr scene = Node::create();
scene->setCore(Group::create());
scene->addChild(ParticleNode);
TutorialWindow->connectKeyPressed(boost::bind(keyPressed, _1, &sceneManager, ExampleParticleSystem.get(), ExamplePSTrailGenerator.get()));
sceneManager.setRoot(scene);
// Show the whole Scene
sceneManager.getNavigator()->set(Pnt3f(0.0,0.0,100.0), Pnt3f(0.0,0.0,0.0), Vec3f(0.0,1.0,0.0));
sceneManager.getNavigator()->setMotionFactor(1.0f);
sceneManager.getCamera()->setFar(10000.0f);
sceneManager.getCamera()->setNear(0.1f);
//Open Window
Vec2f WinSize(TutorialWindow->getDesktopSize() * 0.85f);
Pnt2f WinPos((TutorialWindow->getDesktopSize() - WinSize) *0.5);
TutorialWindow->openWindow(WinPos,
WinSize,
"02ParticleSystemParticleTrail");
std::cout << "Controls: " << std::endl
<< "P: Increase Trail Resolution" << std::endl
<< "L: Decrease Trail Resolution" << std::endl
<< "O: Increase Trail Length" << std::endl
<< "K: Decrease Trail Length" << std::endl
<< "J: Toggle calculating trail length by num points/time" << std::endl
<< "Y: Toggle calculating trail point spacing by time/distance" << std::endl
<< "B: Particle burst" << std::endl;
//Enter main Loop
TutorialWindow->mainLoop();
}
osgExit();
return 0;
}
示例2: main
//.........这里部分代码省略.........
ShrapnelBurstGenerator->setBurstAmount(50.0);
ShrapnelBurstGenerator->setVelocityDistribution(createShrapnelVelocityDistribution());
ShrapnelBurstGenerator->setAccelerationDistribution(createShrapnelAccelerationDistribution());
NodeRefPtr ShrapnelParticleNode = Node::create();
ShrapnelParticleNode->setCore(ShrapnelParticleNodeCore);
//end/////////////////////
//fireball
BurstParticleGeneratorRecPtr FireballGenerator = BurstParticleGenerator::create();
NodeRefPtr FireballParticlePrototypeNode = SceneFileHandler::the()->read("Data/bubble.obj");
NodeParticleSystemCoreRefPtr FireballParticleNodeCore = NodeParticleSystemCore::create();
FireballParticleNodeCore->setSystem(FireballParticleSystem);
FireballParticleNodeCore->setPrototypeNode(FireballParticlePrototypeNode);
//Attach the function objects to the Generator
Distribution3DRefPtr FireballPositionDistribution = createFireballPositionDistribution();
FireballGenerator->setPositionDistribution(FireballPositionDistribution);
FireballGenerator->setLifespanDistribution(createFireballLifespanDistribution());
FireballGenerator->setBurstAmount(100.0);
FireballGenerator->setVelocityDistribution(createFireballVelocityDistribution());
FireballGenerator->setAccelerationDistribution(createFireballAccelerationDistribution());
//Attach the function objects the Affectors
AgeSizeParticleAffectorRecPtr FireballAgeSizeParticleAffector = AgeSizeParticleAffector::create();
//ages
FireballAgeSizeParticleAffector->editMFAges()->push_back(0.1);
FireballAgeSizeParticleAffector->editMFAges()->push_back(0.2);
FireballAgeSizeParticleAffector->editMFAges()->push_back(0.3);
FireballAgeSizeParticleAffector->editMFAges()->push_back(0.5);
FireballAgeSizeParticleAffector->editMFAges()->push_back(0.7);
FireballAgeSizeParticleAffector->editMFAges()->push_back(0.8);
FireballAgeSizeParticleAffector->editMFAges()->push_back(1.0);
//sizes
FireballAgeSizeParticleAffector->editMFSizes()->push_back(Vec3f(2.0,2.0,2.0));
FireballAgeSizeParticleAffector->editMFSizes()->push_back(Vec3f(2.3,2.3,2.3));
FireballAgeSizeParticleAffector->editMFSizes()->push_back(Vec3f(2.5,2.5,2.5));
FireballAgeSizeParticleAffector->editMFSizes()->push_back(Vec3f(3.0,3.0,3.0));
FireballAgeSizeParticleAffector->editMFSizes()->push_back(Vec3f(4.0,4.0,4.0));
FireballAgeSizeParticleAffector->editMFSizes()->push_back(Vec3f(5.0,5.0,5.0));
FireballAgeSizeParticleAffector->editMFSizes()->push_back(Vec3f(6.5,6.5,6.5));
NodeRefPtr FireballParticleNode = Node::create();
FireballParticleNode->setCore(FireballParticleNodeCore);
//end/////////////////////
//Attach the Affector to the Smoke Particle System
SmokeParticleSystem->pushToAffectors(SmokeAgeFadeParticleAffector);
SmokeParticleSystem->pushToAffectors(SmokeAgeSizeParticleAffector);
//Attach the Affector to the fireball Particle System
FireballParticleSystem->pushToAffectors(FireballAgeSizeParticleAffector);
// Make Main Scene Node
NodeRefPtr scene = Node::create();
scene->setCore(Group::create());
scene->addChild(RocketParticleNode);
scene->addChild(SmokeParticleNode);
scene->addChild(ShrapnelParticleNode);
scene->addChild(FireballParticleNode);
scene->addChild(EnvironmentNode);
RocketParticleSystem->connectParticleKilled(boost::bind(particleKilled, _1,
ShrapnelParticleSystem.get(),
ShrapnelBurstGenerator.get(),
SmokeParticleSystem.get(),
SmokeGenerator.get(),
FireballParticleSystem.get(),
FireballGenerator.get()));
TutorialWindow->connectMousePressed(boost::bind(mousePressed, _1,
&sceneManager,
RocketParticleSystem.get()));
sceneManager.setRoot(scene);
//Create the Documentation
SimpleScreenDoc TheSimpleScreenDoc(&sceneManager, TutorialWindow);
sceneManager.getNavigator()->set(Pnt3f(0.0,0.0,-10.0), Pnt3f(0.0,0.0,0.0), Vec3f(0.0,1.0,0.0));
sceneManager.getNavigator()->setMotionFactor(1.0f);
sceneManager.getCamera()->setNear(0.1f);
sceneManager.getCamera()->setFar(1000.0f);
//Open Window
Vec2f WinSize(TutorialWindow->getDesktopSize() * 0.85f);
Pnt2f WinPos((TutorialWindow->getDesktopSize() - WinSize) *0.5);
TutorialWindow->openWindow(WinPos,
WinSize,
"20RocketLauncher");
//Enter main Loop
TutorialWindow->mainLoop();
}
osgExit();
return 0;
}
示例3: main
//.........这里部分代码省略.........
plane_mat->setAmbient(Color3f(0.7,0.7,0.7));
plane_mat->setDiffuse(Color3f(0.9,0.6,1.0));
plane->setMaterial(plane_mat);
//create Physical Attachments
PhysicsBoxGeomRecPtr planeGeom = PhysicsBoxGeom::create();
planeGeom->setLengths(Vec3f(30.0, 30.0, 1.0));
//add geoms to space for collision
planeGeom->setSpace(physicsSpace);
//add Attachments to nodes...
spaceGroupNode->addAttachment(physicsSpace);
spaceGroupNode->addAttachment(physHandler);
spaceGroupNode->addAttachment(physicsWorld);
spaceGroupNode->addChild(planeNode);
planeNode->addAttachment(planeGeom);
scene->addChild(spaceGroupNode);
//Create Statistics Foreground
SimpleStatisticsForegroundRecPtr PhysicsStatForeground = SimpleStatisticsForeground::create();
PhysicsStatForeground->setSize(25);
PhysicsStatForeground->setColor(Color4f(0,1,0,0.7));
PhysicsStatForeground->addElement(WindowEventProducer::statWindowLoopTime, "Draw FPS: %r.3f");
PhysicsStatForeground->getCollector()->getElem(WindowEventProducer::statWindowLoopTime, true);
PhysicsStatForeground->addElement(RenderAction::statNGeometries,
"%d Nodes drawn");
PhysicsStatForeground->getCollector()->getElem(RenderAction::statNGeometries, true);
PhysicsStatForeground->addElement(PhysicsHandler::statPhysicsTime,
"Physics time: %.3f s");
PhysicsStatForeground->getCollector()->getElem(PhysicsHandler::statPhysicsTime, true);
PhysicsStatForeground->addElement(PhysicsHandler::statCollisionTime,
"Collision time: %.3f s");
PhysicsStatForeground->getCollector()->getElem(PhysicsHandler::statCollisionTime, true);
PhysicsStatForeground->addElement(PhysicsHandler::statSimulationTime,
"Simulation time: %.3f s");
PhysicsStatForeground->getCollector()->getElem(PhysicsHandler::statSimulationTime, true);
PhysicsStatForeground->addElement(PhysicsHandler::statNCollisions,
"%d collisions");
PhysicsStatForeground->getCollector()->getElem(PhysicsHandler::statNCollisions, true);
PhysicsStatForeground->addElement(PhysicsHandler::statNCollisionTests,
"%d collision tests");
PhysicsStatForeground->getCollector()->getElem(PhysicsHandler::statNCollisionTests, true);
PhysicsStatForeground->addElement(PhysicsHandler::statNPhysicsSteps,
"%d simulation steps per frame");
PhysicsStatForeground->getCollector()->getElem(PhysicsHandler::statNPhysicsSteps, true);
TutorialWindow->connectUpdate(boost::bind(handleStatisticsReset, _1), boost::signals2::at_front);
StatCollector::setGlobalCollector(PhysicsStatForeground->getCollector());
SimpleStatisticsForegroundRecPtr RenderStatForeground = SimpleStatisticsForeground::create();
RenderStatForeground->setSize(25);
RenderStatForeground->setColor(Color4f(0,1,0,0.7));
// tell the manager what to manage
sceneManager.setRoot (rootNode);
sceneManager.getWindow()->getPort(0)->addForeground(PhysicsStatForeground);
sceneManager.getWindow()->getPort(0)->addForeground(RenderStatForeground);
TutorialWindow->connectKeyPressed(boost::bind(keyPressed, _1,
TriGeometryBase.get(),
spaceGroupNode.get(),
PhysDrawableNode.get(),
physicsWorld.get(),
physicsSpace.get()));
// show the whole rootNode
sceneManager.getNavigator()->set(Pnt3f(20.0,20.0,10.0), Pnt3f(0.0,0.0,0.0), Vec3f(0.0,0.0,1.0));
sceneManager.getNavigator()->setMotionFactor(1.0f);
sceneManager.getCamera()->setFar(10000.0f);
sceneManager.getCamera()->setNear(0.1f);
Vec2f WinSize(TutorialWindow->getDesktopSize() * 0.85f);
Pnt2f WinPos((TutorialWindow->getDesktopSize() - WinSize) *0.5);
TutorialWindow->openWindow(WinPos,
WinSize,
"01SimplePhysics");
//Enter main Loop
TutorialWindow->mainLoop();
}
osgExit();
return 0;
}