TerraExplorer Desktop's rich API allows you to easily develop powerful, customized 3D desktop applications in several programming languages, including C#, JavaScript and C++. This article contains a step-by-step guide to application development with C++.
Download code sample (built with Visual Studio 2019) >
Full TerraExplorer Programmer's Guide >
- Download and install TerraExplorer.
- Create a new Win32 Console Application project in Visual Studio, using Visual C++:
- In Visual Studio, click Create a new project.
- Select a C++ Console Application.
- Name the project 'TerraExplorerShowcaseCPP'.
- Click OK and then click Create.
- Add the "#import" directive after the include statement to link your project to the TerraExplorer COM interface. It is used to incorporate TerraExplorer interfaces in your application. Make sure the name of the file in this command points to the TerraExplorer executable on your computer.
#import "C:\Program Files\Skyline\TerraExplorer Pro\TerraExplorerX.dll" no_namespace, named_guids, no_namespace rename("GetObject","GetTEObject")
- Initialize COM infrastructure inside your main method.
CoInitialize(NULL);
{
// Work with TerraExplorer here, using SGWorld class
}
CoUninitialize(); - Create the SGWorld CoClass.
Note: You must create a SGWorld74 CoClass before working with the interfaces. The constant CLSID_SGWorld74 is automatically defined by the "#import" command.ISGWorld74Ptr pISGWorld;
pISGWorld.CreateInstance(CLSID_SGWorld74); - Call the methods on the interface pointer.
pISGWorld->Project->Open("https://www.skylineglobe.com/SkylineGlobeLayers/SG_ExternalFlys/skylineglobe7.fly",FALSE,"","");
IPosition74Ptr pIPosition74 = pISGWorld->Creator->CreatePosition(-81.374173,28.537068,616.158537,AltitudeTypeCode::ATC_TERRAIN_RELATIVE, 312.967450,313.936515,0.0,0.0);
pISGWorld->Navigate->FlyTo(_variant_t((IDispatch*)pIPosition74),ActionCode::AC_FLYTO); - Build and run the application.
- Full code for the example.
#import "C:\Program Files\Skyline\TerraExplorer Pro\TerraExplorerX.dll" no_namespace, named_guids, no_namespace rename("GetObject","GetTEObject")
int main()
{
//std::cout << "Hello World!\n";
CoInitialize(NULL);
{
try
{
// Work with TerraExplorer here, using SGWorld class
ISGWorld74Ptr pISGWorld;
pISGWorld.CreateInstance(CLSID_SGWorld71);
pISGWorld->Project->Open("https://skylineglobe.com/sg/projects/JS_to_site_71.2896277", false, "", "");
IPosition74Ptr pIPosition74 = pISGWorld->Creator->CreatePosition(-81.374173, 28.537068, 616.158537, AltitudeTypeCode::ATC_TERRAIN_RELATIVE, 312.967450, 313.936515, 0.0, 0.0);
pISGWorld->Navigate->FlyTo(_variant_t((IDispatch*)pIPosition71), ActionCode::AC_FLYTO);
}
catch (_com_error& e)
{
// Crack _com_error
_bstr_t bstrDescription(e.Description());
}
}
CoUninitialize();
}