Contemporary Games Can Take Up To Three Years To Develop

Game Developer on Ulitzer

Subscribe to Game Developer on Ulitzer: eMailAlertsEmail Alerts newslettersWeekly Newsletters
Get Game Developer on Ulitzer: homepageHomepage mobileMobile rssRSS facebookFacebook twitterTwitter linkedinLinkedIn


Game Developer Authors: Shelly Palmer, William Schmarzo, Steve Mordue, Qamar Qrsh, David Balaban

Related Topics: Game Developer

Game Developer: Article

Star Trek Technology for Java3D

Building a particle system for Java3D

Quaternions are put to work in the ColorCubeParticleSystemExample example. This example uses the Java3D ColorCube utility class for the rotating particles and includes the Gravity and BounceShape influences. When running the example, note how the spinning is affected by the collision with the ground. There is a bit of physics at work in the BounceShape influence to calculate the torque of the impact and the resulting spin. You can see that the influences provide an extension point to begin adding physical simulation aspects to the particle system. You can add your own Java3D shape as a particle by creating a factory and assigning it to the particle system as shown in Listing 2.

How about simulating some weather? Clouds as particles would be a powerful tool for steam, smoke, and even a tornado. However, You might be thinking, "But a cloud would take thousands of particles!" All it takes is one particle with just the right shape, an implicit shape to be precise.

Implicit Surfaces
Java3D excels at rendering objects with distinct geometries. How can we render difficult to describe electron density fields, flames or clouds? Complex organic or other vaguely defined objects can be rendered with an approach called implicit surface modeling. This approach is known by several names in the literature including blobby molecules, metaballs, and soft objects. We'll use the term implicit surface because the shape of the object is implicitly determined by a function such as a sphere or ellipsoid. The implicit function is combined with other attributes to create the resulting object. For example, a spherical function can implicitly determine the shape of a cloud without making the cloud look like a ball. Vaguely defined objects like clouds cannot be defined with triangles, but with a visual trick called a billboard as shown in Figure 8.

A billboard is a geometrically flat image whose orien-tation is aligned with the view. You might know bill-boards better as sprites from older computer games. Games like Doom used eight different views for each monster, showing the appropriate image on the billboard based on the direction the monster was heading and the direction the player was facing. You never saw the edge of the image because the billboard was always oriented along a vertical axis to face the player. Java3D includes support for billboards with the Oriented-Shape3D class.

OrientedShape3D goes beyond the Doom-style sprites to include any geometry with orientation about either an axis or a point. You might consider using an axis-oriented OrientedShape3D object if the user cannot move above the object and look down on it. Doing so would spoil the illusion since they would be able to see the image on edge. For this article, we'll use point-oriented OrientedShape3D objects so that they face the user regardless of the view position. We will use a flat geometry, but through the use of textures, transparency, and vertex normals, we'll be able to give the oriented shapes the feeling of depth.

Our overall strategy to implement implicit surfaces is to combine the material color and transparency with an alpha-enabled texture on an OrientedShape3D object as shown in Figure 9. The implicit surface is a sphere and our flat geometry slice of the sphere is a circle. The first texture is fully opaque within the sphere and fully transparent outside of the sphere. The ambient material color is combined with the MODULATE texture mode and vertex normals to create the fake sphere. While the geometry of the implicit surface is a flat QuadArray, the vertex normals are based on the implicit sphere. You can see from the rendered object that Java3D lights the flat geometry as though it is a real sphere. While this may not be a practical use of implicit surfaces, it does demonstrate the effectiveness of the approach. By varying the texture transparency based on the distance from the center of the sphere, we can create a fuzzy ball as shown in the second example. The final example uses the same varying transparency with Perlin noise-based turbulence texture to create a cloud.

The source code includes the ImplicitSurface, Fake-Sphere, FuzzyBall and CloudPuff classes to implement the examples in Figure 9. The ImplicitSurface class extends OrientedShape3D to support the others. The CloudPuff class can be used to implement volumetric fog without our particle system. Because these are all Java3D shapes, they can be used as particles in our shape particle system to create awesome special effects.

Implicit Surface Particles
Implicit surface particles depend heavily on transparency and rendering these objects takes additional care. Java3D logically renders our scene back to front based on the position of the view. This means that visible distant objects are rendered first and the closest objects are rendered last. This depth sorting ensures that the closer objects properly obscure the more distant objects. Ordinarily Java3D draws all of the opaque objects back to front, followed by the transparent objects. The transparent objects are not depth sorted and look incorrect when we use our transparent particles. Java3D depth sorts transparent objects if we call the following method on the view object:

setTransparencySortingPolicy(View.TRANSPARENCY_SORT_GEOMETRY)

Using this sorting policy correctly sorts transparent objects back to front. Now we can use our implicit surface particles to create more advanced examples.

Use Enough Dynamite There, Butch?
The source code included with this article includes several destructive examples worth mentioning. The tornado in Figure 5 was accomplished with the combination of three particle systems. The TornadoExample includes a particle system for the swirling clouds, the twisting funnel, and the resulting debris. Additional destruction is possible with fire as shown in Figure 10.

The FlamesExample combines the use of ridged fractal noise and light-emitting particles to create a real-time fire. The implicit surface particles are textured with a variety of Perlin noise to create the flame. The particle system shoots the particles straight up while shrinking the particles and making them more transparent as they age. Invisible Phantom particles are used to move and dynamically attenuate point lights to make the fire appear to flicker. The BlackHoleExample sucks asteroids into a black abyss by using the Attract influence. And finally, everything we have done is demonstrated in the explosive finale shown in Figure 11.

The ExplosionExample combines most of the features of our particle system into one example. The example begins with a lit stick of dynamite next to large boulder. The fuse burns as a motion blurred point particle system. When the fuse is gone, the boulder explodes with dust, spinning rocks, fire, smoke and lights combined to complete the effect.

Acknowledgments
I would like to thank Ben Moxon and Brad Myers for reviewing this article. Star Trek is a registered trademark of Paramount Pictures. Doom is a registered trademark of id Software.

References

  • Ebert, D.S.; Kenton Musgrave, F.; Peachey, D.; Perlin, K.; and Worley, S. (2003). Texturing & Modeling: A Procedural Approach. Morgan Kaufmann Publishers.
  • Bobick, N. "Rotating Objects with Quaternions." Game Developer. February 1998. Also available at www.gamasutra.com/.
  • Hecker, C. "Physics - The Next Frontier." Game Developer. October/November 1996, December 1996/January 1997, March 1997, and June 1997.
  • Jacobs, M. "Casting Perlin's Movie Magic in Java3D." JDJ, Vol. 10, issue 3.
  • Lander, J. "Better 3D: The Writing Is on the Wall." Game Developer. March 1998.
  • Lander, J. "The Ocean Spray in Your Face." Game Developer. July 1998.
  • Reeves, W.T., "Particle Systems - A Technique for Modeling a Class of Fuzzy Objects." ACM Transactions on Graphics, Vol. 2, No. 2. April 1983, Pages 91-108.
SIDEBAR

Pop Quiz Hot Shot
What is a Quaternion?
a) A resident of the planet Quatern
b) A rogue protein responsible for Bad Programmers Disease
c) A mathematical representation of the rotational position of rigid bodies
d) An elementary particle found in high energy collisions of animated characters

Answer: c. Invented by Sir William Rowan Hamilton in 1845. Quaternions are supported by Java3D, but barely documented.

More Stories By Mike Jacobs

Mike Jacobs is technology architect and Technology Fellow focused on using technology to improve health care.

Comments (10) View Comments

Share your thoughts on this story.

Add your comment
You must be signed in to add a comment. Sign-in | Register

In accordance with our Comment Policy, we encourage comments that are on topic, relevant and to-the-point. We will remove comments that include profanity, personal attacks, racial slurs, threats of violence, or other inappropriate material that violates our Terms and Conditions, and will block users who make repeated violations. We ask all readers to expect diversity of opinion and to treat one another with dignity and respect.


Most Recent Comments
mnjacobs 09/05/11 03:04:00 PM EDT

The commercial version of this particle system is now available free including the source. Visit here.

indie technologies 08/31/05 06:26:58 PM EDT

http://www.indietechnologies.com now has this Java 3D technology available as a commercial product.

indie technologies 08/06/05 07:05:33 PM EDT

This technology is being commercialized for Java 3D game developers. Visit www.indietechnologies.com for more information.

Java Developer's Journal 07/31/05 06:45:05 PM EDT

Star Trek Technology for Java3D. The Star Trek universe has inspired many technology ideas but I'm disappointed I don't have a transporter yet. One Star Trek technology that has been available for sometime is the particle system. No, this is not an exotic propulsion system for your flying car. The particle system was invented to animate the Genesis effect in Star Trek II: The Wrath of Khan. While the Genesis device was used to transform a barren planet into one full of life, we can adopt this technology for more modest effects in Java3D.

Mike Jacobs 07/11/05 09:04:30 AM EDT

If you are looking for the source it is at the following link (my previous comment had a period at the end of the link).

http://res.sys-con.com/story/jun05/99792/source.html

David Morris 07/01/05 09:25:29 AM EDT

Mike, the stated link to the source code is invalid. Could you please update this link.

Thanks, David

Mike Jacobs 06/30/05 10:13:20 AM EDT

The web editor decided to do things a bit different than the past. The first mention of the listings (Listing 1) is a link to all of the code. The link is http://res.sys-con.com/story/jun05/99792/source.html.
Mike

Michael Yankowski 06/29/05 09:57:32 PM EDT

I can't find any links to the source code.

Thanks,
Mike

Mike Jacobs 06/16/05 11:32:10 AM EDT

The source code is now current.

Mike Jacobs 06/16/05 09:20:07 AM EDT

It looks like the source for this article is slightly down level. JDJ is working on it.

Mike