# Visualization Library

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

[Home] [Tutorials] [All Classes] [Grouped Classes]

Public Member Functions | Protected Attributes

# 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:

List of all members.

## 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.
virtual void | onActorDelete (Actor *)
| Event notifying that an Actor is being deleted.
void | bindActor (Actor *actor)
void | init (ResourceDatabase *res_db)
| Initializes a MorphingCallback from a ResourceDatabase.
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)
Geometry * | geometry ()
const Geometry * | geometry () const
bool | animationStarted () const

## Protected Attributes

ref< Geometry > | mGeometry
ref< ArrayFloat3 > | mVertices
ref< ArrayFloat3 > | mNormals
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

## 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 | ( | ) |

Definition at line 41 of file MorphingCallback.cpp.

References mAnim_t, mFrame1, mFrame2, mGeometry, mLastUpdate, resetGLSLBindings(), setAnimation(), setGLSLVertexBlendEnabled(), and VL_DEBUG_SET_OBJECT_NAME.

MorphingCallback::~MorphingCallback | ( | ) |

Definition at line 56 of file MorphingCallback.cpp.

## Member Function Documentation

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:

  actor | The Actor bound to this rendering callback.
  frame_clock | The current rendering frame time, usually used for animation purposes.
  cam | The camera used for the current rendering.
  renderable | The currently selected Actor LOD.
  shader | The currently active Shader.
  pass | The current Actor[s] rendering pass.

Implements vl::ActorEventCallback.

Definition at line 60 of file MorphingCallback.cpp.

References blendFrames(), vl::BUM_KeepRamBuffer, vl::ref< T >::get(), 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.

virtual void vl::MorphingCallback::onActorDelete | ( | Actor * | actor ) | `[inline, virtual]`

Event notifying that an Actor is being deleted.

Implements vl::ActorEventCallback.

Definition at line 55 of file MorphingCallback.hpp.

void MorphingCallback::bindActor | ( | Actor * | actor ) |

Definition at line 168 of file MorphingCallback.cpp.

References vl::Actor::actorEventCallbacks(), vl::ref< T >::get(), mGeometry, vl::Collection< T >::push_back(), and vl::Actor::setLod().

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().

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

Definition at line 230 of file MorphingCallback.cpp.

References vl::BU_DYNAMIC_DRAW, vl::Has_BufferObject, mGeometry, mNormalFrames, mNormals, mVertexFrames, and mVertices.

Referenced by onActorRenderStarted().

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

Definition at line 264 of file MorphingCallback.cpp.

References mAnimationEnd, mAnimationPeriod, mAnimationStart, mAnimationStarted, mAnimationStartTime, mElapsedTime, mFrame1, mFrame2, and mLastUpdate.

Referenced by initFrom(), and MorphingCallback().

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

Definition at line 277 of file MorphingCallback.cpp.

References mAnimationStarted, mAnimationStartTime, mElapsedTime, mFrame1, mFrame2, and mLastUpdate.

void MorphingCallback::stopAnimation | ( | ) |

Definition at line 287 of file MorphingCallback.cpp.

References mAnimationStarted.

void MorphingCallback::initFrom | ( | MorphingCallback * | morph_cb ) |

Definition at line 292 of file MorphingCallback.cpp.

References mGeometry, mNormalFrames, mNormals, mVertexFrames, mVertices, NULL, and setAnimation().

void MorphingCallback::resetGLSLBindings | ( | ) |

Definition at line 325 of file MorphingCallback.cpp.

References mAnim_t_Binding, mNormal2_Binding, and mVertex2_Binding.

Referenced by MorphingCallback().

bool vl::MorphingCallback::glslVertexBlendEnabled | ( | ) | const`[inline]`

Definition at line 83 of file MorphingCallback.hpp.

Referenced by onActorRenderStarted().

void vl::MorphingCallback::setGLSLVertexBlendEnabled | ( | bool | enable ) | `[inline]`

Definition at line 84 of file MorphingCallback.hpp.

Referenced by MorphingCallback().

Geometry* vl::MorphingCallback::geometry | ( | ) | `[inline]`

Definition at line 86 of file MorphingCallback.hpp.

Referenced by init().

const Geometry* vl::MorphingCallback::geometry | ( | ) | const`[inline]`

Definition at line 87 of file MorphingCallback.hpp.

bool vl::MorphingCallback::animationStarted | ( | ) | const`[inline]`

Definition at line 89 of file MorphingCallback.hpp.

## Member Data Documentation

ref<Geometry> vl::MorphingCallback::mGeometry`[protected]`

Definition at line 92 of file MorphingCallback.hpp.

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

ref<ArrayFloat3> vl::MorphingCallback::mVertices`[protected]`

Definition at line 93 of file MorphingCallback.hpp.

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

ref<ArrayFloat3> vl::MorphingCallback::mNormals`[protected]`

Definition at line 94 of file MorphingCallback.hpp.

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

std::vector< ref<ArrayFloat3> > vl::MorphingCallback::mVertexFrames`[protected]`

Definition at line 95 of file MorphingCallback.hpp.

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

std::vector< ref<ArrayFloat3> > vl::MorphingCallback::mNormalFrames`[protected]`

Definition at line 96 of file MorphingCallback.hpp.

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

real vl::MorphingCallback::mLastUpdate`[protected]`

Definition at line 98 of file MorphingCallback.hpp.

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

real vl::MorphingCallback::mElapsedTime`[protected]`

Definition at line 99 of file MorphingCallback.hpp.

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

real vl::MorphingCallback::mAnimationStartTime`[protected]`

Definition at line 100 of file MorphingCallback.hpp.

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

int vl::MorphingCallback::mAnimationStart`[protected]`

Definition at line 101 of file MorphingCallback.hpp.

Referenced by onActorRenderStarted(), and setAnimation().

int vl::MorphingCallback::mAnimationEnd`[protected]`

Definition at line 102 of file MorphingCallback.hpp.

Referenced by onActorRenderStarted(), and setAnimation().

float vl::MorphingCallback::mAnimationPeriod`[protected]`

Definition at line 103 of file MorphingCallback.hpp.

Referenced by onActorRenderStarted(), and setAnimation().

bool vl::MorphingCallback::mAnimationStarted`[protected]`

Definition at line 104 of file MorphingCallback.hpp.

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

int vl::MorphingCallback::mFrame1`[protected]`

Definition at line 105 of file MorphingCallback.hpp.

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

int vl::MorphingCallback::mFrame2`[protected]`

Definition at line 106 of file MorphingCallback.hpp.

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

bool vl::MorphingCallback::mGLSLVertexBlendEnabled`[protected]`

Definition at line 108 of file MorphingCallback.hpp.

int vl::MorphingCallback::mVertex2_Binding`[protected]`

Definition at line 109 of file MorphingCallback.hpp.

Referenced by onActorRenderStarted(), and resetGLSLBindings().

int vl::MorphingCallback::mNormal2_Binding`[protected]`

Definition at line 110 of file MorphingCallback.hpp.

Referenced by onActorRenderStarted(), and resetGLSLBindings().

int vl::MorphingCallback::mAnim_t_Binding`[protected]`

Definition at line 111 of file MorphingCallback.hpp.

Referenced by onActorRenderStarted(), and resetGLSLBindings().

float vl::MorphingCallback::mAnim_t`[protected]`

Definition at line 112 of file MorphingCallback.hpp.

Referenced by MorphingCallback(), and onActorRenderStarted().

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

- D:/VL/BuildSystem/VL_DISTRO/Visualization_Library_SDK/src/vlGraphics/MorphingCallback.hpp
- D:/VL/BuildSystem/VL_DISTRO/Visualization_Library_SDK/src/vlGraphics/MorphingCallback.cpp

Visualization Library v2011.09.1162 Reference Documentation
Copyright 2005-2011 Michele Bosi. All rights reserved.
Updated on Thu Jan 26 2012 00:44:40.
Permission is granted to use this page to write and publish articles regarding Visualization Library.