本文整理汇总了C++中ViewportPtr::editMFForegrounds方法的典型用法代码示例。如果您正苦于以下问题:C++ ViewportPtr::editMFForegrounds方法的具体用法?C++ ViewportPtr::editMFForegrounds怎么用?C++ ViewportPtr::editMFForegrounds使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ViewportPtr
的用法示例。
在下文中一共展示了ViewportPtr::editMFForegrounds方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(int argc, char **argv)
{
osgInit(argc,argv);
// GLUT init
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_RGB | GLUT_DEPTH | GLUT_DOUBLE);
int id=glutCreateWindow("OpenSG");
glutReshapeFunc(reshape);
glutDisplayFunc(display);
glutIdleFunc(display);
glutMouseFunc(mouse);
glutMotionFunc(motion);
glutKeyboardFunc(keyboard);
GLUTWindowPtr gwin=GLUTWindow::create();
gwin->setId(id);
gwin->init();
// create the scene
// NodePtr scene = makeTorus(.5, 2, 16, 16);
NodePtr scene = makeBox(1,1,1, 1,1,1);
// create the SimpleSceneManager helper
mgr = new SimpleSceneManager;
// tell the manager what to manage
mgr->setWindow(gwin );
mgr->setRoot (scene);
// Create the textured material
UChar8 imgdata[] =
{ 255,0,0,128, 0,255,0,128, 0,0,255,255, 255,255,255,255 };
ImagePtr img = Image::create();
beginEditCP(img);
if(argc > 1)
img->read(argv[1]);
else
img->set( Image::OSG_RGBA_PF, 2, 2, 1, 1, 1, 0, imgdata );
endEditCP(img);
addRefCP(img);
SimpleTexturedMaterialPtr mat = SimpleTexturedMaterial::create();
beginEditCP(mat);
mat->setLit(false);
mat->setDiffuse(Color3f(0,1,0));
mat->setImage(img);
mat->setMinFilter(GL_NEAREST);
mat->setMagFilter(GL_NEAREST);
mat->setEnvMode(GL_REPLACE);
endEditCP(mat);
// Add the polygon foregrounds
Pnt2f pos[][4] = {
{ Vec2f(.4,.4), Vec2f(.6,.4), Vec2f(.6,.6), Vec2f(.4,.6) },
{ Vec2f(0,0), Vec2f(1,0), Vec2f(1,.1), Vec2f(0,.1) },
{ Vec2f(1,-100), Vec2f(-2,-100), Vec2f(-2,-2), Vec2f(1,-2) },
{ Vec2f(-1000,-1000), Vec2f(0,0), Vec2f(0,0), Vec2f(0,0) }
};
bool normx[] = { true, true, false };
bool normy[] = { true, true, false };
for(UInt16 ind = 0; pos[ind][0][0] != -1000; ++ind)
{
PolygonForegroundPtr pg = PolygonForeground::create();
beginEditCP(pg);
pg->setMaterial(mat);
pg->editMFTexCoords()->push_back(Vec3f( 0.,0.,0.));
pg->editMFPositions()->push_back(pos[ind][0]);
pg->editMFTexCoords()->push_back(Vec3f( 1.,0.,0.));
pg->editMFPositions()->push_back(pos[ind][1]);
pg->editMFTexCoords()->push_back(Vec3f( 1.,1.,0.));
pg->editMFPositions()->push_back(pos[ind][2]);
pg->editMFTexCoords()->push_back(Vec3f( 0.,1.,0.));
pg->editMFPositions()->push_back(pos[ind][3]);
pg->setNormalizedX(normx[ind]);
pg->setNormalizedY(normy[ind]);
endEditCP(pg);
// take the viewport
ViewportPtr vp = gwin->getPort(0);
beginEditCP(vp);
vp->editMFForegrounds()->push_back(pg);
endEditCP (vp);
}
// Create the edgeblend foreground
const int blendpixel = 50;
UChar8 ebimgdata[] =
{ 0,0,0,0, 0,0,0,255 };
ImagePtr ebimg = Image::create();
//.........这里部分代码省略.........
示例2: main
//.........这里部分代码省略.........
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->updateVolume();
Vec3f min,max;
file->getVolume().getBounds( min, max );
std::cout << "Volume: from " << min << " to " << max << std::endl;
beginEditCP(dlight);
dlight->addChild( file );
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();
// Foreground
GrabForegroundPtr fgnd = GrabForeground::create();
image = Image::create();
beginEditCP(image);
image->set(Image::OSG_RGB_PF, 1);
endEditCP(image);
fgnd->setImage(image);
// Viewport
vp = Viewport::create();
vp->setCamera( cam );
vp->setBackground( bkgnd );
vp->editMFForegrounds()->push_back( fgnd );
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
Vec3f pos( 0, 0, max[2] + ( max[2] - min[2] ) * 1.5 );
tball.setMode( Trackball::OSGObject );
tball.setStartPosition( pos, true );
tball.setSum( true );
tball.setTranslationMode( Trackball::OSGFree );
// run...
glutMainLoop();
return 0;
}
示例3: main
int main(int argc, char **argv)
{
osgInit(argc,argv);
// GLUT init
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_RGB | GLUT_DEPTH | GLUT_DOUBLE);
int id=glutCreateWindow("OpenSG");
glutReshapeFunc(reshape);
glutDisplayFunc(display);
glutIdleFunc(display);
glutMouseFunc(mouse);
glutMotionFunc(motion);
glutKeyboardFunc(keyboard);
GLUTWindowPtr gwin=GLUTWindow::create();
gwin->setId(id);
gwin->init();
// create the scene
// NodePtr scene = makeTorus(.5, 2, 16, 16);
NodePtr scene = Node::create();
beginEditCP(scene);
scene->setCore(Group::create());
endEditCP(scene);
// create the SimpleSceneManager helper
mgr = new SimpleSceneManager;
// tell the manager what to manage
mgr->setWindow(gwin );
mgr->setRoot (scene);
DisplayFilterForegroundPtr fg = DisplayFilterForeground::create();
beginEditCP(fg);
// add filter
endEditCP(fg);
// take the viewport
ViewportPtr vp = gwin->getPort(0);
beginEditCP(vp);
vp->editMFForegrounds()->push_back(fg);
endEditCP (vp);
colorFilterPtr = ColorDisplayFilter::create();
distortionFilterPtr = DistortionDisplayFilter::create();
resolutionFilterPtr = ResolutionDisplayFilter::create();
beginEditCP(colorFilterPtr);
beginEditCP(resolutionFilterPtr);
beginEditCP(distortionFilterPtr);
beginEditCP(fg);
colorFilterPtr->setMatrix(osg::Matrix(0,0,1,0,
1,0,0,0,
0,1,0,0,
0,0,0,1));
resolutionFilterPtr->setDownScale(0.25);
distortionFilterPtr->setColumns(2);
distortionFilterPtr->setRows(2);
distortionFilterPtr->editMFPositions()->push_back(Vec2f(0,.5));
distortionFilterPtr->editMFPositions()->push_back(Vec2f(.5,0));
distortionFilterPtr->editMFPositions()->push_back(Vec2f(.5,1));
distortionFilterPtr->editMFPositions()->push_back(Vec2f(1,.5));
fg->editMFFilter()->push_back(colorFilterPtr);
fg->editMFFilter()->push_back(resolutionFilterPtr);
fg->editMFFilter()->push_back(distortionFilterPtr);
endEditCP(distortionFilterPtr);
endEditCP(colorFilterPtr);
endEditCP(resolutionFilterPtr);
endEditCP(fg);
for(UInt32 a=1 ; a<argc ;a++)
{
NodePtr file = SceneFileHandler::the().read(argv[a],0);
if(file != NullFC)
scene->addChild(file);
else
std::cerr << "Couldn't load file, ignoring " << argv[a] << std::endl;
}
if ( scene->getNChildren() == 0 )
{
scene->addChild(makeTorus( .5, 2, 16, 16 ));
// scene->addChild(makeBox(.6,.6,.6,5,5,5));
}
// show the whole scene
mgr->showAll();
// GLUT main loop
glutMainLoop();
return 0;
}