Hello Mukund,
There are two factors here: your setting the frustum, and OSG's compute
near-far mode.
First, since you are calling setProjectionMatrixAsFrustum yourself, you
are resetting the coordinate system to be Y-up, with the Z axis going
out of the screen. So when you make a line that goes from -640,0,-1800
to 640,0,-1800 and you set up your camera with the identity matrix, you
are looking along the -Z axis, so your far plane actually starts at
-1900 in world space: (0,0,0) + (0,0,1900) dot (0,0,-1)
If you change your camera to look along the +Z axis, or you change your
line to be at Z=1800 instead of -1800 you won't see it anymore, so that
confirms that this first part is what's happening (I've just tried it in
a small test app).
The second part is that by default, OSG recomputes the camera's near and
far planes so that the scene is in view and do not use up too much depth
buffer precision. There are ways to tune this, look at the
osg::CullSettings class which osg::Camera inherits. But in your case, if
you just want to not see your line (because it's closer to the camera
than the near plane, and you want that near plane to stay set the way
you've set it), do this before your frame loop:
viewer.getCamera()->setComputeNearFarMode(osg::CullSettings::DO_NOT_COMPUTE_NEAR_FAR);
Then, as expected, you won't see your line.
See the osgthirdpersonview example for a demo of OSG's compute near far
functionality in action. Also it's a cool way to view your frustum and
be able to debug this kind of thing.
I kind of think if you'd have tried a few things and tried your app in a
debugger, you would have been able to find this out on your own. The
mailing list or forum archives are very useful (the compute near far
thing comes up really often). Also printing the result of
camera->getProjectionMatrixAsFrustum() in your frame loop would have
shown that the near and far values had been changed, and you would have
probably gone looking for what had changed them (data breakpoints in a
debugger can help there).
Hope this helps,
J-S
--
______________________________________________________
Jean-Sebastien Guay [email protected]
http://www.cm-labs.com/
http://whitestar02.webhop.org/
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org