Hi Juan, What you describe should work fine with the OSG, the OSG just passes projection and modelview matrices directly on to OpenGL so should work fine. The only thing I'd add is there you shouldn't use a CameraManipulator if you are setting the viewer's master Camera yourself. osgViewer::Viewer.run() will automatically attach a TrackballManipulator if none is otherwise attached so don't use Viewer::run(), or if you have your own frame loop just don't attach a camera manipulator.
Robert. On 30 November 2011 21:11, Juan Fernando Herrera J. <[email protected]> wrote: > Hi. I'm trying to port an OpenGL augmented reality program based on > the ArUco library (http://www.uco.es/investiga/grupos/ava/node/26) to > OSG (I'm not trying OSGArToolkit yet). The original OpenGL program > shows a perfect overlap between the AR marker and the geometric model. > The OSG version doesn't. > > Here's the code outline. Differences between versions are marked with "-->". >> OPENGL PROGRAM > ============== > > 1) Projecton matrix initialization: > double projection_array[16]; > ar::getProjectionMatrix(opencv camera parameters, projection_array); > -->glMatrixMode(GL_PROJECTION); > -->glLoadMatrix(projection_array); > > 2) Main loop: > cameraCapture(frame); // frame is unsigned char *. > double modelview_array[16]; > ar::getMarkerModelViewMatrix(frame, modelview_array); > -->glMatrixMode(GL_MODELVIEW); > -->glLoadMatrix(modelview_array); > ...draw stuff > > OSG PROGRAM > =========== > > 0) OSG misc initialization: > // Prevent the default (trackball) manipulator from overwriting the > modelView matrix continuously. > // http://forum.openscenegraph.org/viewtopic.php?p=44126#44126 > -->osg::Camera *cam = viewer.getCamera(); > -->cam->setAllowEventFocus(false); > > 1) Projection matrix initialization: > double projection_array[16]; > ar::getProjectionMatrix(opencv camera parameters, projection_array); > -->osg::Matrixd projectionMatrix; > -->projectionMatrix.set(projection_array); > -->viewer.getCamera()->setProjectionMatrix(projectionMatrix); > > 2) Main loop: > cameraCapture(frame); > double modelview_array[16]; > ar::getMarkerModelViewMatrix(frame, modelview_array); > -->osg::Matrixd modelViewMatrix; > -->modelViewMatrix.set(modelview_array); > -->viewer.getCamera()->setViewMatrix(modelViewMatrix); > ... draw stuff (with NodeCallbacks). > > What could be wrong? > > Thanks, > > Juan Herrera > _______________________________________________ > 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

