Howto:Animate models: Difference between revisions

m
fixed typo
m (fixed typo)
(11 intermediate revisions by 4 users not shown)
Line 15: Line 15:
'''Note for SketchUp users:''' when exporting to AC3D in Sketchup, the .ac file will name the objects in your model to "blah" by default. You need to amend the relevant object names in your .ac file using text edit, so that the xml will work.
'''Note for SketchUp users:''' when exporting to AC3D in Sketchup, the .ac file will name the objects in your model to "blah" by default. You need to amend the relevant object names in your .ac file using text edit, so that the xml will work.


== Special code parts ==
== Tags used in most animations ==
=== Name ===
With a name animation, you can group multiple objects.
 
<source>
<animation>
  <name>Collection1</name>
  <object-name>Object1</object-name>
  <object-name>Object2</object-name>
  <object-name>Object3</object-name>
</animation>
</source>
 
The example above creates a "virtual object" with the name Collection1. In animation, we can animate this group of objects, by using:
 
<source>
<object-name>Collection1</object-name>
</source>
 
=== Object-name ===
These names are set in the 3D model. Each single object has a unique name; for easy identification it is advised to use descriptive names (LeftElevator, Rudder etc.). Animations are only applied to those objects that are mentioned in an object-name line (one object per line!). Animations lacking those, will be applied to the entire model.
 
=== Property ===
Each animation must be associated with exactly one property from the main FlightGear property tree (remember that the properties in the wrapper file are not part of the main tree), using <code><property></code> to provide the property path:
 
<source>
<animation>
  <type>rotate</type>
  <object-name>Rudder</object-name>
  <property>controls/rudder</property>
</animation>
</source>
 
Note the omission of the leading slash '/' when reffering to the property. This assures that when the model is used for AI or multiplayer traffic the animations will follow that of the AI controller instead of that of the user.
 
=== Axis ===
=== Axis ===
An axis part is required in every animation that involves a rotating or moving thing.
An axis part is required in every animation that involves a rotating or moving thing.
Line 45: Line 79:


=== Center ===
=== Center ===
Various animations ([[#Rotate|rotate]], [[#Spin|spin]]) move around a center point.
Various animations ([[#Rotate|rotate]], [[#Spin|spin]], [[#Scale|scale]]) move around a center point.


<source>
<source>
Line 57: Line 91:
The axis are similar to the ones of the 3D model, so finding coordinates is easily done in 3D modeling software.
The axis are similar to the ones of the 3D model, so finding coordinates is easily done in 3D modeling software.


== Additional tags that can be used in most animations ==
=== Conditions ===
=== Conditions ===
Multiple animations can make use of a conditional. Check <tt>$FGDATA/Docs/README.conditions</tt> for some more details.
Multiple animations can make use of a conditional. Check <tt>$FGDATA/Docs/README.conditions</tt> for some more details.
Line 162: Line 197:


You can add as many entries as you need. Interpolation tables are often used for gear animations (eg. to open doors during gear-movements and close them again once the gear is either retracted or fully extended).
You can add as many entries as you need. Interpolation tables are often used for gear animations (eg. to open doors during gear-movements and close them again once the gear is either retracted or fully extended).
=== Name ===
With a name animation, you can group multiple objects.
<source>
<animation>
  <name>Collection1</name>
  <object-name>Object1</object-name>
  <object-name>Object2</object-name>
  <object-name>Object3</object-name>
</animation>
</source>
The example above creates a "virtual object" with the name Collection1. In animation, we can animate this group of objects, by using:
<source>
<object-name>Collection1</object-name>
</source>
=== Object-name ===
These names are set in the 3D model. Each single object has a unique name; for easy identification it is advised to use descriptive names (LeftElevator, Rudder etc.). Animations are only applied to those objects that are mentioned in an object-name line (one object per line!). Animations lacking those, will be applied to the entire model.
=== Property ===
Each animation must be associated with exactly one property from the main FlightGear property tree (remember that the properties in the wrapper file are not part of the main tree), using <code><property></code> to provide the property path:
<source>
<animation>
  <type>rotate</type>
  <object-name>Rudder</object-name>
  <property>controls/rudder</property>
</animation>
</source>
Note the omission of the leading slash '/' when reffering to the property. This assures that when the model is used for AI or multiplayer traffic the animations will follow that of the AI controller instead of that of the user.


=== Expressions ===
=== Expressions ===
Line 225: Line 226:
See more detailed info at [[Expressions|Expressions]]
See more detailed info at [[Expressions|Expressions]]


== Animation types ==
== Object animations ==
=== Alpha-test ===
=== Alpha-test ===
<source>
<source>
Line 293: Line 294:


You can optionally add [[#Center|&lt;center&gt;]] coordinates, to scale the object around that point.
You can optionally add [[#Center|&lt;center&gt;]] coordinates, to scale the object around that point.
=== Enable-hot ===
Scenery objects are automatically defined as solid by FlightGear, meaning that an aircraft can taxi on them and/or crash when touching. For certain objects (groundmarkings, beacon light-beams etc.) this might be an unwanted feature. The solidness can be disabled with the following animation:
<source>
<animation>
  <object-name>Object</object-name>
  <enable-hot type="bool">false</enable-hot>
</animation>
</source>
* '''enable-hot:''' can be either true or false. Remember that objects are automatically solid, so it should not be nesecarily to set this at all when wanting solidness.


=== Flash ===
=== Flash ===
Line 346: Line 335:
and this scale factor is applied to the object, from the center specified. It works best if scale is less than 1. Otherwise, there will be clipping issues.
and this scale factor is applied to the object, from the center specified. It works best if scale is less than 1. Otherwise, there will be clipping issues.


=== Interactions ===
=== Noshadow ===
<source>
This animation is used to make sure an object will cast no shadow.
<animation>
  <type>interaction</type>
  <object-name>Object</object-name>
  <interaction-type>carrier-wire</interaction-type>
</animation>
</source>
 
* '''interaction-type:''' can have the following values:
** '''carrier-catapult:'''
** '''carrier-wire:''' makes the object act as an arresting wire, as used on [[aircraft carrier]]s.
 
=== Knob / slider (v. 2.11-) ===
{{Main article|Knob / slider animation}}


=== Material ===
An animation type that can be used in various ways. Of course you can combine the below mentiond systems into one (big) animation.
<source>
<animation>
  <type>material</type>
  <object-name>Object</object-name>
  <property-base>sim/model/c172p/material</property-base>
  <global type="bool">true</global> <!-- This tag is no longer supported -->
  ...
  lines as mentioned below
  ...
</animation>
</source>
'''Optional:'''
* '''property-base:''' when using prop(erties), you might want to set a property-base. All props will be relative to this path.
* '''global (depreciated):''' by setting this to <tt>true</tt>, all objects using the same material as the defined object(s) (via <tt><object-name></tt>) will be affected by the animation. This is preferred to listing several objects in <object-name> tags. It's not only faster, but also doesn't break animations by forcing objects together. <span style="color:red; text-decoration: underline;">This tag is no longer supported</span>
'''Notes:'''
* Numbers are clamped to 0.0-1.0, except "shininess", which is clamped to 0-128.
* By appending <tt>-prop</tt> each of the material properties can read its value from another property.
==== Ambient ====
<source>
  <ambient>
  <red>1.0</red>
  <green>0.2</green>
  <blue>0.0</blue>
  </ambient>
</source>
==== Diffuse ====
<source>
  <diffuse>
  <red>1.0</red>
  <green>0.2</green>
  <blue>0.0</blue>
  </diffuse>
</source>
==== Emission ====
{{Main article|Howto: Illuminate faces}}
<source>
  <emission>
  <red>1.0</red>
  <green>0.2</green>
  <blue>0.0</blue>
  <factor-prop>controls/lighting/panel-norm</factor-prop>
  </emission>
</source>
Emission colors are multiplied by the factor-prop value. 1 is maximum color intensity, while 0 is the minimum. Colors are calculated according to the [http://en.wikipedia.org/wiki/RGB_color_model RGB color model].
==== Shininess ====
Shininess is clamped to 0-128.
<source>
  <shininess>105</shininess>
</source>
==== Specular ====
<source>
  <specular>
  <red>1.0</red>
  <green>0.2</green>
  <blue>0.0</blue>
  </specular>
</source>
==== Texture ====
Used for the [[Livery over MP]] system.
<source>
  <property-base>sim/model/livery</property-base>
  <texture-prop>engine</texture-prop>
  <texture>KLM.png</texture>
</source>
==== Transparency ====
<source>
  <transparency>
  <alpha-prop>rotors/tail/rpm</alpha-prop>
  <factor>-0.0015</factor>
  <offset>1</offset>
  </transparency>
</source>
==== Threshold ====
<source>
  <threshold>0.001</threshold>
</source>
=== Noshadow ===
<source>
<source>
  <animation>
  <animation>
Line 462: Line 345:
</source>
</source>


=== Pick ===
=== Range ===
{{Main article|Howto: Make a clickable panel#Pick}}
: ''See also [[Modeling - Getting Started#Level of Detail (LOD)]].''


=== Range ===
To prevent objects -like instruments- being drawn when the aircraft is actually too far away for them to be seen anyway, a range animation is used.  
To prevent objects -like instruments- being drawn when the aircraft is actually too far away for them to be seen anyway, a range animation is used.  


Line 519: Line 401:
   <object-name>Object</object-name>
   <object-name>Object</object-name>
   <type>rotate</type>
   <type>rotate</type>
   <property>suface-positions/left-aileron-pos-norm</property>
   <property>surface-positions/left-aileron-pos-norm</property>
   <factor>25</factor>
   <factor>25</factor>
   <offset-deg>25</offset-deg>
   <offset-deg>25</offset-deg>
Line 569: Line 451:


* x.offset: the scale factor.
* x.offset: the scale factor.
* '''[[Howto:Animate_models#Expressions|expression]]:''' is optional. For more details see [[Expressions|Expressions]]
* Add [[#Center|&lt;center&gt;]] coordinates, to scale the object around that point.
* '''You can optionally use an [[Howto:Animate_models#Expressions|expression]] in the <factor> or <offset> inputs.''' For more details see [[Expressions|Expressions]]


=== Select ===
=== Select ===
Line 624: Line 507:
* '''factor:''' is optional.
* '''factor:''' is optional.


=== Texture Animations ===
=== Timed ===
Swtiches between objects at specified intervals. This example switches between a lights-on model and a lights-off model. Lights on are shown 0.2 seconds, while lights off are displayed for 0.8 seconds.
 
<source>
<animation>
  <type>timed</type>
  <object-name>BacklightOn</object-name>
  <object-name>BacklightOff</object-name>
  <use-personality type="bool">true</use-personality>
  <branch-duration-sec>0.8</branch-duration-sec>
  <branch-duration-sec>0.2</branch-duration-sec>
</animation>
</source>
 
=== Tracking ===
The new (in 2.11) [[Tracking animation|'''locked-track animation''']] can do exactly the same thing as the [http://wiki.blender.org/index.php/Doc:2.6/Manual/Constraints/Tracking/Locked_Track Locked Track constraint] available in Blender. However it can also be used to simulate simple inverse kinematic systems consisting of two bones connected with a revolute joint (aka hinge). See [[Tracking animation|detailed explanantion]]
 
=== Translate ===
The same as [[#Textranslate|textranslate]], but this animation moves a whole object (so including fixed textures). The example below will move an object in the y-direction:
 
{| class="wikitable" border="0" cellspacing="0"
!Property value
!Output
|-
| -1
| -2.5
|-
| 0
| 2.5
|-
| 1
| 7.5
|}
 
<source>
<animation>
  <type>translate</type>
  <object-name>Object</object-name>
  <property>controls/seat/pilot/position-norm</property>
  <factor>5</factor>
  <offset-m>2.5</offset-m>
  <axis>
  <x>0</x>
  <y>1</y>
  <z>0</z>
  </axis>
</animation>
</source>
 
* '''factor:''' is optional.
* '''offset-m:''' is optional. Offset in meters.
* '''[[Howto:Animate_models#Expressions|expression]]:''' is optional. For more details see [[Expressions|Expressions]]
 
== Material animation ==
An animation type that can be used in various ways. Of course you can combine the below mentiond systems into one (big) animation.
 
<source>
<animation>
  <type>material</type>
  <object-name>Object</object-name>
  <property-base>sim/model/c172p/material</property-base>
  <global type="bool">true</global> <!-- This tag is no longer supported -->
  ...
  lines as mentioned below
  ...
</animation>
</source>
 
'''Optional:'''
* '''property-base:''' when using prop(erties), you might want to set a property-base. All props will be relative to this path.
* '''global (depreciated):''' by setting this to <tt>true</tt>, all objects using the same material as the defined object(s) (via <tt><object-name></tt>) will be affected by the animation. This is preferred to listing several objects in <object-name> tags. It's not only faster, but also doesn't break animations by forcing objects together. <span style="color:red; text-decoration: underline;">This tag is no longer supported</span>
 
'''Notes:'''
* Numbers are clamped to 0.0-1.0, except "shininess", which is clamped to 0-128.
* By appending <tt>-prop</tt> each of the material properties can read its value from another property.
 
=== Ambient ===
<source>
  <ambient>
  <red>1.0</red>
  <green>0.2</green>
  <blue>0.0</blue>
  </ambient>
</source>
 
=== Diffuse ===
<source>
  <diffuse>
  <red>1.0</red>
  <green>0.2</green>
  <blue>0.0</blue>
  </diffuse>
</source>
 
=== Emission ===
{{Main article|Howto: Illuminate faces}}
<source>
  <emission>
  <red>1.0</red>
  <green>0.2</green>
  <blue>0.0</blue>
  <factor-prop>controls/lighting/panel-norm</factor-prop>
  </emission>
</source>
 
Emission colors are multiplied by the factor-prop value. 1 is maximum color intensity, while 0 is the minimum. Colors are calculated according to the [http://en.wikipedia.org/wiki/RGB_color_model RGB color model].
 
=== Shininess ===
Shininess is clamped to 0-128.
<source>
  <shininess>105</shininess>
</source>
 
=== Specular ===
<source>
  <specular>
  <red>1.0</red>
  <green>0.2</green>
  <blue>0.0</blue>
  </specular>
</source>
 
=== Texture ===
Used for the [[Livery over MP]] system.
 
<source>
  <property-base>sim/model/livery</property-base>
  <texture-prop>engine</texture-prop>
  <texture>KLM.png</texture>
</source>
 
=== Transparency ===
<source>
  <transparency>
  <alpha-prop>rotors/tail/rpm</alpha-prop>
  <factor>-0.0015</factor>
  <offset>1</offset>
  </transparency>
</source>
 
=== Threshold ===
<source>
  <threshold>0.001</threshold>
</source>
 
== Texture Animations ==


Applying different matrix transformations to the textures of an object.
Applying different matrix transformations to the textures of an object.


==== Textranslate ====
=== Textranslate ===
A very important animation for cockpits! This animation moves textures over a surface.
A very important animation for cockpits! This animation moves textures over a surface.


Line 651: Line 679:
* axis: the direction in which the texture is translated. Y is up/down, while X is left/right.
* axis: the direction in which the texture is translated. Y is up/down, while X is left/right.


==== Texrotate ====
=== Texrotate ===


<source>
<source>
Line 673: Line 701:
</source>
</source>


==== Textrapezoid ====
=== Textrapezoid ===


<source>
<source>
Line 686: Line 714:
* '''side''': side of quad which should be scaled (''top'' (default)/''right''/''bottom''/''left'')
* '''side''': side of quad which should be scaled (''top'' (default)/''right''/''bottom''/''left'')


==== Texmultiple ====
=== Texmultiple ===


Only one texture matrix can be applied to each object. With ''textmultiple'' multiple texture animations can be combined into a single matrix, applied to the specified object.
Only one texture matrix can be applied to each object. With ''textmultiple'' multiple texture animations can be combined into a single matrix, applied to the specified object.
Line 719: Line 747:
</source>
</source>


=== Timed ===
== Object interaction animations ==
Swtiches between objects at specified intervals. This example switches between a lights-on model and a lights-off model. Lights on are shown 0.2 seconds, while lights off are displayed for 0.8 seconds.
=== Enable-hot ===
Scenery objects are automatically defined as solid by FlightGear, meaning that an aircraft can taxi on them and/or crash when touching. For certain objects (groundmarkings, beacon light-beams etc.) this might be an unwanted feature. The solidness can be disabled with the following animation:


<source>
<source>
  <animation>
  <animation>
  <type>timed</type>
   <object-name>Object</object-name>
  <object-name>BacklightOn</object-name>
   <enable-hot type="bool">false</enable-hot>
   <object-name>BacklightOff</object-name>
   <use-personality type="bool">true</use-personality>
  <branch-duration-sec>0.8</branch-duration-sec>
  <branch-duration-sec>0.2</branch-duration-sec>
  </animation>
  </animation>
</source>
</source>


=== Tracking ===
* '''enable-hot:''' can be either true or false. Remember that objects are automatically solid, so it should not be nesecarily to set this at all when wanting solidness.
The new (in 2.11) [[Tracking animation|'''locked-track animation''']] can do exactly the same thing as the [http://wiki.blender.org/index.php/Doc:2.6/Manual/Constraints/Tracking/Locked_Track Locked Track constraint] available in Blender. However it can also be used to simulate simple inverse kinematic systems consisting of two bones connected with a revolute joint (aka hinge). See [[Tracking animation|detailed explanantion]]
 
=== Interactions ===
<source>
<animation>
  <type>interaction</type>
  <object-name>Object</object-name>
  <interaction-type>carrier-wire</interaction-type>
</animation>
</source>


=== Translate ===
* '''interaction-type:''' can have the following values:
The same as [[#Textranslate|textranslate]], but this animation moves a whole object (so including fixed textures). The example below will move an object in the y-direction:
** '''carrier-catapult:'''
** '''carrier-wire:''' makes the object act as an arresting wire, as used on [[aircraft carrier]]s.


{| class="wikitable" border="0" cellspacing="0"
== Direct manipulation animations ==
!Property value
=== Knob / slider (v. 2.11-) ===
!Output
{{Main article|Knob / slider animation}}
|-
| -1
| -2.5
|-
| 0
| 2.5
|-
| 1
| 7.5
|}


<source>
=== Pick ===
<animation>
{{Main article|Howto: Make a clickable panel#Pick}}
  <type>translate</type>
  <object-name>Object</object-name>
  <property>controls/seat/pilot/position-norm</property>
  <factor>5</factor>
  <offset-m>2.5</offset-m>
  <axis>
  <x>0</x>
  <y>1</y>
  <z>0</z>
  </axis>
</animation>
</source>


* '''factor:''' is optional.
== Shadow Handling ==
* '''offset-m:''' is optional. Offset in meters.
There exist several possibilites for handling of shadows. <br />
* '''[[Howto:Animate_models#Expressions|expression]]:''' is optional. For more details see [[Expressions|Expressions]]
See '''[[ALS_technical_notes|ALS Technical Notes]]''' and more specific '''[[ALS_technical_notes#ALS_fuselage_shadow_effect|Fuselage Shadow Effect with ALS]]''' for a relatively simple shadow handling.<br />
See '''[[Project Rembrandt]]''' which - amongst other functionality - implements a very realistic shadow mapping.


==References==
== References ==
{{Appendix|all|
{{Appendix|all|
* {{cite web |url=http://www.opensubscriber.com/message/flightgear-devel@flightgear.org/958955.html |title="material" animation (and the bo105 as an example) |first=Melchior |last=Franz |date=22 March 2005 |work=FlightGear-devel mailinglist }}
* {{cite web |url=http://www.opensubscriber.com/message/flightgear-devel@flightgear.org/958955.html |title="material" animation (and the bo105 as an example) |first=Melchior |last=Franz |date=22 March 2005 |work=FlightGear-devel mailinglist }}
32

edits