Hi,
I have resolved the problem, I found out that there is a class which helps 
changing projection, that is osg::Projection which provides different 
projections for the same camera.


--- On Sat, 12/27/08, guher b <[email protected]> wrote:

> From: guher b <[email protected]>
> Subject: [osg-users] Both orthographic and perspective projections for the 
> same camera
> To: [email protected]
> Date: Saturday, December 27, 2008, 8:17 PM
> Hi, 
> 
> while trying to implement rtt textures,
> I came a cross a situation that I can not solve in anyway.
> A camera (this camera is  a post render camera (which was
> added to scenegraph) which draws to frame buffer.and
> meanwhile,  the main camera (of the viewer) produces a
> texture (via fbo) that this camera uses to draw to frame
> buffer)
> 
> This camera(post render camera) should draw two different
> geometries; a simple quad, which is used to render a
> textured quad with orthographic projection (to draw the main
> camera's fbo's generated texture in to the frame
> buffer), and secondly a geometry(a sphere) with perspective
> projection to be drawn to the frame buffer afterwards. 
> 
> To handle different projections, I reimplemented the
> drawcallback of the  first geometry (which needed
> orthographic projection) and did nothing for the sphere
> which used the camera's original projection (perspective
> projection). However, when the sphere is visible, sphere is
> not rendered as it should be, the whole scene becomes the
> sphere's color, when the sphere is visible, and nothing
> is drawn when the sphere is not visible. There is no sphere
> shape at all. I belive that the drawcallback of the first
> geometry does something wrong which produces this behavior,
> cause when the drawcallback is not done, the first geom is
> not drawn but the sphere is drawn as it should be. The
> following code shows my drawcallback of the first geometry,
>  class TmpDrawCallback : public osg::Drawable::DrawCallback
>         {
>             public:
>                 TmpDrawCallback() :
> osg::Drawable::DrawCallback(){
>                                       projectionMatrix=new
> osg::RefMatrix(osg::Matrix::ortho(0,1,0,1,0,1));
>                                       osg::Matrix m;
>                                       
> m.getLookAt(osg::Vec3d(0,0,0),osg::Vec3d(0,0,-2),osg::Vec3d(0,1,0));
>                                       modelViewMatrix=new osg::RefMatrix(m);
>                               }
>                 ~TmpDrawCallback() {}
> 
>                 void drawImplementation
> (osg::RenderInfo& ri, const osg::Drawable* dr) const;
>                               osg::RefMatrix * projectionMatrix;
>                               osg::RefMatrix * modelViewMatrix;
>                               
> 
>               
>             
>         };
> void TmpDrawCallback::drawImplementation
> (osg::RenderInfo& ri, const osg::Drawable* dr) const
> {
>       osg::RefMatrix  * originalPm=new
> osg::RefMatrix(ri.getState()->getProjectionMatrix());
>       osg::RefMatrix  * originalMvm=new
> osg::RefMatrix(ri.getState()->getModelViewMatrix());
> 
>       ri.getState()->applyProjectionMatrix(projectionMatrix);
>       ri.getState()->applyModelViewMatrix(modelViewMatrix);
>   
>     dr->drawImplementation(ri);
> 
>       ri.getState()->applyProjectionMatrix(originalPm);
>       ri.getState()->applyModelViewMatrix(originalMvm);
> }
> 
> 
> Does anyone see the flaw here? Or, is there any other way
> of implementing 2 different projections for the
> samecamera(without reimplementing the drawcallback)?
> Thanks in advance
> 
> 
> 
> 
> 
>       
> _______________________________________________
> osg-users mailing list
> [email protected]
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


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

Reply via email to