Hi Koduri,

Maybe you are not getting the correct matrix transformation of your
trackable, so try first to get the model shown without any transformation.
In the other hand _viewer->frame() has to be called every frame you want to
get, not once in your code. Pay attention to the method draw() in
osgMainApp, it's called each osgNativeLib step.

About the camera stream as image background it depends on which AR toolkit
you are using and there are several approximations to accomplish this task.
One of them (it does not mean that this is the best for your case) is to
render the GLSurface with a transparent color and then draw the camera
stream.

Cheers.

2012/8/29 Koduri Lakshmi <[email protected]>

> Hello Jordi Torres,
>
> Thank you very much for the help.
>
> I added OSG macros and got loaded models.
>
> But when I say "viewer->frame" i am getting only blew screen. I am not
> able to see model.
>
> Here is my code
>
> Code:
>
>
>   if(mload)
>   {
>
>         LOG("Init");
>   int x=0;
>   int y=0;
>
>   int width=screenWidth;
>   int height=screenHeight;
>
>   _viewer = new osgViewer::Viewer();
>     _viewer->setUpViewerAsEmbeddedInWindow(x, y, width, height);
>      _root = new osg::Group();
>
>     _viewer->realize();
>     _state = _root->getOrCreateStateSet();
>     _state->setMode(GL_LIGHTING, osg::StateAttribute::ON);
>     _state->setMode(GL_DEPTH_TEST, osg::StateAttribute::ON);
>     _state->setMode(GL_CULL_FACE, osg::StateAttribute::ON);
>
>     //_viewer->setSceneData(_root.get());
>
>     //_viewer->addEventHandler(new osgViewer::StatsHandler);
>    // _viewer->addEventHandler(new
> osgGA::StateSetManipulator(_viewer->getCamera()->getOrCreateStateSet()));
>     //_viewer->addEventHandler(new osgViewer::ThreadingHandler);
>    // _viewer->addEventHandler(new osgViewer::LODScaleHandler);
> _viewer->getViewerStats()->collectStats("scene", true);
>
> trans=new osg::MatrixTransform();
>
>
>     LOG("Load Model");
>   osg::ref_ptr<osg::Node> loadedModel =
> osgDB::readNodeFile("/mnt/sdcard/OSG/lz.osg");
>   if (loadedModel == 0) {
>             LOG("Model not loaded");
>         } else {
>             LOG("Model loaded");
>
>
>             loadedModel->setName("/mnt/sdcard/OSG/lz.osg");
>            // _root->addChild(loadedModel);
>             trans->addChild(loadedModel.get());
>         }
>
>   _root->addChild(trans.get());
>
>         _viewer->setSceneData(NULL);
>     _viewer->setSceneData(_root.get());
>      _viewer->home();
>
>     _viewer->getDatabasePager()->clear();
>     _viewer->getDatabasePager()->registerPagedLODs(_root.get());
>     _viewer->getDatabasePager()->setUpThreads(3, 1);
>     _viewer->getDatabasePager()->setTargetMaximumNumberOfPageLOD(2);
>     _viewer->getDatabasePager()->setUnrefImageDataAfterApplyPolicy(true,
> true);
>     mload=false;
>   }
>
>  modelViewMatrix =
>  Tool::convertPose2GLMatrix(trackable->getPose());//Pose Matrix
>
>         osg::Matrix mat;
>
>
> mat.set(modelViewMatrix.data[0],modelViewMatrix.data[1],modelViewMatrix.data[2],modelViewMatrix.data[3],
>
> modelViewMatrix.data[4],modelViewMatrix.data[5],modelViewMatrix.data[6],modelViewMatrix.data[7],
>
> modelViewMatrix.data[8],modelViewMatrix.data[9],modelViewMatrix.data[10],modelViewMatrix.data[11],
>
> modelViewMatrix.data[12],modelViewMatrix.data[13],modelViewMatrix.data[14],modelViewMatrix.data[15]);
>
>
>                 trans->setMatrix(mat);
>
> trans->preMult(osg::Matrix::scale(osg::Vec3(3,3,3)));//With out this also
> no model
>
>              _viewer->frame();
>
>
>
> Can you please help me why the model is not displayed.
>
> I am doing it for AR application.
> When I run application I got only blue screen. How can I show the camera
> image as background instead of blue screen?
>
>
>
>
>
> ...
>
> Thank you!
>
> Cheers,
> Koduri
>
> ------------------
> Read this topic online here:
> http://forum.openscenegraph.org/viewtopic.php?p=49661#49661
>
>
>
>
> _______________________________________________
> osg-users mailing list
> [email protected]
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>



-- 
Jordi Torres Fabra

gvSIG 3D blog
http://gvsig3d.blogspot.com
Instituto de Automática e Informática Industrial
http://www.ai2.upv.es
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to