Thursday, June 14, 2007

Growing box like structures inside WWJ

As i was working on some aspects of SurfaceShape(s) and Polyline(s) in the WWJ SDK, i came to try out the 'filled' option for polylines - which could allow to make non textured 3D models. Here is a simple method to draw boxes on the globe.


Cut and paste this code into the AWT1Up demo application to reproduce the above example.

This is probably not the right way to build entire cities... but it can certainly help to be able to build some simple 3D structures with a handfull of filled polylines.

See this WWJ forum thread for discussion.

Friday, June 8, 2007

Adding a simple scalebar to WWJ

Here is a simple scalebar layer for WWJ. It can display metric and imperial units and behaves like the Compass layer.


Download ScalebarLayer.java (9k). Remove the .txt extension and add it to the worldwinddemo package or your own project.

See this WWJ forum thread for discussion.

Thursday, June 7, 2007

Loading WW layersets structure into WWJ

Following on my previous steps at loading World Wind existing layersets into WWJ, i moved one step further with more generic WWConfigLoader and LayerSet classes. Together they can read whole layersets hierarchy from WW XML config files and produce the appropriate objects to feed a JTree.


Download WWJ_WWConfigLoader_01.zip (50k) and follow instructions in the readme.txt.

In addition, the new LayerSet object can compute the list of 'active' layers to set the current Model LayerList each time a layer state changes in the tree.

Selection and deselection of layers in the JTree is not done yet. Some checkboxes are needed here... this is a work in progress and some part of this code may become obsolete with future release of the WWJ SDK.

See this thread in the WWJ forum for discussion.

Monday, June 4, 2007

Adding single image layers to WWJ

One thing that is missing in the actual WWJ early release 0.2 is an easy mean to apply a single image over the globe. Here is a first atempt at a renderable SurfaceImage class. The screenshot shows the Geo RSS icon pasted over part of Europe.


Download WWJ_SurfaceImage_01.zip (3k) and follow instructions in the readme.txt to reproduce the above.

One image can be applied to the whole globe too. Here is an example of the code to make a RenderableLayer with one full sphere SurfaceImage :

private RenderableLayer makeImageLayer() {
RenderableLayer layer = new RenderableLayer();
layer.setName("Night Lights SurfaceImage layer");
layer.setPickEnabled(false);
layer.addRenderable(new SurfaceImage("earthlights1k.jpg",
Sector.FULL_SPHERE));
return layer;
}


However, this version - and OGL, does only handle images with size being a power of two (16, 32, 64... 1024, 2048...). Images with other sizes will show a black padding - up to the next power of two. And only the lat/lon projection is supported.

See this WWJ forum thread for discussion.

The Earth Lights image comes from James Hastings-Trew Planetary Pixel Emporium. There are also some nice global earth maps at the original Blue Marble page.

Monday, May 28, 2007

Loading WW Pathlists into WWJ

Again a first try at loading vector pathlists from WW as WWJ polylines. The screenshot shows the Paris Dakar 2007 rally path across the western Sahara desert (icons are loaded with another layer).


Download WWJ_WWXMLPathListLayer.zip (109K) and follow instructions in the readme.txt to add the included "Lewis and Clark trail" to the BasicDemo application.

This first version doesnt work very well except for short and local pathlists. It seems that SurfacePolyline in the current WWJ 0.2 release does not handle very well large or extended sets of path. Also the lines are rendered as bitmaps drapped over the terrain with a fixed line width that is either barely visible from far away or too coarse when close.

Or maybe i should use Polyline instead of SurfacePolyline...

See this WWJ forum thread for discussion.

Saturday, May 26, 2007

Loading icon based WW add-ons in WWJ

Here is a first shot at a WW icon add-ons loader for WWJ. It creates icon layers from a WW add-on XML config file. The screenshot shows the Flags of the World, the 'classic' Landmark Catalog and the Highest Mountains add-ons.


Download WWJ_WWXMLIconLayer_01.zip (10k) and follow instructions in the readme.txt to add the included "Highest Mountains" add-on from Martin Zoepfl aka mazop, in the BasicDemo application.

This version handles icon 'rollover' and displays a short name or description as a 'tooltip' hint. If a 'clickable url' was associated with an icon, clicking on it will (should) launch your web browser to that address. And if the config file contains a 'ChildLayerSet's hierarchy it will be flatten into one linear list.

Note that you have to 'shake' the mouse cursor over an icon before its name pops up... to be continued.

See this WWJ forum thread for discussion.

Wednesday, May 23, 2007

Loading WMS image layers in WWJ

Following on my previous post about a 'WW XML layer loader', here is a second version with support for WMS layers. The screenshot shows the french "BRGM Carte Géologique de France" around the town of Nice.


Download WWJ_WWXMLLayer_02.zip (10k) and follow instructions in the readme.txt to add new layers to the BasicDemo application.

This version suffers from several issues, the main one being that layers start loading even when they are still far away. I have to figure out the number of 'empty levels'...

Thanks to sophiap and vash for their hint about a wms url builder on the WWJ forum.

Loading WW image layers in WWJ

Here is a very first shot at a WW 'layer loader' for WWJ. It can create tiled image layers from a World Wind XML layer definition. No WMS yet. The screenshot shows a portion of the USGS Topo Maps layer - some shading would help though...


Download WWJ_WWXMLLayer_01.zip (5k) and follow instructions in the readme.txt to add new layers to the BasicDemo application. The layer definition will look like that :
private BasicDemo.LayerAction[] layers = new BasicDemo.LayerAction[] {
 new BasicDemo.LayerAction(new BMNGSurfaceLayer(), true),
 new BasicDemo.LayerAction(new LandsatI3(), true),
 new BasicDemo.LayerAction(new USGSDigitalOrtho(), false),
 new BasicDemo.LayerAction(new USGSUrbanAreaOrtho(), true),
  new BasicDemo.LayerAction(new WWXMLLayer("WW_Images.xml",
   "USGS Topo Maps"), false),
  new BasicDemo.LayerAction(new WWXMLLayer("WW_Images.xml",
   "Geocover 1990"), false),
  new BasicDemo.LayerAction(new WWXMLLayer("WW_Images.xml",
   "Geocover 2000"), false),
 new BasicDemo.LayerAction(new EarthNASAPlaceNameLayer(), true),
 new BasicDemo.LayerAction(new CompassLayer(), true),
};

I'm not sure WWJ likes it too much... it works but downloading seems chaotic. Maybe the servers are slow...

Sunday, May 20, 2007

Adding Stars to World Wind Java

Here is my first attempt at a renderable layer for WWJ. It renders a star background based on a subset of ESA Hipparcos catalog of stars.


Download WWJ_Stars_01.zip (104K) and follow instructions in the readme.txt to add the layer to one of the demo application (one line of code).

In the BasicDemo, the layer list should read like that :
private BasicDemo.LayerAction[] layers = new BasicDemo.LayerAction[] {
  new BasicDemo.LayerAction(new StarsLayer(), true),
  new BasicDemo.LayerAction(new BMNGSurfaceLayer(), true),
  new BasicDemo.LayerAction(new LandsatI3(), true),
  new BasicDemo.LayerAction(new USGSDigitalOrtho(), false),
  new BasicDemo.LayerAction(new USGSUrbanAreaOrtho(), true),
  new BasicDemo.LayerAction(new EarthNASAPlaceNameLayer(), true),
  new BasicDemo.LayerAction(new CompassLayer(), true),
};

Note that it is inserted first in the layer list - so that it renders first too. The code also shows how to create a renderable layer and a renderable object to add to it. It boils down to :

public class StarsLayer extends RenderableLayer {

  // The layer
  public StarsLayer() {
    this.setName("Stars");
    this.addRenderable(new Stars());
  }

  // The renderable
  private static class Stars implements Renderable, Disposable {

    public void render(DrawContext dc) {
      GL gl = dc.getGL();
      // Draw here
    }

    public void dispose() {
      // Cleanup here
    }
  }
}

See discussion in the WWJ forum.

Most of the star background code comes from my 'old' WW plugin Stars3D and its implementation in Java for WW2DPlusOne.

Thursday, May 17, 2007

World Wind Java terrain code goodies

I've had a look at the WWJ SDK terrain source and found some very refreshing code - especially after struggling for two years with the C# version we know.

Terrain / images separation

One of the nice feature of this terrain engine is the separation between the terrain geometry and the images layers. It solves a lot of problems we have with WW.

ZBuffer and blurry islands

Each image layer in WW has its own multi-level terrain geometry that is rendered one on top of the other. But they dont have all the same level of detail, so part of one layer would pop out of an other layer... and the depth buffer (ZBuffer) had to be cleared between layers to avoid blur islands.

Then big triangles appear on the horizon when close to the ground. Other rendered objects could not trust the ZBuffer. Things where overlapping in some situations... a lot of problems really. Not long ago i was thinking of porting some of the terrain viewer shadow casting code (to make a shadow plugin), but i wouldn't have been able to apply it properly on the terrain.

In WWJ there is only one terrain geometry segmented into tiles - not necessarily square (more on that later), which are rendered multiple times with the different textures they individually intersect. Texture transforms does the trick. All images are 'painted' on one terrain model. Much cleaner. Shadows could just be easily painted over - no ZBuffer issues or blurry islands (at least inter-layers islands).

Fine terrain with low res images

Another benefit of the separation is that he terrain level of detail is not dependent on the images resolution so that even low res imagery (like BMNG) can be rendered over detailed relief.

In WW, the terrain only gets better when higher res images have loaded, even if the elevation data is available. And it doesn't get better past the best images level, even if there is better elevation data.

www.organicvectory.com
Icosahedron globe

The terrain geometry being disconnected from the images, it can be anything - not necessarily the regular lat/lon grid that is very inefficient at the higher latitudes and awful at the poles. As a matter of fact there is an 'icosahedron tesselator' in the works in WWJ.

The icosahedron 20 faces can be recursively split to approximate a sphere with no 'polar' preference - every latitude has the same vertice density. That will make for a much more efficient model for planets - and asteroids... and clean poles too. However, the move may be challenging with the triangle tesselation introducing a lot of discontinuities (seams) into the terrain mesh. This may be a problem at some point. (Image from www.organicvectory.com)

I still have to discover most of the WWJ SDK code, but so far it is promising...