Question

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(); }
Was it helpful?

Solution

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.

OTHER TIPS

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.

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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow