#include <sglAnimation.hpp>
Inheritance diagram for sglAnimation::
Public Types | |
enum | ModeEnum { eCYCLE, eSWING } |
enum | StateEnum { eSTART, ePAUSE, eRESUME, eSTOP } |
Public Methods | |
sglAnimation () | |
virtual | ~sglAnimation () |
void | setMode (ModeEnum mode) |
ModeEnum | getMode () const |
bool | setState (StateEnum state) |
StateEnum | getState () const |
void | setRange (int first_node=0, int last_node=-1) |
void | getRange (unsigned int &first_node, unsigned int &last_node) const |
void | setSpeed (float speed) |
float | getSpeed () const |
void | setNumCycles (unsigned int num_cycles) |
unsigned int | getNumCycles () const |
virtual void | printInfo (ostream &ostrm, const char *indent_string) const |
Protected Methods | |
virtual void | computeValues ()=0 |
void | copyTo (sglAnimation *dst, unsigned int mode) const |
Protected Attributes | |
ModeEnum | m_mode |
StateEnum | m_state |
bool | m_state_dirty_flag |
bool | m_range_flag |
unsigned int | m_first |
unsigned int | m_last |
bool | m_reverse_flag |
float | m_speed |
unsigned int | m_num_cycles |
The speed of the animation can be changed with a call to setSpeed(..) where negative values reverse the animation. Speeds with magnitude between zero and one slow the animation down (0.5 corresponds to half speed), and magnitudes greater than one speed the animation up (2.0 corresponds to double speed). Specifying a speed of zero disables the animation.
The subset of the children can be animated by specifying the indices of the first and last child in a call to setRange(..). Passing no arguments to this function reverts the animation to using all the children. The number of times the animation is performed can also be set by calling setNumCycles(..). Passing a zero to this function causes the animation to repeat endlessly when activated.
The animation can be set to cycle (mode = eCYCLE) in ascending order or cycle (mode = eSWING) back and forth by calling the setMode(..) member function. A complete cycle in eCYCLE mode consists of animation from the first to last child (either from the complete set of child or the limits specified by a call to setRange()). A complete cycle in eSWING mode consists of a cycle up and back. Note that the last child is not displayed twice, nor is the first if the number of cycles is specified as greater than 1.
The state (control mode) of the system can be one of four: eSTOP (the initial state, and discontinues any current animation), eSTART (begins the animation), ePAUSE (pauses the animation), and eRESUME (continues the animation after a pause). While the state is eSTOP, nothing is shown. Likewise, when the prescribed number of cycles is finished no children will be selected for display. While the animation is running or when the animation ends (provided the number of cycles is not set to zero), it is still in the eSTART state the animation can be restarted by calling setState(sglAnimation::eSTART).
The subclasses of this node depend on either the current frame count or frame time that is stored in the sglScene node at the root of the scene graph containing this node. The frame count is incremented and the current frame time is determined each time sglScene::preDraw() is called. The different traversals use these values to realize the correct behaviour for these nodes so that it is necessary for the traversals to start at the sglScene node. If the state of this node has changed, it will be marked as dirty and the preDraw() traversal will set some member variables internal to this node. If this node is a member of more than one scene graph then proper behaviour is not guaranteed.
Special behaviour for intersect and pick traversals
The default behaviour of the intersect and pick traversals of the subclasses of this node is to test against the current child to be displayed based on the current frame count stored in the sglScene node at the root of the scene graph containing this node. The behaviour of the intersect and pick traversals of these nodes can be modified by adding sglProbe::eANIMATION_ALL or sglProbe::eANIMATION_NONE to the sglProbe mode. The former behaves as a normal sglGroup node testing against all the children, while the latter returns without testing against any children.
Definition at line 98 of file sglAnimation.hpp.
|
Controls the behaviour of the animation Definition at line 102 of file sglAnimation.hpp. |
|
The current state of the animation
Definition at line 111 of file sglAnimation.hpp. |
|
default constructor.
|
|
virtual destructor.
|
|
Set the animation mode for this node to either eCYCLE (the default) or eSWING. When in eCYCLE mode, the children will be displayed in order from lowest index to highest, and repeat (if required) from lowest to highest. When in eSWING mode, the children will be displayed in order from lowest to highest and then reverse from highest to lowest (this entire cycle will be repeated if so configured. In swing mode the highest will only be displayed for its allotted time once before reversing direction.
Definition at line 139 of file sglAnimation.hpp. |
|
Return the current animation mode.
Definition at line 144 of file sglAnimation.hpp. |
|
Change the state of the animation node. Any valid change here causes sets the ANIMATION dirty bit so that preDraw will do something to set up the animation. The current valid state changes are as follows: eSTART->eSTOP/ePAUSE, ePAUSE->eRESUME/eSTOP, eRESUME->eSTOP/ePAUSE, eSTOP->eSTART, and eSTART->eSTART. Note that is eRESUME is specified it will be changed to eSTART automatically during the preDraw traversal.
|
|
Get the current state of the node.
Definition at line 160 of file sglAnimation.hpp. |
|
This sets the range of nodes to display (by child index number). By passing no arguments, then the system reverts to the default of showing all children. If last_node is less than first_node, then they will be exchanged (reverse animations should be specified with a negative speed. Note that if the number of children of this node changes after a range is set and causes one or both of the range values to be invalid, it may lead to unspecified behaviour.
|
|
Get the current range of children to be displayed. If the child list is empty then first_node will be set to zero and last_node will be set to MAX_UINT.
|
|
Set the speed of the animation relative to the durations set by the subclasses (the time that each child is shown, its duration, is divided by this value). A speed of zero disables the animation, a positive speed corresponds to a forward animation, and a negative speed reverses the animation. A speed with magnitude less than 1.0 will slow the animation down, while a magnitude greater than 1.0 will increase the speed.
|
|
Get the current speed.
|
|
Set the number cycles this animations is supposed to perform. For the eCYCLE mode, a period consists of (child 0 ... child n-1). For the eSWING mode, a period consists of (child 0 ... child n-1 ... child 1). If the number cycles is set to zero, then the animation node will cycle continuously. After the specified number of cycles, the state will remain in eSTART/eRESUME (whichever it was in). And the user will have to change the state to eSTOP before typing start again.
|
|
Get the current number of cycles.
Definition at line 217 of file sglAnimation.hpp. |
|
Output the state of this node to the specified ostream.
Reimplemented from sglGroup. Reimplemented in sglKeyFrameAnimation, and sglTimedAnimation. |