Hello Alberto, ok your example works great. I think the main difference is I change the frustum direct on the camera object and you get the camera from the viewer and than you change the frustum. Your way runs good, but my version doesn't works.
I change the run function into the animation loop, like your example. Is the idea to use the camera node as the root node the mistake? Cheers, Martin -----Ursprüngliche Nachricht----- Von: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Im Auftrag von Alberto Luaces Gesendet: Montag, 24. November 2008 13:59 An: OpenSceneGraph Users Betreff: Re: [osg-users] camera settings frustum Hi Martin, El Lunes 24 Noviembre 2008ES 13:14:03 Martin Großer escribió: > Without the frustum definition, it works fine. With the definition, it > works only when the value of zNear greater is than the value of zFar. Or > is it normal? Beware! There are some things to know: - The value of near and far planes must be positive and obviously, zFar > zNear. - You were putting the object 25 units far away but your far plane cuts at 4 units. - By using viewer.run(), you are adding an extra default manipulator (TrackballManipulator) which moves the scene for you in order to be seen by the camera at initialization, so it will overwrite your scene placement. - The viewer has its own camera, you haven't to insert a new one. This code works for me, try it out: #include <osgViewer/Viewer> #include <osgViewer/ViewerEventHandlers> #include <osg/Timer> #include <osg/Group> #include <osg/ArgumentParser> #include <osgDB/ReadFile> #include <osg/MatrixTransform> int main() { // scene osg::ref_ptr<osg::Group> root = new osg::Group; // load object osg::MatrixTransform* mt = new osg::MatrixTransform; mt->setMatrix(::osg::Matrix::translate(0, 0, -25)); root->addChild(mt); mt->addChild(osgDB::readNodeFile("cabina.obj")); // viewer osg::ref_ptr<osgViewer::Viewer> viewer = new osgViewer::Viewer; viewer->setSceneData(root.get()); viewer->getCamera()->setProjectionMatrixAsFrustum(-2,2,-1.5,1.5,1,40); viewer->realize(); while(!viewer->done()) { viewer->frame(); } return (0); } _______________________________________________ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org _______________________________________________ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org