Loading model with Geotransform?

classic Classic list List threaded Threaded
10 messages Options
Johnson prem Johnson prem
Reply | Threaded
Open this post in threaded view
|

Loading model with Geotransform?

Hi

I am trying to load 3ds/osg model with Geotransform as mentioned below,



osg::Node* model = osgDB::readNodeFile("./data/glider.3ds");

osg::Group*root = new osg::Group;
osg::Node* earth = mapNode->asNode();
root->addChild(earth);

const osgEarth::SpatialReference* srs = mapNode->getMapSRS();
osgEarth::GeoTransform* geo = new GeoTransform();
osg::PositionAttitudeTransform* pat = new osg::PositionAttitudeTransform();
pat->addChild(model);
geo->addChild(pat);
mapNode->addChild( geo );
AltitudeMode altMode = ALTMODE_RELATIVE;

GeoPoint pos (srs, 78.f, 17.f, 100000.f, altMode);

geo->setPosition( pos )



I dont see the model getting loaded. What went wrong?

Thanks
gaoyj gaoyj
Reply | Threaded
Open this post in threaded view
|

Re: Loading model with Geotransform?

setPosition only handle a GeoPoint with ALTMODEL_ABSOLUTE
gwaldron gwaldron
Reply | Threaded
Open this post in threaded view
|

Re: Loading model with Geotransform?

In reply to this post by Johnson prem
The osgearth_transform example shows how to use a GeoTransform. See if you that works for you.
Glenn Waldron / Pelican Mapping
Johnson prem Johnson prem
Reply | Threaded
Open this post in threaded view
|

Re: Loading model with Geotransform?

In fact I started from osgearth_transform example. Even the example doesn't work for
me. In that example I just replaced the statement,

 osg::ref_ptr<osg::Node> model = osgDB::readRefNodeFile("../data/axes.osgt.(1000).scale.osgearth_shadergen");

by

osg::ref_ptr<osg::Node> model = osgDB::readNodeFile("./data/glider.3ds");

still is not working.

gwaldron gwaldron
Reply | Threaded
Open this post in threaded view
|

Re: Loading model with Geotransform?

Maybe it's getting clipped by the near clipping plane.

Try reducing the near/far ratio in the example; the line where it calls

viewer.getCamera()->setNearFarRatio

Or, run with the --logdepth command line argument to use a logarithmic depth buffer.

Hope this helps.
Glenn Waldron / Pelican Mapping
Johnson prem Johnson prem
Reply | Threaded
Open this post in threaded view
|

Re: Loading model with Geotransform?

I tried with

LogarithmicDepthBuffer buf;
buf.install( viewer.getCamera() );
viewer.run();

my observation is, even em->setViewpoint( vp ); is not functioning to that example.
I am getting default home view point of the earth.
Johnson prem Johnson prem
Reply | Threaded
Open this post in threaded view
|

Re: Loading model with Geotransform?

I just tried by removing the camera manipulator and set geo node directly to viewer.setSceneData().
It works fine. But with EarthManipulator, it does not happen.
Johnson prem Johnson prem
Reply | Threaded
Open this post in threaded view
|

Re: Loading model with Geotransform?

terribly sorry. There was scaling problem.
I just scaled up the model size to multi folds.
I could get it.
But tethering to model is not working fine for me.
Instead, if setTherNode (to the geotransform node) is set at node callback, it is happening.
Second thing, the model is appearing complete white. Setting of GL_LIGHTING to on/off, switches
only the model color to complete white/black. But model alone rendered complete texture is coming
fine with no issues.

gwaldron gwaldron
Reply | Threaded
Open this post in threaded view
|

Re: Loading model with Geotransform?

Regarding lighting/texturing, please read:

http://docs.osgearth.org/en/latest/faq.html#i-added-a-node-but-it-has-no-texture-lighting-etc-in-osgearth-why

Or, you can append ".osgearth_shadergen" to the filename.
Glenn Waldron / Pelican Mapping
andrews andrews
Reply | Threaded
Open this post in threaded view
|

Re: Loading model with Geotransform?

Even attaching shader to the model node makes it only whiter from dark.
Texture is not visible.
I have another issue that when I tilt the earth, the model is getting clipped (hidden).
The model is visible only at particular view point.