We're creating a simple greenish blue ring that fades in on the front end and then out on the back end. We create a slightly brighter front edge and fade to cooler colors to give the appearance that the front end is hotter and that heat is bleading off over the surface of the wave. In addition to that we're adding a distortion map that will give our ring the appearance of crossing through areas of different densities.
Now we want to animate this ring-wave so in our simpleUpdate(float tpf) method let's add the following:
If you run your application now you should see a nice ring growing in size. While it looks pretty good as-is let's add some more detail to it. Back in the simpleInitApp method let's create another ring:
geom2 = new Geometry("Quad", new Quad(480, 480));
mat = new Material(assetManager, "Common/MatDefs/Circle/Circle.j3md");
mat.setColor("Color", new ColorRGBA(0f, 0f, 0f, 0f));
mat.setColor("Color2", new ColorRGBA(0.3f, 0.97f, 0.9f, 0.4f));
mat.setColor("Color3", new ColorRGBA(0.3f, 0.97f, 0.9f, 0.4f));
mat.setColor("Color4", new ColorRGBA(0f, 0f, 0f, 0f));
mat.setColor("Color5", new ColorRGBA(0f, 0f, 0f, 0f));
By and large we're using the same settings as the first ring with a few notable differences. We removed the sixth color as we don't need the long trail on the inner part of the ring here. We also modified the positions of the other colors so that this one has a slightly larger ring area.
Additionally we've added in a ColorMap and set the material to the AlphaAdditive blend mode because we want this one added on top of the first one. This is going to add a little bit of electricity to our ring-wave.
Head back to the simpleUpdate loop and add the following code just after setting the first geom pos5 property.
Go ahead and run your application. The finished product should look like the following:
In practice if you're using a ring-wave like this in your 3d scene, rather than using the guiNode you may need to place each ring slightly above the other to prevent z-fighting. Depending on how you're using this you may be able to disable depth buffer writing instead: