| 1 |
|
| 2 |
|
| 3 |
<html> |
| 4 |
|
| 5 |
<head> |
| 6 |
<title>FlightGear Flight Simulator</title> |
| 7 |
<link rel="stylesheet" type="text/css" href="../default.css"> |
| 8 |
</head> |
| 9 |
|
| 10 |
<body> |
| 11 |
<div id="top"> |
| 12 |
<a href="../"><img id="titlebar" src="../images/fglogosm.jpg" alt=""></a> |
| 13 |
</div> |
| 14 |
|
| 15 |
<table id="global"> |
| 16 |
<tbody><tr> |
| 17 |
<td id="menu"> |
| 18 |
|
| 19 |
<h3>About</h3> |
| 20 |
<a href="..">Home</a><br> |
| 21 |
</td> |
| 22 |
<td id="page"> |
| 23 |
|
| 24 |
<h1>Mini-HOWTO: 3D Aircraft Models in FlightGear</h1> |
| 25 |
|
| 26 |
<h2>11 March 2002</h2> |
| 27 |
<h2>David Megginson</h2> |
| 28 |
<br> |
| 29 |
|
| 30 |
<div> |
| 31 |
<h3>Introduction</h3> |
| 32 |
|
| 33 |
<br>This mini-HOWTO explains how to add 3D aircraft models to |
| 34 |
FlightGear, and how to animate and position those models. No C++ |
| 35 |
programming is required, but the user will need some knowledge of |
| 36 |
FlightGear's property system and XML markup, and will need to |
| 37 |
understand the coordinate system FlightGear uses for its models:<br> |
| 38 |
|
| 39 |
<ul> |
| 40 |
<li>distances are in meters |
| 41 |
<li>angles are in degrees |
| 42 |
<li>the x-axis runs lengthwise, towards the back |
| 43 |
<li>the y-axis runs sideways, towards the right |
| 44 |
<li>the z-axis runs upwards |
| 45 |
<li>heading is a rotation around the z-axis, where |
| 46 |
positive is clockwise viewed from above |
| 47 |
<li>pitch is a rotation around the y-axis, where |
| 48 |
positive is clockwise viewed from the left |
| 49 |
<li>roll is a rotation around the x-axis, where positive is clockwise |
| 50 |
viewed from behind</li> |
| 51 |
</ul> |
| 52 |
|
| 53 |
<img src="img/model-howto-heading.jpg" width="500" height="497" alt="Heading Illiustration"> |
| 54 |
<img src="img/model-howto-pitch.jpg" width="499" height="349" alt="Pitch Illiustration"> |
| 55 |
<img src="img/model-howto-roll.jpg" width="500" height="244" alt="Roll Illiustration"> |
| 56 |
|
| 57 |
<p>This mini-HOWTO contains three parts:</p> |
| 58 |
|
| 59 |
<ol> |
| 60 |
<li><a href="#loading">Loading the model</a> |
| 61 |
<li><a href="#repositioning">Repositioning the model</a> |
| 62 |
<li><a href="#animating">Animating the model</a></li> |
| 63 |
</ol> |
| 64 |
|
| 65 |
|
| 66 |
</div> |
| 67 |
|
| 68 |
|
| 69 |
<div><a name="loading"></a> |
| 70 |
<h3>1. Loading the model</h3> |
| 71 |
|
| 72 |
<p>Through <a href="http://www.openscenegraph.org/">OpenSceneGraph</a>, |
| 73 |
FlightGear supports many different 3D file formats, including VRML2, |
| 74 |
AC3D, DXF, and |
| 75 |
<a href="http://trac.openscenegraph.org/projects/osg/wiki/Support/UserGuides/Plugins">many others</a>. |
| 76 |
The property <var>/sim/model/path</var> in the main FlightGear |
| 77 |
property tree controls what model will be loaded; it takes |
| 78 |
a string value giving the relative path of the model from |
| 79 |
<var>FG_ROOT</var> (the root of the base package, such as |
| 80 |
<code>/usr/local/lib/FlightGear</code> or |
| 81 |
<code>C:\FLIGHTGEAR\</code>).</p> |
| 82 |
|
| 83 |
<p>The easiest way to load a new model is to set the property at |
| 84 |
startup with the <var>--prop:</var> command-line option; for example, |
| 85 |
to use a 3D aircraft model that you have installed in |
| 86 |
<code>$FG_ROOT/Models/my-cessna.wrl</code>, you could invoke |
| 87 |
FlightGear like this (under Unix-like systems):</p> |
| 88 |
|
| 89 |
<blockquote><pre>fgfs --prop:/sim/model/path=Models/my-cessna.wrl |
| 90 |
</pre></blockquote> |
| 91 |
|
| 92 |
<p>(<strong>Note:</strong> Normaly any textures used by the model must appear |
| 93 |
in the same directory. If <code>my-cessna.wrl</code> uses the |
| 94 |
textures <code>cessna01.rgb</code> and <code>cessna02.rgb</code>, you |
| 95 |
should install those textures in <code>$FG_ROOT/Models/</code>. |
| 96 |
It is howerever possible to specify a path (relative to the model path) |
| 97 |
to specify where the textures could be found.)</p> |
| 98 |
|
| 99 |
<p>When you want to set a 3D model permanently as the default for an |
| 100 |
aircraft rather than specifying it on the command line, you need to |
| 101 |
edit an aircraft settings file. In the |
| 102 |
<code>$FG_ROOT/Aircraft/</code> directory there is a series of files |
| 103 |
ending in <code>-set.xml</code>, such as <code>c172-set.xml</code>, |
| 104 |
<code>dc3-yasim-set.xml</code>, and <code>beech99-uiuc-set.xml</code>. |
| 105 |
When you start FlightGear with the <var>--aircraft</var> option, it |
| 106 |
reads the properties from one of these files; for example</p> |
| 107 |
|
| 108 |
<blockquote><pre>fgfs --aircraft=dc3-yasim |
| 109 |
</pre></blockquote> |
| 110 |
|
| 111 |
<p>Loads the properties from |
| 112 |
<code>$FG_ROOT/Aircraft/dc3-yasim-set.xml</code> into the main |
| 113 |
FlightGear property tree. These files are in the same XML |
| 114 |
property-list format as <code>$FG_ROOT/preferences.xml</code> and the |
| 115 |
FlightGear save files. There may be many XML files with different |
| 116 |
startup conditions, sounds, panels, 3D models, etc. for any single |
| 117 |
aircraft type, so you are best off copying an existing one, renaming |
| 118 |
it, then changing the value inside the <var>path</var> element inside |
| 119 |
<var>model</var> inside <var>sim</var>:</p> |
| 120 |
|
| 121 |
<blockquote><pre><PropertyList> |
| 122 |
<sim> |
| 123 |
<model> |
| 124 |
<path>Models/my-cessna.wrl</path> |
| 125 |
<texture-path>./Textures</texture-path> |
| 126 |
</model> |
| 127 |
</sim> |
| 128 |
</PropertyList> |
| 129 |
</pre></blockquote> |
| 130 |
|
| 131 |
<p>So far, all of the examples have had the <var>/sim/model/path</var> |
| 132 |
property point directly at the 3D model file |
| 133 |
(<code>Models/my-cessna.wrl</code>); however, if you want to be able |
| 134 |
to reposition or animate the model, you need to point to an |
| 135 |
intermediate XML file instead, and then put the repositioning and |
| 136 |
animation information into the XML file. Here's a simple example of a |
| 137 |
3D-model wrapper file, with no repositioning or animation |
| 138 |
information:</p> |
| 139 |
|
| 140 |
<blockquote><pre><PropertyList> |
| 141 |
<path>my-cessna.wrl</path> |
| 142 |
<texture-path>./Textures</texture-path> |
| 143 |
</PropertyList> |
| 144 |
</pre></blockquote> |
| 145 |
|
| 146 |
<p>Like the <var>-set.xml</var> files, this file is in XML property |
| 147 |
list format, but the properties in it are not added to the main |
| 148 |
FlightGear property tree; they're used only while loading the |
| 149 |
model. The following sections will explain how to add repositioning |
| 150 |
and animation information to the file; for now, the only property to |
| 151 |
worry about is <var>path</var>: it provides the relative path to the |
| 152 |
actual 3D file from the XML wrapper file (<strong>not</strong> from |
| 153 |
<var>FG_ROOT</var>!). Usually, you should put the wrapper file in the |
| 154 |
same directory as the 3D file, and then have |
| 155 |
<var>/sim/model/path</var> point to the wrapper file, either on the |
| 156 |
command line</p> |
| 157 |
|
| 158 |
<blockquote><pre>fgfs --prop:/sim/model/path=Models/my-cessna.xml |
| 159 |
</pre></blockquote> |
| 160 |
|
| 161 |
<p>or in the <code>-set.xml</code> file:</p> |
| 162 |
|
| 163 |
<blockquote><pre><PropertyList> |
| 164 |
<sim> |
| 165 |
<model> |
| 166 |
<path>Models/my-cessna.xml</path> |
| 167 |
</model> |
| 168 |
</sim> |
| 169 |
</PropertyList> |
| 170 |
</pre></blockquote> |
| 171 |
|
| 172 |
|
| 173 |
</div> |
| 174 |
|
| 175 |
|
| 176 |
<div><a name="repositioning"></a> |
| 177 |
<h3>2. Repositioning the Model</h3> |
| 178 |
|
| 179 |
<p>Often, an aircraft model not designed specifically for FlightGear |
| 180 |
will not be positioned or oriented correctly; for example, it might be |
| 181 |
too far off the ground, and the nose might point to the side or even |
| 182 |
straight up.</p> |
| 183 |
|
| 184 |
<p>Inside the XML wrapper file (<em>not</em> the main FlightGear |
| 185 |
property tree), there are six properties that allow you to tweak the |
| 186 |
default position and orientation of the model:</p> |
| 187 |
|
| 188 |
<dl compact ><dt><strong>/offsets/x-m</strong><dd>The distance to reposition the model along the |
| 189 |
x-axis.<dt><strong>/offsets/y-m</strong><dd>The distance to reposition the model along the |
| 190 |
y-axis.<dt><strong>/offsets/z-m</strong><dd>The distance to reposition the model along the |
| 191 |
z-axis.<dt><strong>/offsets/heading-deg</strong><dd>The angle by which to rotate the model around |
| 192 |
the z-axis.<dt><strong>/offsets/roll-deg</strong><dd>The angle by which to rotate the model around |
| 193 |
the x-axis.<dt><strong>/offsets/pitch-deg</strong><dd>The angle by which to rotate the model around the y-axis.</dd></dl> |
| 194 |
|
| 195 |
<p>For example, if you wanted to use the 3D model |
| 196 |
<code>my-cessna.wrl</code> but found that the nose was pointing to the |
| 197 |
right instead of straight-ahead and the wheels were 1.5 meters off the |
| 198 |
ground, you could reorient it in the XML wrapper file like this:</p> |
| 199 |
|
| 200 |
<blockquote><pre><PropertyList> |
| 201 |
<path>Models/my-cessna.xml</path> |
| 202 |
<offsets> |
| 203 |
<heading-deg>270</heading-deg> |
| 204 |
<z-m>-1.5</z-m> |
| 205 |
</offsets> |
| 206 |
</PropertyList> |
| 207 |
</pre></blockquote> |
| 208 |
|
| 209 |
<p>It usually takes a bit of experimentation to get the model |
| 210 |
positioned correctly.</p> |
| 211 |
|
| 212 |
|
| 213 |
</div> |
| 214 |
|
| 215 |
|
| 216 |
<div><a name="animating"></a> |
| 217 |
<h3>3. Animating the Model</h3> |
| 218 |
|
| 219 |
<p>Now for the interesting part. FlightGear allows you to animate |
| 220 |
models by having parts rotate or spin in response to property changes: |
| 221 |
for example, the propellers can spin when the engine is on and the |
| 222 |
elevators can move up and down with your controller. There is no |
| 223 |
fixed limit on what parts can be animated: the only requirements are |
| 224 |
that the part is named in the 3D model file, and that there is a |
| 225 |
property in the main tree that you can use to get the positioning |
| 226 |
information.</p> |
| 227 |
|
| 228 |
<p>Currently, there are several types of animation recognized:</p> |
| 229 |
|
| 230 |
<ol> |
| 231 |
<li>none |
| 232 |
<li>billboard |
| 233 |
<li>rotate |
| 234 |
<li><a href="#scale">scale</a> |
| 235 |
<li><a href="#blend">blend</a> |
| 236 |
<li><a href="#select">select</a> |
| 237 |
<li>spin |
| 238 |
<li>timed |
| 239 |
<li>translate |
| 240 |
<li><a href="#texrotate">texrotate</a> |
| 241 |
<li><a href="#textranslate">textranslate</a> |
| 242 |
<li><a href="#textmultiple">textmultiple</a> |
| 243 |
<li><a href="#material">material</a> |
| 244 |
<li><a href="#range">range</a> |
| 245 |
<li><a href="#alphatest">alpha-test</a> |
| 246 |
<li><a href="#noshadow">noshadow</a> |
| 247 |
<li><a href="#dist-scale">dist-scale</a> |
| 248 |
<li><a href="#flash">flash</a></li> |
| 249 |
</ol> |
| 250 |
|
| 251 |
<p>Typically you will use combinations of rotate, spin, and translate |
| 252 |
to animate the main control surfaces for most standard-configuration |
| 253 |
aircraft. <var>spin</var> rotates the |
| 254 |
object around an axis with a known rotational velocity (not worrying |
| 255 |
about the exact position), and <var>rotate</var> rotates the object |
| 256 |
around an axis to an exact position.</p> |
| 257 |
|
| 258 |
<p>Every animation appears inside an <var>animation</var> element, and |
| 259 |
contains a <var>type</var> property and at least one |
| 260 |
<var>object-name</var> property:</p> |
| 261 |
|
| 262 |
<blockquote><pre><animation> |
| 263 |
<type>rotate</type> |
| 264 |
<object-name>Rudder</object-name> |
| 265 |
</animation> |
| 266 |
</pre></blockquote> |
| 267 |
|
| 268 |
<p>It is possible to omit the <var>type</var> parameter. In this case, |
| 269 |
the type is <var>none</var> and the animation is there only to group |
| 270 |
objets under a single name that can be used in another animation located |
| 271 |
farther in the file. Grouping objects in animations, with a <var>type</var> |
| 272 |
or not, has the effect of reparenting the objects specified in <var>object-name</var>. |
| 273 |
The rule is that the group is inserted between the first object and its parent, |
| 274 |
and then subsequent objects are removed from their original parent and added |
| 275 |
to the new group.</p> |
| 276 |
|
| 277 |
<p><var>none</var> animations are also handy to reorganise objects in a model. |
| 278 |
When objects are translucents, they should be drawn back to front in order to |
| 279 |
see the world that lies behind through the object. But the drawing order is often |
| 280 |
the order of appearance in the model file, and it is hard to control inside the |
| 281 |
modeler. This way, one can ignore the order in the modeler, and force the |
| 282 |
reordering at load time. The order is of course the order of appearance of |
| 283 |
the <var>object-name</var> clause inside the animation. Be aware that this |
| 284 |
can be ruined by another subsequent animation (last have precedence over first).</p> |
| 285 |
|
| 286 |
<p>The object name must match exactly the object name used in the 3D |
| 287 |
file (including case). You may include more than one object name to |
| 288 |
apply the same transformation to more than one object, assuming that |
| 289 |
they rotate around exactly the same line:</p> |
| 290 |
|
| 291 |
<blockquote><pre><animation> |
| 292 |
<type>rotate</type> |
| 293 |
<object-name>LeftElevator</object-name> |
| 294 |
<object-name>RightElevator</object-name> |
| 295 |
</animation> |
| 296 |
</pre></blockquote> |
| 297 |
|
| 298 |
<p>It is possible to omit the <var>type</var> parameter. In this case, |
| 299 |
the type is <var>null</var> and the animation is there only to group |
| 300 |
objets under a single name that can be used in another animation located |
| 301 |
farther in the file. Grouping objects in animations, with a <var>type</var> |
| 302 |
or not, has the effect of reparenting the objects specified in <var>object-name</var>. |
| 303 |
The rule is that the group is inserted between the first object and its parent, |
| 304 |
and then subsequent objects are removed from their original parent and added |
| 305 |
to the new group.</p> |
| 306 |
|
| 307 |
<p>The resulting branch is solid when it comes to compute Height Over Terrain (HOT). |
| 308 |
When an object is there to model a beam of light, or another non solid artefact, it |
| 309 |
can be interesting to ignore it for crash detection. It is done by inserting </p> |
| 310 |
<blockquote><pre><enable-hot type="boolean">false</enable-hot></pre></blockquote> |
| 311 |
<p>in the animation clause. By default, <var>enable-hot</var> is set to true and one |
| 312 |
can land on the roof of a building.</p> |
| 313 |
|
| 314 |
<p>Each animation must be associated with exactly one property from |
| 315 |
the main FlightGear property tree (remember that the properties in the |
| 316 |
wrapper file are not part of the main tree), using <var>property</var> |
| 317 |
to provide the property name:</p> |
| 318 |
|
| 319 |
<blockquote><pre><animation> |
| 320 |
<type>rotate</type> |
| 321 |
<object-name>Rudder</object-name> |
| 322 |
<property>controls/rudder</property> |
| 323 |
</animation> |
| 324 |
</pre></blockquote> |
| 325 |
|
| 326 |
<p>This example rotates the rudder according to the value of the |
| 327 |
<var>/controls/rudder</var> property (or at least, it will when we |
| 328 |
specify the center and axis of rotation below); however, |
| 329 |
<var>/controls/rudder</var> is normalized from -1.0 to 1.0, and we |
| 330 |
probably want to rotate the rudder more than that; as a result, we |
| 331 |
need to use the <var>factor</var> property to do scaling. For |
| 332 |
example, if the rudder on the actual aircraft rotates 18 degrees in |
| 333 |
each direction, we would use a factor of 18 to scale the rudder |
| 334 |
position from -18 degrees to 18 degrees:</p> |
| 335 |
|
| 336 |
<blockquote><pre><animation> |
| 337 |
<type>rotate</type> |
| 338 |
<object-name>Rudder</object-name> |
| 339 |
<property>controls/rudder</property> |
| 340 |
<factor>18</factor> |
| 341 |
</animation> |
| 342 |
</pre></blockquote> |
| 343 |
|
| 344 |
<p>If you wanted to reverse the direction of rudder movement, you |
| 345 |
would use a factor of -18.</p> |
| 346 |
|
| 347 |
<p>There is also an <var>offset-deg</var> property that can be useful for |
| 348 |
starting the rotation from a point other than center. For example, |
| 349 |
let's say that you want the rudder to start 1% to the left rather than |
| 350 |
dead center; you could specify that like this:</p> |
| 351 |
|
| 352 |
<blockquote><pre><animation> |
| 353 |
<type>rotate</type> |
| 354 |
<object-name>Rudder</object-name> |
| 355 |
<property>controls/rudder</property> |
| 356 |
<offset-deg>-0.01</offset-deg> |
| 357 |
<factor>18</factor> |
| 358 |
</animation> |
| 359 |
</pre></blockquote> |
| 360 |
|
| 361 |
<p>The offset is applied <em>after</em> the factor.</p> |
| 362 |
|
| 363 |
<p>Finally, there are <var>min</var> and <var>max</var> properties |
| 364 |
that can constrain the amount of rotation in degrees, as in this (very |
| 365 |
complicated) example for the Cessna 310 landing gear:</p> |
| 366 |
|
| 367 |
<blockquote><pre><animation> |
| 368 |
<type>rotate</type> |
| 369 |
<object-name>NoseWheel</object-name> |
| 370 |
<property>gear/gear[0]/position-norm</property> |
| 371 |
<factor>120</factor> |
| 372 |
<offset-deg>-1</offset-deg> |
| 373 |
<min>-90</min> |
| 374 |
<max>0</max> |
| 375 |
<center> |
| 376 |
<x-m>-2.28</x-m> |
| 377 |
<y-m>0.0</y-m> |
| 378 |
<z-m>-0.65</z-m> |
| 379 |
</center> |
| 380 |
<axis> |
| 381 |
<x>0</x> |
| 382 |
<y>1</y> |
| 383 |
<z>0</z> |
| 384 |
</axis> |
| 385 |
</animation> |
| 386 |
</pre></blockquote> |
| 387 |
|
| 388 |
<p>In this example, the gear position (from 0.0 for fully retracted to |
| 389 |
1.0 for fully extended) is multiplied by a factor of 120 and an offset |
| 390 |
of -1, then clamped to between -90 and 0. In the 3D model, the gear |
| 391 |
is extended by default, so we end up with the following rotations |
| 392 |
through the gear's range of movement:</p> |
| 393 |
|
| 394 |
<table border="1"> |
| 395 |
|
| 396 |
<tbody><tr> |
| 397 |
<th>position-norm</th> |
| 398 |
<th>+ offset -1</th> |
| 399 |
<th>* factor 120</th> |
| 400 |
<th>clamped to min/max -90:0</th> |
| 401 |
<th>comments</th> |
| 402 |
</tr> |
| 403 |
|
| 404 |
<tr> |
| 405 |
<td>0.0</td> |
| 406 |
<td>-1.0</td> |
| 407 |
<td>-120.0</td> |
| 408 |
<td>-90.0</td> |
| 409 |
<td>fully retracted</td> |
| 410 |
</tr> |
| 411 |
|
| 412 |
<tr> |
| 413 |
<td>0.25</td> |
| 414 |
<td>-0.75</td> |
| 415 |
<td>-90.0</td> |
| 416 |
<td>-90.0</td> |
| 417 |
<td>still retracted</td> |
| 418 |
</tr> |
| 419 |
|
| 420 |
<tr> |
| 421 |
<td>0.5</td> |
| 422 |
<td>-0.5</td> |
| 423 |
<td>-60.0</td> |
| 424 |
<td>-50.0</td> |
| 425 |
<td>1/3 extended</td> |
| 426 |
</tr> |
| 427 |
|
| 428 |
<tr> |
| 429 |
<td>0.75</td> |
| 430 |
<td>-0.25</td> |
| 431 |
<td>-30.0</td> |
| 432 |
<td>-30.0</td> |
| 433 |
<td>2/3 extended</td> |
| 434 |
</tr> |
| 435 |
|
| 436 |
<tr> |
| 437 |
<td>1.0</td> |
| 438 |
<td>0.0</td> |
| 439 |
<td>0.0</td> |
| 440 |
<td>0.0</td> |
| 441 |
<td>fully extended (default position)</td> |
| 442 |
</tr> |
| 443 |
|
| 444 |
</tbody></table> |
| 445 |
|
| 446 |
<p>The gear does not move at all during the first 1/4 of the |
| 447 |
position-norm value, giving the doors a chance to open and close in a |
| 448 |
separate animation. Obviously, this would be easier to manage with an |
| 449 |
interpolation table, and future versions of the model animation will |
| 450 |
likely support interpolation.</p> |
| 451 |
|
| 452 |
<p>Update: Interpolation tables our now supported. Each table entry |
| 453 |
plots a dependency point and output values |
| 454 |
are interpolated in a linear manner between two points. In the following |
| 455 |
example an input property value of |
| 456 |
25 will result in an application of a value 65 to the animation |
| 457 |
(65 degrees rotation maybe):</p> |
| 458 |
|
| 459 |
<blockquote><pre> <interpolation> |
| 460 |
<entry> |
| 461 |
<ind>0</ind> |
| 462 |
<dep>0</dep> |
| 463 |
</entry> |
| 464 |
<entry> |
| 465 |
<ind>16.67</ind> |
| 466 |
<dep>60</dep> |
| 467 |
</entry> |
| 468 |
<entry> |
| 469 |
<ind>25</ind> |
| 470 |
<dep>65</dep> |
| 471 |
</entry> |
| 472 |
<entry> |
| 473 |
<ind>33.3333</ind> |
| 474 |
<dep>70</dep> |
| 475 |
</entry> |
| 476 |
<entry> |
| 477 |
<ind>66.6667</ind> |
| 478 |
<dep>71</dep> |
| 479 |
</entry> |
| 480 |
<entry> |
| 481 |
<ind>100</ind> |
| 482 |
<dep>75</dep> |
| 483 |
</entry> |
| 484 |
</interpolation> |
| 485 |
</pre></blockquote> |
| 486 |
|
| 487 |
<p>For a <var>spin</var> animation, the property provides a value in |
| 488 |
revolutions per minute (RPM) rather than an absolute position in |
| 489 |
degrees, and offset is not used. You can still use <var>factor</var> |
| 490 |
to scale the property value if it is not in RPM.</p> |
| 491 |
|
| 492 |
<p>Now, it is necessary to specify the axis of rotation for the |
| 493 |
object, its virtual hinge. This is often the hardest part, requiring |
| 494 |
a lot of trial-and-error when the axis of rotation is not lined up |
| 495 |
with the x-, y-, or z- axis (think of ailerons on a swept wing with a |
| 496 |
non-zero dihedral angle). You need to provide two groups of |
| 497 |
information: a point through which the axis of rotation passes, and |
| 498 |
the direction in which the axis is moving.</p> |
| 499 |
|
| 500 |
<p>Update: there is now an alternate method for specifying axes |
| 501 |
that avoids the trial-and-error approach. See below after the Cessna |
| 502 |
172 animation examples.<p> |
| 503 |
<p>For the point through which the axis passes, you use the |
| 504 |
<var>/center/x-m</var>, <var>/center/y-m</var>, and |
| 505 |
<var>/center/z-m</var> properties to specify a position in meters, |
| 506 |
using the aircraft's coordinate system. Note that this is the system |
| 507 |
before repositioning: if the original model was pointing sideways, |
| 508 |
then your fuselage will run along the y-axis rather than the |
| 509 |
x-axis. Here is an example for a rudder:</p> |
| 510 |
|
| 511 |
<blockquote><pre><animation> |
| 512 |
<type>rotate</type> |
| 513 |
<object-name>Rudder</object-name> |
| 514 |
<property>controls/rudder</property> |
| 515 |
<factor>18</factor> |
| 516 |
<center> |
| 517 |
<x-m>5.45</x-m> |
| 518 |
<y-m>0.0</y-m> |
| 519 |
<z-m>0.0</z-m> |
| 520 |
</center> |
| 521 |
</animation> |
| 522 |
</pre></blockquote> |
| 523 |
|
| 524 |
<p>In this example, the point is right on the y and z axes, but 5.45 |
| 525 |
meters along the x axis (i.e. towards the back of the plane).</p> |
| 526 |
|
| 527 |
<p>Finally, in addition to the center point, it's necessary to specify |
| 528 |
the direction of the axis that passes through it, using the properties |
| 529 |
<var>/axis/x</var>, <var>/axis/y</var>, and <var>axis/z</var>. These |
| 530 |
are unitless values showing the rate of change in each direction; for |
| 531 |
example, a straight up-and-down rotational axis could be specified |
| 532 |
like this:</p> |
| 533 |
|
| 534 |
<blockquote><pre><axis> |
| 535 |
<x>0</x> |
| 536 |
<y>0</y> |
| 537 |
<z>1</z> |
| 538 |
</axis> |
| 539 |
</pre></blockquote> |
| 540 |
|
| 541 |
<p>or like this:</p> |
| 542 |
|
| 543 |
<blockquote><pre><axis> |
| 544 |
<x>0</x> |
| 545 |
<y>0</y> |
| 546 |
<z>1000000</z> |
| 547 |
</axis> |
| 548 |
</pre></blockquote> |
| 549 |
|
| 550 |
<p>Since there's 0 movement along the other two axes, it doesn't |
| 551 |
matter. On the other hand, let's say that the rudder hinge sloped |
| 552 |
back 5% because of a swept tail. In that case, the x-axis would have |
| 553 |
to show some movement as well:</p> |
| 554 |
|
| 555 |
<blockquote><pre><axis> |
| 556 |
<x>0.05</x> |
| 557 |
<y>0</y> |
| 558 |
<z>1</z> |
| 559 |
</axis> |
| 560 |
</pre></blockquote> |
| 561 |
|
| 562 |
<p>That could just as easily be written as</p> |
| 563 |
|
| 564 |
<blockquote><pre><axis> |
| 565 |
<x>1</x> |
| 566 |
<y>0</y> |
| 567 |
<z>20</z> |
| 568 |
</axis> |
| 569 |
</pre></blockquote> |
| 570 |
|
| 571 |
<p>as long as the ratios are the same. For a complicated rotation |
| 572 |
axis, like that for an aileron on a swept-back wing with a significant |
| 573 |
dihedral angle, you'll have to specify movement along all three |
| 574 |
axes:</p> |
| 575 |
|
| 576 |
<blockquote><pre><axis> |
| 577 |
<x>0.15</x> |
| 578 |
<y>1.00</y> |
| 579 |
<z>0.01</z> |
| 580 |
</axis> |
| 581 |
</pre></blockquote> |
| 582 |
|
| 583 |
<p>Here's a complete example, showing the animation for the rudder on |
| 584 |
the Cessna 172:</p> |
| 585 |
|
| 586 |
<blockquote><pre><animation> |
| 587 |
<type>rotate</type> |
| 588 |
<object-name>Rudder</object-name> |
| 589 |
<property>controls/rudder</property> |
| 590 |
<factor>18</factor> |
| 591 |
<center> |
| 592 |
<x-m>5.45</x-m> |
| 593 |
<y-m>0.0</y-m> |
| 594 |
<z-m>0.0</z-m> |
| 595 |
</center> |
| 596 |
<axis> |
| 597 |
<x>0.72</x> |
| 598 |
<y>0.0</y> |
| 599 |
<z>1.0</z> |
| 600 |
</axis> |
| 601 |
</animation> |
| 602 |
</pre></blockquote> |
| 603 |
|
| 604 |
<p>And here's an example of a spin, using the Cessna 172 |
| 605 |
propeller:</p> |
| 606 |
|
| 607 |
<blockquote><pre><animation> |
| 608 |
<type>spin</type> |
| 609 |
<object-name>Propeller</object-name> |
| 610 |
<property>engines/engine[0]/rpm</property> |
| 611 |
<center> |
| 612 |
<x-m>0</x-m> |
| 613 |
<y-m>0</y-m> |
| 614 |
<z-m>-.25</z-m> |
| 615 |
</center> |
| 616 |
<axis> |
| 617 |
<x>1.0</x> |
| 618 |
<y>0.0</y> |
| 619 |
<z>0.0</z> |
| 620 |
</axis> |
| 621 |
</animation> |
| 622 |
</pre></blockquote> |
| 623 |
|
| 624 |
<p>There is an alternate method of specifying the axis that can often be find much easier. |
| 625 |
This method is particularly |
| 626 |
helpful for rotating on axes that are at odd angles, such as ailerons on dihedral swept |
| 627 |
wings.</p> |
| 628 |
|
| 629 |
<p>It is not necessary to specify a <center> tag for this method as it will be calculated |
| 630 |
automatically. The <axis> tag requres two sets of coordinates (x1-m,y1-m,z1-m and |
| 631 |
x2-m,y2-m,z2-m), one for each end of the axis. |
| 632 |
With an aileron, for example, you would need to specify coordinates from both the right and left |
| 633 |
corner of the aileron along the hinged edge. If your object rotates in the direction opposite |
| 634 |
of what you intended you may correct it by simply swapping the two sets of coordinate values (swap x1 |
| 635 |
and x2, y1 and y2, z1 and z2).</p> |
| 636 |
|
| 637 |
<p>Here is an example from the 747-400:</p> |
| 638 |
|
| 639 |
<blockquote><pre><animation> |
| 640 |
<type>rotate</type> |
| 641 |
<object-name>AileronLeftOuter</object-name> |
| 642 |
<property>surface-positions/left-aileron-pos-norm</property> |
| 643 |
<factor>-30</factor> |
| 644 |
<axis> |
| 645 |
<x1-m>18.28</x1-m> |
| 646 |
<y1-m>-21.55</y1-m> |
| 647 |
<z1-m>-0.37</z1-m> |
| 648 |
<x2-m>22.51</x2-m> |
| 649 |
<y2-m>-28.37</y2-m> |
| 650 |
<z2-m>0.08</z2-m> |
| 651 |
</axis> |
| 652 |
</animation> |
| 653 |
</pre></blockquote> |
| 654 |
|
| 655 |
<p>You can get a lot of your initial measurements by viewing the model |
| 656 |
in a 3D editor like <a href="http://prettypoly.sourceforge.net/">PPE</a>, and you can also |
| 657 |
use PPE to name or rename objects so that you can animate them in |
| 658 |
FlightGear. In the end, though, you'll almost have to do a little |
| 659 |
tweaking by trial and error until everything looks right.</p> |
| 660 |
|
| 661 |
<p>This document will likely be out of date by the time you read it. |
| 662 |
Look at the actual XML wrapper files (currently in |
| 663 |
<code>$FG_ROOT/Aircraft/<em>aircraft-type</em>/Models/</code>) to look |
| 664 |
at how FlightGear is doing things now. In the future, we'll be adding |
| 665 |
other animation types, including selecting among different versions of |
| 666 |
the same object (such as a translucent propeller disk for high RPM), |
| 667 |
non-rotational transformations, scaling, and conditionals (i.e. draw |
| 668 |
engine exhaust only above a certain velocity).</p> |
| 669 |
|
| 670 |
<p>It is often desired to apply several animations on the same object. |
| 671 |
It is simply done by specifying multiple animations with the same |
| 672 |
<var>object-name</var>. But you must be aware of the order of execution of |
| 673 |
these specified animations. Every new animation takes precedence over previously |
| 674 |
declared one. As we already seen, each new animation is inserted as the parent |
| 675 |
of the object specified as the first <var>object-name</var>. That means that if |
| 676 |
a rotation is already declared, and a new translation is to be inserted, it will |
| 677 |
be between the rotation and the object, making the translation acting on the |
| 678 |
object, and the rotation acting on the translated object.<br> |
| 679 |
So, as a rule of thumb, remember that animations are executed from the |
| 680 |
bottom of the animation file to its top.</p> |
| 681 |
|
| 682 |
<p>Most animations can be conditioned by a boolean expression on |
| 683 |
properties. A condition is introduced by the <var>condition</var> element, |
| 684 |
like in this example :</p> |
| 685 |
<blockquote><pre> <condition> |
| 686 |
<greater-than> |
| 687 |
<property>sim/time/sun-angle-rad</property> |
| 688 |
<value>1.57</value> |
| 689 |
</greater-than> |
| 690 |
</condition></pre></blockquote> |
| 691 |
<p>Valid condition elements are :</p> |
| 692 |
<blockquote><dl> |
| 693 |
<dt><var>property</var></dt> |
| 694 |
<dd>A valid property full path</dd> |
| 695 |
<dt><var>not</var></dt> |
| 696 |
<dt><var>and</var></dt> |
| 697 |
<dt><var>or</var></dt> |
| 698 |
<dd>Boolean operators</dd> |
| 699 |
<dt><var>less-than</var></dt> |
| 700 |
<dt><var>less-than-equals</var></dt> |
| 701 |
<dt><var>greater-than</var></dt> |
| 702 |
<dt><var>greater-than-equals</var></dt> |
| 703 |
<dt><var>equals</var></dt> |
| 704 |
<dt><var>not-equals</var></dt> |
| 705 |
<dd>Comparison operators</dd> |
| 706 |
<dt><var>value</var></dt> |
| 707 |
<dd>A literal value</dd> |
| 708 |
</dl></blockquote> |
| 709 |
<p>These elements can be combined to build an arbitrary expression.</p> |
| 710 |
<p>Animations without conditions are always executed. Animation with a condition |
| 711 |
are only executed when the condition evaluated to <var>true</var>.</p> |
| 712 |
|
| 713 |
<p>FlightGear sceneries use shared models. These models are loaded once and |
| 714 |
displayed multiple times. If we apply a transformation on an object of the model, |
| 715 |
every occurence of the model will show the same transformation, creating a |
| 716 |
very unnatural unison. To solve this kind of problem, several animations |
| 717 |
support the notion of personality. It means that a set of parameters are able |
| 718 |
to randomly vary in a specified range if the <var>use-personality</var> boolean |
| 719 |
property is set to <var>true</var>. For the moment, <var>spin</var> and <var>timed</var> |
| 720 |
animations support personality.</p> |
| 721 |
|
| 722 |
<h3><a name="select">"select" animation type</a></h3> |
| 723 |
|
| 724 |
<p>The select animation is there to remove objects ( specified in the <var>object-name</var> |
| 725 |
elements ) from the scene when the associated condition evaluated to <var>false</var>.</p> |
| 726 |
<p>In the example below :</p> |
| 727 |
<blockquote><pre> <animation> |
| 728 |
<type>select</type> |
| 729 |
<object-name>StrobesOn</object-name> |
| 730 |
<object-name>StrobesOff</object-name> |
| 731 |
<object-name>Fixed</object-name> |
| 732 |
<condition> |
| 733 |
<greater-than> |
| 734 |
<property>sim/time/sun-angle-rad</property> |
| 735 |
<value>1.57</value> |
| 736 |
</greater-than> |
| 737 |
</condition> |
| 738 |
</animation></pre></blockquote> |
| 739 |
<p>Objects <var>StrobesOn</var>, <var>StrobesOff</var> and <var>Fixed</var> are only present |
| 740 |
in the scene ( displayed ) when the sun is below the horizon ( the meaning of the condition). |
| 741 |
In other words, these objects, that are already in the scene because they were added by the |
| 742 |
designer of the model, are removed when the sun is above the horizon.</p> |
| 743 |
|
| 744 |
<h3><a name="timed">"timed" animation type</a></h3> |
| 745 |
|
| 746 |
<p>The timed animation selects only one object among those specified by <var>object-name</var> |
| 747 |
for a specified duration. When the displayed time ends, the next object is selected for the |
| 748 |
matching duration.</p> |
| 749 |
<p>The simpler form is :</p> |
| 750 |
<blockquote><pre> <animation> |
| 751 |
<name>BeaconFlasher</name> |
| 752 |
<type>timed</type> |
| 753 |
<object-name>BeaconOff</object-name> |
| 754 |
<object-name>BeaconOn</object-name> |
| 755 |
<duration-sec>1.0</duration-sec> |
| 756 |
</animation></pre></blockquote> |
| 757 |
<p>In this example, each object is displayed during an equal time, specified in seconds.</p> |
| 758 |
<p>This second example use personality :</p> |
| 759 |
<blockquote><pre> <animation> |
| 760 |
<type>timed</type> |
| 761 |
<object-name>StrobesOn</object-name> |
| 762 |
<object-name>StrobesOff</object-name> |
| 763 |
<use-personality type="bool">true</use-personality> |
| 764 |
<branch-duration-sec> |
| 765 |
<random> |
| 766 |
<min>0.9</min> |
| 767 |
<max>1.1</max> |
| 768 |
</random> |
| 769 |
</branch-duration-sec> |
| 770 |
<branch-duration-sec> |
| 771 |
<random> |
| 772 |
<min>0.9</min> |
| 773 |
<max>1.1</max> |
| 774 |
</random> |
| 775 |
</branch-duration-sec> |
| 776 |
</animation></pre></blockquote> |
| 777 |
<p>In this case, there is a <var>branch-duration-sec</var> element for each |
| 778 |
<var>object-name</var> that specify a duration for that object. The value of |
| 779 |
<var>branch-duration-sec</var> could be a literal double value in seconds.<br> |
| 780 |
Here, literals have been replaced by the <var>random</var> element. It means |
| 781 |
that the duration is choosen randomly between <var>min</var> and <var>max</var>. |
| 782 |
Because of the <var>use-personality</var> element set to true, durations are |
| 783 |
allowed to be different for each occurence of this model, breaking the announced |
| 784 |
unison.</p> |
| 785 |
|
| 786 |
<h3><a name="scale">"scale" animation type</a></h3> |
| 787 |
|
| 788 |
<p>Here is a contrived example of one way to use the "scale" animation |
| 789 |
type. In this case a shadow map is placed below the aircraft and we |
| 790 |
can control the size based on some property value (i.e. alitutude |
| 791 |
above the ground.) In real life, the shadow size should stay pretty |
| 792 |
much fixed, so this technique might ultimately be more useful for a |
| 793 |
landing light.</p> |
| 794 |
|
| 795 |
<blockquote><pre> <animation> |
| 796 |
<type>scale</type> |
| 797 |
<object-name>ShadowMap</object-name> |
| 798 |
<property>position/altitude-agl-ft</property> |
| 799 |
<x-factor>0.05</x-factor> |
| 800 |
<x-offset>1.0</x-offset> |
| 801 |
<y-factor>0.05</y-factor> |
| 802 |
<y-offset>1.0</y-offset> |
| 803 |
<z-factor>0.0</z-factor> |
| 804 |
<z-offset>1.0</z-offset> |
| 805 |
<center> |
| 806 |
<x-m>0.05</x-m> |
| 807 |
<y-m>0.05</y-m> |
| 808 |
<z-m>0.0</z-m> |
| 809 |
</center> |
| 810 |
</animation> |
| 811 |
</pre></blockquote> |
| 812 |
|
| 813 |
<p>As with the other animations, you need to specify an object-name and |
| 814 |
the property that will drive this animation. And, as with other types |
| 815 |
of transform animations, the order they are applied is important. For |
| 816 |
a given object, you will probably want to put the scaling animation |
| 817 |
after any other translate or rotate animations.</p> |
| 818 |
|
| 819 |
<p>You have some individual control over the X, Y, and Z axis scaling. |
| 820 |
For each dimension you can provide factors (x-factor, y-factor, and |
| 821 |
z-factor) and also offsets (x-offset, y-offset, and z-offset.) You |
| 822 |
can also specify minimum values (x-min, y-min, z-min) and maximum |
| 823 |
values (x-max, y-max, and z-max) for scaling results.</p> |
| 824 |
|
| 825 |
<p>You can set the center of scaling with the center tag. The center is |
| 826 |
that point that does not ever change its position under any scaling. |
| 827 |
If unset this defaults to the (0, 0, 0).</p> |
| 828 |
|
| 829 |
<p>The amount of scaling for each dimension is computed by the |
| 830 |
following formula (and then clamped if a min or max value is |
| 831 |
specified.)</p> |
| 832 |
|
| 833 |
<blockquote><pre> scale = property * factor + offset |
| 834 |
</pre></blockquote> |
| 835 |
|
| 836 |
<p>Specifying a factor of 0.0 and an offset of 1.0 is equivalent to no |
| 837 |
scaling at all.</p> |
| 838 |
|
| 839 |
<p>As you can see in the above example, at ground level (the property |
| 840 |
value = 0.0) the scaling formula will evaluate to 1.0 (no scaling.) |
| 841 |
As altitude above the ground increases, the scaling factor will |
| 842 |
increase by agl * 0.05 + 1.0. Note that because a shadow has no depth |
| 843 |
we use a z-factor of 0.0 and a z-offset of 1.0 so the formula always |
| 844 |
evalutes to a scaling factor of 1.0 in the Z dimension.</p> |
| 845 |
|
| 846 |
<h3><a name="blend">"blend" animation type</a></h3> |
| 847 |
|
| 848 |
<p>The blend animation type can be used to adjust the transparency of |
| 849 |
an object. To controll it's behavior it is possible to define:</p><p> |
| 850 |
|
| 851 |
<table> |
| 852 |
<tbody><tr> |
| 853 |
<td><b>property</b></td> |
| 854 |
<td><i>use the value of this property in the calculation</i></td> |
| 855 |
</tr> |
| 856 |
<tr> |
| 857 |
<td><b>offset</b></td> |
| 858 |
<td><i>offset, ranges from 0.0 to 1.0</i></td> |
| 859 |
</tr> |
| 860 |
<tr> |
| 861 |
<td><b>factor</b></td> |
| 862 |
<td><i>multiplication factor for the property</i></td> |
| 863 |
</tr> |
| 864 |
</tbody></table> |
| 865 |
|
| 866 |
</p><p>The formula used is: |
| 867 |
</p><blockquote><pre>alpha = property * factor + offset |
| 868 |
</pre></blockquote> |
| 869 |
|
| 870 |
<p>The result should be between 0.0 and 1.0 where 0.0 equals to a fully visible model and 1.0 equals to a fully transparent model.</p> |
| 871 |
|
| 872 |
<p>To gain greater controll over the result it is possible to limit |
| 873 |
the result by defining a <min> and/or a <max> parameter. |
| 874 |
</p> |
| 875 |
|
| 876 |
<p><strong>Note:</strong> This |
| 877 |
effect will only work if there is already a transparent component in the |
| 878 |
object, either in the vertex color or in the texture. |
| 879 |
|
| 880 |
|
| 881 |
|
| 882 |
<h3><a name="texrotate">"texrotate" texture rotation animation type</a></h3> |
| 883 |
|
| 884 |
<p>This animation will adjust the texture mapping on an object |
| 885 |
so that the texture image appears to rotate about |
| 886 |
the specified center on the object. Note that when talking |
| 887 |
about texture mapping, meaningful values are from |
| 888 |
0.0 ~ 1.0. Texture coordinates are commonly specified as (u,v). |
| 889 |
A square object's lower left corner would generally be |
| 890 |
specified as (u=0,v=0) and the upper right corner as (u=1,v=1). The |
| 891 |
center will be (u=0.5, v=0.5). These values |
| 892 |
will be vary (within the 0.0 ~ 1.0 range) if only a portion of a texture is |
| 893 |
mapped (see compass rose example below).</p> |
| 894 |
|
| 895 |
<p>For the purpose of specifying the <center> tag |
| 896 |
you need only use the x and y coordinates. |
| 897 |
The <axis> tag usually only requires a value for z. It is possible to |
| 898 |
obtain some unusual texture mapping effects, like as giving the illusion of |
| 899 |
perspective on a flat stationary surface by using the other axes. Here is |
| 900 |
an example of a rotating compass rose on the 747-400 PDF |
| 901 |
(primary flight display):<p> |
| 902 |
|
| 903 |
<blockquote><pre> <animation> |
| 904 |
<type>texrotate</type> |
| 905 |
<object-name>rose</object-name> |
| 906 |
<property>orientation/heading-magnetic-deg</property> |
| 907 |
<center> |
| 908 |
<x>0.75</x> |
| 909 |
<y>0.75</y> |
| 910 |
<z>0.0</z> |
| 911 |
</center> |
| 912 |
<axis> |
| 913 |
<x>0</x> |
| 914 |
<y>0</y> |
| 915 |
<z>-1</z> |
| 916 |
</axis> |
| 917 |
</animation> |
| 918 |
</pre></blockquote> |
| 919 |
|
| 920 |
<p>The center in this example is (0.75, 0.75) because the compass |
| 921 |
rose only occupies the upper right corner of the total |
| 922 |
texture image that it is contained in. The other three quardrants |
| 923 |
have other textures for the same model. As mentioned |
| 924 |
before, the coordinates are (0,0) lower left to (1,1) upper right, |
| 925 |
the center of the upper right quadrant is thus (0.75, 0.75). |
| 926 |
|
| 927 |
<h3><a name="textranslate">"textranslate" texture translation animation type</a></h3> |
| 928 |
|
| 929 |
<p>This animation will adjust the texture mapping on an object so |
| 930 |
that the texture image appears to slides around |
| 931 |
on the object. An <axis> tag is required to specify the axis |
| 932 |
along which the texture is moved (the direction of movement). The |
| 933 |
following example displays the right most digit in the altitude indicator |
| 934 |
on the primary flight display:</p> |
| 935 |
|
| 936 |
<blockquote><pre> <animation> |
| 937 |
<type>textranslate</type> |
| 938 |
<object-name>alt1</object-name> |
| 939 |
<property>position/altitude-ft</property> |
| 940 |
<factor>0.01</factor> |
| 941 |
<axis> |
| 942 |
<x>0</x> |
| 943 |
<y>1</y> |
| 944 |
<z>0</z> |
| 945 |
</axis> |
| 946 |
</animation> |
| 947 |
</pre></blockquote> |
| 948 |
|
| 949 |
<p>There are also some special properties available for use in the texture animations. These are:</p> |
| 950 |
|
| 951 |
<ol> |
| 952 |
<li>step</li> |
| 953 |
<li>scroll</li> |
| 954 |
<li>bias</li> |
| 955 |
</ol> |
| 956 |
|
| 957 |
<p>The <step> tag is useful if you want animations to |
| 958 |
happen in steps rather than smoothly. It causes values that are |
| 959 |
fractional (between) steps size to be ingnored. It can be used for |
| 960 |
things like changing digits on nurmeric displays or a ticking second |
| 961 |
hand on a clock. The <scroll> tag works with the |
| 962 |
<step> tag. The scroll value specifies the distance the input |
| 963 |
property value should be from a step when scrolling to the next |
| 964 |
position begins. This type of scrolling is common on EFIS cockpit |
| 965 |
displays. The following example gives an "odometer effect" |
| 966 |
where the hundreds position digit doesn't move until the input value |
| 967 |
is within is within 1 (e.g. > 99):</p> |
| 968 |
|
| 969 |
<blockquote><pre><animation> |
| 970 |
<type>textranslate</type> |
| 971 |
<object-name>asi3</object-name> |
| 972 |
<property>velocities/airspeed-kt</property> |
| 973 |
<factor>0.001</factor> |
| 974 |
<step>100</step> |
| 975 |
<scroll>1</scroll> |
| 976 |
<axis> |
| 977 |
<x>0</x> |
| 978 |
<y>1</y> |
| 979 |
<z>0</z> |
| 980 |
</axis> |
| 981 |
</animation> |
| 982 |
</pre></blockquote> |
| 983 |
|
| 984 |
<p>The <bias> tag was added because the normal tags for adjusting properties, <offset> and |
| 985 |
<factor> are applied after the <step> tag. The <bias> tag allows you to apply an |
| 986 |
offset before the <step> tag and, for example, fix the a radio frequency to display correctly.</p> |
| 987 |
|
| 988 |
<blockquote><pre><animation> |
| 989 |
<type>textranslate</type> |
| 990 |
<object-name>comm-digit1</object-name> |
| 991 |
<property>instrumentation/comm/frequencies/standby-mhz</property> |
| 992 |
<factor>10.0</factor> |
| 993 |
<step>0.01</step> |
| 994 |
<bias>0.005</bias> |
| 995 |
<axis> |
| 996 |
<x>0</x> |
| 997 |
<y>1</y> |
| 998 |
<z>0</z> |
| 999 |
</axis> |
| 1000 |
</animation> |
| 1001 |
</pre></blockquote> |
| 1002 |
|
| 1003 |
<h3><a name="textmultiple">"textmultiple" type, combining texture animation types</a></h3> |
| 1004 |
|
| 1005 |
<p>The textmultiple animation type isn't a real animation type, but |
| 1006 |
instead it is a method of combining multiple texture |
| 1007 |
tansform operations on the same object. Unlike object vertex |
| 1008 |
operations, texture operations can not be stacked, |
| 1009 |
which means that if you configure two or more texture animation tags |
| 1010 |
on the same object, only the first in the list will be used. By |
| 1011 |
listing operations using texmultiple they are combined together in |
| 1012 |
Simgear and then handled as a single operation.</p> |
| 1013 |
|
| 1014 |
<p>If you need to combine together a translation and rotation |
| 1015 |
this is the only way to do it currently. Note that |
| 1016 |
transform operations are applied in the same order that they are |
| 1017 |
listed in the configuration file. The following |
| 1018 |
example for the horizon texture from the 747-400 primary flight |
| 1019 |
display explains the format clearly:</p> |
| 1020 |
|
| 1021 |
<blockquote><pre><animation> |
| 1022 |
<type>texmultiple</type> |
| 1023 |
<object-name>horizon</object-name> |
| 1024 |
<transform> |
| 1025 |
<property>orientation/pitch-deg</property> |
| 1026 |
<subtype>textranslate</subtype> |
| 1027 |
<factor>0.0045</factor> |
| 1028 |
<axis> |
| 1029 |
<x>0</x> |
| 1030 |
<y>1</y> |
| 1031 |
<z>0</z> |
| 1032 |
</axis> |
| 1033 |
</transform> |
| 1034 |
<transform> |
| 1035 |
<property>orientation/roll-deg</property> |
| 1036 |
<subtype>texrotate</subtype> |
| 1037 |
<center> |
| 1038 |
<x>0.50</x> |
| 1039 |
<y>0.50</y> |
| 1040 |
</center> |
| 1041 |
<axis> |
| 1042 |
<x>0</x> |
| 1043 |
<y>0</y> |
| 1044 |
<z>-1</z> |
| 1045 |
</axis> |
| 1046 |
</transform> |
| 1047 |
</animation> |
| 1048 |
</pre></blockquote> |
| 1049 |
<h3><a name="range">"range" animation type</a></h3> |
| 1050 |
<p>The range type is used to select part of a model using its distance from the |
| 1051 |
viewer as the criterion. To be viewed, the model must be between a minimum |
| 1052 |
distance and a maximum one. Minimum distance can be specified either with the |
| 1053 |
<min-m> element or the <min-property> element that are exclusive. |
| 1054 |
The first one allow to specify a fixed distance in meters, the latter allow to |
| 1055 |
lookup the value from a property. Both can be multiplied by a fixed amount, |
| 1056 |
specified in the <min-factor> element. The same apply for the maximum |
| 1057 |
value with <max-m>, <max-property> and <max-factor> elements. |
| 1058 |
The example below shows how it can be used :</p> |
| 1059 |
<blockquote> |
| 1060 |
<pre><animation> |
| 1061 |
<type>range</type> |
| 1062 |
<object-name>Detailed</object-name> |
| 1063 |
<min-m>0</min-m> |
| 1064 |
<max-property>/sim/rendering/static-lod/detailed</max-property> |
| 1065 |
</animation> |
| 1066 |
</pre> |
| 1067 |
</blockquote> |
| 1068 |
<h3><a name="alphatest">"alpha-test" animation type</a></h3> |
| 1069 |
<p>This "animation" is a way to set an alpha test on a model branch. The effect |
| 1070 |
is to avoid depth buffer writing of pixel that are not seen because they are |
| 1071 |
transparent. This is particulary useful when modeling a metallic structure or a |
| 1072 |
tree with a billboard. The threshold of transparency is set with the |
| 1073 |
<alpha-factor> element like this :</p> |
| 1074 |
<blockquote> |
| 1075 |
<pre><animation> |
| 1076 |
<type>alpha-test</type> |
| 1077 |
<object-name>Detailed</object-name> |
| 1078 |
<alpha-factor>0.01</alpha-factor> |
| 1079 |
</animation> |
| 1080 |
</pre> |
| 1081 |
</blockquote> |
| 1082 |
|
| 1083 |
<h3><a name="noshadow">"noshadow" animation type</a></h3> |
| 1084 |
<p>This "animation" prevents the shadow casting code to include this object, |
| 1085 |
which might be handy when it doesn't cast a shadow (exhaust flame) or when |
| 1086 |
it looks ugly.</p> |
| 1087 |
<blockquote> |
| 1088 |
<pre><animation> |
| 1089 |
<type>noshadow</type> |
| 1090 |
<object-name>Wires.1</object-name> |
| 1091 |
<object-name>Wires.2</object-name> |
| 1092 |
</animation> |
| 1093 |
</pre> |
| 1094 |
</blockquote> |
| 1095 |
|
| 1096 |
<h3><a name="dist-scale">"dist-scale" animation type</h3> |
| 1097 |
<p>This animation enables to scale an object based on the distance of its |
| 1098 |
center to the viewer. It was designed to compensate the effect of fog on |
| 1099 |
emissive (light) sources that is too strong ( lights are hardly visible at distance )<br> |
| 1100 |
Parameters, with default values, are :</p> |
| 1101 |
<blockquote> |
| 1102 |
<pre><animation> |
| 1103 |
<type>dist-scale</type> |
| 1104 |
<object-name>RedLight.11</object-name> |
| 1105 |
<factor>1.0</factor> |
| 1106 |
<offset>0.0</offset> |
| 1107 |
<min>0.0</min> |
| 1108 |
<max>1.0</max> |
| 1109 |
<center> |
| 1110 |
<x-m>0.0</x-m> |
| 1111 |
<y-m>0.0</y-m> |
| 1112 |
<z-m>0.0</z-m> |
| 1113 |
</center> |
| 1114 |
</animation> |
| 1115 |
</pre> |
| 1116 |
</blockquote> |
| 1117 |
<p>Or, with an interpolation table :</p> |
| 1118 |
<blockquote> |
| 1119 |
<pre><animation> |
| 1120 |
<type>dist-scale</type> |
| 1121 |
<object-name>RedLight.11</object-name> |
| 1122 |
<interpolation> |
| 1123 |
<entry><ind>0</ind><dep>0.1</dep></entry> |
| 1124 |
<entry><ind>500</ind><dep>0.2</dep></entry> |
| 1125 |
<entry><ind>16000</ind><dep>3</dep></entry> |
| 1126 |
</interpolation> |
| 1127 |
<min>0.0</min> |
| 1128 |
<max>3.0</max> |
| 1129 |
<center> |
| 1130 |
<x-m>0.0</x-m> |
| 1131 |
<y-m>0.0</y-m> |
| 1132 |
<z-m>0.0</z-m> |
| 1133 |
</center> |
| 1134 |
</animation> |
| 1135 |
</pre> |
| 1136 |
</blockquote> |
| 1137 |
|
| 1138 |
<h3><a name="flash">"flash" animation type</h3> |
| 1139 |
<p>This animation was designed to scale an object based on the angle between |
| 1140 |
an arbitrary axis and the axis that goes between the viewer and the center of |
| 1141 |
the object. The sought effect was the <i>flash</i> of a lighthouse or beacon, |
| 1142 |
or whatever intense narrow light beam, hence the name.<br> |
| 1143 |
Parameters, with default values, are :</p> |
| 1144 |
<blockquote> |
| 1145 |
<pre><animation> |
| 1146 |
<type>flash</type> |
| 1147 |
<object-name>WhiteFlash.2</object-name> |
| 1148 |
<offset>0.0</offset> |
| 1149 |
<factor>1.0</factor> |
| 1150 |
<power>1.0</power> |
| 1151 |
<two-sides type="boolean">false</two-sides> |
| 1152 |
<min>0.0</min> |
| 1153 |
<max>1.0</max> |
| 1154 |
<center> |
| 1155 |
<x-m>0.0</x-m> |
| 1156 |
<y-m>0.0</y-m> |
| 1157 |
<z-m>0.0</z-m> |
| 1158 |
</center> |
| 1159 |
<axis> |
| 1160 |
<x>0.0</x> |
| 1161 |
<y>0.0</y> |
| 1162 |
<z>1.0</z> |
| 1163 |
</axis> |
| 1164 |
</animation> |
| 1165 |
</pre> |
| 1166 |
</blockquote> |
| 1167 |
<p>The scale formulae is :<br> |
| 1168 |
<center>S = factor * pow( cos_angle, power ) + offset</center><br> |
| 1169 |
cos_angle being the cosine of the angle between the axis and the line |
| 1170 |
between the center and the viewer.<br> |
| 1171 |
The value S is clamped between min and max.<br> |
| 1172 |
No interpolation table is allowed in this animation. |
| 1173 |
</p> |
| 1174 |
|
| 1175 |
<h3><a name="material">"material" animation type</a></h3> |
| 1176 |
<p>This "animation" can set any of the material properties on a model branch, including |
| 1177 |
the texture file path. The following minimalistic example animation allows to change the |
| 1178 |
"panel" object's emissive color from (0,0,0) to (1,.2,0) by setting the factor property |
| 1179 |
to values between 0.0 and 1.0.</p> |
| 1180 |
|
| 1181 |
<blockquote> |
| 1182 |
<pre><animation> |
| 1183 |
<type>material</type> |
| 1184 |
<object-name>panel</object-name> |
| 1185 |
<emission> |
| 1186 |
<red>1.0</red> |
| 1187 |
<green>0.2</green> |
| 1188 |
<blue>0.0</blue> |
| 1189 |
<factor-prop>/controls/lighting/instruments-norm</factor-prop> |
| 1190 |
</emission> |
| 1191 |
</animation> |
| 1192 |
</pre> |
| 1193 |
</blockquote> |
| 1194 |
|
| 1195 |
|
| 1196 |
<p>Changes made with this animation type are by default only effective for the objects listed in |
| 1197 |
<object-name> tags, whereby you can use more than one of those. The next example, however, |
| 1198 |
sets the optional <global> property, so that changes affect all objects that share |
| 1199 |
the same material. This is the preferred method and should be used whereever possible. It isn't |
| 1200 |
only faster, but also doesn't break other animations by forcing objects into the same branch. |
| 1201 |
Note that all material properties can be set to fixed values, for instance <red> or, by appending |
| 1202 |
"-prop", to the contents of another property node: <red-prop>. Because a "material" animation |
| 1203 |
can contain a lot of such property paths, which is a nuisance to write, hard to read, and a potential |
| 1204 |
source for typos, there's a <property-base> component. Its string value is prepended to |
| 1205 |
all material property names (but not to property paths in a <condition> statement!). |
| 1206 |
The following example shows all available elements:</p> |
| 1207 |
|
| 1208 |
<blockquote> |
| 1209 |
<pre><animation> |
| 1210 |
<type>material</type> |
| 1211 |
<object-name>fuselage</object-name> |
| 1212 |
<condition> |
| 1213 |
<property>sim/model/foo/animate-fuselage-material</property> |
| 1214 |
</condition> |
| 1215 |
<global type="bool">true</global> |
| 1216 |
<property-base>/sim/model/foo/material/fuselage</property-base> |
| 1217 |
<diffuse> |
| 1218 |
<red-prop>diffuse/red</red-prop> |
| 1219 |
<green-prop>diffuse/green</green-prop> |
| 1220 |
<blue-prop>diffuse/blue</blue-prop> |
| 1221 |
<factor-prop>diffuse/factor</factor-prop> |
| 1222 |
<offset-prop>diffuse/offset</offset-prop> |
| 1223 |
</diffuse> |
| 1224 |
<ambient> |
| 1225 |
<red-prop>ambient/red</red-prop> |
| 1226 |
<green-prop>ambient/green</green-prop> |
| 1227 |
<blue-prop>ambient/blue</blue-prop> |
| 1228 |
<factor-prop>ambient/factor</factor-prop> |
| 1229 |
<offset-prop>ambient/offset</offset-prop> |
| 1230 |
</ambient> |
| 1231 |
<emission> |
| 1232 |
<red-prop>emission/red</red-prop> |
| 1233 |
<green-prop>emission/green</green-prop> |
| 1234 |
<blue-prop>emission/blue</blue-prop> |
| 1235 |
<factor-prop>emission/factor</factor-prop> |
| 1236 |
<offset-prop>emission/offset</offset-prop> |
| 1237 |
</emission> |
| 1238 |
<specular> |
| 1239 |
<red-prop>specular/red</red-prop> |
| 1240 |
<green-prop>specular/green</green-prop> |
| 1241 |
<blue-prop>specular/blue</blue-prop> |
| 1242 |
<factor-prop>specular/factor</factor-prop> |
| 1243 |
<offset-prop>specular/offset</offset-prop> |
| 1244 |
</specular> |
| 1245 |
<shininess> |
| 1246 |
<transparency> |
| 1247 |
<alpha-prop>transparency/alpha</alpha-prop> |
| 1248 |
<factor-prop>transparency/factor</factor-prop> |
| 1249 |
<offset-prop>transparency/offset</offset-prop> |
| 1250 |
<min>0.0<min> <!-- no min-prop! --> |
| 1251 |
<max>1.0<max> <!-- no max-prop! --> |
| 1252 |
</transparency> |
| 1253 |
<texture>texture</texture> |
| 1254 |
<threshold>threshold</threshold> |
| 1255 |
</animation> |
| 1256 |
</pre> |
| 1257 |
</blockquote> |
| 1258 |
|
| 1259 |
<p>A change to one of the components in each color group does always update |
| 1260 |
all three color components. Unset values default to zero. The <texture> path |
| 1261 |
is relative to the model's <texture-path> directory, or, if unset, to the model |
| 1262 |
directory. All numerical values are clamped to 0.0-1.0, except <shininess>, which is |
| 1263 |
clamped to 0.0-128.0. The <alpha> property (<transparency> group) makes an |
| 1264 |
object fully transparent (and thus invisible) with 0.0, and fully opaque with 1.0. |
| 1265 |
("alpha" could also be called "opaqueness".) The <threshold> property sets the |
| 1266 |
alpha/opaqueness threshold. It is only relevant for semitransparent textures. Only parts |
| 1267 |
of the texture that are more opaque than this are diplayed at all. If it is set |
| 1268 |
to 0.0, all parts of the texture will be shown. If it is 0.5, only parts with |
| 1269 |
opaqueness greater than 0.5 (or transparency less than 0.5) are shown.</p> |
| 1270 |
|
| 1271 |
<p>Note that defining two or more of these animations for the same object, |
| 1272 |
or a mixture of "material" and "blend" animations, will probably not yield |
| 1273 |
the result that you expect. Try to put all state manipulations for one |
| 1274 |
object or material in one "material" animation, and use its "transparency" |
| 1275 |
property instead of an extra "blend" animation.</p> |
| 1276 |
|
| 1277 |
<p>To make a texture replaceable at runtime, use a "material" animation |
| 1278 |
like this:</p> |
| 1279 |
|
| 1280 |
<blockquote> |
| 1281 |
<pre><animation> |
| 1282 |
<type>material</type> |
| 1283 |
<object-name>tail-vert</object-name> |
| 1284 |
<texture-prop>/sim/model/foo/texture</texture-prop> |
| 1285 |
</animation> |
| 1286 |
</pre> |
| 1287 |
</blockquote> |
| 1288 |
|
| 1289 |
<p>and put something like this into your aircraft's *-set.xml file:</p> |
| 1290 |
|
| 1291 |
<blockquote> |
| 1292 |
<pre><sim> |
| 1293 |
<model> |
| 1294 |
<foo> |
| 1295 |
<texture>logos/tail-logo.rgb</texture> |
| 1296 |
</foo> |
| 1297 |
</model> |
| 1298 |
</sim> |
| 1299 |
</pre> |
| 1300 |
</blockquote> |
| 1301 |
|
| 1302 |
|
| 1303 |
<p>You can explore the influence of material changes at runtime, if you use |
| 1304 |
a material animation like the above complete example, and call the material |
| 1305 |
dialog on it, like in the following Nasal example. Note, that the path is |
| 1306 |
the same that you would set in <property-base>. |
| 1307 |
</p> |
| 1308 |
|
| 1309 |
<blockquote> |
| 1310 |
<pre>material.showDialog("/sim/model/foo/material/fuselage");</pre> |
| 1311 |
</blockquote> |
| 1312 |
|
| 1313 |
<h3><a name="pick">"pick" animation type</h3> |
| 1314 |
<p>This animation type is used to execute a command binding when the mouse |
| 1315 |
is pressed on this particular object. The Commands are the usual bindings |
| 1316 |
like used elsewhere in flightgear. |
| 1317 |
<p>The visible property tells if the object should be visible as is. Setting |
| 1318 |
that to false make sense if you have small buttons on the instrument model |
| 1319 |
but you want to have huge active areas for interaction. It defaults to true. |
| 1320 |
<blockquote> |
| 1321 |
<pre><animation> |
| 1322 |
<type>pick</type> |
| 1323 |
<object-name>Button</object-name> |
| 1324 |
<visible>true</visible> |
| 1325 |
<action> |
| 1326 |
<button>0</button> |
| 1327 |
<repeatable>true</repeatable> |
| 1328 |
<interval-sec>0.1</interval-sec> |
| 1329 |
<binding> |
| 1330 |
<command>property-assign</command> |
| 1331 |
<property>instrumentation/button0-pressed</property> |
| 1332 |
<value>1</value> |
| 1333 |
</binding> |
| 1334 |
<mod-up> |
| 1335 |
<binding> |
| 1336 |
<command>property-assign</command> |
| 1337 |
<property>instrumentation/button0-pressed</property> |
| 1338 |
<value>0</value> |
| 1339 |
</binding> |
| 1340 |
</mod-up> |
| 1341 |
</action> |
| 1342 |
<action> |
| 1343 |
<button>1</button> |
| 1344 |
<repeatable>true</repeatable> |
| 1345 |
<interval-sec>0.1</interval-sec> |
| 1346 |
<binding> |
| 1347 |
<command>property-assign</command> |
| 1348 |
<property>instrumentation/button1-pressed</property> |
| 1349 |
<value>1</value> |
| 1350 |
</binding> |
| 1351 |
<mod-up> |
| 1352 |
<binding> |
| 1353 |
<command>property-assign</command> |
| 1354 |
<property>instrumentation/button1-pressed</property> |
| 1355 |
<value>0</value> |
| 1356 |
</binding> |
| 1357 |
</mod-up> |
| 1358 |
</action> |
| 1359 |
</animation></pre> |
| 1360 |
</blockquote> |
| 1361 |
</p> |
| 1362 |
|
| 1363 |
<hr> |
| 1364 |
<address>David Megginson, 11 March 2002</address> |
| 1365 |
<address>Mathias Fröhlich, 3 Jan 2007</address> |
| 1366 |
|
| 1367 |
</div> |
| 1368 |
</td></tr> |
| 1369 |
</tbody> |
| 1370 |
</table> |
| 1371 |
<br> |
| 1372 |
</body> |
| 1373 |
|
| 1374 |
</html> |
| 1375 |
|
| 1376 |
|