This page has been translated automatically.
Video Tutorials
Interface
Essentials
Advanced
How To
Basics
Rendering
Professional (SIM)
UnigineEditor
Interface Overview
Assets Workflow
Version Control
Settings and Preferences
Working With Projects
Adjusting Node Parameters
Setting Up Materials
Setting Up Properties
Lighting
Sandworm
Using Editor Tools for Specific Tasks
Extending Editor Functionality
Built-in Node Types
Nodes
Objects
Effects
Decals
Light Sources
Geodetics
World Nodes
Sound Objects
Pathfinding Objects
Players
Programming
Fundamentals
Setting Up Development Environment
Usage Examples
C++
C#
UnigineScript
UUSL (Unified UNIGINE Shader Language)
Plugins
File Formats
Materials and Shaders
Rebuilding the Engine Tools
GUI
Double Precision Coordinates
API
Containers
Common Functionality
Controls-Related Classes
Engine-Related Classes
Filesystem Functionality
GUI-Related Classes
Math Functionality
Node-Related Classes
Objects-Related Classes
Networking Functionality
Pathfinding-Related Classes
Physics-Related Classes
Plugins-Related Classes
IG Plugin
CIGIConnector Plugin
Rendering-Related Classes
VR-Related Classes
Content Creation
Content Optimization
Materials
Material Nodes Library
Miscellaneous
Input
Math
Matrix
Textures
Art Samples
Tutorials

Unigine::AnimationTrack Class

Warning
The functionality described here is EXPERIMENTAL and is not recommended for production use. Future releases may bring significant changes to API and features. Backward compatibility of the final production-ready version is not guaranteed.
Header: #include <UnigineAnimation.h>

This class is used to manage animation tracks via code.

AnimationTrack Class

Members

UGUID getGUID() const#

Returns the current GUID of the animation track.

Return value

Current track GUID.

void setName ( const char * name ) #

Sets a new name of the animation track.

Arguments

  • const char * name - The track name.

const char * getName() const#

Returns the current name of the animation track.

Return value

Current track name.

getNumObjects() const#

Returns the current total number of animation objects controlled by the track.

Return value

Current number of animation objects controlled by the track.

getDuration() const#

Returns the current total track duration, in seconds.

Return value

Current track duration, in seconds.

getManualDuration() const#

Returns the current

Return value

Current

const char * getPath() const#

Returns the current path to the track file.

Return value

Current track file path.

void setEventCurve ( const Ptr<AnimationCurveInt>& curve ) #

Sets a new event curve for the track. Events enable you to call a function or method directly from the animation at a certtain frame/time that you specify. You can use events, for example, to play a sound effect or perform any other actions at any moment on the timeline. The key values on this curve define which events are to be triggered at the corresponding moments. You define the desired list of events as a enumeration, and then simply add keys with the certain enum values to the curve at certain moments when you want the corresponding event to occur.
Source code (C++)
// enumeration that defines all available events
enum
{
	EVENT_PLAY_SOUND = 0, 		// on this event we play a sound
	EVENT_CONSOLE_MESSAGE,		// on this event we print a message to the console
	//...
};


// handler function used to process all events by their IDs
void on_event(int id)
{
	if (id == EVENT_PLAY_SOUND)
	{
		sound->stop();
		sound->play();
	}

	if (id == EVENT_CONSOLE_MESSAGE)
	{
		Console::onscreenMessageLine(vec4_blue, "A message.");
	}
	
	// ...
}

// creating a track for events 
AnimationTrackPtr event_track = AnimationTrack::create();

// creating a track for events 
AnimationCurveIntPtr event_curve = AnimationCurveInt::create();
event_curve->addKey(1.25f, EVENT_PLAY_SOUND);
event_curve->addKey(2.07f, EVENT_CONSOLE_MESSAGE);
event_curve->addKey(2.75f, EVENT_PLAY_SOUND);
event_track->setEventCurve(event_curve);

// adding a track to the playback
playback->addLayer(event_track);

// adding a callback handler to process events
event_track->addEventCallback(MakeCallback(on_event));

Arguments


Ptr<AnimationCurveInt> getEventCurve() const#

Returns the current event curve for the track. Events enable you to call a function or method directly from the animation at a certtain frame/time that you specify. You can use events, for example, to play a sound effect or perform any other actions at any moment on the timeline. The key values on this curve define which events are to be triggered at the corresponding moments. You define the desired list of events as a enumeration, and then simply add keys with the certain enum values to the curve at certain moments when you want the corresponding event to occur.
Source code (C++)
// enumeration that defines all available events
enum
{
	EVENT_PLAY_SOUND = 0, 		// on this event we play a sound
	EVENT_CONSOLE_MESSAGE,		// on this event we print a message to the console
	//...
};


// handler function used to process all events by their IDs
void on_event(int id)
{
	if (id == EVENT_PLAY_SOUND)
	{
		sound->stop();
		sound->play();
	}

	if (id == EVENT_CONSOLE_MESSAGE)
	{
		Console::onscreenMessageLine(vec4_blue, "A message.");
	}
	
	// ...
}

// creating a track for events 
AnimationTrackPtr event_track = AnimationTrack::create();

// creating a track for events 
AnimationCurveIntPtr event_curve = AnimationCurveInt::create();
event_curve->addKey(1.25f, EVENT_PLAY_SOUND);
event_curve->addKey(2.07f, EVENT_CONSOLE_MESSAGE);
event_curve->addKey(2.75f, EVENT_PLAY_SOUND);
event_track->setEventCurve(event_curve);

// adding a track to the playback
playback->addLayer(event_track);

// adding a callback handler to process events
event_track->addEventCallback(MakeCallback(on_event));

Return value

Current event curve for the track.

AnimationTrack ( ) #

Constructor. Creates an empty track with default settings.

AnimationTrack ( const char * name ) #

Constructor. Creates an empty track with default settings and specified name.

Arguments

  • const char * name - Animation track name.

void copy ( const Ptr<AnimationTrack> & track ) #

Copies all data from the specified source track to the track.

Arguments

  • const Ptr<AnimationTrack> & track - Source animation track.

void clear ( ) #

Clears the animation track removing all animation objects and modifiers from it. This method also resets track duration to 0.

bool containsObject ( const Ptr<AnimationObject> & anim_obj ) #

Returns a value indicating if the animation track contains the specified animation object.

Arguments

Return value

true if the the animation playback contains the specified animation object; otherwise, false.

Ptr<AnimationObject> getObject ( int index ) const#

Returns an animation object by its index.

Arguments

  • int index - Animation object index.

Return value

Animation object with the specified index.

int addObject ( const Ptr<AnimationObject> & anim_obj ) #

Adds the specified animation object to the track.

Arguments

Return value

Index of the new animation object added on success; otherwise, -1.

void removeObject ( const Ptr<AnimationObject> & anim_obj ) #

Removes the specified animation object along with all modifiers added for it.

Arguments

void addObjectModifier ( const Ptr<AnimationObject> & anim_obj, const Ptr<AnimationModifier> & modifier ) #

Adds the specified modifier to the specified animation object to control changes of a certain parameter over time.

Arguments

bool updateObjectModifier ( const Ptr<AnimationObject> & anim_obj, const Ptr<AnimationModifier> & modifier ) #

Updates the specified modifier for the specified animation object.

Arguments

Return value

true if the specified modifier was successfully updated for the animation object; otherwise, false.

void removeObjectModifier ( const Ptr<AnimationObject> & anim_obj, const Ptr<AnimationModifier> & modifier ) #

Removes the specified modifier from the specified animation object.

Arguments

int getObjectModifiers ( const Ptr<AnimationObject> & anim_obj, Vector<Ptr<AnimationModifier>> & OUT_out_modifiers ) const#

Collects all modifiers for the specified animation object and puts them to the out_modifiers buffer.

Arguments

  • const Ptr<AnimationObject> & anim_obj - Animation object.
  • Vector<Ptr<AnimationModifier>> & OUT_out_modifiers - Output buffer for the list of all modifiers for the specified object.
    Notice
    This output buffer is to be filled by the Engine as a result of executing the method.

Return value

Number of modifiers for the specified object.

void addObjectModifier ( const char * anim_obj_name, const Ptr<AnimationModifier> & modifier ) #

Adds the specified modifier to the animation object with the specified name to control changes of a certain parameter over time.

Arguments

  • const char * anim_obj_name - Name of the target animation object to which a modifier should be added.
  • const Ptr<AnimationModifier> & modifier - Animation modifier to be added.

void addSingletonModifier ( const Ptr<AnimationModifier> & modifier ) #

Adds the specified singleton animation modifier to control changes of a certain parameter of some Engine's singleton class, such as Physics, Render, etc.

Arguments

bool updateSingletonModifier ( const Ptr<AnimationModifier> & modifier ) #

Updates the specified singleton animation modifier used to control changes of a certain parameter of some Engine's singleton class, such as Physics, Render, etc.

Arguments

Return value

true if the specified singleton modifier was successfully updated; otherwise, false.

void removeSingletonModifier ( const Ptr<AnimationModifier> & modifier ) #

Removes the specified singleton animation modifier from the track.

Arguments

int getSingletonModifiers ( Vector<Ptr<AnimationModifier>> & OUT_out_modifiers ) const#

Collects all singleton animation modifiers of the track and puts them to the out_modifiers buffer.

Arguments

  • Vector<Ptr<AnimationModifier>> & OUT_out_modifiers - Output buffer for the list of all singleton modifiers of the track.
    Notice
    This output buffer is to be filled by the Engine as a result of executing the method.

Return value

Number of singleton animation modifiers of the track.

Ptr<AnimationFrame> getFrame ( float time ) #

Returns the animation frame for the specified moment of time. A frame can be thought of as a vertical slice of values of all tracks and modifiers played at the specified moment.

Arguments

  • float time - Time (in seconds) for which a frame is to be obtained.

Return value

Animation frame for the specified time.

Ptr<AnimationFrame> getFrameByNormalizedTime ( float time ) #

Returns the animation frame for the specified moment of time (normalized). A frame can be thought of as a vertical slice of values of all tracks and modifiers played at the specified moment.

Arguments

  • float time - Normalized time value (in the [0.0f, 1.0f] range) for which a frame is to be obtained .

Return value

Animation frame for the specified time.
Last update: 2024-08-16
Build: ()