Last updated 4/14/2000

Main Menu


Generating 'Beam' Visual Effects

 

Yeah, now we have beam effects. They are still in progress, but we have almost all the basic effects in at the moment. I imagine that these would be used for stuff like boots' attacks and Demo's tractor beam skill. Things that need scaleable lines for variable relative targets.

Creating Beams in APE

What is a beam? It's a screen-oriented polygon that starts at one point and ends at another. So basically a line. These lines can have various effects such as fading from opaque to solid, fading between colors, growing/shrinking, etc.

Right now, you can only create beams in APE. There are two APE externs to make beams:

BEAM_CreateBeam [srchandle] [tgthandle] [r] [g] [b] [a] [time] [radius] [flags]

srchandle/tgthandle: The two handles are handles to the source and target entities--the entity origins will be the start and end points of the beam.

r, g, b, a: These represent the red, green, blue, and alpha components of the beam's color.

time: The lifetime of the beam in milliseconds.

radius: The thickness of the beam.

flags: The effects flags of the beam (to be described later)

The second command is a more complex version of creatbeam with more arguments for greater control over the beam's appearance.

BEAM_CreateBeamEx [srchandle] [srcsurface] [tgthandle] [tgtsurface] [r] [g] [b] [a] [r2] [g2] [b2] [time] [radius] [radius2] [texture #] [scrollx] [scrolly] [flags]

srchandle/tgthandle: These are the same as in the previous command, they represent the start and end entities.

srcsurface/tgtsurface: These are the names of the triangles for the source and target that you want the beams start and endpoints to be. They are optional. So if you just want entity to entity beams, just make both surfaces 0. If you want just a source surface (the most common application), say for an eye-beam effect, just use a source surface and keep the target surface as "0". You still need to have valid handles for using surface-basedbeams.

r, g, b, a: The red, green, blue, and alpha components of the beam's color.

r2, g2, b2: The red, green, and blue components of the 2nd color. If the 1st and 2nd color are not the same, then the beam will fade between these two colors as it decays.

time: Lifetime of beam.

radius: Thickness of beam/thickness of start point.

radius2: Thickness of end point of beam. If both radii are different, then you will get a flared-out beam.

texture #:Texture number. This is the same texture number you use for particles--it will apply a texture from the pool of particle textures to the beam. It is tiled down the length of the beam, but in width it is stretched.

scrollx: Texture scroll X speed.

scrolly: Texture scroll Y speed.

flags: Flags (to be described later)

Creating Beams in PLANET

The Planet Command is basically createbeamex, but slightly more flexible. This goes on the command path for any given track and references the entity that belongs to that track as the source of the beam. Therefore, it's not necessary to specify a source entity:

beam=[surfacea],[tgttrack],[surfaceb],[r],[g],[b],[a],[r2],[g2],[b2],[time],[radius],[radius2],[texnum],[scrollx],[scrolly],[flags], [segments]

surfacea: The surface of the target entity the beam will emit from. "0" if none.

tgttrack: The track of the target entity. Can also be either the sequence or classname of the desired target entity.

surfaceb: The surface you want to hit on the target entity. "0" if none.

r, g, b, a: The red, green, blue, and alpha components of the first color.

r2, g2, b2: The second color of the beam. If the same as the first, no color fading will occur.

time: Time, in milliseconds, of the beam's life. 2500 is 2 and a half seconds, for a ballpark value.

radius: Radius, 0-256, of the beam.

radius2: Second radius--if the same as the first, no flaring will occur.

texnum: Texture #, same as the texnum for particles. If -1 or 0, will not use a texture. (I probably have to let it use 0)

scrollx: Scroll velocity along the x axis of the texture (if available).

scrolly: Scroll velocity along the y axis of the texture (if available).

flags: Effects flags.

segments: Number of segments for lightning. (optional, only used for lightning beams--3-12 segments. Let me know if you need more)

FLAGS

These are the values that you add up and use for the flags field. You can use the windows calculator in hex mode to add in the appropriate effects flags. More info to come...


#define BE_SHRINK 0x0001 // beam shrinks with time (radius -> 0)
#define BE_FADE 0x0002 // beam fades with time
#define BE_PARTICLE 0x0008 // add particles to beam length
#define BE_GLOW 0x0020 // draw halo around beam
#define BE_GROW 0x0040 // beam grows with time ( 0 -> radius)
#define BE_LIGHTNING 0x0200 // segmented lightning beam
#define BE_2RADIUS 0x0400 // different source and target radius
#define BE_ALPHALEFT 0x0800 // fade from 0 alpha, target -- source : fade
#define BE_ALPHARIGHT 0x1000 // fade from 0 falpha, source -- target : fade
#define BE_INFINITE 0x2000 // beam lasts forever (until killed)

If you are using the lightning flag, the radius2 argument is referenced as the deviation instead of the flared radius since lightning would look pretty stupid with tapered beams. If it's set to 0, it will just use a default value.

A Small Note About the INFINITE Flag

If you use the INFINITE flag, the beam will last forever. You can explicitly kill the beam with the command:

BEAM_KillBeam [handle]

This will kill the infinite beam associated with the entity handle passed in. If you have more than one beam emitting from a single entity, this function will kill all beams associated with that entity.

LIMITATIONS

Beams are a single polygon (except lightning). So you will notice if you have a particularly wide beam that the end points will spin around as you move the camewra because it always draws the beam orthogonal to the screen. It's not that bad with small to medium sized beams, but beware of this when using obscenely wide beams.

Using The Beam Editor

Now we have a Beam Editor. This allows you to quickly demo different styles of beams and view their flag values for easy creation of new effects.

The Beam Editor is similar to the Particle Editor in that it needs to be launched from NoxDroppings. To start the editor, type the console command "ndbeamedit +" from the console.

Now you'll see an interface similar to the Particle Editor. There are a bunch of sliders on the right for adjusting parameters and a listbox on the lower left for flags. You can click on the flags just like particle flags. These will apply different styles.

Now, when you click the create beam button, a beam will be created in front of you. (It spawns two invisible entities in front of the camera for this) When this button is clicked you will see the text "Beam Flags" in the upper left hand corner of the screen. This is the effect argument for this given beam. That way you don't have to use a calculator.

By using the values of the sliders and the beam flags number, you can easily create particle commands with the editor.

Complain about this document to the wonderful author, Ralph Barbagallo