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
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org