GL Studio C++ Runtime API
gls_serial_morph_mesh.h
Go to the documentation of this file.
1/*! \file
2 \brief The disti::GlsSerialMorphMesh class.
3
4 \par Copyright Information
5
6 Copyright (c) 2017 by The DiSTI Corporation.<br>
7 11301 Corporate Blvd; Suite 100<br>
8 Orlando, Florida 32817<br>
9 USA<br>
10 <br>
11 All rights reserved.<br>
12
13 This Software contains proprietary trade secrets of DiSTI and may not be
14reproduced, in whole or part, in any form, or by any means of electronic,
15mechanical, or otherwise, without the written permission of DiSTI. Said
16permission may be derived through the purchase of applicable DiSTI product
17licenses which detail the distribution rights of this content and any
18Derivative Works based on this or other copyrighted DiSTI Software.
19
20 NO WARRANTY. THE SOFTWARE IS PROVIDED "AS-IS," WITHOUT WARRANTY OF ANY KIND,
21AND ANY USE OF THIS SOFTWARE PRODUCT IS AT YOUR OWN RISK. TO THE MAXIMUM EXTENT
22PERMITTED BY APPLICABLE LAW, DISTI AND ITS SUPPLIERS DISCLAIM ALL WARRANTIES
23AND CONDITIONS, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
24IMPLIED WARRANTIES AND CONDITIONS OF MERCHANTABILITY AND/OR FITNESS FOR A
25PARTICULAR PURPOSE, TITLE, AND NON-INFRINGEMENT, WITH REGARD TO THE SOFTWARE.
26
27 LIMITATION OF LIABILITY. TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW,
28IN NO EVENT SHALL DISTI OR ITS SUPPLIERS BE LIABLE FOR ANY SPECIAL, INCIDENTAL,
29INDIRECT, OR CONSEQUENTIAL DAMAGES WHATSOEVER (INCLUDING, WITHOUT LIMITATION,
30DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, LOSS OF BUSINESS
31INFORMATION, OR ANY OTHER PECUNIARY LOSS) ARISING OUT OF THE USE OF OR
32INABILITY TO USE THE SOFTWARE, EVEN IF DISTI HAS BEEN ADVISED OF THE POSSIBILITY
33OF SUCH DAMAGES. DISTI'S ENTIRE LIABILITY AND YOUR EXCLUSIVE REMEDY SHALL NOT
34EXCEED FIVE DOLLARS (US$5.00).
35
36 The aforementioned terms and restrictions are governed by the laws of the
37State of Florida and the United States of America.
38
39*/
40
41#ifndef INCLUDED_GLS_SERIAL_MORPH_MESH_H
42#define INCLUDED_GLS_SERIAL_MORPH_MESH_H
43
44#ifdef _WIN32
45# include <windows.h>
46#endif
47
49#include "gls_resource_file_mgr.h"
50#include "group.h"
51
52#include "gls_advanced_mesh.h"
54
55/// Provides support for creating DLLs.
56#if( defined( GLSGEN_EXPORT_GLSADVANCEDMESH ) || defined( GLSGEN_IMPORT_GLSADVANCEDMESH ) || defined( GLS_EXPORT_GENERATED ) || defined( GLS_IMPORT_GENERATED ) ) \
57 && defined( _MSC_VER )
58# if defined( GLSGEN_EXPORT_GLSADVANCEDMESH ) || defined( GLS_EXPORT_GENERATED )
59# define GLSGEN_GlsSerialMorphMesh_EXPORT __declspec( dllexport )
60# else
61# define GLSGEN_GlsSerialMorphMesh_EXPORT __declspec( dllimport )
62# endif
63#else
64# define GLSGEN_GlsSerialMorphMesh_EXPORT
65#endif
66///////////////////////////////////////////////////////////////////////////////
67
68/// Automatically link the runtime library plugin (on Windows).
69#define LIB_BASE_NAME "gls_advanced_mesh"
70#include "gls_auto_lib.h"
71#undef LIB_BASE_NAME
72
73namespace disti
74{
75#ifdef GLES
76// Forward Declaration
77class GlsGloFileAttribute;
78#endif
79
80/**
81 The GlsSerialMorphMesh contains a series of morph targets (keyframes) that make up an animation.
82*/
84{
85public:
86 DISTI_DEPRECATED( "This identifier is forbidden by the C++ standard. Use BaseClass instead." )
87 typedef GlsGeometryResourceMesh _BaseClass; ///< Deprecated typedef for the base class.
88 typedef GlsGeometryResourceMesh BaseClass; ///< Typedef for the base class.
89 friend class GlsSerialMorphMeshEditor;
90
91 /** Create a new GlsSerialMorphMesh. */
93
94 /// Copy constructor
95 /// \param that The object to copy from.
96 /// \param generateNames Whether or not an instance name should be generated for this object.
98
99 /** Destructs a GlsSerialMorphMesh object */
101
102 /// \return A pointer to a new GlsSerialMorphMesh object.
104
105 //////////////////////////////////////////////////
106 // Overridden base class methods
107 //////////////////////////////////////////////////
108
113
114#ifndef GLES
117#endif
118
120
121 //////////////////////////////////////////////////
122 // GlsSerialMorphMesh specific operations
123 //////////////////////////////////////////////////
124
125 /** Set the number of keyframes in the mesh
126 If this is less than the current number of keyframes, then keyframes >=NumKeyframes() will be released
127 The initial Geometry and Values for new keyframes are undefined, be sure to fill them in before you
128 try to draw/pick/etc.
129 \param count the new number of keyframes
130 */
132
133 /** Get the number of keyframes in the mesh
134 \returns the number of keyframes
135 */
137
138 /// \return The geometry for the given keyframe.
139 /// \param index The index whose geometry is to be returned.
141
142 /// Set the geometry for the given keyframe.
143 /// Note that the render geometry Type() is derived from keyframe 0.
144 /// If you modify the Type() of the keyframe geometry you must call this method to update the render mesh.
145 /// \param keyframeIndex
146 /// \param newKeyframeGeometry Pointer to the new geometry to use
147 GLSGEN_GlsSerialMorphMesh_EXPORT void SetKeyframeGeometry( unsigned int keyframeIndex, GlsGeometry_Generic* newKeyframeGeometry );
148
149 /// Set the value for the given animation keyframe.
150 /// \param index The keyframe index whose value is to be set.
151 /// \param value The new value to set.
152 GLSGEN_GlsSerialMorphMesh_EXPORT void SetKeyframePercent( unsigned int index, const float& value );
153
154 /** Get the value for the given animation keyframe
155 * \param index keyframe index
156 * \returns percent
157 */
159
160 /// Set the mesh to the given animation value.
161 /// \param value The new animation value to set.
163
164 /** Get the current animation value
165 * \returns percent animation value
166 */
168
169 /** Set the tension parameter.
170 * Tension affects how the mesh is interpolated between targets.
171 * \param value value to determine what interpolation is used
172 * 0.0 is linear interpolation
173 * higher values use spline interpolation to smooth out the transitions at each target.
174 * Recommended values are 0.0 and 0.5. Other values result in "special effects".
175 */
177
178 /** Get the current 'tension' value
179 * \returns tension value
180 */
182
183 /** Flag the render mesh as dirty so that it will be updated before it is drawn
184 */
185 inline void InvalidateRenderMesh() { _renderMeshIsValid = false; }
186
187 /** Update the render mesh immeadiately
188 * This is normally done as needed automatically
189 */
191
192protected:
194
195#ifdef GLES
196 /** Set a single attribute from the GLO file.
197 * \param data The attribute to set and its associated data.
198 */
200#endif
201
202 /// \details The Keyframe_Data class. Stores data for one keyframe of animation.
204 {
205 protected:
206 DistiAttribDict* _attribDict; ///< The attribute dictionary for this object's members.
207
208 /// Populates the attribute dictionary.
210
211 public:
212 GlsGeometry_Generic* _geometry; ///< An observing pointer to the mesh data values for this keyframe.
213 float _value; ///< The key value for this keyframe.
214
216
217 /// Copy constructor
219
221
222 /// Assignment operator
223 /// \return The resulting object (this).
225
226 /// Set the pointer to the mesh data values for this keyframe.
227 /// \param geom The new mesh pointer to set.
229
230 /// \return The pointer to the mesh data values for this keyframe.
232
233 /// \return A reference to the attribute dictionary for this object.
235 };
236
237 /// \details The KeyframeDataArray class. Holds multiple Keyframe_Data instances.
239 {
240 public:
241 GlsSerialMorphMesh* _parentMesh; ///< Observing pointer to the GlsSerialMorphMesh object.
242
244 : _parentMesh( NULL )
245 {}
246
247 /// Read an item from the stream into a KeyFrame.
248 /// \param index The index to write into.
249 /// \param array The array to write into.
250 /// \param instr The stream to read from.
251 static void element_read_func( int index, KeyframeDataArray& array, std::istream& instr );
252
253 /// Write an item from a KeyFrame into the stream.
254 /// \param index The index to read from.
255 /// \param array The array to read from.
256 /// \param outstr The stream to write to.
257 static void element_write_func( int index, KeyframeDataArray& array, std::ostream& outstr );
258
259 /// Set the number of elements in the array, it will resize accordingly.
260 /// \param count The new number of elements to resize to.
261 void Count( unsigned count ) { _keyframes.Count( count ); }
262
263 /// \return The number of elements in the array.
264 unsigned Count() const { return _keyframes.Count(); }
265
266 /// Clear all elements in the array.
267 void Clear() { _keyframes.Clear(); }
268
269 /// Index operator
270 /// \param index The index of the item to return.
271 /// \return A modifiable reference to the desired item.
272 Keyframe_Data& operator[]( const std::size_t index ) { return _keyframes[ static_cast<unsigned>( index ) ]; }
273
274 /// Index operator
275 /// \param index The index of the item to return.
276 /// \return A const reference to the desired item.
277 const Keyframe_Data& operator[]( const std::size_t index ) const { return _keyframes[ static_cast<unsigned>( index ) ]; }
278
279 private:
281 };
282
283 KeyframeDataArray _keyframes; ///< The list of animation keyframes.
284
285 float _currentValue; ///< The current position in the animation.
286 float _tension; ///< The interpolation tension value.
287
288 unsigned int _last_keyframe_index; ///< The first keyframe where _value <= _currentValue.
289 unsigned int _next_keyframe_index; ///< The next keyframe after last_keyframe_index where _value > _currentValue. If _value matches _currentValue exactly, then last_keyframe_index == next_keyframe_index.
290 float _last_keyframe_weight; ///< The blend weight for the first keyframe [0,1].
291 float _next_keyframe_weight; ///< The blend weight for the next keyframe [0,1].
292
293 bool _renderMeshIsValid; ///< If false, the mesh will be recalculated prior to next draw.
294 GlsGeometry_Generic* _renderMesh; ///< The mesh being morphed.
295
296 /// Update the _last_keyframe_index, _next_keyframe_index, _last_keyframe_weight and _next_keyframe_weight
298
299 /// Called by the KeyframeData class when the geometry changes.
301
302private:
303#ifdef GLES
304 int _gloKeyframeIndex;
305#endif
306
307 void CalculateBSplineInterpolation() const;
308
309 // Used by constructors
310 GLSGEN_GlsSerialMorphMesh_EXPORT void InitializeMembers();
311
312 // Disable implicit generated Members
315};
316
317} // namespace disti
318
319#endif
Definition: cull.h:50
Definition: display.h:96
Definition: disti_metadata.h:734
Definition: dynamic_array.h:79
Definition: gls_geometry_resource_mesh.h:80
Definition: gls_geometry_resource.h:87
Definition: gls_geometry_resource.h:507
Definition: gls_glo_file.h:1243
Definition: gls_serial_morph_mesh.h:239
void Count(unsigned count)
Definition: gls_serial_morph_mesh.h:261
static void element_read_func(int index, KeyframeDataArray &array, std::istream &instr)
unsigned Count() const
Definition: gls_serial_morph_mesh.h:264
const Keyframe_Data & operator[](const std::size_t index) const
Definition: gls_serial_morph_mesh.h:277
GlsSerialMorphMesh * _parentMesh
Observing pointer to the GlsSerialMorphMesh object.
Definition: gls_serial_morph_mesh.h:241
void Clear()
Clear all elements in the array.
Definition: gls_serial_morph_mesh.h:267
Keyframe_Data & operator[](const std::size_t index)
Definition: gls_serial_morph_mesh.h:272
static void element_write_func(int index, KeyframeDataArray &array, std::ostream &outstr)
Definition: gls_serial_morph_mesh.h:204
Keyframe_Data(const Keyframe_Data &)
Copy constructor.
float _value
The key value for this keyframe.
Definition: gls_serial_morph_mesh.h:213
void SetupAttribDict()
Populates the attribute dictionary.
const Keyframe_Data & operator=(const Keyframe_Data &)
GlsGeometry_Generic * _geometry
An observing pointer to the mesh data values for this keyframe.
Definition: gls_serial_morph_mesh.h:212
DistiAttribDict * _attribDict
The attribute dictionary for this object's members.
Definition: gls_serial_morph_mesh.h:206
void SetGeometry(GlsGeometry_Generic *geom)
Definition: gls_serial_morph_mesh.h:84
virtual InterfaceListType * GetCppInterfaceDescription(InterfaceListType *addToThisList=NULL) DISTI_METHOD_OVERRIDE
virtual void SetAvailableAttributes(unsigned int value) DISTI_METHOD_OVERRIDE
virtual void GetCppInterfaceDescriptionFree(InterfaceListType *array) DISTI_METHOD_OVERRIDE
void SetMorphPercent(const float &value)
float _last_keyframe_weight
The blend weight for the first keyframe [0,1].
Definition: gls_serial_morph_mesh.h:290
virtual DisplayObject * CloneObject(bool generateNames=false) DISTI_METHOD_OVERRIDE
void RecalculateKeyframeIndicesAndWeights()
Update the _last_keyframe_index, _next_keyframe_index, _last_keyframe_weight and _next_keyframe_weigh...
virtual void PreDraw(const OpenGLMatrices &parentMatrices, Culler &culler) DISTI_METHOD_OVERRIDE
float GetKeyframePercent(unsigned int index)
void KeyframeGeometryChanged(Keyframe_Data *)
Called by the KeyframeData class when the geometry changes.
void SetKeyframePercent(unsigned int index, const float &value)
virtual GlsGeometryResource * GetRenderMesh() DISTI_METHOD_OVERRIDE
void InvalidateRenderMesh()
Definition: gls_serial_morph_mesh.h:185
static DisplayObject * CreateInstance()
float _tension
The interpolation tension value.
Definition: gls_serial_morph_mesh.h:286
virtual void CopyGeometry(DisplayObject *src) DISTI_METHOD_OVERRIDE
float _next_keyframe_weight
The blend weight for the next keyframe [0,1].
Definition: gls_serial_morph_mesh.h:291
void SetNumKeyframes(unsigned int count)
GlsGeometry_Generic * _renderMesh
The mesh being morphed.
Definition: gls_serial_morph_mesh.h:294
void SetTension(const float &value)
GlsGeometry_Generic * GetKeyframeGeometry(unsigned int index)
void SetKeyframeGeometry(unsigned int keyframeIndex, GlsGeometry_Generic *newKeyframeGeometry)
virtual void CopyProperties(DisplayObject *src) DISTI_METHOD_OVERRIDE
unsigned int _last_keyframe_index
The first keyframe where _value <= _currentValue.
Definition: gls_serial_morph_mesh.h:288
float _currentValue
The current position in the animation.
Definition: gls_serial_morph_mesh.h:285
KeyframeDataArray _keyframes
The list of animation keyframes.
Definition: gls_serial_morph_mesh.h:283
unsigned int NumKeyframes()
bool _renderMeshIsValid
If false, the mesh will be recalculated prior to next draw.
Definition: gls_serial_morph_mesh.h:293
unsigned int _next_keyframe_index
The next keyframe after last_keyframe_index where _value > _currentValue. If _value matches _currentV...
Definition: gls_serial_morph_mesh.h:289
Class to contain current OpenGL view, projection and draw matrices.
Definition: util.h:544
The disti::GlsAdvancedMesh class.
The gls_auto_lib.
Macros and helper code to determine what subset of C++11/14/17 is available.
#define DISTI_SPECIAL_MEM_FUN_DELETE
Macro to wrap function deletion, removed on compilers that don't support it.
Definition: gls_cpp_lang_support.h:235
#define DISTI_DEPRECATED(msg)
Defines whether this compiler supports the C++14 deprecated attribute.
Definition: gls_cpp_lang_support.h:457
#define DISTI_METHOD_OVERRIDE
Macro to wrap the override keyword, removed on compilers that don't support it.
Definition: gls_cpp_lang_support.h:214
The disti::GlsGeometryResource class.
#define GLSGEN_GlsSerialMorphMesh_EXPORT
Provides support for creating DLLs.
Definition: gls_serial_morph_mesh.h:64
The disti::Group class. Implements groups of objects.
Force inclusion of the DirectShow library.
Definition: bmpimage.h:47