Hi Lindmark,
I added the camera to the group node and changed the
view.Still no luck :( ..Here arethe steps which Iam following:
osg::Image* shot = new osg::Image(); // the image object where I want to
store my image
osg::Camera* camera = new osg::Camera; //the camera
shot->allocateImage(width, height, 24, GL_RGB,GL_UNSIGNED_BYTE);
camera->setProjectionMatrixAsOrtho2D(0,width,0,height);
camera->setReferenceFrame(osg::Transform::ABSOLUTE_RF);
camera->setViewMatrix(findNode.returnMatrix());
camera->setViewport(new osg::Viewport(0,0, width, height));
camera->setRenderOrder(osg::Camera::PRE_RENDER);
camera->setRenderTargetImplementation(osg::Camera::FRAME_BUFFER_OBJECT);
camera->attach(osg::Camera::COLOR_BUFFER, shot);
camera->addChild(loadedModel);
camera->setPostDrawCallback(new MyCameraPostDrawCallback(shot));
osg::Group *grp=new osg::Group;
grp->addChild(camera);
viewer->setSceneData(grp);
In MyCameraPostDrawCallback's operator function,I just wrote the
image into a file..
Adding this camera to the viewer is taking me to some part of the scene
which doesnt have the model..And the image Iam getting is completely black
Where am I going wrong??
On Nov 30, 2007 12:41 PM, <[EMAIL PROTECTED]> wrote:
> Add the camera to your scenegraph.
> Straight from the osgprerender.cpp example
> parent->addChild(camera);
>
> osg will find the camera and try to render using this camera as well.
>
> /Andreas Lindmark
> > ----- Original Message -----
> > From: "deepti g" <[EMAIL PROTECTED]>
> > To: "OpenSceneGraph Users" <[email protected]>
> > Subject: Re: [osg-users] Taking an image of an intermediate node.
> > Date: Fri, 30 Nov 2007 12:02:24 +0000
> >
> >
> > Hi Robert
> > I need to take the image without changing the present
> view
> > on the screen.. The view which my camera has and the view which my
> screen
> > has are completely different.If I add the camera to the viewer,the
> screen
> > might be showing what view my camera has which I dont want.. Can you
> please
> > guide as to how this could be achieved.
> >
> > ThankYou
> > Deepti
> >
> > On Nov 30, 2007 11:53 AM, Robert Osfield <[EMAIL PROTECTED]>
> wrote:
> >
> > > 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
> > >
> >
> > _______________________________________________
> > osg-users mailing list
> > [email protected]
> >
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>
> >
>
>
> =
>
>
> --
> Powered by Outblaze
> _______________________________________________
> 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