Hi, As a solution, I decided to change the viewpoint of the camera and then take pictures as I change the viewpoint. However, with the code I have, it's really slow (cow rotates very slowly) Any suggestions or ways I can over come this problem?
Code: //capture an image of the scenegraph class CCameraPostDrawCallback: public osg::Camera::DrawCallback { public: CCameraPostDrawCallback(const int cX, const int cY, const int w, const int h, const std::string str) { centerX = cX; centerY = cY; width = w; height = h; fileName = str; } void operator () (const osg::Camera& cam) const { //take a picture of the scene osg::ref_ptr<osg::Image> screenShot = new osg::Image; screenShot->readPixels(centerX, centerY, width, height, GL_RGB, GL_UNSIGNED_BYTE); osgDB::writeImageFile(*screenShot, fileName); } private: int centerX; int centerY; int width; int height; std::string fileName; }; osg::Node* CreateScene() { //add rendering modifications //load the osg model osg::Node* loadedModel = osgDB::readNodeFile("cow.osg"); return loadedModel; } int main(int argc, char *argv[]) { osgViewer::Viewer viewer; viewer.setSceneData(CreateScene()); viewer.getCamera()->setProjectionMatrixAsPerspective(60., 1., 1., 100. ); viewer.setUpViewInWindow(0, 0, 500, 500); //create a matrix to specify a distance from the viewpoint. osg::Matrix trans; trans.makeTranslate(0., 0., -12.); //Rotation angle (in radians) double angle(0.); while (!viewer.done()) { viewer.getCamera()->setPostDrawCallback(new CCameraPostDrawCallback(0, 0, 500, 500, "screenshot.jpg")); //Create the rotation matrix. osg::Matrix rot; rot.makeRotate(angle, osg::Vec3(1, 0., 0.)); angle += 0.01; viewer.getCamera()->setViewMatrix(rot * trans); viewer.frame(); } } Thank you! Cheers, Ricky ------------------ Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=29188#29188 _______________________________________________ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org