views:

179

answers:

3

Hey,

I'm looking for a way to reproduce this foggy-sphere-glowing effect using Java3D.

http://bzflag.org/screenshots/bzfi0021.jpg http://bzflag.org/screenshots/bzfi0019.jpg http://bzflag.org/screenshots/bzfi0022.jpg

I'm creating a transform group with a point light source and an emissive-material-sphere, but I can't reproduce the foggyness.

Ideas?

Thanks!

============ SOLUTION (Thanks to Ricket) ===========

    try
    {
        TextureLoader myLoader = new TextureLoader( new File("./data/grad.png").toURI().toURL(), this );

        ImageComponent2D myImage = myLoader.getImage( );

        Raster raster = new Raster( );
        raster.setPosition( new Point3f( 0.0f, 0.0f, 0.0f ) );
        raster.setType( Raster.RASTER_COLOR );
        raster.setSize( 50, 50);
        raster.setImage( myImage );

        TransparencyAttributes ta =  new TransparencyAttributes( TransparencyAttributes.BLENDED, 0.0f );
        Appearance app = new Appearance();
        app.setTransparencyAttributes( ta );

        objScale.addChild( new OrientedShape3D(raster, app, OrientedShape3D.ROTATE_ABOUT_POINT, new Point3f( 0.0f, 0.0f, 0.0f )));


    }
    catch (MalformedURLException e) { throw new RuntimeException(); }
+1  A: 

The Article Understanding Lighting in the Java 3D API explains how to setup the lighting parameters. If you can't simulate the glowing effect with one sphere you could try to put a smaller brigther one into a colored transparent sphere.

stacker
A: 

You might try looking at the code. They even have a guide.

genpfault
Thanks, unfortunately, it appears they're using a totally different library and different language.
Jim
The OpenGL command sequences should be the same no matter what binding you're using.
genpfault
@genpfault Java3D doesn't use OpenGL command sequences, it's a high-level, scene-graph-based 3D library. You deal with trees of nodes.
Ricket
Sorry, you're exactly right. I had somehow assumed the OP was using a thin Java binding for OpenGL.
genpfault
+2  A: 

I'm pretty sure the "sphere" is actually a 2D sprite drawn in 3D space as a billboard, and then a matching color light also 'drawn' at its position. The fogginess is just a 2D gradient of the image.

This is just my best guess from having played the game though, I haven't looked at the source.

Ricket
Thanks! As far as I can tell, that's the correct suggestion. The Java3D object is called an OrientedShape3D - in case any one else wants the answer too.
Jim