本文整理汇总了C++中Navigator::setMode方法的典型用法代码示例。如果您正苦于以下问题:C++ Navigator::setMode方法的具体用法?C++ Navigator::setMode怎么用?C++ Navigator::setMode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Navigator
的用法示例。
在下文中一共展示了Navigator::setMode方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
//.........这里部分代码省略.........
beginEditCP(dl);
dl->setAmbient( .3, .3, .3, 1 );
dl->setDiffuse( 1, 1, 1, 1 );
dl->setDirection(0,0,1);
dl->setBeacon( b1n);
endEditCP(dl);
// root
root = Node::create();
GroupPtr gr1 = Group::create();
beginEditCP(root);
root->setCore( gr1 );
root->addChild( t1n );
root->addChild( dlight );
endEditCP(root);
// Load the file
NodePtr file = NullFC;
if ( argc > 1 )
file = SceneFileHandler::the().read(argv[1]);
if ( file == NullFC )
{
std::cerr << "Couldn't load file, ignoring" << std::endl;
//file = makeTorus( .5, 2, 16, 16 );
file = makeBox( 2,4,6, 1,1,1 );
}
file->updateVolume();
Vec3f min,max;
file->getVolume().getBounds( min, max );
std::cout << "Volume: from " << min << " to " << max << std::endl;
NodePtr file2=makeBox(2,4,6,1,1,1);
beginEditCP(dlight);
dlight->addChild( file );
dlight->addChild( file2 );
endEditCP(dlight);
std::cerr << "Tree: " << std::endl;
// root->dump();
// Camera
cam = PerspectiveCamera::create();
cam->setBeacon( b1n );
cam->setFov( deg2rad( 90 ) );
cam->setNear( 0.1 );
cam->setFar( 10000 );
// Background
SolidBackgroundPtr bkgnd = SolidBackground::create();
// Viewport
vp = Viewport::create();
vp->setCamera( cam );
vp->setBackground( bkgnd );
vp->setRoot( root );
vp->setSize( 0,0, 1,1 );
// Window
std::cout << "GLUT winid: " << winid << std::endl;
GLUTWindowPtr gwin;
GLint glvp[4];
glGetIntegerv( GL_VIEWPORT, glvp );
gwin = GLUTWindow::create();
gwin->setId(winid);
gwin->setSize( glvp[2], glvp[3] );
win = gwin;
win->addPort( vp );
win->init();
// Action
ract = DrawAction::create();
// tball
trackball.setMode(Navigator::TRACKBALL);
trackball.setViewport(vp);
// run...
glutMainLoop();
return 0;
}
示例2: main
//.........这里部分代码省略.........
std::string skyPath = Configuration::getPath("Skybox");
skybox.init(5,5,5, 1000, (skyPath+"lostatseaday/lostatseaday_dn.jpg").c_str(),
(skyPath+"lostatseaday/lostatseaday_up.jpg").c_str(),
(skyPath+"lostatseaday/lostatseaday_ft.jpg").c_str(),
(skyPath+"lostatseaday/lostatseaday_bk.jpg").c_str(),
(skyPath+"lostatseaday/lostatseaday_rt.jpg").c_str(),
(skyPath+"lostatseaday/lostatseaday_lf.jpg").c_str());
//----------------------------------------------------------------------------//
// Snippet-2-15 - END //
//----------------------------------------------------------------------------//
NodePtr root = Node::create();
beginEditCP(root);
root->setCore(Group::create());
//----------------------------------------------------------------------------//
// Snippet-1-3 - BEGIN //
//----------------------------------------------------------------------------//
OpenSGSceneGraphInterface* sgIF =
dynamic_cast<OpenSGSceneGraphInterface*>(OutputInterface::getSceneGraphInterface());
if (!sgIF) {
printf("Error: Failed to get OpenSGSceneGraphInterface!\n");
printf("Please check if the OutputInterface configuration is correct!\n");
return -1;
}
// retrieve root node of the SceneGraphInterface (method is OpenSG specific)
NodePtr scene = sgIF->getNodePtr();
root->addChild(scene);
//----------------------------------------------------------------------------//
// Snippet-1-3 - END //
//----------------------------------------------------------------------------//
//----------------------------------------------------------------------------//
// Snippet-2-16 - BEGIN //
//----------------------------------------------------------------------------//
// add the SkyBox to the scene
root->addChild(skybox.getNodePtr());
//----------------------------------------------------------------------------//
// Snippet-2-16 - END //
//----------------------------------------------------------------------------//
endEditCP(root);
//----------------------------------------------------------------------------//
// Snippet-2-5 - BEGIN //
//----------------------------------------------------------------------------//
// fetch users camera, it is used to tell the Navigator where we are
localUser = UserDatabase::getLocalUser();
if (!localUser) {
printd(ERROR, "Error: Could not find localUser!\n");
return -1;
}
camera = localUser->getCamera();
if (!camera) {
printd(ERROR, "Error: Could not find camera!\n");
return -1;
}
avatar = localUser->getAvatar();
if (!avatar) {
printd(ERROR, "Error: Could not find avatar!\n");
return -1;
}
avatar->showAvatar(false);
// set our transformation to the start transformation
TransformationData startTrans =
WorldDatabase::getEnvironmentWithId(1)->getStartTransformation(0);
localUser->setNavigatedTransformation(startTrans);
//----------------------------------------------------------------------------//
// Snippet-2-5 - END //
//----------------------------------------------------------------------------//
mgr = new SimpleSceneManager; // create the SimpleSceneManager
mgr->setWindow(gwin); // tell the manager what to manage
mgr->setRoot(root); // attach the scenegraph to the root node
mgr->showAll(); // show the whole scene
mgr->getCamera()->setNear(0.1);
//----------------------------------------------------------------------------//
// Snippet-2-6 - BEGIN //
//----------------------------------------------------------------------------//
// Navigator is part of SimpleSceneManager and not of the inVRs framework
Navigator *nav = mgr->getNavigator();
nav->setMode(Navigator::NONE); // turn off the navigator
lastTimeStamp = timer.getTime(); // initialize timestamp;
camMatrix = gmtl::MAT_IDENTITY44F; // initial setting of the camera matrix
//----------------------------------------------------------------------------//
// Snippet-2-6 - END //
//----------------------------------------------------------------------------//
//----------------------------------------------------------------------------//
// Snippet-5-2 //
//----------------------------------------------------------------------------//
glutMainLoop(); // GLUT main loop
return 0;
}