I have implemented an RTT reflection in OSG, it's pretty straight
forward. 

 

The code below may be of use to you.

 

camMatrix is set by viewer.getCamera()->getViewMatrix().

 

--- CODE ---

 

osg::Matrixd reflection( 1,  0,  0,  0, 

                         0,  1,  0,  0,

                         0,  0, -1,  0,

                         0,  0,  0,  1 );

 

osg::ref_ptr<osg::Camera> camera = new osg::Camera;

 

camera.get()->setClearColor( p_clearColor );

camera.get()->setClearMask(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);

 

camera.get()->setReferenceFrame( osg::Transform::RELATIVE_RF );

camera.get()->setProjectionMatrix( osg::Matrixd::identity() );

camera.get()->setViewMatrix( camMatrix * reflection );

 

camera.get()->setViewport(x, y, width, height );

 

camera.get()->setRenderOrder(osg::Camera::PRE_RENDER);

 

camera.get()->setRenderTargetImplementation(osg::Camera::FRAME_BUFFER_OB
JECT);

 

camera.get()->attach(osg::Camera::COLOR_BUFFER, p_texture);

 

--- CODE ---

 

From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Tanja &
Paul
Sent: 22 January 2008 16:51
To: [email protected]
Subject: [osg-users] RTT Camera for Reflections

 

Hi , I've also been dealing with the problem of RTT with osgCamera and
using it as reflections in my ocean. I'e used the reflection example as
a basis However The problem I have is I've been pulling the view matrix
from osgViewer and inverting it and using that matrix in my RTT Camera .
Needless to say I'm not getting the desired results. I was wondering if
anyone else has toyed with the same problem and if they might have any
advice for me in producing reflections in  my scene.

*****************************************************************************************
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