Graphics.Planet2ElevationThroughCPlugin - lordmundi/wikidoctest GitHub Wiki

Planet 2 Elevation Through C Plugin

the planet2 plugin has a few ways to convert information about layers defined in it. For example, if you want to see how to get the altitiude or lat/long at a certain position on the planet within a tcl script, you can see how to do it here.

If you want to get the same information from a C plugin, here is how you might do that:

#include "doug.h"
#include "dsp_planet2.h"

static DSP_PLANET2  *dsp_planet2 = 0;

void
UpdateScene()
{
    static int first_pass = 1;
    double xpos, ypos, zpos, lat, lon, alt, radius;

    if( first_pass )
    {
        dsp_planet2 = (DSP_PLANET2*)DSF_GetDataFromProcess( "DSP_PLANET2" );
        first_pass = 0;
    }

    /* THIS POINTER IS NOT NULL IF THE DSP_PLANET2 PLUGIN IS INSTALLED */
    if( dsp_planet2 )
    {
        /* GIVEN AN XYZ LOCATION IN THE PLANET FRAME, THIS WILL RETURN THE LAT,LON,ALT INFORMATION */
        dsp_planet2->XYZ_to_LatLonAltitude( "EARTH", "ground", xpos, ypos, zpos, &lat, &lon, &alt );

        /* GIVEN AN LAT/LON THIS WILL RETURN THE DISTANCE FROM THE PLANET CENTER TO THE SPECIFIED LAT/LON */
        radius = dsp_planet2->LatLon_to_Radius( "EARTH", "ground", lat, lon );

        /* GIVEN A LAT/LON/ALT THIS WILL RETURN THE XYZ LOCATION IN THE PLANET FRAME */
        dsp_planet2->LatLonAltitude_to_XYZ( "EARTH", "ground", lat, lon, alt, &xpos, &ypos, &zpos );
    }

    DSF_ExecuteCore();
}

DSP_InitializePlugin( DSS_PLUGIN *pplug )
{
    DSF_InstallPluginFunction( pplug->handle, UpdateScene, DSD_PLUGIN_UPDATE_SCENE );
}