Re: [osg-users] Error while loading OSG model on Android

2012-09-06 Thread Jordi Torres
Hi Koduri,


I forgot to mention in the previous post that I made video as background by
 making GL_DEPTH_BUFFER_BIT. That is I used 
 _viewer-getCamera()-setClearMask(GL_DEPTH_BUFFER_BIT ).


 I have a look at the code of osgAnroidExample. But I am not able to find
 any specific info about camera settings in any of the C++ files.


I think you missunderstood me, I was referring to the project osgAndroid (
https://gitorious.org/osgandroid ). It has a osgCamera example, take a look.

Anyway the settings for GlSurface it's done in Java, not in C++. About the
matrices you have to study how the OSG manage their matrices respect how
vuforia (QCAR) does it. I know quite well this integration it's possible.
We have done it, but we are not able to release it as OpenSource :( ... at
least at this moment.

Cheers.

--
Read this topic online here:

 http://forum.openscenegraph.org/viewtopic.php?p=49775#49775




 ___
 osg-users mailing list
 osg-users@lists.openscenegraph.org
 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
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] Error while loading OSG model on Android

2012-09-06 Thread Koduri Lakshmi
Hi Jordi Torres,

Thanks a lot for the nice help.

To day I did some experiments. 

The AR library is giving pose matrix. Now I decomposed it into tans, rotation 
and scale vectors. And checked with each one by matrix multiplication. I found 
that the translation vector is irrelevant. I got transpose as like   17.98  
14.45 155.76 ect. With these values the model is not appread on the screen.  If 
I set the trans vect as 0.0 0.0 1 then the model is at the center of the screen.

I don't know why this behavior. I am posting in QCAR forum for help.

Is there any think I need to to with OSG?

Here is the complete code again 


Code:
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-addEventHandler(new 
osgGA::StateSetManipulator(_viewer-getCamera()-getOrCreateStateSet()));


_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);



_viewer-getCamera()-setViewport(0,0,screenWidth, screenHeight);


_viewer-getCamera()-setClearMask(GL_DEPTH_BUFFER_BIT );



modelSwitch=new osg::Switch;
trans=new osg::MatrixTransform();


osg::ref_ptrosg::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);

trans-addChild(loadedModel.get());
modelSwitch-addChild(trans.get());
}

_root-addChild(modelSwitch.get());

_viewer-setSceneData(NULL);
_viewer-setSceneData(_root.get());
_manipulator-getNode();
_viewer-home();


mload=false;
}
modelSwitch-setAllChildrenOff(); 
modelSwitch-setChildValue(trans,1);





State state = Renderer::getInstance().begin();
// Explicitly render the Video Background
Renderer::getInstance().drawVideoBackground();

for(int tIdx = 0; tIdx  state.getNumActiveTrackables(); tIdx++)
{

  // Get the trackable:
  const Trackable* trackable = state.getActiveTrackable(tIdx);
  Matrix44F modelViewMatrix = 
Tool::convertPose2GLMatrix(trackable-getPose());




  osg::Matrix mat;
  mat.set(osg::Matrix(modelViewMatrix.data));


  osg::Vec3f tr,scal;
  osg::Quat rot,so,rot1,rot2;
  mat.decompose(tr,rot,scal,so);


  mat=osg::Matrix( 
osg::Matrix::scale(osg::Vec3(scal.x(),scal.y(),scal.z()))  * 
osg::Matrix::translate(0.0,0.0,1.0) * osg::Matrix::rotate(rot));

  trans-setMatrix(mat);

  _viewer-frame();
  Renderer::getInstance().end();
  break;
}




I am reading the OSG model every time while rendering. That is for every 
viewer-frame(). If not reading the model is displayed only once. Do I need to 
take any clean up steps after viewer-frame().

Once again I will go through osgAndroid ( https://gitorious.org/osgandroid ) 
example.
 
Once again thank you very much for the nice help.



... 

Thank you!

Cheers,
Koduri

--
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=49799#49799




___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] Error while loading OSG model on Android

2012-09-05 Thread Koduri Lakshmi
Hi,

Thank you verymuch for the quick help.

I forgot to mention in the previous post that I made video as background by 
making GL_DEPTH_BUFFER_BIT. That is I used  
_viewer-getCamera()-setClearMask(GL_DEPTH_BUFFER_BIT ).


I have a look at the code of osgAnroidExample. But I am not able to find any 
specific info about camera settings in any of the C++ files.

If I assign the transformation matrix which I got from the 3rd Party AR library 
then model is not appearing on the screen. If not assign the transformation 
matrix then the model is appeared on the screen.

AR library is giving a projection matrix. I used 
_viewer-getCamera()-setProjectionMatrix(osg::Matrix(projectionMatrix.data));.
 But even I am not able to see model on scree. 

Here I listed the full OSG code with the transformation matrix


Code:
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-addEventHandler(new 
osgGA::StateSetManipulator(_viewer-getCamera()-getOrCreateStateSet()));


_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);

_viewer-getCamera()-setViewport(0,0,screenWidth, screenHeight);
_viewer-getCamera()-setClearMask(GL_DEPTH_BUFFER_BIT );

modelSwitch=new osg::Switch;
trans=new osg::MatrixTransform();

osg::ref_ptrosg::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/test.osg);

trans-addChild(loadedModel.get());
modelSwitch-addChild(trans.get());
}

_root-addChild(modelSwitch.get());

_viewer-setSceneData(NULL);
_viewer-setSceneData(_root.get());
_manipulator-getNode();
_viewer-home();


   State state = Renderer::getInstance().begin();
  // Explicitly render the Video Background
   Renderer::getInstance().drawVideoBackground();
  
  for(int tIdx = 0; tIdx  state.getNumActiveTrackables(); tIdx++)
   {
  
//_viewer-getCamera()-setProjectionMatrix(osg::Matrix(projectionMatrix.data));
 //NotGetting even I set projection matrix
 // Get the trackable:
const Trackable* trackable = state.getActiveTrackable(tIdx);
Matrix44F modelViewMatrix = 
Tool::convertPose2GLMatrix(trackable-getPose());

osg::Matrix mat;
mat.set(osg::Matrix(modelViewMatrix.data));
trans-setMatrix(mat);

osg::Vec3f tr,scal;
osg::Quat rot,so,rot1,rot2;
mat.decompose(tr,rot,scal,so);


 _viewer-frame();

  Renderer::getInstance().end();
  break;
   }


   
I logged the Transformation matrix and here I am giving two of them


Code:
0.953237  -0.0311842  0.300609  0  
0.165658  -0.778015  -0.606012  0  
0.252777  0.627472  -0.736467  0  
16.6605  14.1914  162.78  1  

Equalent OSG scale and Tranlate vectors (x,y,z values):  1  1  1 and 16.6605   
14.1914   162.78 


0.999434  0.0286711  0.0175895  0  
0.0336364  -0.853354  -0.520246  0  
9.4044e-05  0.520543  -0.853835  0  
75.0211  38.932  197.853  1  

Equalent OSG scale and Tranlate vectors (x,y,z values):  1  1  1 and 75.0211  
38.932  197.853 



3rdParty AR library gave an example to draw a teapot. Here I am giving that 
code for the reference. 


Code:


 // Set GL11 flags:
glEnableClientState(GL_VERTEX_ARRAY);
glEnableClientState(GL_NORMAL_ARRAY);
glEnableClientState(GL_TEXTURE_COORD_ARRAY);

glEnable(GL_TEXTURE_2D);
glDisable(GL_LIGHTING);

//getting tracker code and setting video code here (as above)
...



// Load projection matrix:
glMatrixMode(GL_PROJECTION);
glLoadMatrixf(projectionMatrix.data);

// Load model 

Re: [osg-users] Error while loading OSG model on Android

2012-09-03 Thread Koduri Lakshmi
Hi Jordi Torres,

Thank you very much for the help.

As you suggested I rendered the model with out transform. Model rendered on 
screen.

I am using a 3rd party lib for AR tracking. This lib is configured video 
background. This config is for video background. 

Here is the config code


Code:
 CameraDevice cameraDevice = QCAR::CameraDevice::getInstance();
 VideoMode videoMode = cameraDevice.  
getVideoMode(QCAR::CameraDevice::MODE_DEFAULT);

VideoBackgroundConfig config;
config.mEnabled = true;  //Enables/disables rendering of the video backgroun
config.mSynchronous = true; //Enables/disables synchronization of video 
background and tracking data
/*Relative position of the video background in the render target in pixels. 
Describes the offset of the center of video background to the center of the 
screen (viewport) in pixels. (0,0) is the center of the screen*/
config.mPosition.data[0] = 0.0f;
config.mPosition.data[1] = 0.0f;
/*Width and height of the video background in pixels. */
config.mSize.data[0] = screenWidth;
config.mSize.data[1] = videoMode.mHeight
* (screenWidth / (float)videoMode.mWidth); //for 
correct aspect ratio



Renderer::getInstance().setVideoBackgroundConfig(config);



After config video background I am rendering video background with the 
following statement


Code:
Renderer::getInstance().drawVideoBackground();




Even with the transformation matrix the model is rendering correctly with out 
this statement. When I added this statement the model disappears on the screen.

I tried to set Viewport and projection matrix to the viewers camera. But still 
I not able to see the 3D model on screen.


This is the code for OSG INIT


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);

 _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);


_viewer-getCamera()-setViewport(0,0,width, height);


_viewer-getCamera()-setProjectionMatrix(osg::Matrix(projectionMatrix.data));



trans=new osg::MatrixTransform();


LOG(Load Model);
  osg::ref_ptrosg::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(); [b]If I enabled only this by commenting the following then 
the model renders correctly.[/b]


State state = Renderer::getInstance().begin();
  // Explicitly render the Video Background
Renderer::getInstance().drawVideoBackground();   //
  
  for(int tIdx = 0; tIdx  state.getNumActiveTrackables(); tIdx++)
   {
 // Get the trackable:
const Trackable* trackable = state.getActiveTrackable(tIdx);
Matrix44F modelViewMatrix = 
Tool::convertPose2GLMatrix(trackable-getPose());


 

Re: [osg-users] Error while loading OSG model on Android

2012-09-03 Thread Jordi Torres
Hi Koduri,

As I said in the previous mail, try to set the osg GL_SURFACE as
trasparent. Take a look to osgAndroid (this project was released a week ago
by Rafa Gaitán), it has a camera example.

Cheers.

2012/9/3 Koduri Lakshmi ankiredd...@gmail.com

 Hi Jordi Torres,

 Thank you very much for the help.

 As you suggested I rendered the model with out transform. Model rendered
 on screen.

 I am using a 3rd party lib for AR tracking. This lib is configured video
 background. This config is for video background.

 Here is the config code


 Code:
  CameraDevice cameraDevice = QCAR::CameraDevice::getInstance();
  VideoMode videoMode = cameraDevice.
  getVideoMode(QCAR::CameraDevice::MODE_DEFAULT);

 VideoBackgroundConfig config;
 config.mEnabled = true;  //Enables/disables rendering of the video
 backgroun
 config.mSynchronous = true; //Enables/disables synchronization of
 video background and tracking data
 /*Relative position of the video background in the render target in
 pixels. Describes the offset of the center of video background to the
 center of the screen (viewport) in pixels. (0,0) is the center of the
 screen*/
 config.mPosition.data[0] = 0.0f;
 config.mPosition.data[1] = 0.0f;
 /*Width and height of the video background in pixels. */
 config.mSize.data[0] = screenWidth;
 config.mSize.data[1] = videoMode.mHeight
 * (screenWidth / (float)videoMode.mWidth);
 //for correct aspect ratio



 Renderer::getInstance().setVideoBackgroundConfig(config);



 After config video background I am rendering video background with the
 following statement


 Code:
 Renderer::getInstance().drawVideoBackground();




 Even with the transformation matrix the model is rendering correctly with
 out this statement. When I added this statement the model disappears on the
 screen.

 I tried to set Viewport and projection matrix to the viewers camera. But
 still I not able to see the 3D model on screen.


 This is the code for OSG INIT


 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);

  _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);


 _viewer-getCamera()-setViewport(0,0,width, height);


 _viewer-getCamera()-setProjectionMatrix(osg::Matrix(projectionMatrix.data));



 trans=new osg::MatrixTransform();


 LOG(Load Model);
   osg::ref_ptrosg::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(); [b]If I enabled only this by commenting the following
 then the model renders correctly.[/b]


 State state = Renderer::getInstance().begin();
   // Explicitly render the Video Background
 Renderer::getInstance().drawVideoBackground();   //

   

Re: [osg-users] Error while loading OSG model on Android

2012-08-29 Thread Koduri Lakshmi
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_ptrosg::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
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] Error while loading OSG model on Android

2012-08-29 Thread Jordi Torres
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 ankiredd...@gmail.com

 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_ptrosg::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
 osg-users@lists.openscenegraph.org
 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
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


[osg-users] Error while loading OSG model on Android

2012-08-28 Thread Koduri Lakshmi
Hi,

I build OSGAndroid example on Ubuntu device. I loaded and displayed OSG model 
successfully on my mobile device.

Now I used the OSG lib in my project which are using some other libs. 
I made changes to Android.mk and Application.mk and compiled successfully.
But to load model I gave static path to readNodeFile as 
/mnt/sdcard/OSG/lz.osg.

When I run as Android Application I got Model not loaded message on cat log.

If I give the same static path in OSGAndroid example then it is working. 

I am using Android 2.2 and OpenGl1.1 versions.

Do i need to add any other things to my project.

Can you please help me why the model is not loading?
... 

Thank you!

Cheers,
Koduri

--
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=49621#49621




___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] Error while loading OSG model on Android

2012-08-28 Thread Jordi Torres
Hi koduri,

Make sure you have added the macro USE_OSGPLUGIN(osg) in your code, maybe
this is the problem.

Cheers
El 28/08/2012 13:44, Koduri Lakshmi ankiredd...@gmail.com escribió:

 Hi,

 I build OSGAndroid example on Ubuntu device. I loaded and displayed OSG
 model successfully on my mobile device.

 Now I used the OSG lib in my project which are using some other libs.
 I made changes to Android.mk and Application.mk and compiled successfully.
 But to load model I gave static path to readNodeFile as
 /mnt/sdcard/OSG/lz.osg.

 When I run as Android Application I got Model not loaded message on cat
 log.

 If I give the same static path in OSGAndroid example then it is working.

 I am using Android 2.2 and OpenGl1.1 versions.

 Do i need to add any other things to my project.

 Can you please help me why the model is not loading?
 ...

 Thank you!

 Cheers,
 Koduri

 --
 Read this topic online here:
 http://forum.openscenegraph.org/viewtopic.php?p=49621#49621




 ___
 osg-users mailing list
 osg-users@lists.openscenegraph.org
 http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org