Hi,
I am new to Qualcomm SDK. I did ImageTargets sample on my Android device.
Now I am trying to replace tea pot with some 3D object.
To render 3D object i choosed OpenSceneGraph (OSG) library.
I successfully added OSG rendering code to ImageTargets example.
This is the code I added to "renderFrame" method.
if(mload)//to init OSG { 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); _manipulator = new osgGA::KeySwitchMatrixManipulator; _manipulator->addMatrixManipulator( '1', "Trackball", new osgGA::TrackballManipulator() ); _manipulator->addMatrixManipulator( '2', "Flight", new osgGA::FlightManipulator() ); _manipulator->addMatrixManipulator( '3', "Drive", new osgGA::DriveManipulator() ); _manipulator->addMatrixManipulator( '4', "Terrain", new osgGA::TerrainManipulator() ); _manipulator->addMatrixManipulator( '5', "Orbit", new osgGA::OrbitManipulator() ); _manipulator->addMatrixManipulator( '6', "FirstPerson", new osgGA::FirstPersonManipulator() ); _manipulator->addMatrixManipulator( '7', "Spherical", new osgGA::SphericalManipulator() ); _viewer->setCameraManipulator( _manipulator.get() ); _viewer->getViewerStats()->collectStats("scene", true); //config.mSize.data[0] = screenWidth; // config.mSize.data[1] = videoMode.mHeight * (screenWidth / (float)videoMode.mWidth);_viewer->getCamera()->setViewport(0,0,800, 600);//_viewer->setLightingMode(osg::View::HEADLIGHT); _viewer->getCamera()->setProjectionMatrix(osg::Matrix(projectionMatrix.data));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()); _manipulator->getNode(); _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; }
_viewer->frame();// called every time
only with this code the model is rendering on the screen.
But the 3D model is not rendering when I draw video background. That is when I added this statement "QCAR::Renderer::getInstance().drawVideoBackground();" the model is not redering on the screen.
I tried to setting the viewPort and projection matrix to OSG. But still the model is not rendering on the screen.
Can you please help me where am i doing the mistake.
Thanks & Regards
ANReddy.
3D model is not rendering with OSG render lib
I haven't worked w/ OSG before, but if you can PM me w/ a link to your code, I'll take a look at it.
3D model is not rendering with OSG render lib
Hi,
I did some experiments with QCAR. I decomposed the QCAR Pose matrix (from Matrix44f) into transilation, scale and rotation vectors and checked with each one.
3D model is not rendering with OSG render lib
The pose matrix describes the position and orientation of the target from the camera perspective. The ModelView matrix describes the position of the model in relation to the target. So try modifying the modelview matrix to adjust the position of your model.
3D model is not rendering with OSG render lib
Hi,
Thank you very much for the help.
I tried as your guidence. But still the model is not appeared in the screen.
Here is the code what I did
const QCAR::Trackable* trackable = state.getActiveTrackable(tIdx);