<sprite> ‐ An animated sprite
The element sprite defines a set of media objects that will be displayed sequentially, one after another to produce animated graphics. The integer value of the nb_states attribute is the number of states that the sprite can have. The integer value of the size attribute is the number of media objects that define each state of the sprite.+ The sprite is thus defined by nb_states×size objects.
The graphical aspect of a sprite is defined by the media-objects embedded in the element child. In each state of the sprite, the element element contains the nodes that will be displayed in turn to render the agents animation. The integer value state of the current_state attribute defines the current state of the sprite. In state state, the nodes are displayed in turn in a cyclic way from node (state-1)×size+1 to node state×size. The change of media object is made every update_rate frame (the float value of the attribute update_rate).
The values of the begin and end attributes define the beginning and the end of a sprite animation.
If the value of the boolean attribute self_oriented is true, the sprite automatically faces the viewer. (The view matrix rotation component of the media objects contained in the element element is set to identity.)
The following element must occur in sprite:
one element with id attribute. This element must contain size media object nodes.
The example below defines a sprite of 10 quads. The change of graphical aspect is made every two frames between time 100 and time 110. The quads automatically face the viewer.
<node id="sprite_film{#n}"> <sprite id="sprite_film{#n}_node" size="10" begin="100" end="110" update_rate="2" self_oriented="true" nb_states="1" current_state="1"> <element id="sprite_film{#n}_elements"> <repeat begin="1" end="10" step="1" id="nbElts"> <node id="sprite_element_{#nbElts}"> <quad id="quad_{#nbElts}" x1="0.0" y1="1.0" z1="0.0" x2="1.0" y2="1.0" z2="0.0" x3="1.0" y3="0.0" z3="0.0" x4="0.0" y4="0.0" z4="0.0"> <texture encoding="pnga" env_mode="blend" mipmapped="true" xlink:href="textures/film{#n}-{#nbElts}.png" id="ground_metal" tile_s="1" tile_t="-1" /> </quad> </node> </repeat> </element> </sprite> </node>