|
Hi
thanks for that
i got that to work,
but i dont understand
why the bellow option where i adjust the
viewer camera directly does not work as well
?
It only seems to
work if i set them as nodes and add as childs.
Why is that ?
It seems to me to
be doing the same thing
In addition i assume
1. using the
ABSOLUTE_RF option sets the view matrix to
the default opengl (is that right ??) is
it the same as the default opengl glLoadidentity
for a different axis alignment
2. then i
would have to use osg:Matrix rot;
rot.makeRotate(90,osg::Vec3(1,0,0));
to rotate the matrix so that i have a +x(right),
+Y (up) axis alignement.
int main(int, char
**)
{
// create the model osg::Group* root = new osg::Group; root->addChild( createScene() ); osgViewer::Viewer viewer;
viewer.getCamera()->setProjectionMatrixAsOrtho2D(-2,2,-2,2); viewer.getCamera()->setViewMatrix(osg::Matrix::identity()); // add model to viewer. viewer.setSceneData( root ); return viewer.run(); } thanks for any help
Peter
> Hi,
try this modified code and compare with the unchanged example. You can use ABSOLUTE_RF as well, you will just need to rotate the matrix for the viewer's default camera. Or change the default camera to be in your coord system. From the transform callback you can see that the default view direction of the camera is aligned with the y-axis. transform->setMatrix(osg::Matrix::translate(0.0f,1.0f+cosf(time*_angular_velocity),0.0f)); Therefore, the flat geometry will be drawn in the x-z plane (as you can see from the example's geom). You can use the 3rd coordinate of your geometry to place different things at different ranges (layers) from the camera. cheers jp int main(int, char **) { // create the model osg::ref_ptr<osg::MatrixTransform> modelview_abs = new osg::MatrixTransform(); //modelview_abs->setReferenceFrame(osg::Transform::ABSOLUTE_RF); modelview_abs->setMatrix(osg::Matrix::identity()); osg::ref_ptr<osg::Projection> projection = new osg::Projection(); projection->setMatrix(osg::Matrix::ortho2D(-2,2,-2, 2)); projection->addChild(modelview_abs.get()); modelview_abs->addChild(createScene()); modelview_abs->addChild( createBackground() ); /* osg::Group* root = new osg::Group; root->addChild( createScene() ); root->addChild( createBackground() ); */ //osgDB::writeNodeFile(*root,"geoemtry.osg"); osgViewer::Viewer viewer; // add model to viewer. //viewer.setSceneData( root ); viewer.setSceneData( projection.get() ); return viewer.run(); } Peter DeSantis wrote: > Hello, > > im sorry to keep asking for help but im totaly stuck on trying to draw > prmitive geometry to a 2D ortho screen in OSG. > > Ive been experimenting with both the OSGhud and OSG geometry examples an > i have just ended up with a huge mess, with no visible results. > > > I have taken the OSG geometry example and i can compile and run it fine > and see the lines and polygons. I have then converted the viewer camera > to a 2Dorth projection matrix, but in doing so i get no geomtry visible. > In addition it seems the gemoetry example is still rendering the geomtry > in 3d space with Vec3 required for the vertex points, > but in the native opengl examples i have seen on the net they use Vec2 > for simple X,Y. > > this is the original main code from the OSG geometry example > > > int main(int, char **) > > { > > // create the model > > osg::Group* root = new osg::Group; > > root->addChild( createScene() ); > > root->addChild( createBackground() ); > > //osgDB::writeNodeFile(*root,"geoemtry.osg"); > > osgViewer::Viewer viewer; > > // add model to viewer. > > viewer.setSceneData( root ); > > return viewer.run(); > > } > > > > can any help me by showing how the viewer camera can be set to 2D orth, > no quad, no background,so that one can still see the geometry rendered > on screen. > > > > Everytime i set it to 2D ortho no geometry is ever visible. > > > > > > Any help appreciated, im tearing my hair out, and have no idea what to > try next. > > > > > Thanks > > Peter DeSantis > [EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]> > Jumbo Vision International Pty Ltd > Unit 2 ,1 Aitken Way > Kewdale WA 6105 > Australia > > Tel: 61 8 9353 6200 > Fax: 61 8 9353 6211 > > > ------------------------------------------------------------------------ > > _______________________________________________ > osg-users mailing list > [email protected] > http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org -- This message is subject to the CSIR's copyright terms and conditions, e-mail legal notice, and implemented Open Document Format (ODF) standard. The full disclaimer details can be found at http://www.csir.co.za/disclaimer.html. This message has been scanned for viruses and dangerous content by MailScanner, and is believed to be clean. MailScanner thanks Transtec Computers for their support. _______________________________________________ osg-users mailing list [email protected] http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org < ----------------------- Original
Message -----------------------
From: "J.P. Delport" <[EMAIL PROTECTED]>
To: OpenSceneGraph Users
<[email protected]>
Date: Wed, 23 Jan 2008 13:41:27
+0200
Subject: Re: [osg-users]
drawing line geometry on a 2D ortho viewport
Hi,
try this modified code and compare with the unchanged example. You can use ABSOLUTE_RF as well, you will just need to rotate the matrix for the viewer's default camera. Or change the default camera to be in your coord system. From the transform callback you can see that the default view direction of the camera is aligned with the y-axis. transform->setMatrix(osg::Matrix::translate(0.0f,1.0f+cosf(time*_angular_velocity),0.0f)); Therefore, the flat geometry will be drawn in the x-z plane (as you can see from the example's geom). You can use the 3rd coordinate of your geometry to place different things at different ranges (layers) from the camera. cheers jp int main(int, char **) { // create the model osg::ref_ptr<osg::MatrixTransform> modelview_abs = new osg::MatrixTransform(); //modelview_abs->setReferenceFrame(osg::Transform::ABSOLUTE_RF); modelview_abs->setMatrix(osg::Matrix::identity()); osg::ref_ptr<osg::Projection> projection = new osg::Projection(); projection->setMatrix(osg::Matrix::ortho2D(-2,2,-2, 2)); projection->addChild(modelview_abs.get()); modelview_abs->addChild(createScene()); modelview_abs->addChild( createBackground() ); /* osg::Group* root = new osg::Group; root->addChild( createScene() ); root->addChild( createBackground() ); */ //osgDB::writeNodeFile(*root,"geoemtry.osg"); osgViewer::Viewer viewer; // add model to viewer. //viewer.setSceneData( root ); viewer.setSceneData( projection.get() ); return viewer.run(); } Peter DeSantis wrote: > Hello, > > im sorry to keep asking for help but im totaly stuck on trying to draw > prmitive geometry to a 2D ortho screen in OSG. > > Ive been experimenting with both the OSGhud and OSG geometry examples an > i have just ended up with a huge mess, with no visible results. > > > I have taken the OSG geometry example and i can compile and run it fine > and see the lines and polygons. I have then converted the viewer camera > to a 2Dorth projection matrix, but in doing so i get no geomtry visible. > In addition it seems the gemoetry example is still rendering the geomtry > in 3d space with Vec3 required for the vertex points, > but in the native opengl examples i have seen on the net they use Vec2 > for simple X,Y. > > this is the original main code from the OSG geometry example > > > int main(int, char **) > > { > > // create the model > > osg::Group* root = new osg::Group; > > root->addChild( createScene() ); > > root->addChild( createBackground() ); > > //osgDB::writeNodeFile(*root,"geoemtry.osg"); > > osgViewer::Viewer viewer; > > // add model to viewer. > > viewer.setSceneData( root ); > > return viewer.run(); > > } > > > > can any help me by showing how the viewer camera can be set to 2D orth, > no quad, no background,so that one can still see the geometry rendered > on screen. > > > > Everytime i set it to 2D ortho no geometry is ever visible. > > > > > > Any help appreciated, im tearing my hair out, and have no idea what to > try next. > > > > > Thanks > > Peter DeSantis > [EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]> > Jumbo Vision International Pty Ltd > Unit 2 ,1 Aitken Way > Kewdale WA 6105 > Australia > > Tel: 61 8 9353 6200 > Fax: 61 8 9353 6211 > > > ------------------------------------------------------------------------ > > _______________________________________________ > osg-users mailing list > [email protected] > http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org -- This message is subject to the CSIR's copyright terms and conditions, e-mail legal notice, and implemented Open Document Format (ODF) standard. The full disclaimer details can be found at http://www.csir.co.za/disclaimer.html. This message has been scanned for viruses and dangerous content by MailScanner, and is believed to be clean. MailScanner thanks Transtec Computers for their support. _______________________________________________ osg-users mailing list [email protected] http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org |
_______________________________________________ osg-users mailing list [email protected] http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

