Hi Paul,
 
If I understand the problem correctly you can use a screen aligned quad with a 
post render camera that has an orthographic projection.
 
i.e.
 
osg::Geometry* quadGeometry = osg::createTexturedQuadGeometry( osg::Vec3(0.0, 
0.0, -1.0), osg::Vec3(screenWidth,0.0,0.0), osg::Vec3(0.0,screenHeight,0.0), 
texSize.x(),texSize.y() );
 
Bind texture to the quadGeometry
 
Then use the following camera:
 
osg::Camera* camera = new osg::Camera;
 
camera->setClearMask(GL_DEPTH_BUFFER_BIT);
camera->setClearColor( osg::Vec4(0.f, 0.f, 0.f, 1.0) );
camera->setReferenceFrame(osg::Transform::ABSOLUTE_RF_INHERIT_VIEWPOINT);
camera->setProjectionMatrixAsOrtho( 0.f, screenWidth, 0.f, screenHeight, 1.0, 
500.f );
camera->setViewMatrix(osg::Matrix::identity());
camera->setViewport( 0, 0, _screenDims.x(), _screenDims.y() );
camera->setRenderOrder( osg::Camera::POST_RENDER );
camera->addChild(quadGeometry);
 
root->addChild(camera);
 
Using that the texture will always be infront of the camera and facing the 
screen.
 
Regards,
 
Kim.

________________________________

From: [email protected] on behalf of Paul Griffiths
Sent: Sat 23/05/2009 08:42
To: [email protected]
Subject: [osg-users] Texture always facing screen?



Hi,
How can i get a texture to be displayed always facing the screen? the width of 
the texture has to be the width of the screen, same for height. and the corner 
of the texture always start at screen coords 0,0


                osg::StateSet* stateset = new osg::StateSet();
                osg::Image* image = 
osgDB::readImageFile("Images/panelForeground.png");
                if (image)
                {
                        image->setPixelFormat(GL_BGRA);

                        osg::Texture2D* texture = new osg::Texture2D;
                        texture->setImage(image);
                        texture->setWrap(osg::Texture2D::WRAP_S, 
osg::Texture2D::REPEAT);
                        texture->setWrap(osg::Texture2D::WRAP_T, 
osg::Texture2D::REPEAT);

                        
stateset->setTextureAttributeAndModes(0,texture,osg::StateAttribute::ON);
                        stateset->setMode(GL_LIGHTING,osg::StateAttribute::ON);
                        
stateset->setMode(GL_DEPTH_TEST,osg::StateAttribute::ON);

                        foregroundGeometry->setStateSet( stateset );
                }

...

Thank you!

Cheers,
PaulG

------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=12801#12801





_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


<<winmail.dat>>

*****************************************************************************************
To view the terms under which this email is distributed, please go to 
http://www.hull.ac.uk/legal/email_disclaimer.html
*****************************************************************************************
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to