223 lines
No EOL
14 KiB
HTML
223 lines
No EOL
14 KiB
HTML
<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 “Client Side Commands” 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’s an example of a animation block in the crossbow.tik model. We will be analyzing the client commands that are in the “fire” 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 ‘fire’ and the animation file is ‘fire.skc’. 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 ‘(‘ on line 7d denotes the beginning of a block of ‘modifiers’ and ‘properties’ 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>“Spawned Particle System.”</b> There are other particle systems called <b>“Emitters”</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’s the end of the crossbow). The next set of ‘modifiers’ can be placed in any order after the opening ‘(‘. 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>‘count.’</b> This is the number of particles that will be spawned in this system. The second command is <b>‘model’</b> which lets the system know which model the particle system should be made from. In the example it’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>‘life’</b> command. This is the amount of time (in seconds) each spawned particle will live. When a particle’s life runs out, it is removed from the system. The next command is <b>‘accel’</b> which is short for acceleration. This defines the acceleration of the particle. In this case it’s 50 units in the Upward Z direction. Accel is always relative to the world’s coordinate system and is independent of the parent model’s orientation. <br>
|
||
<br>
|
||
The rest of the commands are outlined in the “Client Side Commands” 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>‘randvel’</b> command gives them a slight variation in velocity when they are spawned so they spread apart in a natural way. The <b>‘fade’</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 “Spawned Particle Systems” 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 “shut off” unless you tell them to. Instead of a <b>‘count’</b> command they use a <b>‘spawnrate’</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 – see below) they are defined in the <b>Init</b> section of the TIKI file. Here’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’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 ‘spawnrate’ command. This is used to control the number of particles per second that are emitted in this system. This ‘sparks’ 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 ‘emitteron’ and ‘emitteroff’ commands in an animation. Here’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’s script file to play the ‘turn_on’ animation. To turn off the emitter simply play the ‘turn_off’ animation. This model doesn’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>‘spritescale’</b> shader command. The <b>‘spritegen’</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 “Emitter”. 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 – 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 “Place Emitter” 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 ‘emitter’ menu. <br>
|
||
<br>
|
||
Here’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’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> – The model that the emitter will emit.
|
||
<li><b>spawnrate</b> – The rate at which the emitter emits (this is number of models per second). This overrides any value set in the “count” field.
|
||
<li><b>Count</b> – How many models to emit at one time. This is only valid for non-spawnrate emitters, like spawners.
|
||
<li><b>life</b> – The amount of time in seconds the emitted model will live.
|
||
<li><b>Spawnrange</b> – 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> – 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> – 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> – randomly perturb the color between 80% and 100% of its set value.
|
||
<li><b>Flicker</b> – randomly modulate the visibility of the emitted model. Think of a firefly.
|
||
<li><b>alpha</b> – 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> – how long it should take to fade in the emitted model
|
||
<li><b>Fade delay</b> – how long to wait before starting to fade out the model
|
||
<li><b>Fade</b> – 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> – 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> – 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> – 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> – When collision is on and the emitted model touches something, kill it.
|
||
<li><b>Collision</b> – Perform collision on each emitted model. NOTE: This can be expensive.
|
||
<li><b>scale</b> – The scale of the emitted model.
|
||
<li><b>scalemin / scalemax</b> – The min/max scale of the model. The scale will be randomized between the 2 specified values
|
||
<li><b>scalerate</b> – 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> – 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> – align the model along the path of movement.
|
||
<li><b>forwardvel</b> – 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> – 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 –value and +value. Ra means that the angle will be randomized between 0 and +value.
|
||
<li><b>randvelx / randvely / randvelz</b> – 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> – 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: ‘offsetalongaxis.’
|
||
<li><b>acceleration</b> – This is the vector specifying the direction that the emitted models will accelerate. This is relative to the world axis.
|
||
<li><b>sphereradius</b> – 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> – These flags are used to set some of the effects on the spawned models.
|
||
<li><b>dumpemitter</b> – 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>
|
||
|
||
</p>
|
||
|
||
|
||
|
||
<pre>
|
||
<i><font color=blue>
|
||
|
||
</font>
|
||
</i>
|
||
</pre> |