Visualization Library 2.0.0

A lightweight C++ OpenGL middleware for 2D/3D graphics

VL     Star     Watch     Fork     Issue

[Download] [Tutorials] [All Classes] [Grouped Classes]
Public Member Functions | Protected Attributes | List of all members
vl::MorphingCallback Class Reference

The MorphingCallback class implements a simple morphing animation mechanism using the GPU acceleration where available. More...

#include <MorphingCallback.hpp>

+ Inheritance diagram for vl::MorphingCallback:

Public Member Functions

 MorphingCallback ()
 
 ~MorphingCallback ()
 
virtual void onActorRenderStarted (Actor *actor, real frame_clock, const Camera *cam, Renderable *renderable, const Shader *, int pass)
 Event generated just before an Actor is rendered but after the render states are ready and setup. More...
 
virtual void onActorDelete (Actor *)
 Event notifying that an Actor is being deleted. More...
 
void bindActor (Actor *actor)
 
void init (ResourceDatabase *res_db)
 Initializes a MorphingCallback from a ResourceDatabase. More...
 
void blendFrames (int a, int b, float t)
 
void setAnimation (int start, int end, float period)
 
void startAnimation (real time=-1)
 
void stopAnimation ()
 
void initFrom (MorphingCallback *morph_cb)
 
void resetGLSLBindings ()
 
bool glslVertexBlendEnabled () const
 
void setGLSLVertexBlendEnabled (bool enable)
 
Geometrygeometry ()
 
const Geometrygeometry () const
 
bool animationStarted () const
 
- Public Member Functions inherited from vl::ActorEventCallback
 ActorEventCallback ()
 
void setEnabled (bool enabled)
 
bool isEnabled () const
 
- Public Member Functions inherited from vl::Object
 Object ()
 Constructor. More...
 
 Object (const Object &other)
 Copy constructor: copies the name, ref count mutex and user data. More...
 
Objectoperator= (const Object &other)
 Copy operator: copies the object's name, ref count mutex and user data. More...
 
const std::string & objectName () const
 The name of the object, by default set to the object's class name. More...
 
void setObjectName (const char *name)
 The name of the object, by default set to the object's class name in debug builds. More...
 
void setObjectName (const std::string &name)
 The name of the object, by default set to the object's class name in debug builds. More...
 
void setRefCountMutex (IMutex *mutex)
 The mutex used to protect the reference counting of an Object across multiple threads. More...
 
IMutexrefCountMutex ()
 The mutex used to protect the reference counting of an Object across multiple threads. More...
 
const IMutexrefCountMutex () const
 The mutex used to protect the reference counting of an Object across multiple threads. More...
 
int referenceCount () const
 Returns the number of references of an object. More...
 
void incReference () const
 Increments the reference count of an object. More...
 
void decReference ()
 Decrements the reference count of an object and deletes it if both automaticDelete() is true the count reaches 0. More...
 
void setAutomaticDelete (bool autodel_on)
 If set to true the Object is deleted when its reference count reaches 0. More...
 
bool automaticDelete () const
 If set to true the Object is deleted when its reference count reaches 0. More...
 
template<class T >
T * as ()
 Casts an Object to the specified class. More...
 
template<class T >
const T * as () const
 Casts an Object to the specified class. More...
 

Protected Attributes

ref< GeometrymGeometry
 
ref< ArrayFloat3mVertices
 
ref< ArrayFloat3mNormals
 
std::vector< ref< ArrayFloat3 > > mVertexFrames
 
std::vector< ref< ArrayFloat3 > > mNormalFrames
 
real mLastUpdate
 
real mElapsedTime
 
real mAnimationStartTime
 
int mAnimationStart
 
int mAnimationEnd
 
float mAnimationPeriod
 
bool mAnimationStarted
 
int mFrame1
 
int mFrame2
 
bool mGLSLVertexBlendEnabled
 
int mVertex2_Binding
 
int mNormal2_Binding
 
int mAnim_t_Binding
 
float mAnim_t
 
- Protected Attributes inherited from vl::ActorEventCallback
bool mEnabled
 
- Protected Attributes inherited from vl::Object
std::string mObjectName
 
IMutexmRefCountMutex
 
int mReferenceCount
 
bool mAutomaticDelete
 

Additional Inherited Members

- Protected Member Functions inherited from vl::Object
virtual ~Object ()
 

Detailed Description

The MorphingCallback class implements a simple morphing animation mechanism using the GPU acceleration where available.

Definition at line 44 of file MorphingCallback.hpp.

Constructor & Destructor Documentation

◆ MorphingCallback()

MorphingCallback::MorphingCallback ( )

◆ ~MorphingCallback()

MorphingCallback::~MorphingCallback ( )

Definition at line 56 of file MorphingCallback.cpp.

Member Function Documentation

◆ animationStarted()

bool vl::MorphingCallback::animationStarted ( ) const
inline

Definition at line 89 of file MorphingCallback.hpp.

◆ bindActor()

void MorphingCallback::bindActor ( Actor actor)

◆ blendFrames()

void MorphingCallback::blendFrames ( int  a,
int  b,
float  t 
)

◆ geometry() [1/2]

Geometry* vl::MorphingCallback::geometry ( )
inline

Definition at line 86 of file MorphingCallback.hpp.

Referenced by init().

◆ geometry() [2/2]

const Geometry* vl::MorphingCallback::geometry ( ) const
inline

Definition at line 87 of file MorphingCallback.hpp.

◆ glslVertexBlendEnabled()

bool vl::MorphingCallback::glslVertexBlendEnabled ( ) const
inline

Definition at line 83 of file MorphingCallback.hpp.

Referenced by onActorRenderStarted().

◆ init()

void MorphingCallback::init ( ResourceDatabase res_db)

Initializes a MorphingCallback from a ResourceDatabase.

The given ResourceDatabase must contain a Geometry with all the desired DrawCalls and vertex attributes setup with the exception of the vertex position array and vertex normal array since they are automatically generated in realtime time during the rendering from the vertex and normal frames specified below. In addition ResourceDatabase must contain:

  • N ArrayFloat3 objects named 'vertex_frame' containing the vertex position for every frame
  • N ArrayFloat3 objects named 'normal_frame' containing the vertex normal for every frame where N is the number of animation frames.

Definition at line 174 of file MorphingCallback.cpp.

References vl::ResourceDatabase::count(), vl::Log::error(), geometry(), vl::ResourceDatabase::get(), mGeometry, mNormalFrames, mNormals, mVertexFrames, mVertices, NULL, and vl::Object::objectName().

◆ initFrom()

void MorphingCallback::initFrom ( MorphingCallback morph_cb)

◆ onActorDelete()

virtual void vl::MorphingCallback::onActorDelete ( Actor actor)
inlinevirtual

Event notifying that an Actor is being deleted.

Implements vl::ActorEventCallback.

Definition at line 55 of file MorphingCallback.hpp.

◆ onActorRenderStarted()

void MorphingCallback::onActorRenderStarted ( Actor actor,
real  frame_clock,
const Camera cam,
Renderable renderable,
const Shader shader,
int  pass 
)
virtual

Event generated just before an Actor is rendered but after the render states are ready and setup.

Reimplement to react to this event.

Parameters
actorThe Actor bound to this rendering callback.
frame_clockThe current rendering frame time, usually used for animation purposes.
camThe camera used for the current rendering.
renderableThe currently selected Actor LOD.
shaderThe currently active Shader.
passThe current Actor[s] rendering pass.

Implements vl::ActorEventCallback.

Definition at line 60 of file MorphingCallback.cpp.

References blendFrames(), vl::BUM_KeepRamBuffer, vl::GLSLProgram::getAttribLocation(), vl::GLSLProgram::getUniformLocation(), vl::Shader::glslProgram(), glslVertexBlendEnabled(), mAnim_t, mAnim_t_Binding, mAnimationEnd, mAnimationPeriod, mAnimationStart, mAnimationStarted, mAnimationStartTime, mElapsedTime, mFrame1, mFrame2, mGeometry, mLastUpdate, mNormal2_Binding, mNormalFrames, mNormals, mVertex2_Binding, mVertexFrames, mVertices, NULL, and VL_CHECK.

◆ resetGLSLBindings()

void MorphingCallback::resetGLSLBindings ( )

Definition at line 322 of file MorphingCallback.cpp.

References mAnim_t_Binding, mNormal2_Binding, and mVertex2_Binding.

Referenced by MorphingCallback().

◆ setAnimation()

void MorphingCallback::setAnimation ( int  start,
int  end,
float  period 
)

◆ setGLSLVertexBlendEnabled()

void vl::MorphingCallback::setGLSLVertexBlendEnabled ( bool  enable)
inline

Definition at line 84 of file MorphingCallback.hpp.

Referenced by MorphingCallback().

◆ startAnimation()

void MorphingCallback::startAnimation ( real  time = -1)

◆ stopAnimation()

void MorphingCallback::stopAnimation ( )

Definition at line 284 of file MorphingCallback.cpp.

References mAnimationStarted.

Member Data Documentation

◆ mAnim_t

float vl::MorphingCallback::mAnim_t
protected

Definition at line 112 of file MorphingCallback.hpp.

Referenced by MorphingCallback(), and onActorRenderStarted().

◆ mAnim_t_Binding

int vl::MorphingCallback::mAnim_t_Binding
protected

Definition at line 111 of file MorphingCallback.hpp.

Referenced by onActorRenderStarted(), and resetGLSLBindings().

◆ mAnimationEnd

int vl::MorphingCallback::mAnimationEnd
protected

Definition at line 102 of file MorphingCallback.hpp.

Referenced by onActorRenderStarted(), and setAnimation().

◆ mAnimationPeriod

float vl::MorphingCallback::mAnimationPeriod
protected

Definition at line 103 of file MorphingCallback.hpp.

Referenced by onActorRenderStarted(), and setAnimation().

◆ mAnimationStart

int vl::MorphingCallback::mAnimationStart
protected

Definition at line 101 of file MorphingCallback.hpp.

Referenced by onActorRenderStarted(), and setAnimation().

◆ mAnimationStarted

bool vl::MorphingCallback::mAnimationStarted
protected

◆ mAnimationStartTime

real vl::MorphingCallback::mAnimationStartTime
protected

Definition at line 100 of file MorphingCallback.hpp.

Referenced by onActorRenderStarted(), setAnimation(), and startAnimation().

◆ mElapsedTime

real vl::MorphingCallback::mElapsedTime
protected

Definition at line 99 of file MorphingCallback.hpp.

Referenced by onActorRenderStarted(), setAnimation(), and startAnimation().

◆ mFrame1

int vl::MorphingCallback::mFrame1
protected

◆ mFrame2

int vl::MorphingCallback::mFrame2
protected

◆ mGeometry

ref<Geometry> vl::MorphingCallback::mGeometry
protected

◆ mGLSLVertexBlendEnabled

bool vl::MorphingCallback::mGLSLVertexBlendEnabled
protected

Definition at line 108 of file MorphingCallback.hpp.

◆ mLastUpdate

real vl::MorphingCallback::mLastUpdate
protected

◆ mNormal2_Binding

int vl::MorphingCallback::mNormal2_Binding
protected

Definition at line 110 of file MorphingCallback.hpp.

Referenced by onActorRenderStarted(), and resetGLSLBindings().

◆ mNormalFrames

std::vector< ref<ArrayFloat3> > vl::MorphingCallback::mNormalFrames
protected

Definition at line 96 of file MorphingCallback.hpp.

Referenced by blendFrames(), init(), initFrom(), and onActorRenderStarted().

◆ mNormals

ref<ArrayFloat3> vl::MorphingCallback::mNormals
protected

Definition at line 94 of file MorphingCallback.hpp.

Referenced by blendFrames(), init(), initFrom(), and onActorRenderStarted().

◆ mVertex2_Binding

int vl::MorphingCallback::mVertex2_Binding
protected

Definition at line 109 of file MorphingCallback.hpp.

Referenced by onActorRenderStarted(), and resetGLSLBindings().

◆ mVertexFrames

std::vector< ref<ArrayFloat3> > vl::MorphingCallback::mVertexFrames
protected

Definition at line 95 of file MorphingCallback.hpp.

Referenced by blendFrames(), init(), initFrom(), and onActorRenderStarted().

◆ mVertices

ref<ArrayFloat3> vl::MorphingCallback::mVertices
protected

Definition at line 93 of file MorphingCallback.hpp.

Referenced by blendFrames(), init(), initFrom(), and onActorRenderStarted().


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