Saturday, September 15, 2007

The dilemma

Looking at the WWJ source code, I feel very happy. Honestly, my work in the Balloon's project core API is not as complete as the WWJ API:
  • not use any geode to calculate lat/lon,
  • not use the concept of LevelSet,
  • and more important, I don't implement any elevation model, my world is flat :(
Take in account nothing is perfect. Currently WWJ has a big problem with rendering vector data (polygons and points) in the surface (using elevation model).

The good things
On the other hand. Balloon is a one person project, and I think my work is enough good:
  • Balloon speed is similar to WWJ, inclusive when data are loading (remotely and locally at the same time).
  • Although my core API (my SDK) is simpler than WWJ, Balloon is a desktop application not only a SDK, it has a GUI module.
  • All objects allow change its features like: color, transparency, etc, without any distinction. This is not possible in WWJ with many layers.
  • All renderable objects are, optionally, timestamped and those Balloon can animate information.
  • Recently I was finishing the pick selection process of objects, and I want to improve GUI calculating the lat/lon position of the cursor in the screen.
The sentence that resumes my spirit and is enough for me to continue working is:
I want to improve the core API for the simple reason to learn and develop more and better.

The bad things
The problem is that for one person, develop the core API and GUI is too much job, and then the dilemma comes to me:
Why spend time in the core API if there exists a good API that makes something similar and, in more areas, better? Why doesn't use WWJ as the core API in the Balloon project?

Conclusion
I think I stop my project for a while, start learning more in WWJ API and trying to implement my existent layers and animation time concepts with the WWJ.
I think the real prolem is I don't know how to focus Balloon project Create another virtual globe? Focus it as another GIS application?

Finally I am thinking Why don't make a fork of the project: one using my core API and one using the WWJ API?

Sunday, September 09, 2007

Picking objects

After some days of work I have finally added the picking mechanism to the project. Now the objects can react when mouse is moving, button is clicked, pressed or released.
It is based on picking and selection mechanism of OpenGL and doesn't affect the performance in a visible way.
I'm happy :)

Tuesday, September 04, 2007

My first hack on WWJ

It is not any amazing thing but I want to show my first hack on WWJ code. Really this is the second hack, the first is my LayerSet class that allows create set of layers.

I have modified a bit the WWJ source code (in the SurfaceTileRenderer class) to allow some layers make use of the, until now not used, property opacity.
For example you can put a BMNGSurfaceLayer but you can change its opacity, or better said, you can invoke the setOpacity method but the opacity value is never used in the render process and thus the layer never changes its opacity.

Take a look at this two screenshots. The first is a normal set of layers:


The second shows the CountryBoundariesLayer and the landsat layer with opacity changed:


Which is the secret?
You know some layers like BMNGSurfaceLayer, CountryBoundariesLayer and USGS* are based on BasicTiledImageLayer that extends the TiledImageLayer class. The later class uses the SurfaceTileRenderer to render the tiles.


In
TiledImageLayer.draw() method change:
dc.getGeographicSurfaceTileRenderer().renderTiles(dc, this.currentTiles);
by
dc.getGeographicSurfaceTileRenderer().renderTiles(dc, this.currentTiles, this);

In SurfaceTileRenderer change:
public void renderTiles(DrawContext dc, Iterable tiles) {
by
public void renderTiles(DrawContext dc, Iterable tiles, AbstractLayer layer) {

and put this code (only the later 'if):
...
if (!dc.isPickingMode()) {
gl.glTexEnvi(GL.GL_TEXTURE_ENV, GL.GL_TEXTURE_ENV_MODE, GL.GL_REPLACE);
} else {
gl.glTexEnvf(GL.GL_TEXTURE_ENV, GL.GL_TEXTURE_ENV_MODE, GL.GL_COMBINE);
gl.glTexEnvf(GL.GL_TEXTURE_ENV, GL.GL_SRC0_RGB, GL.GL_PREVIOUS);
gl.glTexEnvf(GL.GL_TEXTURE_ENV, GL.GL_COMBINE_RGB, GL.GL_REPLACE);
}

if(layer!=null){
// Set transparency
gl.glTexEnvi(GL.GL_TEXTURE_ENV, GL.GL_TEXTURE_ENV_MODE, GL.GL_MODULATE);
gl.glColor4f(1, 1, 1, (float)layer.getOpacity());
}
...

Finally, create overload the method (to not affect other calls):
public void renderTiles(DrawContext dc, Iterable tiles) {
this.renderTiles(dc, tiles, null);
}

And thats all.