Welcome!

Java IoT Authors: Pat Romanski, Elizabeth White, Liz McMillan, Yeshim Deniz, Mehdi Daoudi

Related Topics: Java IoT

Java IoT: Article

Star Trek Technology for Java3D

Building a particle system 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.

In the Beginning
In previous articles, we've focused on creating planetary surfaces with Java3D. One challenging area of graphics programming is rendering irregular or ill-defined objects like clouds, smoke, or fireworks. William Reeves faced that challenge when Lucasfilm was asked to create a planetary creation effect called the Genesis effect for Star Trek II: Wrath of Khan. The idea was that a planet would be hit with a missile that would transform it from a barren wasteland into one full of life. Explosions and flames on a planetary scale gave birth to a new form of animation called a particle system.

Reeves' original paper (see references) describes a particle system as one defined by clouds of primitive particles or points in three dimensions. These particles change and move with time making a particle system dynamic. How a particle changes or moves is based on a controlled stochastic process giving it a natural look. How particles evolve in a particle system is called the particle life cycle.

Your morning shower is just like a particle system. Particles are born and emitted by the system. Where the particles are born and where they are headed is assigned by the particle system. Your plumbing system determines the water temperature and velocity of the droplets. Particles exist and change under the influence of external forces. The room temperature and gravity affect how the water changes temperature and where it collides with you or the tub. So where does that fancy stochastic process come into play? To make the rate of particle emission, ejection angle, velocity, or any other attribute more interesting we need to vary them in slightly unpredictable ways. Reeves described the approach of adding a randomly selected variance to the central value of an attribute:

Attribute = CentralAttibuteValue + Random() * AttributeVariance

This approach can be applied to just about any attribute of the particle or the particle system. Figure 1 provides a simple example. The particle system evolves over time by repeating a series of steps and varying the attributes along the way. The steps are:

  1. New particles are initialized and emitted using varying attributes.
  2. Particles past their life expectancy die and are removed.
  3. Surviving particles are updated based on external forces, velocity, etc.
  4. The particles are rendered.
This cycle is repeated until the particle system has no more particles or lives beyond its lifetime. That's all you need to know to get started building a particle system, so let's build one for Java3D.

Transporting to Java3D
Before we build the particle system in Java3D, let's lay out the objectives. First of all, the particle system should be easy to add to the scene graph just like any other Java3D shape. We should allow the Java3D TransformGroup to be used to position and orient the particle system. The design should allow us to use anything from pixels to Shade3D objects for our particles. The particles should be emitted from a variety of nozzle shapes and be affected by external forces like wind or gravity. These objectives should give us the flexibility to graduate from simple water fountain particle systems to tornado simulations. Before we jump straight into an F5 tornado, let's get a simple spray working.

Figure 2 is a subset of a design that satisfies our particle system objectives. It's probably easiest to describe it from the bottom up so let's start with the Particle object. This obviously represents a particle in the particle system and logically maintains its position, velocity, and acceleration. I used the word "logically" because I am fibbing a bit to make it easier to describe. A ParticleEmitter object emits particles and controls the movement of the particles as you might expect. The particle emitter delegates the initial position of particles to a GenerationShape object. During the animation cycle, ExternalInfluence objects such as Gravity affect the particles. All of these objects are independent of Java3D so they could be used in other environments as well. Now I'm going to fess up about the particle location. The location of a particle is actually maintained by the particle emitter. This is done so that the locations of all particles can be shared in one array for use in a Java3D specific Shape3D implementation of a particle system.

Do You Have a Point, Spock?
So far we have satisfied just a few of our objectives. Let's use the particle emitter to make a single Shape3D particle system. We can do this by making ParticleSystem a subclass of the Shape3D class and using a PointArray for the geometry. Luckily for us, the particle emitter has a float array of particle locations that will fit nicely into a PointArray. This geometry class is about the simplest supported by Java3D, accepting a float value for each x, y and z location of the point. The geometry needs to change as the particles move so this means that this particle system should implement the GeometryUpdater interface. If you're not familiar with how to change the geometry of a Java3D shape during runtime, refer back to my previous article ("Casting Perlin's Movie Magic in Java3D" [JDJ, Vol. 10, issue 3]) for an overview. The last piece of the design is the ParticleSystemManager that is responsible for notifying the particle systems to run through their life-cycle steps. Before we dig into the details of how it works, have a look at two of the examples included in the source code and shown in Figure 3.

The particle system is created in Listing 1. The particle emitter is created with a point generation shape having a spread angle of 45 degrees, and specific central and variance values for emission rate, initial velocity, and particle lifetime. We fade the particles by adding the FadePoint influence to the particle emitter (one of many influence objects included in the source code). This influence gradually changes the transparency of the particle as it ages. Now the particle system is created with the emitter and a green particle color. Adding the particle system to the scene graph is not shown due to space constraints, but it's added just like any other Java3D shape. Finally the particle system manager is added to the scene graph and the animation begins.

The ParticleSystemManager is a Java3D behavior that notifies all active particle systems after a specified time has elapsed. I covered behaviors and their use in animation in my previous article so refer back to it if you need a refresher. This implementation uses a combination of elapsed frames and time to create a stable animation cycle. The particle system manager starts and maintains the Reeves particle system life cycle.

More Stories By Mike Jacobs

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

Comments (10)

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.


IoT & Smart Cities Stories
The platform combines the strengths of Singtel's extensive, intelligent network capabilities with Microsoft's cloud expertise to create a unique solution that sets new standards for IoT applications," said Mr Diomedes Kastanis, Head of IoT at Singtel. "Our solution provides speed, transparency and flexibility, paving the way for a more pervasive use of IoT to accelerate enterprises' digitalisation efforts. AI-powered intelligent connectivity over Microsoft Azure will be the fastest connected pat...
There are many examples of disruption in consumer space – Uber disrupting the cab industry, Airbnb disrupting the hospitality industry and so on; but have you wondered who is disrupting support and operations? AISERA helps make businesses and customers successful by offering consumer-like user experience for support and operations. We have built the world’s first AI-driven IT / HR / Cloud / Customer Support and Operations solution.
Codete accelerates their clients growth through technological expertise and experience. Codite team works with organizations to meet the challenges that digitalization presents. Their clients include digital start-ups as well as established enterprises in the IT industry. To stay competitive in a highly innovative IT industry, strong R&D departments and bold spin-off initiatives is a must. Codete Data Science and Software Architects teams help corporate clients to stay up to date with the mod...
At CloudEXPO Silicon Valley, June 24-26, 2019, Digital Transformation (DX) is a major focus with expanded DevOpsSUMMIT and FinTechEXPO programs within the DXWorldEXPO agenda. Successful transformation requires a laser focus on being data-driven and on using all the tools available that enable transformation if they plan to survive over the long term. A total of 88% of Fortune 500 companies from a generation ago are now out of business. Only 12% still survive. Similar percentages are found throug...
Druva is the global leader in Cloud Data Protection and Management, delivering the industry's first data management-as-a-service solution that aggregates data from endpoints, servers and cloud applications and leverages the public cloud to offer a single pane of glass to enable data protection, governance and intelligence-dramatically increasing the availability and visibility of business critical information, while reducing the risk, cost and complexity of managing and protecting it. Druva's...
BMC has unmatched experience in IT management, supporting 92 of the Forbes Global 100, and earning recognition as an ITSM Gartner Magic Quadrant Leader for five years running. Our solutions offer speed, agility, and efficiency to tackle business challenges in the areas of service management, automation, operations, and the mainframe.
The Jevons Paradox suggests that when technological advances increase efficiency of a resource, it results in an overall increase in consumption. Writing on the increased use of coal as a result of technological improvements, 19th-century economist William Stanley Jevons found that these improvements led to the development of new ways to utilize coal. In his session at 19th Cloud Expo, Mark Thiele, Chief Strategy Officer for Apcera, compared the Jevons Paradox to modern-day enterprise IT, examin...
With 10 simultaneous tracks, keynotes, general sessions and targeted breakout classes, @CloudEXPO and DXWorldEXPO are two of the most important technology events of the year. Since its launch over eight years ago, @CloudEXPO and DXWorldEXPO have presented a rock star faculty as well as showcased hundreds of sponsors and exhibitors! In this blog post, we provide 7 tips on how, as part of our world-class faculty, you can deliver one of the most popular sessions at our events. But before reading...
DSR is a supplier of project management, consultancy services and IT solutions that increase effectiveness of a company's operations in the production sector. The company combines in-depth knowledge of international companies with expert knowledge utilising IT tools that support manufacturing and distribution processes. DSR ensures optimization and integration of internal processes which is necessary for companies to grow rapidly. The rapid growth is possible thanks, to specialized services an...
At CloudEXPO Silicon Valley, June 24-26, 2019, Digital Transformation (DX) is a major focus with expanded DevOpsSUMMIT and FinTechEXPO programs within the DXWorldEXPO agenda. Successful transformation requires a laser focus on being data-driven and on using all the tools available that enable transformation if they plan to survive over the long term. A total of 88% of Fortune 500 companies from a generation ago are now out of business. Only 12% still survive. Similar percentages are found throug...