| 1 |
Document started 27/01/2008 by Tiago Gusmão |
| 2 |
Updated 02/02/2008 to reflect syntax changes |
| 3 |
Updated 03/02/2008 to add trails (connected particles) |
| 4 |
|
| 5 |
This is a short specification/tutorial to define particle systems in |
| 6 |
FlightGear using XML |
| 7 |
|
| 8 |
Meaningless example (what i had accumulated due to tests): |
| 9 |
|
| 10 |
<particlesystem> |
| 11 |
<name>fuel</name> |
| 12 |
<!-- <texture>particle.rgb</texture> --> |
| 13 |
<emissive>false</emissive> |
| 14 |
<lighting>true</lighting> |
| 15 |
|
| 16 |
<offsets> |
| 17 |
<x-m>35</x-m> |
| 18 |
<y-m>-0.3</y-m> |
| 19 |
<z-m>0</z-m> |
| 20 |
<!--<pitch-deg>90</pitch-deg>--> |
| 21 |
</offsets> |
| 22 |
|
| 23 |
<!--<condition> |
| 24 |
<and> |
| 25 |
<equals> |
| 26 |
<property>engines/engine/smoking</property> |
| 27 |
<value>true</value> |
| 28 |
</equals> |
| 29 |
<less-than> |
| 30 |
<property>position/altitude-agl-ft</property> |
| 31 |
<value>12000</value> |
| 32 |
</less-than> |
| 33 |
</and> |
| 34 |
</condition>--> |
| 35 |
|
| 36 |
<attach>world</attach> |
| 37 |
|
| 38 |
<placer> |
| 39 |
<type>point</type> |
| 40 |
</placer> |
| 41 |
|
| 42 |
<shooter> |
| 43 |
<theta-min-deg>84</theta-min-deg> |
| 44 |
<theta-max-deg>86</theta-max-deg> |
| 45 |
<phi-min-deg>-1.5</phi-min-deg> |
| 46 |
<phi-max-deg>1.5</phi-max-deg> |
| 47 |
<speed> |
| 48 |
<value>10</value> |
| 49 |
<spread>2.5</spread> |
| 50 |
</speed> |
| 51 |
<rotation-speed> |
| 52 |
<x-min-deg-sec>0</x-min-deg-sec> |
| 53 |
<y-min-deg-sec>0</y-min-deg-sec> |
| 54 |
<z-min-deg-sec>0</z-min-deg-sec> |
| 55 |
<x-max-deg-sec>0</x-max-deg-sec> |
| 56 |
<y-max-deg-sec>0</y-max-deg-sec> |
| 57 |
<z-max-deg-sec>0</z-max-deg-sec> |
| 58 |
</rotation-speed> |
| 59 |
</shooter> |
| 60 |
|
| 61 |
<counter> |
| 62 |
<particles-per-sec> |
| 63 |
<value>1</value> |
| 64 |
<spread>0</spread> |
| 65 |
</particles-per-sec> |
| 66 |
</counter> |
| 67 |
|
| 68 |
<align>billboard</align> |
| 69 |
|
| 70 |
<particle> |
| 71 |
<start> |
| 72 |
<color> |
| 73 |
<red> |
| 74 |
<value>0.9</value> |
| 75 |
</red> |
| 76 |
<green> |
| 77 |
<value>0.09</value> |
| 78 |
</green> |
| 79 |
<blue> |
| 80 |
<value>0.09</value> |
| 81 |
</blue> |
| 82 |
<alpha> |
| 83 |
<value>1.0</value> |
| 84 |
</alpha> |
| 85 |
</color> |
| 86 |
<size> |
| 87 |
<value>0.25</value> |
| 88 |
</size> |
| 89 |
</start> |
| 90 |
|
| 91 |
<end> |
| 92 |
<color> |
| 93 |
<red> |
| 94 |
<value>1</value> |
| 95 |
</red> |
| 96 |
<green> |
| 97 |
<value>0.1</value> |
| 98 |
</green> |
| 99 |
<blue> |
| 100 |
<value>0.1</value> |
| 101 |
</blue> |
| 102 |
<alpha> |
| 103 |
<value>0.0</value> |
| 104 |
</alpha> |
| 105 |
</color> |
| 106 |
<size> |
| 107 |
<value>4</value> |
| 108 |
</size> |
| 109 |
</end> |
| 110 |
|
| 111 |
<life-sec> |
| 112 |
<value>10</value> |
| 113 |
</life-sec> |
| 114 |
|
| 115 |
<mass-kg>0.25</mass-kg> |
| 116 |
<radius-m>0.1</radius-m> |
| 117 |
</particle> |
| 118 |
|
| 119 |
<program> |
| 120 |
<fluid>air</fluid> |
| 121 |
<gravity type="bool">true</gravity> |
| 122 |
<wind type="bool">true</wind> |
| 123 |
</program> |
| 124 |
</particlesystem> |
| 125 |
|
| 126 |
Stick this inside any model XML like it was an animation and it should |
| 127 |
work (notice the condition requires wheel on the ground) |
| 128 |
|
| 129 |
Specification: |
| 130 |
|
| 131 |
Note: |
| 132 |
<VALUEORPROP/> means you can either specify a property with factor and |
| 133 |
offset (result = (prop*factor)+offset ) in the usual way |
| 134 |
|
| 135 |
|
| 136 |
<particlesystem> = the base tag |
| 137 |
<type>string</type> = can be "normal" or "trail", normal is the usual quad |
| 138 |
particles, trail is a string of connected line shapes |
| 139 |
by default. |
| 140 |
<offsets> = this places the source of the particles (the emitter) in relation |
| 141 |
to the perhaps already offset model (see model-howto.html for details) |
| 142 |
<x-m>float</x-m> |
| 143 |
<y-m>float</y-m> |
| 144 |
<z-m>float</z-m> |
| 145 |
<pitch-deg>float</pitch-deg> |
| 146 |
<roll-deg>float</roll-deg> |
| 147 |
<heading-deg>float</heading-deg> |
| 148 |
</offsets> |
| 149 |
<condition> = a typical condition that if not true stops particles from being |
| 150 |
.... emitted (PPS=0) |
| 151 |
</condition> |
| 152 |
<name>string</name> = the name of the particle system (so it can be referenced |
| 153 |
by normal animations) |
| 154 |
<attach>string</attach> = can be "world" or "local". "world means the particles |
| 155 |
aren't "physically linked" to the model (necessary for |
| 156 |
use outside moving models), "local" means the opposite |
| 157 |
(can be used for static objects or inside moving objects) |
| 158 |
<texture>string</texture> = the texture path relative to the XML file location |
| 159 |
<emissive>bool</emissive> = self-explanatory |
| 160 |
<lighting>bool</lighting> = yet to be tested, but seems obvious |
| 161 |
<align>string</align> = can be "billboard" or "fixed" |
| 162 |
<placer> = where particles are born |
| 163 |
<type>string</type> = can be "sector" (inside a circle), "segments"(user-defined |
| 164 |
segments) and "point" (default) |
| 165 |
*<radius-min-m>float</radius-min-m> = only for sector, inner radius at which |
| 166 |
particles appear |
| 167 |
*<radius-max-m>float</radius-max-m> = only for sector, outer radius at which |
| 168 |
particles appear |
| 169 |
*<phi-min-deg>float</phi-min-deg> = only for sector, starting angle of the |
| 170 |
slide at which particles appear |
| 171 |
*<phi-max-deg>float</phi-max-deg> = only for sector, ending angle of the slide |
| 172 |
at which particles appear |
| 173 |
<segments> = only for segments, encloses sequential points that form segments |
| 174 |
<vertex> = specifies one point, put as many as you want |
| 175 |
<x-m>float</x-m> |
| 176 |
<y-m>float</y-m> |
| 177 |
<z-m>float</z-m> |
| 178 |
</vertex> |
| 179 |
.... |
| 180 |
<vertex> |
| 181 |
... |
| 182 |
</vertex> |
| 183 |
</segments> |
| 184 |
</placer> |
| 185 |
<shooter> = the shooter defines the initial velocity vector for your particles |
| 186 |
*<theta-min-deg>float</theta-min-deg> = horizontal angle limits of the particle cone |
| 187 |
*<theta-max-deg>float</theta-max-deg> |
| 188 |
*<phi-min-deg>float</phi-min-deg> = vertical angle limits of the particle cone |
| 189 |
*<phi-max-deg>float</phi-max-deg> for an illustration of theta/phi see |
| 190 |
http://www.cs.clemson.edu/~malloy/courses/3dgames-2007/tutor/web/particles/particles.html |
| 191 |
<speed-mps> = the scalar velocity (meter per second) |
| 192 |
<VALUEORPROP/> = see note |
| 193 |
*<spread> = the "tolerance" in each direction so values are in the range |
| 194 |
[value-spread, value+spread] |
| 195 |
</speed-mps> |
| 196 |
<rotation-speed> = the range of initial rotational speed of the particles |
| 197 |
*<x-min-deg-sec>float</x-min-deg-sec> |
| 198 |
*<y-min-deg-sec>float</y-min-deg-sec> |
| 199 |
*<z-min-deg-sec>float</z-min-deg-sec> |
| 200 |
*<x-max-deg-sec>float</x-max-deg-sec> |
| 201 |
*<y-max-deg-sec>float</y-max-deg-sec> |
| 202 |
*<z-max-deg-sec>float</z-max-deg-sec> |
| 203 |
</rotation-speed> |
| 204 |
</shooter> |
| 205 |
<counter> |
| 206 |
<particles-per-sec> |
| 207 |
<VALUEORPROP/> = see note |
| 208 |
*<spread> = the "tolerance" in each direction so values are in the range |
| 209 |
[value-spread, value+spread] |
| 210 |
</particles-per-sec> |
| 211 |
</counter> |
| 212 |
<particle> = defines the particle properties |
| 213 |
<start> |
| 214 |
<color> = initial color (at time of emission) |
| 215 |
<red><VALUEORPROP/></red> = color component in normalized value [0,1] |
| 216 |
<green><VALUEORPROP/></green> |
| 217 |
<blue><VALUEORPROP/></blue> |
| 218 |
<alpha><VALUEORPROP/></alpha> |
| 219 |
</color> |
| 220 |
<size> = as above, but for size |
| 221 |
<VALUEORPROP/> |
| 222 |
</size> |
| 223 |
</start> |
| 224 |
<end> |
| 225 |
<color> = final color (at the end of the particle life) |
| 226 |
<red><VALUEORPROP/></red> |
| 227 |
<green><VALUEORPROP/></green> |
| 228 |
<blue><VALUEORPROP/></blue> |
| 229 |
<alpha><VALUEORPROP/></alpha> |
| 230 |
</color> |
| 231 |
<size> |
| 232 |
<VALUEORPROP/> |
| 233 |
</size> |
| 234 |
</end> |
| 235 |
*<life-sec> = the time the particles will be alive, in seconds |
| 236 |
<VALUEORPROP/> |
| 237 |
*</life-sec> |
| 238 |
*<radius-m>float</radius-m> = each particles is physically treated as a sphere |
| 239 |
with this radius |
| 240 |
*<mass-kg>float</mass-kg> = mass in KG |
| 241 |
</particle> |
| 242 |
<program> = defines external forces acting upon a particle |
| 243 |
<fluid>string<fluid> = can be "air" or "water" |
| 244 |
<gravity>bool</gravity> = can be "true" or "false". uses standard gravity |
| 245 |
<wind>bool</wind> = can be "true" or "false". uses user position wind (not the |
| 246 |
model position, but shouldn't be noticeable, you want to |
| 247 |
disabled it when using local attach) |
| 248 |
</program> |
| 249 |
</particles> |
| 250 |
|
| 251 |
Remarks: |
| 252 |
* Don't forget you can use existing animations with particles, so if you want to |
| 253 |
direct or translate the emitter, just use translate, rotate, spin and so on |
| 254 |
(other animations might have interesting effects too I guess) |
| 255 |
|
| 256 |
* Particle XML should be compatible with plib, as the tags will be ignored (you |
| 257 |
might get some warning if you attach them to animations though) |
| 258 |
|
| 259 |
* Try not to use a lot of particles in a way that fills the screen, that will demand |
| 260 |
lots of fill rate and hurt FPS |
| 261 |
|
| 262 |
* If you don't use any properties nor conditions, your particle system doesn't need |
| 263 |
to use a callback a so it's slightly better on the CPU (mostly useful for static models) |
| 264 |
|
| 265 |
* If your particle lifetime is too big you might run out of particles temporarily |
| 266 |
(still being investigated) |
| 267 |
|
| 268 |
* Use mass and size(radius) to adjust the reaction to gravity and wind |
| 269 |
(mass/size = density) |
| 270 |
|
| 271 |
* Although at the moment severe graphical bugs can be seen in the trails, |
| 272 |
they are usable. |
| 273 |
|
| 274 |
* Consider your options correctly! You should consider giving them no initial |
| 275 |
velocity and most important, no spread, otherwise particles will race and the |
| 276 |
trail will fold. Start simple (no velocities and forces) and work your way up. |