mohaa-spearhead-sdk/docs/MOH particles.html

223 lines
14 KiB
HTML
Raw Normal View History

2003-02-06 00:00:00 +00:00
<html>
<head>
<title>MOHAA - SDK</title>
</head>
<body>
<b><u><font size=+2><center>Particles and Emitters</center></font></u></b>
<br>
<center>Last Updated: December 11, 2002</center>
<br>
<br>
<b><font size=+1>Overview</font></b>
<p>
This document provides an overview of the Ghost Particle System. It should be used with the document title <20>Client Side Commands<64> to get the full list of functionality.<br>
<br>
The functionality of Ghost resides in the client side game DLL (cgame DLL) and particle systems are defined in the client commands and init sections of TIKI files. Every Ghost system is defined in a TIKI file. In some cases the model of the TIKI file is hidden and not used, so we just get a pure particle system from the TIKI with no animations. <br>
<br>
The nimation alias system can be used to define different particle systems in 1 TIKI file. For example: blah.tik can have 3 different client side animations: smoke, fire, blaze. These 3 animations can have different commands associated with them which will be executed on the client when its frame is played.<br>
</p>
<b><font size=+1>Example</font></b>
<p>
Here<EFBFBD>s an example of a animation block in the crossbow.tik model. We will be analyzing the client commands that are in the <20>fire<72> animation. The lines are numbered for reference and is not included in the TIKI file.
</p>
<pre>
<i><font color=blue>
1. animations
2. {
3. idle idle.skc
4. fire fire.skc
5. {
6. server
a. {
b. first shoot
c. }
7. client
a. {
b. first sound $xbowdir$/alt4.wav 1
c. 2 tagspawn tag_barrel
d. (
e. count 5
f. model crossbow_exhaust.spr
g. life 1.00
h. accel 0.00 0.00 50.00
i. scalerate -0.01
j. radius 5.00
k. randvel crandom 10.00 crandom 5.00 crandom 20.00
l. scalemin 0.15
m. scalemax 0.50
n. sphere
o. fade
p. )
q. 1 sound $xbowdir$/charge1a.wav 2 .5
r. }
8. }
9. }
</font>
</i>
</pre>
<p>
Line 4 is the beginning of a new animation. The alias for the animation is <20>fire<72> and the animation file is <20>fire.skc<6B>. Line 5 is the begin block of the animation commands. Line 6a-c define the server commands that will be executed when the frame is played.<br>
<br>
Line 7 is the beginning of the client commands section. Line 7b denotes a sound effect that will be played on the first frame. 7c is the command that defines a particle system to be spawned on the 2nd frame of the animation. The tagspawn command is used to spawn particles (or tempmodels) from a specified location. The <20>(<28> on line 7d denotes the beginning of a block of <20>modifiers<72> and <20>properties<65> that the particle system will have.<br>
<br>
Since this particle system is created on a specific frame of animation, it is called a <b><EFBFBD>Spawned Particle System.<2E></b> There are other particle systems called <b><EFBFBD>Emitters<EFBFBD></b> that wll be discussed below. <br>
<br>
The tagspawn command takes 1 parameter which is the name of the tag that the origin of the particle system starts at. In this example tag_barrel is used (it<69>s the end of the crossbow). The next set of <20>modifiers<72> can be placed in any order after the opening <20>(<28>. Each command will modify the particle system in a different way. Combining these modifiers in different ways can lead to an unlimited method of creating special effects.<br>
<br>
The first parameter is <b><EFBFBD>count.<2E></b> This is the number of particles that will be spawned in this system. The second command is <b><EFBFBD>model<EFBFBD></b> which lets the system know which model the particle system should be made from. In the example it<69>s crossbow_exhaust.spr. This is a sprite model which will be talked about later. The model can also be another TIKI file. Line 7g has the <b><EFBFBD>life<EFBFBD></b> command. This is the amount of time (in seconds) each spawned particle will live. When a particle<6C>s life runs out, it is removed from the system. The next command is <b><EFBFBD>accel<EFBFBD></b> which is short for acceleration. This defines the acceleration of the particle. In this case it<69>s 50 units in the Upward Z direction. Accel is always relative to the world<6C>s coordinate system and is independent of the parent model<65>s orientation. <br>
<br>
The rest of the commands are outlined in the <20>Client Side Commands<64> document.<br>
<br>
As you may be able to tell, this particle system defines a 5 puffs of smoke that will appear at the barrel of the gun and slowly rise upward for 1 second. The <b><EFBFBD>randvel<EFBFBD></b> command gives them a slight variation in velocity when they are spawned so they spread apart in a natural way. The <b><EFBFBD>fade<EFBFBD></b> command will allow them to fade out over their life time. This gives a nice effect of smoke dissipating away in the game.<br>
</p>
<b><font size=+1>Emitters</font></b>
<p>
As mentioned above <20>Spawned Particle Systems<6D> are associated with animations. Basically they are used to create effects that happen on a certain frame of an animation. Emitters are an entirely different system. They are particle emittters that never <20>shut off<66> unless you tell them to. Instead of a <b><EFBFBD>count<EFBFBD></b> command they use a <b><EFBFBD>spawnrate<EFBFBD></b> command. This is used to set the rate at which the emitter will emit particles<br>
<br>
Since emitters are not tied to animations (although they may be controlled by them <20> see below) they are defined in the <b>Init</b> section of the TIKI file. Here<72>s an example of an emitter:<br>
</p>
<pre>
<i><font color=blue>
a. init
b. {
c. client
d. {
e. tagemitter tag_weldsparks sparks
a. (
b. model weldsparks.spr
c. spawnrate 150
d. velocity 1
e. randvel crandom 1 crandom 1 crandom 1
f. scale .02
g. life 1.5
h. offset random 1 random 1 random 1
i. )
j. }
k. }
</font>
</i>
</pre>
<p>
It<EFBFBD>s similar to the Spawned Particle system above, but a little different. The command is called tagemitter and it takes 2 parameters. The first parameter is the tag name. This is the same as the tag name that is used in the spawned system above. The second parameter is the name of the emitter. The name is used to control the emitter in an animation.<br>
<br>
Another difference in this emitter is the <20>spawnrate<74> command. This is used to control the number of particles per second that are emitted in this system. This <20>sparks<6B> emitter will spawn 150 particles a second! <br>
<br>
Most of the other commands are identical to the spawned system and will effect the system the same way. You may also have more than 1 emitter in the init section. This allows you to combine systems in one model file.<br>
</p>
<b><font size=+1>Controlling Emitters</font></b>
<p>
To control an emitter you can use the <20>emitteron<6F> and <20>emitteroff<66> commands in an animation. Here<72>s an example:
</p>
<pre>
<i><font color=blue>
animations
{
client
{
turn_on idle.skc
{
client
{
emitteron sparks
}
}
turn_off idle.skc
{
client
{
emitteroff sparks
}
}
</font>
</i>
</pre>
<p>
If you wanted to make this emitter turn on, use the level<65>s script file to play the <20>turn_on<6F> animation. To turn off the emitter simply play the <20>turn_off<66> animation. This model doesn<73>t really have an animation, it just uses a dummy model with the idle.skc animation. Although you can have emitters on models with animation.
</p>
<b><font size=+1>Sprites</font></b>
<p>
Sprites are derived from shaders. To make a particle system use a sprite, set the model to the name of the shader appended with a .spr (E.g. weldsparks.spr). This will render a sprite with the specified shader.<br>
<br>
The default size of the sprite will be equal to the size of the base texturemap. but these can be modified with the <b><EFBFBD>spritescale<EFBFBD></b> shader command. The <b><EFBFBD>spritegen<EFBFBD></b> shader command is used to create the type of sprite to display (parallel, parallel_oriented, oriented, and parallel_upright).<br>
</p>
<b><font size=+1>Developing Particle Systems</font></b>
<p>
Particle systems can be created using an in game menu called <20>Emitter<65>. This menu allows the developer to interactively adjust the parameters of a particle system and then save them out for later use in the game. <br>
<br>
To bring up this menu, it is advised that you bind a key to it. To bind it to the F1 key, issue the following command: bind f1 pushmenu emitter<br>
<br>
Fundamentally there are two different types of particle systems, emitters and spawns. Emitters are persistant and are activated and deactivated by command. Spawners are one shot emissions that take place at key events. Generally models use spawners more often than emitters.<br>
<b>The testemitter menu does not cover all of the available commands that can be used <20> refer to the Client Side Commands.doc for the full list of commands that may be applied to emitters.</b><br>
<br>
The first step in creating an emitter or spawner is to place the emitter on the ground in front of you. This can be done by pressing the <20>Place Emitter<65> button on the Emitter menu. This will create a default emitter out in front of the camera. You can now adjust the parameters of the emitter using the <20>emitter<65> menu. <br>
<br>
Here<EFBFBD>s a screenshot of what the menu looks like:<br>
<br>
<img src="MOH particles/1-1.jpg"><br>
<br>
This menu allows you to modify some of the properties of emitters to test out different values. The first thing you should do is set the model to a valid value. The test emitter will update automatically as you type into the menu, so you may see some error messages while updating the values. Here<72>s a quick rundown of what the buttons and sliders change. All of the commands are in the document
<br>
</p>
<ul>
<li><b>model</b> <20> The model that the emitter will emit.
<li><b>spawnrate</b> <20> The rate at which the emitter emits (this is number of models per second). This overrides any value set in the <20>count<6E> field.
<li><b>Count</b> <20> How many models to emit at one time. This is only valid for non-spawnrate emitters, like spawners.
<li><b>life</b> <20> The amount of time in seconds the emitted model will live.
<li><b>Spawnrange</b> <20> the minimum and maximum distance in which models will be spawned. This allows you to control the culling distance of the spawned models.
<li><b>Delay</b> <20> how long to delay before starting to spawn. Used in multi-stacked emitters on the same model, triggered from the same animation.
<li><b>Red, Green, Blue</b> <20> the color of the emitted particles/models. In order for this to work, the shader parameters of the emitted particles/models must support it properly.
<li><b>Varycolor</b> <20> randomly perturb the color between 80% and 100% of its set value.
<li><b>Flicker</b> <20> randomly modulate the visibility of the emitted model. Think of a firefly.
<li><b>alpha</b> <20> The alpha of the emitted model. In order for this to work, the shader parameters of the emitted particles/models must support it properly.
<li><b>Fadein time</b> <20> how long it should take to fade in the emitted model
<li><b>Fade delay</b> <20> how long to wait before starting to fade out the model
<li><b>Fade</b> <20> whether or not to fade out the model. The timing of the model is based off of life and Fade delay.
<li><b>Pitch, Yaw, Roll</b> <20> Set the angles of the emitted models. The first column represents the base values. The second column is the offset. The final value will be a random value between [base] and [base + offset]. In order to specify a range between (-10) and (10), a base of -10 would be specified with an offset of 20. To specify a range between 20 and 60, a base of 20 would be specified with an offset of 60.
<li><b>AvelP, AVelY, AvelR</b> <20> Set the angular velocity of the emitted models. The first column represents the base values. The second column is the offset. The final value will be a random value between [base] and [base + offset].
<li><b>RandRoll</b> <20> give the emitted model a random roll. This is obsolete considering you have perfect control over the Roll from above.
<li><b>Die Touch</b> <20> When collision is on and the emitted model touches something, kill it.
<li><b>Collision</b> <20> Perform collision on each emitted model. NOTE: This can be expensive.
<li><b>scale</b> <20> The scale of the emitted model.
<li><b>scalemin / scalemax</b> <20> The min/max scale of the model. The scale will be randomized between the 2 specified values
<li><b>scalerate</b> <20> This is the rate at which the model will scale in size. If you specify a negative number the model will shrink.
<li><b>Alignstretch</b> <20> align the model along the path of movement and stretch it in that direction based on its current speed and the value of this scalar.
<li><b>Align</b> <20> align the model along the path of movement.
<li><b>forwardvel</b> <20> This will be the forward velocity of the emitted models in the direction of the orientation of the parent model.
<li><b>pitch / yaw / roll</b> <20> Sets the angles of the emitted models. The 3 items to the left of the sliders is No,Cr,and Ra. This stands for No Random, Crandom, and Random. The No means that no randomness will be applied to the emitted model. Cr means that the angles will be randomized between <20>value and +value. Ra means that the angle will be randomized between 0 and +value.
<li><b>randvelx / randvely / randvelz</b> <20> Applies a velocity to the emitted model. The No,Cr, and Ra are applied the same as mentioned above. These velocities are applied to the world orientation. For example: the setting randvelz to 100 means that the emitter will have 100 velocity in the up direction with respect to the world
<li><b>randorgx / randorgy / randorgz</b> <20> applies an origin offset from the normal origin of the spawned entity. This is relative to the world. If you want to set an offset that is relative to the model, use the command: <20>offsetalongaxis.<2E>
<li><b>acceleration</b> <20> This is the vector specifying the direction that the emitted models will accelerate. This is relative to the world axis.
<li><b>sphereradius</b> <20> This is used to spawn models in a sphere around the point of origin. This radius specifies how far from the origin the model will spawn.
<li><b>fade / flicker / randroll / sphere / insphere / align</b> <20> These flags are used to set some of the effects on the spawned models.
<li><b>dumpemitter</b> <20> This allows the user to dump out the current state of the testemitter to get the commands. This allows you to cut and paste the commands directly into a TIKI file.
</ul>
</body>
<p>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</p>
<pre>
<i><font color=blue>
</font>
</i>
</pre>