Derived particle cluster types 108

Một phần của tài liệu Design and architecture of a portable and extensible multiplayer 3d game engine thesis (Trang 115 - 118)

PART II: Design and Architecture of Parsec

12.6 Derived particle cluster types 108

As already noted, basic particle clusters are never used directly without adding additional fields via inheritance.

These derived structures contain the information needed for different cluster animation types and are shown in figure 12.9.

struct linear_pcluster_s : pcluster_s;

struct particleobj_pcluster_s : pcluster_s;

struct sphereobj_pcluster_s : particleobj_pcluster_s;

struct objectbase_pcluster_s : pcluster_s;

struct basesphere_pcluster_s : objectbase_pcluster_s;

struct genobject_pcluster_s : objectbase_pcluster_s;

struct lightning_pcluster_s : objectbase_pcluster_s;

struct photon_sphere_pcluster_s : objectbase_pcluster_s;

struct callback_pcluster_s : pcluster_s;

struct customdraw_pcluster_s : pcluster_s;

Figure 12.9: Derived particle cluster structures

For adding a new particle effect that does not fit into the framework provided by any of these cluster types, creating a new cluster type via derivation is easy.

We are now going to describe each of the already defined cluster types in more detail.

linear_pcluster_s: Particle cluster containing linearly animated particles

All contained particles are animated along a linear trajectory, i.e., a line through three-space, moving at a specified constant speed. The only information needed for this kind of animation is a direction vector and a scalar speed value. Actually, the speed is not stored separately, but already multiplied into the direction vector.

The Particle System 109 This cluster type is used to implement the constant velocity animation type described above.

particleobj_pcluster_s: Particle cluster containing position-relative particles

This cluster type is the base class for all clusters that need information about a fixed point in space as a point of reference. At this time, this is only the cluster type for particle sphere objects (sphereobj_pcluster_s), see immediately below. It is never used directly, i.e., it is only used for further deriving new cluster types.

sphereobj_pcluster_s: Particle cluster comprising a sphere at a specific position

The contained particles comprise a sphere located at a fixed position in three-space.

This cluster type is used to implement the particle sphere object animation type described above. It is able to perform all the different sphere animation types (rotating, exploding, pulsating, contracting, stochastic), also described above.

objectbase_pcluster_s: Particle cluster containing GenObject-relative particles

This cluster type is the base class for all clusters that can be attached to a geometric object. Particle clusters attached to an object will be transformed along with that object. Since an arbitrary number of clusters may be attached, this cluster type also contains a field needed for inserting it into a linear list. It is never used directly, i.e., it is only used for further deriving new cluster types.

The cluster types derived from this type at the moment are basesphere_pcluster_s, genobject_pcluster_s,lightning_pcluster_s, andphoton_sphere_pcluster_s.

basesphere_pcluster_s: Particle cluster comprising a sphere around a GenObject

The contained particles comprise a sphere that is centered about a certain geometric object. Like all cluster types derived fromobjectbase_pcluster_sit will be transformed along with that object.

This cluster type is used to implement the object-centered sphere animation type described above. It is able to perform all the different sphere animation types (rotating, exploding, pulsating, contracting, stochastic), also described above.

genobject_pcluster_s: Particle cluster for particles that are part of an object's geometry

The position of particles contained in clusters of this type is usually not animated at all. Such particles are used to augment the geometry of an object at specific positions. This is used for blinking position lights of spacecraft and thrust particles, for instance. That is, they usually employ only appearance animation to achieve the desired effect.

In order for particles of this kind to stick to the corresponding object geometry it is especially important that they are transformed along with it, like with all cluster types derived fromobjectbase_pcluster_s.

The Particle System 110 Figure 12.10 shows the rear of a spacecraft, the Stingray, which has flashing white particles attached to it. These particles depict the ship’s propulsion drive and are part of its geometry.

Figure 12.10: Particles being part of an object’s geometry

lightning_pcluster_s: Particle cluster of lightning particles

This is a very specific cluster type only used to contain the particles of the bolts of lightning, needed for the lightning cannon. These bolts are transformed along with the spacecraft they are attached to.

Thus, this cluster type is used to implement the lightning cannon animation type described above.

photon_sphere_pcluster_s: Particle cluster containing GenObject-relative photon particles

This is a very specific cluster type only used to contain the particles for the photon cannon.

Thus, this cluster type is used to implement the photon cannon animation type described above.

callback_pcluster_s: Particle cluster with generic callback function for animation

The particle system itself does not perform any behavior animation for particles contained in clusters of this type at all. Instead, each frame it calls a callback function which is responsible for animating the position of the particles comprising the cluster. This function is given access to all information and data concerning the cluster and the corresponding particles.

This cluster type is used to implement the callback trajectory animation type described above.

customdraw_pcluster_s: Particle cluster for customdraw animation

This is a very special cluster type, since the particle system not even draws particles contained therein. They have to be manually drawn at some other time. This is also the reason of existence of this cluster type, since some special particles might not be eligible to be drawn when all the other particles are drawn.

This is currently used for drawing explosion particles without using the depth buffer, but employing a depth sort instead. The reason for this is to avoid artifacts when a rather large particle pierces a spacecraft which may look extremely strange and unrealistic.

Một phần của tài liệu Design and architecture of a portable and extensible multiplayer 3d game engine thesis (Trang 115 - 118)

Tải bản đầy đủ (PDF)

(147 trang)