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