本文整理汇总了C++中osgviewer::Viewer::getCameraManipulator方法的典型用法代码示例。如果您正苦于以下问题:C++ Viewer::getCameraManipulator方法的具体用法?C++ Viewer::getCameraManipulator怎么用?C++ Viewer::getCameraManipulator使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类osgviewer::Viewer
的用法示例。
在下文中一共展示了Viewer::getCameraManipulator方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: playerDied
void Level::playerDied()
{
Player::getInstance()->getPlayerState()->setSpeed(0.0f);
Player::getInstance()->resetPosition();
((LazyCameraManipulator *)viewer.getCameraManipulator())->resetCamera();
_headUpDisplay->resetTimer();
_numDeaths++;
}
示例2: startApplication
void startApplication()
{
startMenu->hideAll();
osg::ref_ptr<osg::Node> groundRoot = genWorld(filename);
root->addChild(groundRoot);
osg::ref_ptr<FirstPersonController> controller = new FirstPersonController(&viewer);
viewer.setCameraManipulator(controller);
// Add main HUD
mainHud = new hud(&viewer);
root->addChild(mainHud->_camera);
// Set user position (aka camera)
osg::Vec3d eye( 0.0, -1.0, 0.0 );
osg::Vec3d center( 0.0, 0.0, 0.0 );
osg::Vec3d up( 0.0, 0.0, 90.0 );
viewer.getCameraManipulator()->setHomePosition(eye, center, up);
viewer.home();
}
示例3: operator
void LevelUpdater::operator()(osg::Node *node, osg::NodeVisitor *nv)
{
double currentStepTime = viewer.getFrameStamp()->getSimulationTime();
// compensate error arising from the osg::Viewer resetting its SimulationTime
if(currentStepTime - _previousStepTime < 0.0f)
{
Player::getInstance()->resetPosition();
((LazyCameraManipulator *)viewer.getCameraManipulator())->resetCamera();
_previousStepTime = currentStepTime - 0.5;
}
int numSimulationSubSteps = _level->getPhysicsWorld()->stepSimulation(currentStepTime - _previousStepTime,
(int)((currentStepTime - _previousStepTime) * 60.0f) + 1);
((LazyCameraManipulator *)viewer.getCameraManipulator())->setNumSimulationSubSteps(numSimulationSubSteps);
_previousStepTime = currentStepTime;
// player dies when falling too low
{
btVector3 position = Player::getInstance()->getController()->getGhostObject()->getWorldTransform().getOrigin();
int yBucketIndex = (int)(position.y() / 20.0f);
if(yBucketIndex >= _level->getDeadlyAltitudes().size())
yBucketIndex = _level->getDeadlyAltitudes().size() - 1;
float minimum = min(_level->getDeadlyAltitudes()[yBucketIndex],
(_level->getDeadlyAltitudes())[yBucketIndex + 1]);
if(position.z() < (minimum - 5.0f))
_level->playerDied();
}
// fade out when level is finished
osg::Vec4 constantBlendColor = _blendColor->getConstantColor();
float alpha = constantBlendColor.a();
// player reached finish
{
osg::Vec3 position = Player::getInstance()->getPosition();
std::vector<osg::Vec3> finishs = _level->getFinishs();
for(size_t i = 0; i < finishs.size(); i++)
{
float maxDistance = 1.0f;
osg::Vec3 diff = position - finishs[i];
if(diff.x() < maxDistance && diff.x() > -maxDistance &&
diff.y() < maxDistance * 3.0f && diff.y() > -maxDistance &&
diff.z() < maxDistance && diff.z() > -maxDistance)
{
if(alpha == 1.0f)
{
alpha -= 0.01f;
_level->getHeadUpDisplay()->stopTimer();
viewer.getEventHandlers().remove(_level->getKeyboardHandler());
((LazyCameraManipulator *)viewer.getCameraManipulator())->fadeOut();
Player::getInstance()->getPlayerState()->setRequestAccelerate(false);
Player::getInstance()->getPlayerState()->setRequestDecelerate(true);
}
}
}
if(alpha < 1.0f)
{
alpha -= 0.01f;
if(alpha <= 0.0f)
{
alpha = 0.0f;
_level->setReachedFinish(true);
}
constantBlendColor[3] = alpha;
_blendColor->setConstantColor(constantBlendColor);
}
}
traverse(node, nv);
}