IMS2
Pre-Alpha
An Orbiter add-on to allow on-runtime construction of spacecraft from predefined modules
|
An animation that can track a specified target in two axes. More...
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_Base * | PropagateAnimation (double simdt) |
propagates the animation and returns an AnimationFinishedEvent if the animation stoped. More... | |
virtual AnimationEvent_Base * | StartAnimation (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. | |
ANIMATIONDATA * | data |
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. | |
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.
IMS_Animation_Tracking::IMS_Animation_Tracking | ( | ANIMATIONDATA * | _data | ) |
_data | Pointer to the data defining this animation |
|
virtual |
Adds the animation to the vessel using the orbiter API.
_vessel | The vessel to add the animation to |
_meshindex | The index of the mesh that is influenced by this animation |
moduleorientation | Matrix to transform from module-relative to vessel-relative coordinates |
modulelocalpos | Vessel-relative position of the module containing this animation |
Reimplemented from IMS_Animation_Base.
|
protected |
Determines the direction the rotation has to move in.
targetstate | The state the animation has to aim for |
currentstate | The state the animation is in currently |
canloop | pass true if the animation can loop, i.e. has a 360 degree range |
|
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.
|
protectedvirtual |
Enables updating of the animation state in orbiter.
Reimplemented from IMS_Animation_Base.
|
virtual |
Reimplemented from IMS_Animation_Base.
|
protectedvirtual |
sets the facing to origin
needs to be called whenever animation is added to new vessel!
|
protected |
Initialises the secondary rotation axis of the animation on creation.
|
virtual |
Initialises the animation state from a scenario line.
line | A list of strings, representing the scenario line cut by " " |
Reimplemented from IMS_Animation_Base.
|
virtual |
Modifies an animation, usually its speed and direction.
modifyevent | The event that modifies the animation |
Reimplemented from IMS_Animation_Base.
|
virtual |
propagates the animation and returns an AnimationFinishedEvent if the animation stoped.
propagation behavior has to be implemented by child classes.
simdt | The time elapsed since the last frame |
Implements IMS_Animation_Base.
|
protected |
propagates the passed state toward a target state
_state | The current state of the animation (will be modified by function!!) |
_targetstate | The state the animation has to reach |
_speed | The speed and direction of the animation |
simdt | Elapsed time since last call in miliseconds |
canloop | pass true if the animation can loop |
|
virtual |
|
virtual |
Starts the animation.
startevent | The StartAnimationEvent that triggers the start of the animation |
Reimplemented from IMS_Animation_Base.
|
virtual |
Stops the animation.
Reimplemented from IMS_Animation_Base.