scg3  0.6
scg::TransformAnimation Class Reference

An animation that creates a transformation to be applied to its sub-tree (composite node). More...

#include "TransformAnimation.h"

Inheritance diagram for scg::TransformAnimation:
[legend]
Collaboration diagram for scg::TransformAnimation:
[legend]

Public Member Functions

 TransformAnimation ()
 
virtual ~TransformAnimation ()
 
GLfloat getFloatParam () const
 
TransformAnimationsetFloatParam (GLfloat param)
 
const glm::vec3 & getVec3Param () const
 
TransformAnimationsetVec3Param (const glm::vec3 &param)
 
const glm::mat4 & getMat4Param () const
 
TransformAnimationsetMat4Param (const glm::mat4 &param)
 
TransformAnimationsetStartFunc (std::function< void(TransformAnimation *)> startFunc)
 
TransformAnimationsetUpdateFunc (std::function< void(TransformAnimation *, double, double, double)> updateFunc)
 
virtual void start (double currTime)
 
virtual void update (double currTime)
 
- Public Member Functions inherited from scg::Animation
 Animation ()
 
virtual ~Animation ()
 
bool isStarted () const
 
bool isRunning () const
 
virtual void stop ()
 
virtual void reset ()
 
- Public Member Functions inherited from scg::Transformation
 Transformation ()
 
virtual ~Transformation ()
 
const glm::mat4 & getMatrix () const
 
virtual TransformationsetMatrix (const glm::mat4 &matrix)
 
virtual Transformationtranslate (glm::vec3 translation)
 
virtual TransformationrotateRad (GLfloat angleRad, glm::vec3 axis)
 
virtual Transformationrotate (GLfloat angleDeg, glm::vec3 axis)
 
virtual Transformationscale (glm::vec3 scaling)
 
virtual void accept (Traverser *traverser)
 
virtual void acceptPost (Traverser *traverser)
 
virtual void render (RenderState *renderState)
 
virtual void renderPost (RenderState *renderState)
 
- Public Member Functions inherited from scg::Composite
 Composite ()
 
virtual ~Composite ()=0
 
virtual void destroy ()
 
CompositeaddChild (NodeSP child)
 
CompositeremoveChild (Node *node, bool &result)
 
CompositeremoveChild (Node *node)
 
virtual void traverse (Traverser *traverser)
 
- Public Member Functions inherited from scg::Node
 Node ()
 
virtual ~Node ()=0
 
virtual void clear ()
 
int getNCores () const
 
const std::string & getMetaInfo (const std::string &key) const
 
void setMetaInfo (const std::string &key, const std::string &value)
 
bool isVisible () const
 
void setVisible (bool isVisible=true)
 

Static Public Member Functions

static TransformAnimationSP create ()
 
- Static Public Member Functions inherited from scg::Transformation
static TransformationSP create ()
 

Protected Attributes

GLfloat floatParam_
 
glm::vec3 vec3Param_
 
glm::mat4 mat4Param_
 
std::function< void(TransformAnimation *)> startFunc_
 
std::function< void(TransformAnimation *, double, double, double)> updateFunc_
 
- Protected Attributes inherited from scg::Animation
bool isStarted_
 
bool isRunning_
 
double lastTime_
 
double diffTime_
 
double totalTime_
 
- Protected Attributes inherited from scg::Transformation
glm::mat4 matrix_
 
- Protected Attributes inherited from scg::Composite
NodeSP leftChild_
 
- Protected Attributes inherited from scg::Node
NodeSP rightSibling_
 
Compositeparent_
 
std::vector< CoreSPcores_
 
bool isVisible_
 
std::unordered_map< std::string, std::string > metaInfo_
 

Additional Inherited Members

- Protected Member Functions inherited from scg::Node
void addSibling_ (NodeSP sibling)
 
void removeSibling_ (Node *node, bool &result)
 
void processCores_ (RenderState *renderState)
 
void postProcessCores_ (RenderState *renderState)
 

Detailed Description

An animation that creates a transformation to be applied to its sub-tree (composite node).

The update function can be set as a function object for a global function, a member function (method) of a class, or a lambda function.

Example (lambda function):

auto myAnimation = TransformAnimation::create();
float angularVel = 50.f;
glm::vec3 axis(1.f, 0.f, 0.f);
myAnimation->setUpdateFunc(
[angularVel, axis](TransformAnimation* animation,
double currTime, double diffTime, double totalTime) {
animation->rotate(angularVel * static_cast<GLfloat>(diffTime), axis);
});
aNode->addChild(myAnimation);
myAnimation->addChild(anotherNode);
myViewer.addAnimation(myAnimation);
myViewer.startAnimations();

Definition at line 63 of file TransformAnimation.h.

Constructor & Destructor Documentation

◆ TransformAnimation()

scg::TransformAnimation::TransformAnimation ( )

Constructor.

◆ ~TransformAnimation()

virtual scg::TransformAnimation::~TransformAnimation ( )
virtual

Destructor.

Member Function Documentation

◆ create()

static TransformAnimationSP scg::TransformAnimation::create ( )
static

Create shared pointer.

◆ getFloatParam()

GLfloat scg::TransformAnimation::getFloatParam ( ) const

Get parameter.

◆ getMat4Param()

const glm::mat4& scg::TransformAnimation::getMat4Param ( ) const

Get parameter.

◆ getVec3Param()

const glm::vec3& scg::TransformAnimation::getVec3Param ( ) const

Get parameter.

◆ setFloatParam()

TransformAnimation* scg::TransformAnimation::setFloatParam ( GLfloat  param)

Set parameter to be used by animation function.

Returns
this pointer for method chaining

◆ setMat4Param()

TransformAnimation* scg::TransformAnimation::setMat4Param ( const glm::mat4 &  param)

Set parameter to be used by animation function.

Returns
this pointer for method chaining

◆ setStartFunc()

TransformAnimation* scg::TransformAnimation::setStartFunc ( std::function< void(TransformAnimation *)>  startFunc)

Set start function f_start that is called when the animation is started as f(this).

Parameters
startFuncfunction object with signature void f(TransformAnimation*).
Returns
this pointer for method chaining

◆ setUpdateFunc()

TransformAnimation* scg::TransformAnimation::setUpdateFunc ( std::function< void(TransformAnimation *, double, double, double)>  updateFunc)

Set update function that is called when the animation is updated as f(this, currTime, diffTime, totalTime) (cf. Animation).

Parameters
updateFuncfunction object with signature void f(TransformAnimation*, double, double, double).
Returns
this pointer for method chaining

◆ setVec3Param()

TransformAnimation* scg::TransformAnimation::setVec3Param ( const glm::vec3 &  param)

Set parameter to be used by animation function.

Returns
this pointer for method chaining

◆ start()

virtual void scg::TransformAnimation::start ( double  currTime)
virtual

Start or restart animation with given time, call start function (if defined).

Parameters
currTimecurrent time (seconds)

Reimplemented from scg::Animation.

◆ update()

virtual void scg::TransformAnimation::update ( double  currTime)
virtual

Update animation with given time, call update function (if defined).

Parameters
currTimecurrent time (seconds)

Implements scg::Animation.

Member Data Documentation

◆ floatParam_

GLfloat scg::TransformAnimation::floatParam_
protected

Definition at line 148 of file TransformAnimation.h.

◆ mat4Param_

glm::mat4 scg::TransformAnimation::mat4Param_
protected

Definition at line 150 of file TransformAnimation.h.

◆ startFunc_

std::function<void(TransformAnimation*)> scg::TransformAnimation::startFunc_
protected

Definition at line 151 of file TransformAnimation.h.

◆ updateFunc_

std::function<void(TransformAnimation*, double, double, double)> scg::TransformAnimation::updateFunc_
protected

Definition at line 152 of file TransformAnimation.h.

◆ vec3Param_

glm::vec3 scg::TransformAnimation::vec3Param_
protected

Definition at line 149 of file TransformAnimation.h.


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