Hi,

i'm quite new to OSG and try to write some simple tasks. In the code
below i tried ortho projection, but not matter if I put the triangle in
the XY or XZ plane,if i attach the_geode or trans as scene data,nothing
gets displayed. the corresponding code in pure GL works without any
problem. what did i do wrong?

thanks in advance.

#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;
  the_viewer.getCamera()->setViewMatrix(osg::Matrix::identity());
  the_viewer.getCamera()->setProjectionMatrixAsOrtho2D(-1,1,-1,1);

  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();
  the_array->push_back(osg::Vec3(0,0,0));
  // swapping the next two lines for different triangle orientation doesn't 
work also
  the_array->push_back(osg::Vec3(1,0,0));
  the_array->push_back(osg::Vec3(0,0,1)); // (0,1,0) also does not work here
  the_geometry->setVertexArray(the_array.get());
  the_geometry->addPrimitiveSet(new 
osg::DrawArrays(osg::PrimitiveSet::TRIANGLES,0,3));
  the_geode->addDrawable(the_geometry.get());

  osg::ref_ptr<osg::MatrixTransform> trans = new osg::MatrixTransform();
  trans->setReferenceFrame(osg::Transform::ABSOLUTE_RF);
  trans->addChild(the_geode.get());
  trans->setMatrix(osg::Matrix::identity());
  the_viewer.setSceneData(trans.get()); // the_geode.get() doesn't work too

  the_viewer.run();
}


_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to