Plugin FAQ

From World Wind Wiki

(Difference between revisions)
Jump to: navigation, search
Revision as of 23:30, 22 June 2005 (edit)
80.202.208.86 (Talk)
(How do I get the location of WW's main directory)
← Previous diff
Current revision (11:35, 24 February 2018) (edit) (undo)
Bull (Talk | contribs)
m (Reverted edits by Monday (Talk); changed back to last version by Mkpl)
 
(21 intermediate revisions not shown.)
Line 1: Line 1:
==General== ==General==
-===Is it possible to run binary plugins===+===Is it possible to run binary plugins?===
In addition to loading source code plugins World Wind also probes for .dll files inside the '''Plugins''' directory that implement the plugin interface. If found they will be displayed in the [[Plugin Dialog]]. In addition to loading source code plugins World Wind also probes for .dll files inside the '''Plugins''' directory that implement the plugin interface. If found they will be displayed in the [[Plugin Dialog]].
-===Which programming languages are supported===+===Which programming languages are supported?===
Currently, '''VB.net''', '''C#''' and '''JScript.net''' in addition to pre-compiled binary plugins. Currently, '''VB.net''', '''C#''' and '''JScript.net''' in addition to pre-compiled binary plugins.
Line 11: Line 11:
==Troubleshooting== ==Troubleshooting==
-===Why doesn't World Wind unload my plugin cleanly===+===Why doesn't World Wind unload my plugin cleanly?===
It is the responsibilty of the plugin to restore World Wind to the original state when the plugin is unloaded. For example if the plugin adds menu items, the plugin must remove those menu items when unloading. It is the responsibilty of the plugin to restore World Wind to the original state when the plugin is unloaded. For example if the plugin adds menu items, the plugin must remove those menu items when unloading.
 +
 +===Why isn't my custom RenderableObject rendering where I put it?===
 +
 +In World Wind 1.4 or newer, a change was made to the rendering code to try to reduce the camera jitter caused by precision error when zoomed in close to the terrain. In your overridden Render method you need to modify the 3d device to work relative to the camera's reference center before doing any rendering, then reset it afterwards. See [http://issues.worldwind.arc.nasa.gov/confluence/display/ADD/Version+1.3.6+Plugin+Compatibility this page] for an example.
==How-to== ==How-to==
-===How do I get the location of WW's main directory===+===How do I print debug data on screen?===
 + 
 +Check [http://svn.sourceforge.net/viewvc/nasa-exp/trunk/WorldWind/WorldWindow/WorldWindow.cs?view=markup WorldWindow].RenderPositionInfo for ideas on how to draw text on screen.
 + 
 +===How do I subscribe to the event that fires when vertical exaggeration changes?===
 + 
 +Currently events aren't used in World Wind. If you are writing a layer you can instead in the Update method store the current vertical exaggeration value. Next time your update method is called (by the background worker thread) you check if it has changed.
 + 
 +===How do I access the layer list (renderable objects)?===
 + 
 + ParentApplication.WorldWindow.CurrentWorld.RenderableObjects
 + 
 +This [[RenderableObjectList]] contains a collection of [[RenderableObject]]s and RenderableObjectLists making it a tree.
 + 
 +===How do I get the location of WW's main directory?===
MainApplication.DirectoryPath MainApplication.DirectoryPath
-===How do I reference additional assemblies from my plugin===+===How do I reference additional assemblies from my plugin?===
Use the '''REFERENCES''' keyword in the [[Plugin Header]]. Use the '''REFERENCES''' keyword in the [[Plugin Header]].
-===How do I add my own property dialog for a layer===+===How do I add my own property dialog for a layer?===
Override '''OnPropertiesClick''' for example like this: Override '''OnPropertiesClick''' for example like this:
Line 40: Line 58:
} }
-===How do I remote control World Wind===+===How do I remote control World Wind?===
- ParentApplication.WorldWindow.GotoLatLonAltitude(50.94299, 6.96291, 10000)+ ParentApplication.WorldWindow.GotoLatLonAltitude(50.94299, 6.96291, 10000) for Latitude, Longitude, Altitude input
-===How do I retrieve the current position===+ ParentApplication.WorldWindow.GotoLatLon(double latitude, double longitude) for Latitude, Longitude input
 + 
 + ParentApplication.WorldWindow.GotoLatLonHeadingAltitude(double latitude, double longitude, double
 + heading, double altitude) for Latitude, Longitude, Heanding, Altitude input
 + 
 + ParentApplication.WorldWindow.GotoLatLon(double latitude, double longitude, double heading, double
 + altitude, double perpendicularViewRange, double tilt) for Latitude, Longitude, Heanding, Altitude, FOV, Tilt input
 + 
 + For URI Input first add in the class:
 + public static WorldWindUri worldWindUri;
 + ParentApplication.WorldWindow.ParentApplication.WorldWindow.Goto(WorldWindUri.Parse("worldwind://
 + goto/world=Earth&lat="+Latitude + "&lon=" + Longitude + "&alt=" + Altitude+ "&dir=" + Heading +
 + "&tilt=" + Tilt));
 + 
 +===How do I retrieve the current position?===
ParentApplication.WorldWindow.DrawArgs.WorldCamera.Latitude ParentApplication.WorldWindow.DrawArgs.WorldCamera.Latitude
ParentApplication.WorldWindow.DrawArgs.WorldCamera.Longitude ParentApplication.WorldWindow.DrawArgs.WorldCamera.Longitude
-===How do I detect what directory my plugin was loaded from===+===How do I detect what directory my plugin was loaded from?===
The Plugin base class has a property '''PluginDirectory''' that contains the path from which the plugin was loaded. This path may be used to find any additional files you may want to load. The Plugin base class has a property '''PluginDirectory''' that contains the path from which the plugin was loaded. This path may be used to find any additional files you may want to load.
Line 55: Line 87:
this.PluginDirectory this.PluginDirectory
-[[Category:Dev]]+===How to make a plugin into a dll===
-[[Category:Plugins]]+ 
 +Plugins in WorldWind can also be DLL files as well as raw *.cs code. Like the *.cs plugins, they also have to be placed under the 'Plugins' folder so that WW can find them. A DLL plugin will show up in the Plugins-->Load box.
 + 
 +* 1. In solution explorer, Right-click 'Solution WorldWind(xx Projects)' and choose Add-->New Project
 + 
 +* 2. In the 'VS installed templates' box, choose 'Class Library' and give it the name of your plugin (a class library is a dll project) and go OK.
 + 
 +* 3. Delete the created *.cs file from your new project and replace it with your plugin *.cs file if you have one.
 + 
 +* 4. Right-click your new project and choose 'Properties', it opens the project properties.
 + 
 +* 5. Click on the 'Build Events' item on the left, in the 'Post-build event command line:' box put:
 + 
 +mkdir $(SolutionDir)bin\Release\Plugins\"mypro ject"
 +copy $(TargetFileName) $(SolutionDir)\bin\Release\Plugins\"mypr oject"\
 + 
 +...replace what's in the quotes with the name of your plugin, eg: "AccessDemo" (make sure to leave out the quotes). This will place a copy of the dll (on successful build) where it needs to be relative to the Worldwind master tree for execution. Save your new project properties. You would put 'Debug' instead of 'Release' for a Debug build.
 + 
 +If you had the plugin.cs file under the 'WorldWind' project while you were developing it, and you have moved it to it's own new project, make sure that a copy didn't stay under the 'WorldWind' project...if it did, delete the duplicate copy from under the 'WorldWind' project.
 + 
 +* 6. You will have to manually add references to your new project for 'WorldWind', 'PluginSDK', 'Microsoft.DirectX', 'WorldWindow', etc. Try a build and add the references it asks for in the References tree of your new project.
 + 
 +Don't know if these instructions are flawless, but they'll get you most of the way
 + 
 + 
 +[[Category:Plugin development]]

Current revision

Contents

[edit] General

[edit] Is it possible to run binary plugins?

In addition to loading source code plugins World Wind also probes for .dll files inside the Plugins directory that implement the plugin interface. If found they will be displayed in the Plugin Dialog.

[edit] Which programming languages are supported?

Currently, VB.net, C# and JScript.net in addition to pre-compiled binary plugins.

[edit] Troubleshooting

[edit] Why doesn't World Wind unload my plugin cleanly?

It is the responsibilty of the plugin to restore World Wind to the original state when the plugin is unloaded. For example if the plugin adds menu items, the plugin must remove those menu items when unloading.

[edit] Why isn't my custom RenderableObject rendering where I put it?

In World Wind 1.4 or newer, a change was made to the rendering code to try to reduce the camera jitter caused by precision error when zoomed in close to the terrain. In your overridden Render method you need to modify the 3d device to work relative to the camera's reference center before doing any rendering, then reset it afterwards. See this page for an example.

[edit] How-to

[edit] How do I print debug data on screen?

Check WorldWindow.RenderPositionInfo for ideas on how to draw text on screen.

[edit] How do I subscribe to the event that fires when vertical exaggeration changes?

Currently events aren't used in World Wind. If you are writing a layer you can instead in the Update method store the current vertical exaggeration value. Next time your update method is called (by the background worker thread) you check if it has changed.

[edit] How do I access the layer list (renderable objects)?

ParentApplication.WorldWindow.CurrentWorld.RenderableObjects

This RenderableObjectList contains a collection of RenderableObjects and RenderableObjectLists making it a tree.

[edit] How do I get the location of WW's main directory?

MainApplication.DirectoryPath

[edit] How do I reference additional assemblies from my plugin?

Use the REFERENCES keyword in the Plugin Header.

[edit] How do I add my own property dialog for a layer?

Override OnPropertiesClick for example like this:

/// <summary>
/// Layer properties context menu item
/// </summary>
protected virtual void OnPropertiesClick(object sender, System.EventArgs e)
{
  if(m_propertyBrowser!=null)
    m_propertyBrowser.Dispose();
  m_propertyBrowser = new MyFancyPropertyDialog(this);
  m_propertyBrowser.Show();
}

[edit] How do I remote control World Wind?

ParentApplication.WorldWindow.GotoLatLonAltitude(50.94299, 6.96291, 10000) for Latitude, Longitude,  Altitude input
ParentApplication.WorldWindow.GotoLatLon(double latitude, double longitude) for Latitude, Longitude  input
ParentApplication.WorldWindow.GotoLatLonHeadingAltitude(double latitude, double longitude, double
heading, double altitude) for Latitude, Longitude, Heanding, Altitude input
ParentApplication.WorldWindow.GotoLatLon(double latitude, double longitude, double heading, double
altitude, double perpendicularViewRange, double tilt) for Latitude, Longitude, Heanding, Altitude,   FOV, Tilt input
For URI Input first add in the class:
public static WorldWindUri worldWindUri; 
ParentApplication.WorldWindow.ParentApplication.WorldWindow.Goto(WorldWindUri.Parse("worldwind://
goto/world=Earth&lat="+Latitude + "&lon=" + Longitude + "&alt=" + Altitude+ "&dir=" + Heading + 
"&tilt=" + Tilt));

[edit] How do I retrieve the current position?

ParentApplication.WorldWindow.DrawArgs.WorldCamera.Latitude
ParentApplication.WorldWindow.DrawArgs.WorldCamera.Longitude

[edit] How do I detect what directory my plugin was loaded from?

The Plugin base class has a property PluginDirectory that contains the path from which the plugin was loaded. This path may be used to find any additional files you may want to load.

this.PluginDirectory

[edit] How to make a plugin into a dll

Plugins in WorldWind can also be DLL files as well as raw *.cs code. Like the *.cs plugins, they also have to be placed under the 'Plugins' folder so that WW can find them. A DLL plugin will show up in the Plugins-->Load box.

  • 1. In solution explorer, Right-click 'Solution WorldWind(xx Projects)' and choose Add-->New Project
  • 2. In the 'VS installed templates' box, choose 'Class Library' and give it the name of your plugin (a class library is a dll project) and go OK.
  • 3. Delete the created *.cs file from your new project and replace it with your plugin *.cs file if you have one.
  • 4. Right-click your new project and choose 'Properties', it opens the project properties.
  • 5. Click on the 'Build Events' item on the left, in the 'Post-build event command line:' box put:

mkdir $(SolutionDir)bin\Release\Plugins\"mypro ject" copy $(TargetFileName) $(SolutionDir)\bin\Release\Plugins\"mypr oject"\

...replace what's in the quotes with the name of your plugin, eg: "AccessDemo" (make sure to leave out the quotes). This will place a copy of the dll (on successful build) where it needs to be relative to the Worldwind master tree for execution. Save your new project properties. You would put 'Debug' instead of 'Release' for a Debug build.

If you had the plugin.cs file under the 'WorldWind' project while you were developing it, and you have moved it to it's own new project, make sure that a copy didn't stay under the 'WorldWind' project...if it did, delete the duplicate copy from under the 'WorldWind' project.

  • 6. You will have to manually add references to your new project for 'WorldWind', 'PluginSDK', 'Microsoft.DirectX', 'WorldWindow', etc. Try a build and add the references it asks for in the References tree of your new project.

Don't know if these instructions are flawless, but they'll get you most of the way

Personal tools