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]
MorphingCallback.hpp
Go to the documentation of this file.
1 /**************************************************************************************/
2 /* */
3 /* Visualization Library */
4 /* http://visualizationlibrary.org */
5 /* */
6 /* Copyright (c) 2005-2020, Michele Bosi */
7 /* All rights reserved. */
8 /* */
9 /* Redistribution and use in source and binary forms, with or without modification, */
10 /* are permitted provided that the following conditions are met: */
11 /* */
12 /* - Redistributions of source code must retain the above copyright notice, this */
13 /* list of conditions and the following disclaimer. */
14 /* */
15 /* - Redistributions in binary form must reproduce the above copyright notice, this */
16 /* list of conditions and the following disclaimer in the documentation and/or */
17 /* other materials provided with the distribution. */
18 /* */
19 /* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND */
20 /* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED */
21 /* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE */
22 /* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR */
23 /* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES */
24 /* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; */
25 /* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON */
26 /* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT */
27 /* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS */
28 /* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */
29 /* */
30 /**************************************************************************************/
31 
32 #ifndef MorphingCallback_INCLUDE_ONCE
33 #define MorphingCallback_INCLUDE_ONCE
34 
35 #include <vlGraphics/Actor.hpp>
36 #include <vlGraphics/Geometry.hpp>
37 
38 namespace vl
39 {
40  class ResourceDatabase;
41 
45  {
47 
48  public:
50 
52 
53  virtual void onActorRenderStarted(Actor* actor, real frame_clock, const Camera* cam, Renderable* renderable, const Shader*, int pass);
54 
55  virtual void onActorDelete(Actor*) {}
56 
57  void bindActor(Actor* actor);
58 
69  void init(ResourceDatabase* res_db);
70 
71  void blendFrames(int a, int b, float t);
72 
73  void setAnimation(int start, int end, float period);
74 
75  void startAnimation(real time = -1);
76 
77  void stopAnimation();
78 
79  void initFrom(MorphingCallback* morph_cb);
80 
81  void resetGLSLBindings();
82 
83  bool glslVertexBlendEnabled() const { return mGLSLVertexBlendEnabled; }
84  void setGLSLVertexBlendEnabled(bool enable) { mGLSLVertexBlendEnabled = enable; }
85 
86  Geometry* geometry() { return mGeometry.get(); }
87  const Geometry* geometry() const { return mGeometry.get(); }
88 
89  bool animationStarted() const { return mAnimationStarted; }
90 
91  protected:
95  std::vector< ref<ArrayFloat3> > mVertexFrames;
96  std::vector< ref<ArrayFloat3> > mNormalFrames;
97 
105  int mFrame1;
106  int mFrame2;
107 
112  float mAnim_t;
113  };
114  //-----------------------------------------------------------------------------
115 }
116 
117 #endif
Associates a Renderable object to an Effect and Transform.
Definition: Actor.hpp:130
std::vector< ref< ArrayFloat3 > > mNormalFrames
bool animationStarted() const
ref< ArrayFloat3 > mNormals
#define VL_INSTRUMENT_CLASS(ClassName, BaseClass)
Definition: TypeInfo.hpp:122
The Geometry class is a Renderable that implements a polygonal mesh made of polygons, lines and points.
Definition: Geometry.hpp:66
Visualization Library main namespace.
ref< Geometry > mGeometry
void setGLSLVertexBlendEnabled(bool enable)
An abstract class that represents all the objects that can be rendered.
Definition: Renderable.hpp:58
bool glslVertexBlendEnabled() const
std::vector< ref< ArrayFloat3 > > mVertexFrames
The ActorEventCallback class defines a callback object to react to Actor-related events.
Definition: Actor.hpp:75
Manages most of the OpenGL rendering states responsible of the final aspect of the rendered objects...
Definition: Shader.hpp:1830
virtual void onActorDelete(Actor *)
Event notifying that an Actor is being deleted.
ref< ArrayFloat3 > mVertices
The MorphingCallback class implements a simple morphing animation mechanism using the GPU acceleratio...
The ref<> class is used to reference-count an Object.
Definition: Object.hpp:55
const Geometry * geometry() const
Represents a virtual camera defining, among other things, the point of view from which scenes can be ...
Definition: Camera.hpp:50
The ResourceDatabase class contains and manipulates a set of resources.