[This is a pretty long response to Tria's particular problem: displaying a
rotating Earth with clickable countries linked to URLs]

Tria,

I have been following your (many) posts over the past few weeks, for the
"World - URL Navigation" applet that you're are trying to build.

I've had a little time to think about how you might tackle the problem -
though like most people on the list, I am too busy to provide in-depth
implementation help.

Best of luck!

Daniel Selman

[EMAIL PROTECTED]
http://www.tornadolabs.com


Here are my thoughts.

My first thought was that maybe Java 3D might not be the best tool for this
problem. It might be like using a sledge-hammer to crack a nut. If the
sphere for the world only rotates on one axis, you should be able to
generate 36 (or whatever) angular views of the earth using your favorite 3D
rendering software.

You can then write a purely 2D applet (i.e. lightweight and will run on
1.1). The applet will swap the images based on the users rotation inputs
(using a ring-buffer to store the images).

You can then use Java Image Map support to link locations in the images to
URLs. If you need to do highlighting you can double-buffer your drawing
operations and either just draw straight into the images using 1.1 or use
the Image API if you need to get fancy. Popup ToolTips can be based either
on AWT support or Swing support depending on your preference.

The advantages of this is that you will get a small, responsive, fast applet
that runs on 1.1. The flip-side is that you will have to do a lot of asset
preparation (images and image-maps) as well as write a moderate amount of
code (actually, shouldn't be that much).

It might also be more appropriate to build a VRML2 world...? I'm not a VRML
expert (by any means!) but VRML is pretty good at linking picked objects to
URLs. Most browsers ship with a VRML viewer.

However, this is a Java 3D list - so lets assume you decide to opt for Java
3D. Maybe your rotational requirements cannot be satisfied using
pre-computed images, or you want fine control over your scene?

1. Display the Earth Model with Texture

You can use the Sphere Primitive to model the earth. Here is some code from
the ConicWorld demo that creates a Sphere and assigns a texture to it:

// Set up the texture map
TextureLoader tex = new TextureLoader("../images/earth.jpg", this);
app.setTexture(tex.getTexture());
TextureAttributes texAttr = new TextureAttributes();
texAttr.setTextureMode(TextureAttributes.MODULATE);
app.setTextureAttributes(texAttr);

obj = (Primitive) new Sphere(1.0f,
       Sphere.GENERATE_NORMALS |
       Sphere.GENERATE_TEXTURE_COORDS,
       j*8 + 4, app);

Doubtless, you will require a more complex texture image than the one
supplied with the demo.

2. Handle user-interaction

Create your scenegraph something like this:

BG 1
  Lights
  TG 1(scale)
      TG 2 (translate?)
         BG 2
            MouseRotate (modifies TG 2)
         BG 3
            RotationInterpolator (modifies TG 2)
         Sphere

When you want to allow the user to control rotation detach BG3 from TG2 and
attach BG2 (and vice-a-versa for automatic rotation).

3. Pick hit testing on Texture image

To retrieve the clicked point on the sphere.

This is not something that I have done personally but it has come up on the
list several times. I believe that it is possible (using a sequence of
transformations to map from world coordinate system to texture image
coordinates (finally!). Check the email list archives.

You will no doubt have to make your geometry pickable and add a behavior to
watch for pick events.

4. Highlight the selected country

Presumably you need to pause rotation also? You might be able to highlight
your countries automatically if you pre-process your texture image
carefully - i.e. do the equivalent of a "flood-fill" operation. This might
be risky however. You will have to create a BufferedImage for the texture
image, modify it, and reassign the texture image. It might be easier to
create a map that maps picked 2D pixel locations to texture images and just
swap in a pre-computed image with the country highlighted. Beware of texture
image "out of memory" errors that have been mentioned on the list. Check the
archives for details.

5. Display the Popup ToolTip

This is probably best handled using a Raster object (or Text2D). You can
reposition/show/hide the Raster at runtime based on the user's picking. This
would be added under TG2 (and maybe controlled by a Switch Node).

6. Jump to URL...

I'm sure you've done this!

To finish, I guess it's fair to state the advantages of implementing it
using Java 3D:

- You can support arbitrary rotations
- You can support arbitrary geometry (i.e. you could map your images onto a
cube, a house, or whatever.
- There are far fewer images to create
- You could use any image you like, especially if you do a good job writing
the code to load the image and manage the image map / pick testing
- Could "zoom-in" on the selected country
- You could support labels for all your countries using the popup technique.
- Scales easily. If you design the system properly there would be nothing to
stop you from having several "pick URL objects" in your universe. Perhaps
jumping the user from the earth map to a detailed country map for example?

etc. etc.

Sounds like a fun project. Feel free to keep me posted - I'd like to give it
a try once you're done!

> -----Original Message-----
> From: Discussion list for Java 3D API
> [mailto:[EMAIL PROTECTED]]On Behalf Of Tria
> Sent: 28 October 1999 08:04
> To: [EMAIL PROTECTED]
> Subject: [JAVA3D] combining java2 and j3d
>
>
> I need to :
> 1. displaying popup message on the rotating sphere
> 2. draw polygon on the rotating sphere
> How can I do those things with j3d?
> Should I use swaping, stopRenderer, etc? And what is swap method actually
> do?
>
> Looking forward to your help..
>
> Regards..
> Tria
>
> ==================================================================
> =========
> To unsubscribe, send email to [EMAIL PROTECTED] and include
> in the body
> of the message "signoff JAVA3D-INTEREST".  For general help, send email to
> [EMAIL PROTECTED] and include in the body of the message "help".
>

===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff JAVA3D-INTEREST".  For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".

Reply via email to