On Wed, 1 Oct 2008 18:21:29 -0600
"Paul Martz" <[EMAIL PROTECTED]> wrote:

Thanks for the quick answer. :-)

> Have you looked at the examples? I'm sure there's an ortho example
> somewhere. Try searching the code. It _does_ work (I used it in an RTT
> example recently), so this is almost certainly a bug in your code.

I never thought it is something else,than a bug in my code ;) I looked
at the osgpick example and got the triangle displayed. Though it seems
I have to use an extra osg::Camera node.

Sorry,but I have some new strange thing: It seems like all nodes with
entirely positive z coordinates are not displayed, though my viewing
volume still should be [-1.1] in z. I tried to play with setCullingMode
of both cameras, but it did not change a thing. I also tried
disabling the geode's depth test without success. This seems to be an
OSG thing, because when I have 2 triangles one with positive and one
with negative z coordinates,both get displayed.

here is the code:
#include <osgViewer/Viewer>
#include <osgText/Text>
#include <osg/ShapeDrawable>
#include <osg/MatrixTransform>
#include <osg/Geometry>

int main(int argc,char** argv)
{
  osgViewer::Viewer the_viewer;
  osg::ref_ptr<osg::Camera> camera = new osg::Camera();
  camera->setReferenceFrame(osg::Transform::ABSOLUTE_RF);
  camera->setViewMatrix(osg::Matrix::identity());
  camera->setProjectionMatrixAsOrtho(-1,1,-1,1,-1,1);
  camera->setClearMask(GL_DEPTH_BUFFER_BIT|GL_COLOR_BUFFER_BIT);

  osg::ref_ptr<osg::Geode> the_geode = new osg::Geode();
  osg::ref_ptr<osg::Geometry> the_geometry = new osg::Geometry();
  osg::ref_ptr<osg::Vec3Array> the_array = new osg::Vec3Array();
  // change this to (0,0,.1) to make the triangle disappear
  the_array->push_back(osg::Vec3(0,0,0));
  the_array->push_back(osg::Vec3(1,0,.1));
  the_array->push_back(osg::Vec3(0,1,.1));
  the_geometry->setVertexArray(the_array.get());
  the_geometry->addPrimitiveSet(new
osg::DrawArrays(osg::PrimitiveSet::TRIANGLES,0,3));
the_geode->addDrawable(the_geometry.get());

  camera->addChild(the_geode.get());
  the_viewer.setSceneData(camera.get());

  while(!the_viewer.done())
    the_viewer.frame();
}


_______________________________________________
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to