本文整理汇总了C++中osg::SimpleSceneManagerRefPtr::getWindow方法的典型用法代码示例。如果您正苦于以下问题:C++ SimpleSceneManagerRefPtr::getWindow方法的具体用法?C++ SimpleSceneManagerRefPtr::getWindow怎么用?C++ SimpleSceneManagerRefPtr::getWindow使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类osg::SimpleSceneManagerRefPtr
的用法示例。
在下文中一共展示了SimpleSceneManagerRefPtr::getWindow方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
//
// transform vector from world space to eye space
//
OSG::Vec3f transform_to_eye_space(const OSG::Vec3f& v, OSG::SimpleSceneManager* pSSM)
{
if (!pSSM || !pSSM->getWindow() || pSSM->getWindow()->getMFPort()->size() == 0)
return v;
OSG::Viewport* pPort = mgr->getWindow()->getPort(0);
OSG::Vec3f v_es;
OSG::Matrix view;
OSG::Int16 width = pPort->calcPixelWidth();
OSG::Int16 height = pPort->calcPixelHeight();
pPort->getCamera()->getViewing(view, width, height);
view.multFull( v, v_es);
return v_es;
}
示例2: doMain
//.........这里部分代码省略.........
OSG::Vec3f color(sc);
OSG::Int32 x = - size;
OSG::Int32 y = - size;
OSG::Int32 z = - size;
OSG::UInt32 iterations = size*2 * size*2 * size*2;
printf("Creating %u cubes ...\n", iterations);
for(OSG::UInt32 i=0; i<iterations; ++i)
{
OSG::ChunkMaterialUnrecPtr cmat = OSG::ChunkMaterial::create();
// ok use one SHLChunk and n SHLParameterChunks
// Assing a different "SurfaceColor" parameter to each geometry.
OSG::SimpleSHLVariableChunkUnrecPtr shlparameter =
OSG::SimpleSHLVariableChunk::create();
// shlparameter->setSHLChunk(shl);
shlparameter->addUniformVariable("SurfaceColor", color);
_shlparameter = shlparameter;
cmat->addChunk(shl);
cmat->addChunk(shlparameter);
OSG::TransformUnrecPtr trans;
OSG::NodeUnrecPtr trans_node =
OSG::makeCoredNode<OSG::Transform>(&trans);
trans->editMatrix().setTranslate(OSG::Real32(x),
OSG::Real32(y),
OSG::Real32(z));
OSG::MaterialGroupUnrecPtr mg;
OSG::NodeUnrecPtr mg_node = OSG::makeCoredNode<OSG::MaterialGroup>(&mg);
mg->setMaterial(cmat);
OSG::NodeUnrecPtr geonode = OSG::Node::create();
geonode->setCore(geo);
mg_node->addChild(geonode);
trans_node->addChild(mg_node);
// add to scene
_scene->addChild(trans_node);
// ----
++x;
color[0] += sr;
if(x == size)
{
x = - size;
++y;
color[0] = sc[0];
color[1] += sg;
if(y == size)
{
y = - size;
++z;
color[1] = sc[1];
color[2] += sb;
}
}
}
// create the SimpleSceneManager helper
_mgr = OSG::SimpleSceneManager::create();
// tell the manager what to manage
_mgr->setWindow(gwin );
_mgr->setRoot(_scene);
// show the whole scene
_mgr->showAll();
// create a gradient background.
OSG::GradientBackgroundUnrecPtr gback = OSG::GradientBackground::create();
gback->clearLines();
gback->addLine(OSG::Color3f(0.7f, 0.7f, 0.8f), 0);
gback->addLine(OSG::Color3f(0.0f, 0.1f, 0.3f), 1);
OSG::Window *win = _mgr->getWindow();
for(unsigned int i=0; i<win->getMFPort()->size(); ++i)
{
OSG::Viewport *vp = win->getPort(i);
vp->setBackground(gback);
}
return 0;
}
示例3: keyboard
// react to keys
void keyboard(unsigned char k, int x, int y)
{
static OSG::Real32 season = 0.0f;
switch(k)
{
case 27:
case 'q':
_mgr = NULL;
_scene = NULL;
_shl = NULL;
_shl_vp = NULL;
_shl_fp = NULL;
OSG::osgExit();
exit(1);
break;
case 'c':
_mgr->getWindow()->getShaderCache()->dump();
break;
case 'w':
OSG::SceneFileHandler::the()->write(_scene, "scene.osb.gz", true);
printf("wrote scene.osb.gz\n");
break;
case 's':
if(season < 0.435)
season += 0.01f;
_shl_vp->updateUniformVariable("season", season);
break;
case 'S':
if(season > -0.435)
season -= 0.01f;
_shl_vp->updateUniformVariable("season", season);
break;
case 'd':
_animation = 1 - _animation;
break;
case 'b':
if(!_shl_fp->readProgram("Earth.fp"))
fprintf(stderr, "Couldn't read fragment program 'Earth.fp'\n");
else
fprintf(stderr, "blue loaded\n");
break;
case 'r':
if(!_shl_fp->readProgram("Earth_red.fp"))
fprintf(stderr, "Couldn't read fragment program 'Earth.fp'\n");
else
fprintf(stderr, "red loaded\n");
break;
case 'B':
_shl_fp = OSG::ShaderProgram::create();
_shl_fp->setShaderType(GL_FRAGMENT_SHADER);
_shl_fp->addUniformVariable("EarthDay", 0);
_shl_fp->addUniformVariable("EarthNight", 1);
_shl_fp->addUniformVariable("EarthCloudGloss", 2);
if(!_shl_fp->readProgram("Earth.fp"))
{
fprintf(stderr, "Couldn't read fragment program 'Earth.fp'\n");
}
else
{
_shl->subFragmentShader(0);
_shl->addFragmentShader(_shl_fp);
fprintf(stderr, "blue loaded\n");
}
break;
case 'R':
_shl_fp = OSG::ShaderProgram::create();
_shl_fp->setShaderType(GL_FRAGMENT_SHADER);
_shl_fp->addUniformVariable("EarthDay", 0);
_shl_fp->addUniformVariable("EarthNight", 1);
_shl_fp->addUniformVariable("EarthCloudGloss", 2);
if(!_shl_fp->readProgram("Earth_red.fp"))
{
fprintf(stderr, "Couldn't read fragment program 'Earth.fp'\n");
}
else
{
_shl->subFragmentShader(0);
_shl->addFragmentShader(_shl_fp);
fprintf(stderr, "red loaded\n");
}
break;
case 'A':
//.........这里部分代码省略.........
示例4: keyboard
//.........这里部分代码省略.........
break;
case 'P':
{
OSG::Real32 cover = tact->getScreenLODCoverageThreshold();
cover+=0.001f;
tact->setScreenLODCoverageThreshold(cover);
std::cout << "ScreenLOD Coverage Threshold now: " << cover << std::endl;
}
break;
case 'p':
{
OSG::Real32 covera = tact->getScreenLODCoverageThreshold();
covera-=0.001f;
tact->setScreenLODCoverageThreshold(covera);
std::cout << "ScreenLOD Coverage Threshold now: " << covera << std::endl;
}
break;
case 'D':
{
OSG::Real32 user_dega = tact->getScreenLODDegradationFactor();
user_dega+=0.01f;
tact->setScreenLODDegradationFactor(user_dega);
std::cout << "ScreenLOD User Degradation Factor now: " << user_dega << std::endl;
}
break;
case 'd':
{
OSG::Real32 user_deg = tact->getScreenLODDegradationFactor();
user_deg-=0.01f;
tact->setScreenLODDegradationFactor(user_deg);
std::cout << "ScreenLOD User Degradation Factor now: " << user_deg << std::endl;
}
break;
case 'N':
{
OSG::Real32 coverb = tact->getScreenLODCoverageThreshold();
coverb=0.0;
tact->setScreenLODCoverageThreshold(coverb);
std::cout << "ScreenLOD Coverage Threshold now: " << coverb << std::endl;
}
break;
case 'o':
{
tact->setOcclusionCulling(false);
std::cout << "OCC Off" << std::endl;
}
break;
case 'O':
{
tact->setOcclusionCulling(true);
std::cout << "OCC On" << std::endl;
}
break;
case 'f':
{
std::cout << "Freeze Occlusion result" << std::endl;
//initElements();
mgr->setUseTraversalAction(false);
// Render stuff that is visible and tested
mgr->getWindow()->getPort(0)->setTravMask(0x5);
}
break;
case 'F':
{
std::cout << "Unfreeze Occlusion result" << std::endl;
//initElements();
mgr->setUseTraversalAction(true);
mgr->getWindow()->getPort(0)->setTravMask(0xffffffff);
}
break;
case 'W':
{
std::string sss = "out.osb";
OSG::SceneFileHandler::the()->write(scene, sss.c_str());
}
break;
#ifdef OSG_WITH_NVPERFSDK
case 'e':
runExperiment = true;
break;
#endif
}
redisplay();
}
示例5: main
int main(int argc, char **argv)
{
g_error = 0.01f;
if ( argc > 1 && !strcmp(argv[1], "-f"))
{
std::cerr << "Using forceTesselate()." << std::endl;
useForceTesselate = true;
++argv, --argc;
}
if ( argc == 2 )
{
g_error = atof( argv[1] );
}
if ( g_error < 0.001 )
{
g_error = 0.001f;
}
OSG::osgInit(argc,argv);
// GLUT init
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_RGB | GLUT_DEPTH | GLUT_DOUBLE);
int winid = glutCreateWindow("OpenSG");
glutReshapeFunc(reshape);
glutDisplayFunc(display);
glutIdleFunc(display);
glutMouseFunc(mouse);
glutMotionFunc(motion);
glutKeyboardFunc(keyboard);
{
OSG::GLUTWindowRefPtr gwin = OSG::GLUTWindow::create();
gwin->setGlutId(winid);
gwin->init();
// create the scene
OSG::NodeRefPtr scene;
scene = makeScene( );
if ( scene == NULL )
{
std::cerr<<"makeScene returned NullFC, exiting..."<<std::endl;
return -1;
}
// create the SimpleSceneManager helper
mgr = OSG::SimpleSceneManager::create();
// create the window and initial camera/viewport
mgr->setWindow( gwin );
// tell the manager what to manage
mgr->setRoot ( scene );
// show the whole scene
mgr->showAll();
mgr->redraw();
OSG::SolidBackgroundRefPtr bgr = OSG::SolidBackground::create();
bgr->setColor( OSG::Color3f( 0.7f, 0.7f, 0.7f ));
mgr->getWindow()->getPort(0)->setBackground( bgr );
}
// GLUT main loop
glutMainLoop();
return 0;
}