SceneView doesn't utilise all its topmost CameraNode's features, only currently using it for its view, projection matrices and viewport. Internally CameraNode's in the scene graph do implement more of the features including the post draw callback.
In the post draw callback SceneView should certainly be checking for it a calling it, as what you are doing is a perfectly reasonable thing to do. I'll pop this on my TODO list for the day.
Robert.
On 8/31/06, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
Hi!
I have a cameraNode and i need to take a screenshot. I see that the
producer camera implements a postDrawcallback to take the screenshot.
I copy this code for my cameranode (yes, i have a osg::CameraNode
camera) and it doesn't works. I debug it and never calls the
operator(). Someone can i help me???
this is my drawcallback class...
class SnapImageDrawCallback : public osg::CameraNode::DrawCallback
{
public:
SnapImageDrawCallback():
_snapImageOnNextFrame(false)
{
}
void setFileName(const std::string& filename) { _filename = filename; }
const std::string& getFileName() const { return _filename; }
void setSnapImageOnNextFrame(bool flag) { _snapImageOnNextFrame = flag; }
bool getSnapImageOnNextFrame() const { return _snapImageOnNextFrame; }
virtual void operator () (const osg::CameraNode& camera) const
{
if (!_snapImageOnNextFrame) return;
int x,y,width,height;
camera.getViewport()->getViewport(x,y,width,height);
osg::ref_ptr<osg::Image> image = new osg::Image;
image->readPixels(x,y,width,height,GL_RGB,GL_UNSIGNED_BYTE);
if (osgDB::writeImageFile(*image,_filename))
{
osg::notify(osg::NOTICE) << "Saved screen image to
`"<<_filename<<"`"<< std::endl;
}
_snapImageOnNextFrame = false;
}
protected:
std::string _filename;
bool _snapImageOnNextFrame;
};
and then asign the callback to my cameranode:
SnapImageDrawCallback* snapImageDrawCallback = new SnapImageDrawCallback();
sceneView->getCamera()->setPostDrawCallback(snapImageDrawCallback);
----------------------------------------------------------------
This message was sent using IMP, the Internet Messaging Program.
_______________________________________________
osg-users mailing list
[email protected]
http://openscenegraph.net/mailman/listinfo/osg-users
http://www.openscenegraph.org/
_______________________________________________ osg-users mailing list [email protected] http://openscenegraph.net/mailman/listinfo/osg-users http://www.openscenegraph.org/
