Tuesday, October 2, 2007

Real time terrain cross section in WWJ

What does Antarctica looks like if you slice it in two?

Here is a fun visualization tool prototype layer for WWJ. It displays a real time terrain profile in a screen corner. The section plane itself will either follow the view position or the mouse cursor, allowing you to 'scan' entire continents, oceans and mountain ranges at any scale in a single hand gesture.


Download TerrainProfileLayer.java (updated oct. 30) and add it to worldwind.layers.earth, after removing the .txt extension. In BasicDemo, add the layer before or after the compass. Important: this layer implements a PositionListener and needs to have its event source set before it will operate:
new BasicDemo.LayerAction(new TerrainProfileLayer(), true),
new BasicDemo.LayerAction(new CompassLayer(), true)
...
for (BasicDemo.LayerAction action : layers) {
   ...
   if (action.layer instanceof TerrainProfileLayer)
      ((TerrainProfileLayer)action.layer).setEventSource(this.wwd);
}



You can set the profile graph to maintain the distance/elevation proportion to have exact slopes (not the case in the above screenshot though), but it is a lot less fun for wide range sections.

Friday, September 28, 2007

Text and messages translation in WWJ

In the WWJ SDK you may have noticed a file named MessageStrings.properties and several others named the same but with an extra two characters country code like de, ja,or zh. These are simple text files that contain all the constant character strings for one language. WWJ will use the one that has the same country code as your computer settings.


To have WWJ 'speak' your tongue, just make a copy of the default english file - the only one that contains all the messages, and name it MessageStrings_xx.properties, xx being your country code. Then translate the messages you want and delete all the others. You dont need to have all the messages translated in your file, the missing ones will fall back to english.

Note that special characters must be specified as Unicode hexadecimal numbers (eg. \u00c9 for 'É').

Here is a portion of a french property file with translated layer names. Get MessageStrings_fr.properties, and after removing the .txt extension, place it with the other MessageStrings files. Run one of the demo or example applications.

Also note that this doesnt translate the placenames...

Tuesday, September 25, 2007

3D stereo anaglyph view in WWJ

3D graphics are great, but stereo 3D is even better. Here is a quickly put together AnaglyphSceneController for WWJ. Is is to be used in place of the BasicSceneController from the SDK and will produce real time red/cyan anaglyphs whenever the view is pitched more than twenty degrees.


Download AnaglyphSceneController.java (updated sept 27) and add it to src.gov.nasa.worldwind - after removing the .txt extension. To use it, edit src.config.worldwind.properties and change the class name for the gov.nasa.worldwind.avkey.SceneControllerClassName entry:

gov.nasa.worldwind.avkey.SceneControllerClassName
                =gov.nasa.worldwind.AnaglyphSceneController


Overall it works reasonably well considering the amount of code - its quite simple. However, the stereo effect tends to shift when the view is being moved or rotated, but it eventually settles down to the proper settings when you stop moving around.


You need red and cyan glasses (with the red filter on the left eye) to view those anaglyphs. Caution, you may quickly feel sick... reduce the focusAngle to 1.5 or 1 degree if the stereo separation is too sharp.

Enjoy the world in real 3D ;)

World Wind Java forum tread.

Monday, September 24, 2007

Sky gradient and atmosphere for WWJ

Here is a preview of the SkyGradientLayer for WWJ. It works very well with the fog and stars layers, and makes for some nice screenshots. Still needs some tuning and cleanup though.


Download SkyGradientLayer.java (updated sept 27) and add it to the layers.earth package of the SDK - after removing the .txt extension.


The layer should be placed between the stars and the fog like : stars, sky gradient, fog, blue marble, I3 Landsat...

World Wind Java forum tread.

Saturday, September 22, 2007

Saving a WWJ layer tiles composite

Many have asked on the WW forum how to 'extract' a portion of a layer imagery and save it for further use with other applications. It happens that WWJ has a built in public method in TiledImageLayer that does exactly that - at least the hard part of it, the tiles retrieval and composition. All what's left to do is save the composited BufferedImage.

Here is some test code:

// Save a composite of a layer's tiles into a file
private void saveImageForSector(TiledImageLayer layer)
{
int imageSize = 1024; // Saved image max dimension
int level = 0; // level number (-1 = best)
Sector sector = new Sector(
Angle.fromDegrees(43.4), Angle.fromDegrees(44.4),
Angle.fromDegrees(6), Angle.fromDegrees(8));
java.awt.image.BufferedImage image =
layer.composeImageForSector(sector, imageSize, level);
try
{
javax.imageio.ImageIO.write(image, "png",
new java.io.File("SavedImageSector.png"));
}
catch (IOException e) {}
}

The above method needs a TiledImageLayer reference - the like of BMNGSurfaceLayer or LandsatI3. The level number must take into account the layer empty levels: if it has 10 levels with 4 empty ones then the first real level is 4, the second 5 and so on until 9. Chosing level zero will always give you the first non empty level anyway.

The composeImageForSector() method does quite a tedious work of tracking down all the tiles needed and will trigger download requests if necessary. It will then scale and paste each of them into the final image.

It works but would probably need some tuning, as you seem to quickly run out of memory when dealing with larger numbers of tiles or larger output dimensions. The final composited image quality may vary a lot too, depending on how much scaling has been applied to the original tiles... so dont expect too much ;)

Monday, September 17, 2007

Community maintained geotags in a WWJ applet

And again a new World Wind Java applet is online. GeoFlexy is a web site that lets you add community shared geographic tags and view them over a 2D Google Map or a 3D WWJ applet.

The 'spots' can be added by navigating a map and filling a form with description, address, Zip code and other informations, including one picture and a link to a web site.

Developed by turman a forum contributor, the site as of now is more an experiment than a fully operational community portal, but it is the most interesting WWJ applet usage i've seen so far.

Thursday, August 30, 2007

Italian Alps at 1m in a WWJ applet

Andrea Caporin from GIS Solution recently posted a link to a WWJ applet showing a 1m resolution image set near Bressanone in the italian Alps - just north of Venice. It is nice to see WWJ with some higher resolution imagery in such mountainous areas.


I wouldnt think this particular image set is public domain though...

WWJ forum thread...

Saturday, July 28, 2007

Picking at objects in WWJ

I recently added 'picking' support to the WorldMapLayer - so you can 'click-and-fly' to any place, and had a bit of head scratching and code reading to figure out the picking process. I thought it would be usefull to write it down, so here are my notes on picking in WWJ.


WWJ is using a 'unique color' rendering scheme - where the world is rendered with unique colors for each object, but we never get to see it. So i also thought it would be nice to have a quick look, and there it is : the frame buffer at the end of the pick process on terrain.


And here we see picking at the globe in the AWT1Up demo. The rectangle at top left is the world map selection area.

Note that only the terrain geometry sector under the mouse cursor is rendered with unique colors for each of its faces.

The above images have been processed to bring out the uniqueness of the colors. The real frame buffer is less explicit, with continuous shades of blue most of the time.

To see it for yourself, in BasicSceneController, comment out the last two steps of the doRepaint() method - clearFrame and draw, run, take a screenshot, convert it to 256 indexed colors with an adaptive palette, then change the palette to Mac or Windows system.

The world map layer with pick support is to come with the next release of the SDK. Some major refactoring have taken place and posting the code here would probably be confusing with the current version. Sorry for the delay.

Sunday, July 22, 2007

Adding a touch of fog to WWJ

Here is a simple fog effect layer for WWJ. It will adjust the fog near and far distance according to the current view altitude. The screenshot shows the Segara Anak caldera and Mount Rinjani (3726m), Indonesia, looking east.


Download FogLayer.java and add it to the worldwinddemo package - after removing the .txt extension. In BasicDemo, insert the layer just before the blue marble, and after the stars and the sky if you have them.

The default fog settings also produces a light atmospheric 'inside' halo around the planet.

Wednesday, July 4, 2007

Adding a blue sky background to WWJ

Here is a very simple sky background color layer for WWJ. It paints a blue background when the 'camera' goes inside the atmosphere, with a smooth fading effect between the stars and the sky.


Download SkyColorLayer.java and add it to the layers.Earth package of the SDK - after removing the .txt extension. In the layer list, add the new layer before blue marble and after the stars if you have them.

This layer along with better versions of the stars, scalebar and worldmap will be included in the next version 0.3 of the SDK - that should be out very soon. Hopefully, i will come up with a more sophisticated sky/atmosphere before long - update sept 27: see the SkyGradientLayer.