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.

Viewer::run() adds a camera manipulator under the hood, which is changing
your view matrix, so you aren't getting the view matrix you specify.
Instead, use Viewer::done() and Viewer::frame().

Take out the code that adds an identity MatrixTransform with ABSOLUTE
reference frame; it is not needed and is just making things more confusing
for those of us trying to debug your code for you.

With your view and projection matrices, you'll want to draw into the xy
plane.
   -Paul


> 
> 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-opensce
negraph.org

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

Reply via email to