Thursday, October 25, 2007

A couple tricks to speed up WWJ

There are many applications where you only need the globe without elevation details - think satellite tracking or global imagery viewing, and others where you are ready to give up a bit of relief geometry details for a faster interaction.

If that is the case, there are two ways you can help yourself.

Using a full sphere SurfaceImage

One feature that has been incorporated a few month ago allows you to use a single image and paint it over the globe inside a sector or over the full sphere. This allows you to trade the BMNG tiled image layer for a single image BMNG layer - that is also included in the worldwind.jar, which results in a faster startup time and 'lighter' globe to interact with.
// From examples.applet.WWJApplet
// Add a BMNG base layer to the model layer
// list, before the Blue Marble
insertBeforeLayerName(this.wwd,
        new BMNGOneImage(), "Blue Marble");

Of course, if you zoom onto that layer, you will not get better details as with the tiled version... unless you also have it on top. The wwj applet example uses that one-image layer.

Hacking the tesselator

If you have a look at the actual default configuration EllipsoidRectangularTessellator in globe, you will notice right at the start a static constant named DEFAULT_DENSITY with the value 24. This class is responsible for building the terrain geometry using regular lat/lon aligned (rectangular) tiles each segmented like a check board in rows and columns. With the default density, there are 24 rows and columns per tiles.
// From EllipsoidRectangularTessellator
private static final int DEFAULT_DENSITY = 3; // 24;

The density determines how fine - and accurate, the terrain relief will look. However, you would be surprised to see that with a density value as low as 3 the terrain still displays very decent mountains and relief... and WWJ gets much more responsive.

Update march 22, 2008: After further scrutiny, it appears i was wrong about what i though the density value would control. When decreasing this value, it does indeed reduce the number of rows and columns per tile, but then the tiles are smaller - and there are more of them, which results in many more 'skirts' or tile sides to render, and doesn't change the geometry level of detail...

What does matter is another value named DEFAULT_LOG10_RESOLUTION_TARGET and located in the upper portion (but not the beginning) of the globe.RectangularTesselator.

// From globes.RectangularTesselator.java
private static final double 
      DEFAULT_LOG10_RESOLUTION_TARGET = 1.3;


This one will indeed control the mesh 'density' - see screenshot below.

Log10 resolution: 1.0 (left), default 1.3 (center) and 2.0 (right)

There is no public interface yet to access and change the tessellator density (or log10 resolution) setting(s) - i'll push for one to be implemented at some point. So all you can do for now is either edit the SDK source or clone the tessellator in your own package, change the setting and refer to it in the WWJ config file worldwind.properties.

6 comments:

Anonymous said...

énorme ce logiciel. on peut le télécharger stp?

Patrick Murris said...
This comment has been removed by the author.
Patrick Murris said...

NASA WorldWind Java SDK.

Patrick Murris said...

Sorry bad html like. Here it is : NASA WorldWind Java SDK
http://worldwind.arc.nasa.gov/java/index.html

Patrick Murris said...

The WWJ SDK is not an application you can download, install and run right away. It is a toolkit for developers who want to add geospatial 3d capabilities to their application.

If you are only interested in trying it, you can lauch a WWJ online demo using Java Web Start. Although the demo only show the basic features and wont give you access to WMS layers, stereo anaglyphs or the terrain profile tool.

Note that you must have at least java 1.5_07 installed and up to date video drivers to run WWJ.

Patrick Murris said...

WorlWind Java peut fonctionner sur toutes plateformes supportant Java (Mac, Linux, Windows et possiblement de futurs mobiles), peut être inclus dans une page web sous forme d'applet et enfin peut être lancer directement sans installation avec Java Web Start.

D'autre part cette technologie est gratuite pour qui veut l'utiliser dans son application et les développeurs peuvent accéder aux sources et les modifier.

Ça fait quelques plus par rapport à GE il me semble ;)