Hi Deepti,

A Camera has to be rendered before the image is populated, you have to
add it to a viewer and run a frame.

Robert.

On Nov 30, 2007 10:19 AM, deepti g <[EMAIL PROTECTED]> wrote:
> Hi
>      My problem is regarding taking an image of any intermediate node. If
> the user gives the name of a node,I need to display its image on screen. The
> algorithm I used is :
> 1)set up a node visitor and make it traverse the entire scenegraph
>
> 2) If there is a node with the same name as that given by the user,get the
> nodepath which was used to reach that node and get the transformation
> matrix..(i.e., the entire transformation which is required to get to that
> node's position)
>
>    osg::Matrix matrix= osg::computeWorldToLocal(NodeVisitor->getNodePath()
> ); //the transformation matrix
>
> 3)Now,according to me,all I need to do is create a camera and set its view
> matrix to be this matrix.So , I did this:
>
>  osg::Camera *camera=new osg::Camera();
> camera->setViewport(new osg::Viewport(0,0, width, height));
> camera->setProjectionMatrixAsOrtho2D(0,width,0,height); //FIXME
> camera->setRenderTargetImplementation ( osg::Camera::FRAME_BUFFER_OBJECT);
> camera->setViewMatrix(matrix);
>
> 4) Then I attached an osg::Image  object to this camera and tried to record
> the image.
>
>  osg::Image* shot = new osg::Image();
>  shot->allocateImage(width, height, 24, GL_RGB, GL_UNSIGNED_BYTE);
>  camera->attach(osg::Camera::COLOR_BUFFER, shot);
>  osgDB::writeImageFile(*shot,"image_file.png");
>
> But the image which Iam getting is completely black.I have no idea where Iam
> going wrong..Can anybody please point out where my mistake is?
>
> ThankYou
> Deepti.
>
> _______________________________________________
> 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