GL Studio C++ Runtime API
gls_dynamic_path.h
Go to the documentation of this file.
1/// \file gls_dynamic_path.h
2/// \brief The disti::GlsDynamicPath class and global enumerations.
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 DISTI_INCLUDED_GLS_DYNAMIC_PATH_H
40#define DISTI_INCLUDED_GLS_DYNAMIC_PATH_H
41
43#include "group.h"
44
45/// Provides support for creating DLLs.
46#if( defined( GLSGEN_EXPORT_GLSDYNAMICPATH ) || defined( GLSGEN_IMPORT_GLSDYNAMICPATH ) || defined( GLS_EXPORT_GENERATED ) || defined( GLS_IMPORT_GENERATED ) ) \
47 && defined( _MSC_VER )
48# if defined( GLSGEN_EXPORT_GLSDYNAMICPATH ) || defined( GLS_EXPORT_GENERATED )
49# define GLSGEN_GLSDYNAMICPATH_EXPORT __declspec( dllexport )
50# else
51# define GLSGEN_GLSDYNAMICPATH_EXPORT __declspec( dllimport )
52# endif
53#else
54# define GLSGEN_GLSDYNAMICPATH_EXPORT
55#endif
56///////////////////////////////////////////////////////////////////////////////
57
58/// Automatically link the runtime library plugin (on Windows).
59#define LIB_BASE_NAME "gls_dynamic_path"
60#include "gls_auto_lib.h"
61#undef LIB_BASE_NAME
62
63namespace disti
64{
65// SetValue enumerations
66enum
67{
68 GLS_DYNAMICPATH_FIRST_VALUE = GLS_LAST_INITIALIZER + 1,
69 GLS_DYNAMICPATH_AFFECTS_LOCATION_X,
70 GLS_DYNAMICPATH_AFFECTS_LOCATION_Y,
71 GLS_DYNAMICPATH_AFFECTS_LOCATION_Z,
72 GLS_DYNAMICPATH_AFFECTS_ROTATION_X,
73 GLS_DYNAMICPATH_AFFECTS_ROTATION_Y,
74 GLS_DYNAMICPATH_AFFECTS_ROTATION_Z,
75 GLS_DYNAMICPATH_AFFECTS_SCALE_X,
76 GLS_DYNAMICPATH_AFFECTS_SCALE_Y,
77 GLS_DYNAMICPATH_AFFECTS_SCALE_Z,
78 GLS_DYNAMICPATH_USE_SHORT_ROTATION_PATHS,
79 GLS_DYNAMICPATH_STATE_COUNT,
80 GLS_DYNAMICPATH_STATE
81};
82
83/** Runtime implementation of a GlsDynamicPath */
85{
86 friend class GlsDynamicPathEditor;
87
88private:
91
92public:
93 DISTI_DEPRECATED( "This identifier is forbidden by the C++ standard. Use BaseClass instead." )
94 typedef DisplayObject _BaseClass; ///< Deprecated typedef for the base class.
95 typedef DisplayObject BaseClass; ///< Typedef for the base class.
96
97 /** Create a new GlsDynamicPath.
98 * \param generateInstanceName Whether or not to generate an instance name
99 * for this inputdevice */
100 GLSGEN_GLSDYNAMICPATH_EXPORT GlsDynamicPath( bool generateInstanceName = false );
101
102 /** The copy constructor for GlsDynamicPath
103 *
104 * \param that The GlsDynamicPath object that is being copied
105 * \param generateNames Whether or not to generate a new instance name
106 */
107 GLSGEN_GLSDYNAMICPATH_EXPORT GlsDynamicPath( const GlsDynamicPath& that, const bool generateNames );
108
109 /** Destructs a GlsDynamicPath object */
111
112 /// \return A pointer to a new GlsDynamicPath object.
114
118
119#ifndef GLES
122#endif
123
127 GLSGEN_GLSDYNAMICPATH_EXPORT bool Hit( float x, float y, float z, float scale, const Vector& directionVector, Vector* collisionPoint ) DISTI_METHOD_OVERRIDE;
131
132 //////////////////////////////////////////////////
133 // GlsDynamicPath specific operations
134 //////////////////////////////////////////////////
135
136 /// Set whether the path will affect the X component of the object's dynamic translation.
137 /// \param value The new component value.
139
140 /// \return Whether the path will affect the X component of the object's dynamic translation.
141 bool AffectsLocationX() const { return _affectsLocationX; }
142
143 /// Set whether the path will affect the Y component of the object's dynamic translation.
144 /// \param value The new component value.
146
147 /// \return Whether the path will affect the Y component of the object's dynamic translation.
148 bool AffectsLocationY() const { return _affectsLocationY; }
149
150 /// Set whether the path will affect the Z component of the object's dynamic translation.
151 /// \param value The new component value.
153
154 /// \return Whether the path will affect the Z component of the object's dynamic translation.
155 bool AffectsLocationZ() const { return _affectsLocationZ; }
156
157 /// Set whether the path will affect the X component of the object's dynamic rotation.
158 /// \param value The new component value.
160
161 /// \return Whether the path will affect the X component of the object's dynamic rotation.
162 bool AffectsRotationX() const { return _affectsRotationX; }
163
164 /// Set whether the path will affect the Y component of the object's dynamic rotation.
165 /// \param value The new component value.
167
168 /// \return Whether the path will affect the Y component of the object's dynamic rotation.
169 bool AffectsRotationY() const { return _affectsRotationY; }
170
171 /// Set whether the path will affect the Z component of the object's dynamic rotation.
172 /// \param value The new component value.
174
175 /// \return Whether the path will affect the Z component of the object's dynamic rotation.
176 bool AffectsRotationZ() const { return _affectsRotationZ; }
177
178 /// Set whether the path will affect the X component of the object's dynamic scale.
179 /// \param value The new component value.
181
182 /// \return Whether the path will affect the X component of the object's dynamic scale.
183 bool AffectsScaleX() const { return _affectsScaleX; }
184
185 /// Set whether the path will affect the Y component of the object's dynamic scale.
186 /// \param value The new component value.
188
189 /// \return Whether the path will affect the Y component of the object's dynamic scale.
190 bool AffectsScaleY() const { return _affectsScaleY; }
191
192 /// Set whether the path will affect the Z component of the object's dynamic scale.
193 /// \param value The new component value.
195
196 /// \return Whether the path will affect the Z component of the object's dynamic scale.
197 bool AffectsScaleZ() const { return _affectsScaleZ; }
198
199 /// If true, the shortest path between rotations is taken (360 degrees = no net rotation). If false, the long path is taken.
200 /// \param value The new rotation behavior.
202
203 /// \return True if the shortest path between rotations is taken (360 degrees = no net rotation), otherwise false.
205
206 /// \details The State class. Contains the data for a state along the path.
207 class State
208 {
209 friend class GlsDynamicPath;
210
211 public:
213
214 /// Copy constructor
216
218
219 /// Assignment operator
220 /// \return The resulting object (this).
222
223 /// Sets up DistiAttributes associated with each member of this class.
225
226 /// \return The attribute dictionary associated with the members of this class.
228 {
229 if( !_attribDict )
231 return *_attribDict;
232 };
233
234 /// Set the location value of this animation state.
235 /// \param value The new location value.
236 void Location( const Vector& value ) { _location = value; }
237
238 /// \deprecated Use the const version instead.
239 /// \return The location value of this animation state.
241
242 /// \return The location value of this animation state.
243 Vector Location() const { return _location; }
244
245 /// Set the rotation value of this animation state.
246 /// \param value The new rotation value.
247 void Rotation( const Vector& value ) { _rotation = value; }
248
249 /// \deprecated Use the const version instead.
250 /// \return The rotation value of this animation state.
252
253 /// \return The rotation value of this animation state.
254 Vector Rotation() const { return _rotation; }
255
256 /// Set the scale value of this animation state.
257 /// \param value The new scale value.
258 void Scale( const Vector& value ) { _scale = value; }
259
260 /// \deprecated Use the const version instead.
261 /// \return The scale value of this animation state.
262 Vector Scale() { return _scale; }
263
264 /// \return The scale value of this animation state.
265 Vector Scale() const { return _scale; }
266
267 /// Set the key value of this animation state
268 /// \param value The new key value.
269 void Value( const float& value ) { _value = value; }
270
271 /// \deprecated Use the const version instead.
272 /// \return The key value of this animation state.
273 float Value() { return _value; }
274
275 /// \return The key value of this animation state.
276 float Value() const { return _value; }
277
278 protected:
279 Vector _location; ///< The location of the animation state.
280 Vector _rotation; ///< The rotation of the animation state.
281 Vector _scale; ///< The scale of the animation state.
282 float _value; ///< The key value of the animation state.
283 DistiAttribDict* _attribDict; ///< Attribute storage for the members of this class.
284 };
285
286 typedef DynamicArray<State> StateArrayType; ///< Typedef for a list of States.
287
288 /// \returns the StateArray associated with this object. Use this array to modify the states that make up the path.
290
291 /// \returns the const StateArray associated with this object.
292 const StateArrayType& StateArray() const { return _stateArray; }
293
294 /// Iterates through the path segments and returns the first one found
295 /// that contains the given value.
296 /// Special cases:
297 /// value is before start of the path: index1 == index2 == 0
298 /// value is past the end of the path: index1 == index2 == (StateArray().Count()-1)
299 /// \param value The value to search for.
300 /// \param index1 Returns the index of the state at the start of the segment or -1 if no segments are found.
301 /// \param index2 Returns the index of the state at the end the segment or -1 if no segments are found.
302 GLSGEN_GLSDYNAMICPATH_EXPORT void FindFirstPathSegmentContainingValue( float value, int* index1, int* index2 );
303
304 /// \return The Value for the first state or 0 if there are no states.
306 {
307 if( _stateArray.Count() )
308 {
309 return _stateArray[ 0 ].Value();
310 }
311 else
312 {
313 return 0;
314 }
315 }
316
317 /// \return The Value for the last state or 0 if there are no states.
319 {
320 if( _stateArray.Count() )
321 {
322 return _stateArray[ _stateArray.Count() - 1 ].Value();
323 }
324 else
325 {
326 return 0;
327 }
328 }
329
330 /// \return The linearly interpolated location along the path for the given value.
331 /// \param value The value used to get the path location.
333
334 /// \return The linearly interpolated rotation along the path for the given value.
335 /// \param value The value used to get the path rotation.
337
338 /// \return The linearly interpolated scale along the path for the given value.
339 /// \param value The value used to get the path scale.
341
342 /** Moves a DisplayObject to the position along the path corresponding with the given value.
343 * \param obj the DisplayObject to move
344 * \param value The value used to position the object on the path
345 */
347
348 /** Sets the object to the position corresponding with the given state.
349 * Which values are applied is controlled by the AffectsLocation* and AffectsRotation* properties.
350 * \param obj Pointer to the object to move.
351 * \param stateNumber The index of the state to set the object to. If this value is outside the range [0,StateArray().Count()-1] nothing is done.
352 */
354
355protected:
356#ifdef GLES
357 /** Set a single attribute from the GLO file.
358 * \param data The attribute to set and its associated data.
359 */
360 GLS_EXPORT void SetFromGloData( GlsGloFileAttribute& data ) DISTI_METHOD_OVERRIDE;
361#endif
362
363 bool _affectsLocationX; ///< If true, this path will affect an object's X location.
364 bool _affectsLocationY; ///< If true, this path will affect an object's Y location.
365 bool _affectsLocationZ; ///< If true, this path will affect an object's Z location.
366 bool _affectsRotationX; ///< If true, this path will affect an object's X rotation.
367 bool _affectsRotationY; ///< If true, this path will affect an object's Y rotation.
368 bool _affectsRotationZ; ///< If true, this path will affect an object's Z rotation.
369 bool _affectsScaleX; ///< If true, this path will affect an object's X scale.
370 bool _affectsScaleY; ///< If true, this path will affect an object's Y scale.
371 bool _affectsScaleZ; ///< If true, this path will affect an object's Z scale.
372
373 bool _useShortRotationPaths; ///< If true, this state will rotate in the direction that will reach the desired angle the fastest.
374
375 StateArrayType _stateArray; ///< The list of animation states for this path.
376};
377
378} // namespace disti
379
380#endif
Definition: cull.h:49
Definition: events.h:111
Definition: display.h:95
Definition: disti_metadata.h:750
Definition: disti_metadata.h:220
Definition: dynamic_array.h:79
unsigned Count() const
Definition: dynamic_array.h:218
Definition: gls_dynamic_path.h:208
void Value(const float &value)
Definition: gls_dynamic_path.h:269
void Scale(const Vector &value)
Definition: gls_dynamic_path.h:258
void Location(const Vector &value)
Definition: gls_dynamic_path.h:236
Vector Scale() const
Definition: gls_dynamic_path.h:265
Vector Location()
Definition: gls_dynamic_path.h:240
Vector Rotation() const
Definition: gls_dynamic_path.h:254
float _value
The key value of the animation state.
Definition: gls_dynamic_path.h:282
float Value() const
Definition: gls_dynamic_path.h:276
Vector Scale()
Definition: gls_dynamic_path.h:262
State(const State &)
Copy constructor.
void MakeAttribDict()
Sets up DistiAttributes associated with each member of this class.
Vector _rotation
The rotation of the animation state.
Definition: gls_dynamic_path.h:280
float Value()
Definition: gls_dynamic_path.h:273
Vector Rotation()
Definition: gls_dynamic_path.h:251
Vector Location() const
Definition: gls_dynamic_path.h:243
DistiAttribDict & Attributes()
Definition: gls_dynamic_path.h:227
Vector _scale
The scale of the animation state.
Definition: gls_dynamic_path.h:281
DistiAttribDict * _attribDict
Attribute storage for the members of this class.
Definition: gls_dynamic_path.h:283
const State & operator=(const State &)
Vector _location
The location of the animation state.
Definition: gls_dynamic_path.h:279
void Rotation(const Vector &value)
Definition: gls_dynamic_path.h:247
Definition: gls_dynamic_path.h:85
const StateArrayType & StateArray() const
Definition: gls_dynamic_path.h:292
bool AffectsRotationZ() const
Definition: gls_dynamic_path.h:176
DynamicArray< State > StateArrayType
Typedef for a list of States.
Definition: gls_dynamic_path.h:286
bool _affectsScaleZ
If true, this path will affect an object's Z scale.
Definition: gls_dynamic_path.h:371
void FindFirstPathSegmentContainingValue(float value, int *index1, int *index2)
bool AffectsScaleZ() const
Definition: gls_dynamic_path.h:197
bool _affectsLocationY
If true, this path will affect an object's Y location.
Definition: gls_dynamic_path.h:364
bool AffectsLocationY() const
Definition: gls_dynamic_path.h:148
void SetValue(int spec, va_list &args) DISTI_METHOD_OVERRIDE
bool AffectsScaleY() const
Definition: gls_dynamic_path.h:190
DistiAttributeBase & Resource(const char *name) DISTI_METHOD_OVERRIDE
bool AffectsRotationY() const
Definition: gls_dynamic_path.h:169
Vector GetPathRotation(float value)
void CopyProperties(DisplayObject *src) DISTI_METHOD_OVERRIDE
bool _affectsRotationY
If true, this path will affect an object's Y rotation.
Definition: gls_dynamic_path.h:367
void SetAvailableAttributes(unsigned int value) DISTI_METHOD_OVERRIDE
void GetCppInterfaceDescriptionFree(InterfaceListType *array) DISTI_METHOD_OVERRIDE
bool _affectsRotationX
If true, this path will affect an object's X rotation.
Definition: gls_dynamic_path.h:366
void GetResources(std::ostream &outstr, GlsResourceFilter *filter) DISTI_METHOD_OVERRIDE
StateArrayType _stateArray
The list of animation states for this path.
Definition: gls_dynamic_path.h:375
DisplayObject * handle(DisplayEvent *ev) DISTI_METHOD_OVERRIDE
void AffectsScaleY(const bool &value)
void UseShortRotationPaths(const bool &value)
void MoveObjectToState(DisplayObject *obj, int stateNumber)
bool AffectsRotationX() const
Definition: gls_dynamic_path.h:162
float FirstStateValue()
Definition: gls_dynamic_path.h:305
void PreDraw(const OpenGLMatrices &parentMatrices, Culler &culler) DISTI_METHOD_OVERRIDE
static DisplayObject * CreateInstance()
void Draw() DISTI_METHOD_OVERRIDE
void AffectsRotationZ(const bool &value)
bool _useShortRotationPaths
If true, this state will rotate in the direction that will reach the desired angle the fastest.
Definition: gls_dynamic_path.h:373
bool Hit(float x, float y, float z, float scale, const Vector &directionVector, Vector *collisionPoint) DISTI_METHOD_OVERRIDE
Vector GetPathLocation(float value)
bool _affectsRotationZ
If true, this path will affect an object's Z rotation.
Definition: gls_dynamic_path.h:368
bool _affectsLocationZ
If true, this path will affect an object's Z location.
Definition: gls_dynamic_path.h:365
void AffectsRotationX(const bool &value)
bool UseShortRotationPaths() const
Definition: gls_dynamic_path.h:204
void MoveObject(DisplayObject *obj, float value)
bool AffectsLocationX() const
Definition: gls_dynamic_path.h:141
Vector GetPathScale(float value)
bool _affectsScaleY
If true, this path will affect an object's Y scale.
Definition: gls_dynamic_path.h:370
DisplayObject * CloneObject(bool generateNames=false) DISTI_METHOD_OVERRIDE
bool _affectsLocationX
If true, this path will affect an object's X location.
Definition: gls_dynamic_path.h:363
bool AffectsLocationZ() const
Definition: gls_dynamic_path.h:155
void AffectsRotationY(const bool &value)
void AffectsScaleZ(const bool &value)
InterfaceListType * GetCppInterfaceDescription(InterfaceListType *addToThisList=NULL) DISTI_METHOD_OVERRIDE
void AffectsScaleX(const bool &value)
bool _affectsScaleX
If true, this path will affect an object's X scale.
Definition: gls_dynamic_path.h:369
StateArrayType & StateArray()
Definition: gls_dynamic_path.h:289
void AffectsLocationZ(const bool &value)
float LastStateValue()
Definition: gls_dynamic_path.h:318
bool AffectsScaleX() const
Definition: gls_dynamic_path.h:183
void AffectsLocationY(const bool &value)
Definition: gls_glo_file.h:1241
Definition: gls_resources.h:49
Class to contain current OpenGL view, projection and draw matrices.
Definition: util.h:540
Definition: vertex.h:84
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
#define GLSGEN_GLSDYNAMICPATH_EXPORT
Provides support for creating DLLs.
Definition: gls_dynamic_path.h:54
#define GLS_EXPORT
Macro denoting which functions should be visible from the runtime library.
Definition: gls_include.h:50
The disti::Group class. Implements groups of objects.
Definition: bmpimage.h:46