osgEarth integration into Delta3d.

classic Classic list List threaded Threaded
4 messages Options
energonQuest energonQuest
Reply | Threaded
Open this post in threaded view
|

osgEarth integration into Delta3d.

I am integrating osgEarth with delta3d.  The osgearth_toc example works perfectly in osg, when I integrate the code from the example into delta3d I am having issues with the coordinate systems being screwed.  

The call to getCoordinateFrame(point) returns the wrong vector in EarthManipulator::getRotation(point).  Any ideas before I start tearing through delta3d, I have had this problem in the past where delta3d is doing things to make life easier for the average user but really mess people up trying to use many of osg's cooler features.

any help would be greatly appreciated.
jasonbeverage jasonbeverage
Reply | Threaded
Open this post in threaded view
|

Re: osgEarth integration into Delta3d.

Hi,

Great to hear your integrating osgEarth into Delta3D, very cool!

One guess would be that if you're adding the osgEarth node AFTER the
initial call to viewer->setSceneData make sure to call
viewer->computeActiveCoordinateSystemNodePath() after you add the
osgEarth node.  This updates the coordinate system node path in OSG so
getCoordinateFrame should work correctly.

Keep us posted on how things are going!

Thanks,

Jason



On Thu, Jul 8, 2010 at 5:38 PM, energonQuest [via osgEarth]
<[hidden email]> wrote:

> I am integrating osgEarth with delta3d.  The osgearth_toc example works
> perfectly in osg, when I integrate the code from the example into delta3d I
> am having issues with the coordinate systems being screwed.
>
> The call to getCoordinateFrame(point) returns the wrong vector in
> EarthManipulator::getRotation(point).  Any ideas before I start tearing
> through delta3d, I have had this problem in the past where delta3d is doing
> things to make life easier for the average user but really mess people up
> trying to use many of osg's cooler features.
>
> any help would be greatly appreciated.
>
> ________________________________
> View message @
> http://forum.osgearth.org/osgEarth-integration-into-Delta3d-tp5272060p5272060.html
> To start a new topic under osgEarth, email
> [hidden email]
> To unsubscribe from osgEarth, click here.
>
energonQuest energonQuest
Reply | Threaded
Open this post in threaded view
|

Re: osgEarth integration into Delta3d.

aaaawesome...that did the trick.  I would like to make a plugin for delta3d, but I am on the beginning stages of just getting it up and running.  I will keep you posted on my progress on this thread.

so far, building with delta3d2.4 and osgEarth1.3 with VC9, (i like lists for some reason)
-I started with a delta3d console application that i created using the console app wizard that comes with delta3d2.4.
-In the application class i have a ref_ptr to a MapNode.
-In the application class config function is where i cut and paste a lot of the code from the toc example.
-and now i have just an arcGIS image layer that is using the earth manipulator.

the only gotcha that i ran into is listed below:

-couldn't find a Proj.dll that worked with the distro, so i had to install FWTools and use the Proj.dll in that install.

i could post the code if you would like.

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

Re: osgEarth integration into Delta3d.

i'm just going to post the code...please don't judge my coding skills by this prototype...not that they would get any better if it was not...  ;)  enjoy...

[code]
[file Delta3dEarthTest.h]
#ifndef DELTA_Delta3dEarthTest
#define DELTA_Delta3dEarthTest

// Delta3dEarthTest.cpp : declares the interface of the application

#include <dtABC/application.h>
#include <osgEarth/MapNode>

class Delta3dEarthTest : public dtABC::Application
{
public:
    Delta3dEarthTest(const std::string& configFilename = "config.xml");

    virtual void Config();

    virtual bool KeyPressed(const dtCore::Keyboard* keyboard, int kc);

    virtual void PreFrame(const double deltaFrameTime);
    virtual void PostFrame(const double deltaFrameTime);

protected:
    virtual ~Delta3dEarthTest();

private:
    void Init();
    //place member variables here
    osg::ref_ptr<osgEarth::MapNode> mMapNode;
};

#endif // DELTA_Delta3dEarthTest

[\file Delta3dEarthTest.h]
[file Delta3dEarthTest.cpp]
// Delta3dEarthTest.cpp : defines the implementation of the application

#include "Delta3dEarthTest.h"
#include <dtCore/deltawin.h>
#include <dtCore/scene.h>
#include <osgDB/FileUtils>
#include <osgEarth/Export>
#include <osgEarth/Registry>
#include <osgEarth/TileSource>
#include <osgEarthUtil/EarthManipulator>
#include <osgEarthUtil/FadeLayerNode>
#include <osgGA/StateSetManipulator>
#include <osgViewer/Viewer>

using namespace dtCore;
using namespace dtABC;
using namespace osg;
using namespace osgEarth;
using namespace osgEarthUtil;

struct BlankTileSource : public osgEarth::TileSource
{
    BlankTileSource(const PluginOptions* options =0L) : osgEarth::TileSource( options ) { }

        virtual void initialize( const std::string& referenceURI, const Profile* overrideProfile =0)
        {
                if (overrideProfile)
                {
                        setProfile( overrideProfile );
                }
                else
                {
                        setProfile( osgEarth::Registry::instance()->getGlobalGeodeticProfile() );
                }
        }


    virtual osg::Image* createImage( const TileKey* key, ProgressCallback* progress ) {
        osg::Image* image = new osg::Image();
        image->setAllocationMode( osg::Image::USE_NEW_DELETE );
        image->allocateImage( 256, 256, 1, GL_RGBA, GL_UNSIGNED_BYTE );
        for( int y=0; y<image->t(); y++ ) {
            for( int x=0; x<image->s(); x++ ) {
                *((unsigned int*)(image->data(x,y))) = 0xff00ff00;
            }
        }
        return image;
    }
};

Delta3dEarthTest::Delta3dEarthTest(const std::string& configFilename)
: Application(configFilename)
{
    Init();
    //Generating a default config file if there isn't one already
    if(!osgDB::fileExists(configFilename))
    {
        GenerateDefaultConfigFile();
    }
}

void Delta3dEarthTest::Init()
{
    mMapNode = 0;
}

Delta3dEarthTest::~Delta3dEarthTest()
{
}

void Delta3dEarthTest::Config()
{  
    GetWindow()->SetWindowTitle("Delta3dEarthTest");

    //setup scene here

    // Create a Map and set it to Geocentric to display a globe
    Map* map = new Map();

    // ArcGIS imagery:
    {
        osgEarth::Config conf;
        conf.add( "url", "http://server.arcgisonline.com/ArcGIS/rest/services/ESRI_Imagery_World_2D/MapServer" );
        MapLayer* layer = new MapLayer( "ESRI Imagery", MapLayer::TYPE_IMAGE, "arcgis", conf );
        map->addMapLayer( layer );
    }

    osg::Group* group = GetScene()->GetSceneNode();
    mMapNode = new MapNode(map);
    osg::ref_ptr<osg::Node> loadedModel = mMapNode;
    FadeLayerNode* fadeLayerNode = new FadeLayerNode( mMapNode->getMap(), mMapNode->getEngine()->getEngineProperties());
    fadeLayerNode->addChild(loadedModel.get());
    group->addChild(fadeLayerNode);
    GetView()->GetOsgViewerView()->setSceneData(group);
    GetView()->GetOsgViewerView()->computeActiveCoordinateSystemNodePath();
    GetView()->GetOsgViewerView()->setCameraManipulator( new osgEarthUtil::EarthManipulator() );
    //GetView()->GetOsgViewerView()->addEventHandler(
    //    new osgGA::StateSetManipulator(
    //    GetView()->GetOsgViewerView()->getCamera()->getOrCreateStateSet() ) ) ;

    Application::Config();
}

bool Delta3dEarthTest::KeyPressed(const dtCore::Keyboard* keyboard, int kc)
{
    bool handled(false);
    switch(kc)
    {
    case osgGA::GUIEventAdapter::KEY_Escape:
        Quit();
        handled = true;
        break;
        //make cases for other keys
    default:
        break;
    }

    return handled;
}

void Delta3dEarthTest::PreFrame(const double deltaFrameTime)
{
    //called prior to rendering of frame, do you scene updates here
}

void Delta3dEarthTest::PostFrame(const double deltaFrameTime)
{
    //called after frame has been rendering, collect information about results from scene interaction here
}

[\file Delta3dEarthTest.cpp]
[file main.cpp]
// main.cpp : defines the entry point for the console application.

#include "Delta3dEarthTest.h"
#include <dtCore/globals.h>

int main()
{
   //set data search path to parent directory and delta3d/data
   dtCore::SetDataFilePathList( "..;" + dtCore::GetDeltaDataPathList() );
       
   //Instantiate the application and look for the config file
   dtCore::RefPtr<Delta3dEarthTest> app = new Delta3dEarthTest();
       
   app->Config(); //configuring the application
   app->Run(); // running the simulation loop
   
   return 0;

}

[\file main.cpp]
[\code]