IMS2  Pre-Alpha
An Orbiter add-on to allow on-runtime construction of spacecraft from predefined modules
IMS_Animation_Tracking Class Reference

An animation that can track a specified target in two axes. More...

Inheritance diagram for IMS_Animation_Tracking:
IMS_Animation_Base

Public Member Functions

 IMS_Animation_Tracking (ANIMATIONDATA *_data)
 
virtual void AddAnimationToVessel (IMS2 *_vessel, int _meshindex, MATRIX3 moduleorientation, VECTOR3 modulelocalpos)
 Adds the animation to the vessel using the orbiter API. More...
 
virtual AnimationEvent_BasePropagateAnimation (double simdt)
 propagates the animation and returns an AnimationFinishedEvent if the animation stoped. More...
 
virtual AnimationEvent_BaseStartAnimation (StartAnimationEvent *startevent)
 Starts the animation. More...
 
virtual void ModifyAnimation (ModifyAnimationEvent *modifyevent)
 Modifies an animation, usually its speed and direction. More...
 
virtual void RemoveAnimationFromVessel ()
 Removes the animation from the vessel. More...
 
virtual void StopAnimation ()
 Stops the animation. More...
 
virtual string GetScenarioLine ()
 
virtual void InitStateFromScenario (vector< string > &line)
 Initialises the animation state from a scenario line. More...
 
- Public Member Functions inherited from IMS_Animation_Base
 IMS_Animation_Base (ANIMATIONDATA *_data)
 
bool IsRunning ()
 
double GetState ()
 
void GetDependencies (vector< ANIMATIONDEPENDENCY > &OUT_dependencies)
 Fills the passed reference with the dependencies of this animation.
 

Protected Member Functions

virtual void EnableAnimation ()
 Enables updating of the animation state in orbiter. More...
 
virtual void DisableAnimation ()
 Disables updating of the animation state in orbiter. More...
 
virtual void initFacing ()
 sets the facing to origin More...
 
void calculateTargetState ()
 Calculates the animation states at which the facig vector will be pointing towards the target.
 
int determineMovementDirection (double targetstate, double currentstate, bool canloop)
 Determines the direction the rotation has to move in. More...
 
bool propagateState (double &_state, double _targetstate, double _speed, double simdt, bool canloop)
 propagates the passed state toward a target state More...
 
void initMovingAnimation ()
 Initialises the secondary rotation axis of the animation on creation. More...
 
- Protected Member Functions inherited from IMS_Animation_Base
MGROUP_ROTATE * createRotationComponent (ANIMCOMPONENTDATA *comp, VECTOR3 modulelocalpos, MATRIX3 moduleorientation)
 Creates a rotation animation component that can be added to the animation on the vessel. More...
 
MGROUP_TRANSLATE * createTranslationComponent (ANIMCOMPONENTDATA *comp, VECTOR3 modulelocalpos, MATRIX3 moduleorientation)
 Creates a translation animation component that can be added to the animation on the vessel. More...
 
MGROUP_SCALE * createScaleComponent (ANIMCOMPONENTDATA *comp, VECTOR3 modulelocalpos, MATRIX3 moduleorientation)
 Creates a scale animation component that can be added to the animation on the vessel. More...
 

Protected Attributes

OBJHANDLE target = NULL
 Handle to the object in orbiter the animation is supposed to track.
 
VECTOR3 facing
 The directional vector of the origin state of the animation (vessel relative)
 
VECTOR3 primaryaxis
 The primary axis of rotation transformed to vessel internal frame.
 
VECTOR3 secondaryaxis
 the secondary axis of rotation transformed to vessel internal frame
 
int secondaryorbiterid = -1
 identifier that identifies the secondary animation in orbiter
 
double secondarystate = 0.0
 The state of the secondary animation.
 
double secondaryspeed = 0.0
 The speed of the secondary animation.
 
double primarytargetstate = 0.0
 the state the primary animation is aiming to achieve
 
double secondarytargetstate = 0.0
 the state the secondary animation is aiming to achieve
 
double lastalignement = 0.0
 time since the last alignement (check of target position) in miliseconds
 
MGROUP_ROTATE * secondrotation
 Pointer to the component of the secondary animation.
 
bool stopanimation = false
 Sets to true when the animation needs to stop and return to origin.
 
bool initmovinganim = false
 True if the animation is already moving when initialising.
 
- Protected Attributes inherited from IMS_Animation_Base
IMS2 * vessel
 The vessel this animation is currently a part of.
 
ANIMATIONDATAdata
 Pointer to the data defining this animation.
 
double speed = 0.0
 The current speed/direction of the animation.
 
int orbiterid
 The orbiter-generated identifier for this animation.
 
double state = 0.0
 The current state of the animation (>= 0.0 <= 1.0)
 
int meshindex = 0
 The orbiter generated index of the mesh this animation acts on.
 
double maxspeed = 1e12
 The maximum speed the animation can have. Effects not yet implemented.
 
vector< UINT * > animationgroups
 List meshgroup indices this animation acts on.
 
vector< ANIMATIONCOMPONENT_HANDLE > animationcomponents
 List of orbiter-internal components this animation consists of.
 
bool enabled = false
 An animation is disabled when the vessel visual doesn't exist. state still gets propagated, but the animation state on the vessel doesn't get updated.
 

Detailed Description

An animation that can track a specified target in two axes.

For both animations, a radial range can be defined. The animation will notice itself when the target is outside its allowed radial range and inform of that fact with an appropriate TrackingAnimationStatusEvent.

A tracking animation does in fact consist of two independant rotation animations, a primary (aligned first) and a secondary. Tracking is achieved by calculating a directional vector to the target, moving one animation until the apropriate axes are aligned, modifying the second animation's axis to align with the first animation, and then runs the second animation until all axes are aligned. Compared to the other animations, it's a rather complex beast.

Constructor & Destructor Documentation

IMS_Animation_Tracking::IMS_Animation_Tracking ( ANIMATIONDATA _data)
Parameters
_dataPointer to the data defining this animation

Member Function Documentation

void IMS_Animation_Tracking::AddAnimationToVessel ( IMS2 *  _vessel,
int  _meshindex,
MATRIX3  moduleorientation,
VECTOR3  modulelocalpos 
)
virtual

Adds the animation to the vessel using the orbiter API.

Parameters
_vesselThe vessel to add the animation to
_meshindexThe index of the mesh that is influenced by this animation
moduleorientationMatrix to transform from module-relative to vessel-relative coordinates
modulelocalposVessel-relative position of the module containing this animation

Reimplemented from IMS_Animation_Base.

int IMS_Animation_Tracking::determineMovementDirection ( double  targetstate,
double  currentstate,
bool  canloop 
)
protected

Determines the direction the rotation has to move in.

Parameters
targetstateThe state the animation has to aim for
currentstateThe state the animation is in currently
canlooppass true if the animation can loop, i.e. has a 360 degree range
Returns
1 or -1, indicating whether the rotation should move forward or backward
void IMS_Animation_Tracking::DisableAnimation ( )
protectedvirtual

Disables updating of the animation state in orbiter.

Animations should be disabled when a vessel visual does not exist (not close enough to camera) or if the whole vessel doesn't exist. The animation state will still propagate even if disabled, so when the vessel are created it will be as if the animation never stoped

Reimplemented from IMS_Animation_Base.

void IMS_Animation_Tracking::EnableAnimation ( )
protectedvirtual

Enables updating of the animation state in orbiter.

See also
DisableAnimation()

Reimplemented from IMS_Animation_Base.

string IMS_Animation_Tracking::GetScenarioLine ( )
virtual
Returns
a string describing the state of the animation to write into a scenario file.

Reimplemented from IMS_Animation_Base.

void IMS_Animation_Tracking::initFacing ( )
protectedvirtual

sets the facing to origin

needs to be called whenever animation is added to new vessel!

void IMS_Animation_Tracking::initMovingAnimation ( )
protected

Initialises the secondary rotation axis of the animation on creation.

Note
only needs to be called if the tracking animation is in a state of movement when being created
void IMS_Animation_Tracking::InitStateFromScenario ( vector< string > &  line)
virtual

Initialises the animation state from a scenario line.

Parameters
lineA list of strings, representing the scenario line cut by " "

Reimplemented from IMS_Animation_Base.

void IMS_Animation_Tracking::ModifyAnimation ( ModifyAnimationEvent modifyevent)
virtual

Modifies an animation, usually its speed and direction.

Parameters
modifyeventThe event that modifies the animation

Reimplemented from IMS_Animation_Base.

AnimationEvent_Base * IMS_Animation_Tracking::PropagateAnimation ( double  simdt)
virtual

propagates the animation and returns an AnimationFinishedEvent if the animation stoped.

propagation behavior has to be implemented by child classes.

Parameters
simdtThe time elapsed since the last frame

Implements IMS_Animation_Base.

bool IMS_Animation_Tracking::propagateState ( double &  _state,
double  _targetstate,
double  _speed,
double  simdt,
bool  canloop 
)
protected

propagates the passed state toward a target state

Parameters
_stateThe current state of the animation (will be modified by function!!)
_targetstateThe state the animation has to reach
_speedThe speed and direction of the animation
simdtElapsed time since last call in miliseconds
canlooppass true if the animation can loop
Returns
True if the targeted state was reached, false otherwise
void IMS_Animation_Tracking::RemoveAnimationFromVessel ( )
virtual

Removes the animation from the vessel.

debug

debug

Reimplemented from IMS_Animation_Base.

AnimationEvent_Base * IMS_Animation_Tracking::StartAnimation ( StartAnimationEvent startevent)
virtual

Starts the animation.

Parameters
starteventThe StartAnimationEvent that triggers the start of the animation

Reimplemented from IMS_Animation_Base.

void IMS_Animation_Tracking::StopAnimation ( )
virtual

Stops the animation.

Note
stopping behavior is implemented by inheriting classes

Reimplemented from IMS_Animation_Base.


The documentation for this class was generated from the following files: