ObjectPlacer: terrain is missing either a Map or CSN Node

classic Classic list List threaded Threaded
11 messages Options
DPD DPD
Reply | Threaded
Open this post in threaded view
|

ObjectPlacer: terrain is missing either a Map or CSN Node

I'm new at OSG and osgEarth.  I'm trying to add a object an image using osgEarthUtil::ObjectPlacer but the osg::CoordinateSystemNode* is invalid.

I can get the function to work correctly if I pass a MapNode::mapNode* to the ObjectPlacer constructor, but I always get a "...missing ether Map or CSN node" when I pass an
osg::CoordinateSystemNode*.

How do I pass a valid osg::CoordinateSystemNode* to ObjectPlacer?

Code snip:

...

osg::TessellationHints* hints = new osg::TessellationHints;
    hints->setDetailRatio(1.0f);

osg::Geode* geode = new osg::Geode;
    geode->addDrawable(new osg::ShapeDrawable(new osg::Box(osg::Vec3(0.0f,0.0f,0.0f),2)));
    std::string filename = osgDB::findDataFile("C:\\vpb\\Clouds\\Gfwb.jpg");
    geode->getOrCreateStateSet()->setTextureAttributeAndModes(0, new osg::Texture2D
        (osgDB::readImageFile(filename)));

    osg::CoordinateSystemNode* csn = new osg::CoordinateSystemNode;
    csn->setEllipsoidModel(new osg::EllipsoidModel());
    csn->addChild(geode);

       
   osg::Group* group = new osg::Group;
   group->addChild(csn);
   osgEarthUtil::ObjectPlacer* op = new osgEarthUtil::ObjectPlacer(csn,0,false,20);
   group->addChild(op->placeNode(mapNode,21.00,86.00,6500000));
               
jasonbeverage jasonbeverage
Reply | Threaded
Open this post in threaded view
|

Re: ObjectPlacer: terrain is missing either a Map or CSN Node

Hi,

The ObjectPlacer works on a MapNode as well as a CoordinateSystemNode, so it won't work with just a CSN.  Why do you need to just pass in a CSN and not the MapNode?

Jason

On Tue, Sep 22, 2009 at 4:05 PM, DPD (via Nabble) <[hidden email]> wrote:
I'm new at OSG and osgEarth.  I'm trying to add a object an image using osgEarthUtil::ObjectPlacer but the osg::CoordinateSystemNode* is invalid.

I can get the function to work correctly if I pass a MapNode::mapNode* to the ObjectPlacer constructor, but I always get a "...missing ether Map or CSN node" when I pass an
osg::CoordinateSystemNode*.

How do I pass a valid osg::CoordinateSystemNode* to ObjectPlacer?

Code snip:

...

osg::TessellationHints* hints = new osg::TessellationHints;
    hints->setDetailRatio(1.0f);

osg::Geode* geode = new osg::Geode;
    geode->addDrawable(new osg::ShapeDrawable(new osg::Box(osg::Vec3(0.0f,0.0f,0.0f),2)));
    std::string filename = osgDB::findDataFile("C:\\vpb\\Clouds\\Gfwb.jpg");
    geode->getOrCreateStateSet()->setTextureAttributeAndModes(0, new osg::Texture2D
        (osgDB::readImageFile(filename)));

    osg::CoordinateSystemNode* csn = new osg::CoordinateSystemNode;
    csn->setEllipsoidModel(new osg::EllipsoidModel());
    csn->addChild(geode);

       
   osg::Group* group = new osg::Group;
   group->addChild(csn);
   osgEarthUtil::ObjectPlacer* op = new osgEarthUtil::ObjectPlacer(csn,0,false,20);
   group->addChild(op->placeNode(mapNode,21.00,86.00,6500000));
               


View message @ http://n2.nabble.com/ObjectPlacer-terrain-is-missing-either-a-Map-or-CSN-Node-tp3695383p3695383.html
To start a new topic under osgEarth, email [hidden email]
To unsubscribe from osgEarth, click here.


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

Re: ObjectPlacer: terrain is missing either a Map or CSN Node

In reply to this post by DPD
Hum..My thinking was that the createPlacerMatrix function would accept a mapNod or a coordinatedSystemNode.  When I pass a mapNode, the function works,  but the result is an earth sphere positioned on top of a second earth sphere at the correct lat/lon.

What I'm attempting to achieve is to place a "marker" ( e.g. dot made from a jpeg, etc ) at a specific lat/lon on top of a georeferenced image.  I have not achieved that yet, I so put the georefrenced image on a Map and started working that angle.  Any advice?  
jasonbeverage jasonbeverage
Reply | Threaded
Open this post in threaded view
|

Re: ObjectPlacer: terrain is missing either a Map or CSN Node

It looks like you're passing in the mapNode to the the placeNode function.  you need to construct the ObjectPlacer using the mapNode, then use your geode in placeNode.

Jason

On Tue, Sep 22, 2009 at 4:43 PM, DPD (via Nabble) <[hidden email]> wrote:
Hum..My thinking was that the createPlacerMatrix function would accept a mapNod or a coordinatedSystemNode.  When I pass a mapNode, the function works,  but the result is an earth sphere positioned on top of a second earth sphere at the correct lat/lon.

What I'm attempting to achieve is to place a "marker" ( e.g. dot made from a jpeg, etc ) at a specific lat/lon on top of a georeferenced image.  I have not achieved that yet, I so put the georefrenced image on a Map and started working that angle.  Any advice?  


View message @ http://n2.nabble.com/ObjectPlacer-terrain-is-missing-either-a-Map-or-CSN-Node-tp3695383p3695598.html
To start a new topic under osgEarth, email [hidden email]
To unsubscribe from osgEarth, click here.


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

Re: ObjectPlacer: terrain is missing either a Map or CSN Node

I tried this... but it only rotates the geode northward.  Maybe I need to re-think.  I must be missing something.   The op->placeNode function is not returning NULL but I'm getting could not find map with id=1.  If I replace "geode" below with "mapMode" I get the two earths.


...
csn->addChild(geode);
osg::Group* group = new osg::Group;
group->addChild(mapNode);

osgEarthUtil::ObjectPlacer* op = new osgEarthUtil::ObjectPlacer(mapNode,0,false,20);
group->addChild(op->placeNode(geode,60.00,-86.00,6500000));
//group->addChild(op->placeNode(geode,30.00,-86.00,6500000));
...
gwaldron gwaldron
Reply | Threaded
Open this post in threaded view
|

Re: ObjectPlacer: terrain is missing either a Map or CSN Node

In general I would discourage you from adding children to the MapNode or the CSN. Keep them in a separate group. Try something like this:

    // make a top level group to hold the map and other objects:
    osg::Group* top = new osg::Group();
    viewer.setSceneData( top );
    top->addChild( mapNode );

    // make an object
    osg::Geode* geode = new osg::Geode();
    geode->addDrawable( new osg::ShapeDrawable( new osg::Sphere( osg::Vec3d(0,0,0), radius ) ) );

    // place the geode on the map:
    osgEarthUtil::ObjectPlacer placer( mapNode );
    top->addChild( placer.placeNode( geode, lat, lon, altitude ));
Glenn Waldron / Pelican Mapping
DPD DPD
Reply | Threaded
Open this post in threaded view
|

Re: ObjectPlacer: terrain is missing either a Map or CSN Node

This concept works much better.
Daniel.S Daniel.S
Reply | Threaded
Open this post in threaded view
|

Re: ObjectPlacer: terrain is missing either a Map or CSN Node

This post was updated on .
In reply to this post by gwaldron
I am having problems making this object placer working, here is my code snipet equivalent:

 osgEarth::MapNode* mapNode = new osgEarth::MapNode( map );
        osg::Group* top = new osg::Group();
        viewer.setSceneData( top );

        top->addChild( mapNode );
       
        // ObjectPlacer Test
        osg::Geode* placedNode = new osg::Geode();
    placedNode->addDrawable( new osg::ShapeDrawable( new osg::Sphere( osg::Vec3d(0,0,0), 0.01 ) ) );

        osgEarthUtil::ObjectPlacer* objectPlacer = new osgEarthUtil::ObjectPlacer( mapNode );
        top->addChild( objectPlacer->placeNode( placedNode, 0, 0, 3000 ));

I put this in the osgearth_simple project. I only see the blue screen. If I change the order of the addChilds, I either see the earth or the ball only, never both. Ill keep reading and playing around with it in the meantime. Thanks.
gwaldron gwaldron
Reply | Threaded
Open this post in threaded view
|

Re: ObjectPlacer: terrain is missing either a Map or CSN Node

Daniel,

placeNode() returns a NEW node; that return value is what you should be adding to the scene graph. See if that helps.

Glenn
Glenn Waldron / Pelican Mapping
Daniel.S Daniel.S
Reply | Threaded
Open this post in threaded view
|

Re: ObjectPlacer: terrain is missing either a Map or CSN Node

In reply to this post by Daniel.S
Ok, it was just a matter of units, duh! The sphere I was drawing was too small! Since the osgearth_simple application draws a map node using the geocentric coord system, 1 unit = 1 meter. So I was attempting to draw a 0.01m spehere and expecting to see it all the way from space :) I also put the viewer.setSceneData( top );  at the very end.
I will still want my 'objects' to be scaled in the coord system, but I also want an option to draw 'non-scaled' ones, i.e map symbology... Off to reading the code again..
gwaldron gwaldron
Reply | Threaded
Open this post in threaded view
|

Re: ObjectPlacer: terrain is missing either a Map or CSN Node

Dan,
For your "non-scaled" symbology points, you might want to look into osg::AutoTransform.

Glenn
Glenn Waldron / Pelican Mapping