| GL Studio C++ Runtime API

gls_path_manager.h
Go to the documentation of this file.
1/*! \file
2 \brief The disti::GlsPathManager class and global enumerations.
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
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*/
40#ifndef INCLUDED_GLS_PATH_MANAGER_H
41#define INCLUDED_GLS_PATH_MANAGER_H
42
43#include "gls_cpp_lang_support.h"
44#include "gls_dynamic_path.h"
45#include "group.h"
46
47// Windows #defines this symbol which we use
48#if defined( WIN32 ) && defined( GetObject )
49# undef GetObject
50#endif
51
52 namespace disti
53{
54// SetValue enumerations
55 enum
56{
57 GLS_PATHMANAGER_FIRST_VALUE = GLS_LAST_INITIALIZER + 1,
58 GLS_PATHMANAGER_PATHOBJPAIR_COUNT,
59 GLS_PATHMANAGER_PATHOBJPAIR,
60 GLS_PATHMANAGER_STRINGPATHOBJPAIR
61};
62
63/** Runtime implementation of a GlsPathManager */
64 class GlsPathManager : public DisplayObject
65{
66 friend class GlsPathManagerEditor;
67
68 private:
69 GlsPathManager& operator=( const GlsPathManager& ) DISTI_SPECIAL_MEM_FUN_DELETE;
70 GlsPathManager( const GlsPathManager& ) DISTI_SPECIAL_MEM_FUN_DELETE;
71
72 public:
73 DISTI_DEPRECATED( "This identifier is forbidden by the C++ standard. Use BaseClass instead." )
74 typedef DisplayObject _BaseClass; ///< Deprecated typedef for the base class.
75 typedef DisplayObject BaseClass; ///< Typedef for the base class.
76
77 /// Constructor
78 /// \param generateInstanceName Whether or not to generate an instance name for this object.
79 GLSGEN_GLSDYNAMICPATH_EXPORT GlsPathManager( bool generateInstanceName = false );
80
81 /// Copy constructor
82 /// \param that The object to copy from.
83 /// \param generateNames Whether or not to generate an instance name for this object.
84 GLSGEN_GLSDYNAMICPATH_EXPORT GlsPathManager( const GlsPathManager& that, const bool generateNames );
85
86 /** Destructs a GlsPathManager object */
87 virtual GLSGEN_GLSDYNAMICPATH_EXPORT ~GlsPathManager();
88
89 /// \return A pointer to a new GlsPathManager object.
90 static GLSGEN_GLSDYNAMICPATH_EXPORT DisplayObject* CreateInstance();
91
92 virtual GLSGEN_GLSDYNAMICPATH_EXPORT void SetAvailableAttributes( unsigned int value ) DISTI_METHOD_OVERRIDE;
93 virtual GLSGEN_GLSDYNAMICPATH_EXPORT DisplayObject* CloneObject( bool generateNames = false ) DISTI_METHOD_OVERRIDE;
94 virtual GLSGEN_GLSDYNAMICPATH_EXPORT void CopyProperties( DisplayObject* src ) DISTI_METHOD_OVERRIDE;
95
96#ifndef GLES
97 virtual GLSGEN_GLSDYNAMICPATH_EXPORT InterfaceListType* GetCppInterfaceDescription( InterfaceListType* addToThisList = NULL ) DISTI_METHOD_OVERRIDE;
98 virtual GLSGEN_GLSDYNAMICPATH_EXPORT void GetCppInterfaceDescriptionFree( InterfaceListType* array ) DISTI_METHOD_OVERRIDE;
99#endif
100
101 virtual GLSGEN_GLSDYNAMICPATH_EXPORT void Draw() DISTI_METHOD_OVERRIDE;
102 virtual GLSGEN_GLSDYNAMICPATH_EXPORT bool Hit( float x, float y, float z, float scale, const Vector& directionVector, Vector* collisionPoint ) DISTI_METHOD_OVERRIDE;
103 virtual GLSGEN_GLSDYNAMICPATH_EXPORT void SetValue( int spec, va_list& args ) DISTI_METHOD_OVERRIDE;
104 virtual GLSGEN_GLSDYNAMICPATH_EXPORT DistiAttributeBase& Resource( const char* name ) DISTI_METHOD_OVERRIDE;
105 virtual GLSGEN_GLSDYNAMICPATH_EXPORT void GetResources( std::ostream& outstr, GlsResourceFilter* filter ) DISTI_METHOD_OVERRIDE;
106
107 //////////////////////////////////////////////////
108 // GlsPathManager specific operations
109 //////////////////////////////////////////////////
110
111 /// \details The PathObjectPair class. Contains a dynamic path and the object that path animates.
112 class PathObjectPair
113 {
114 public:
115 /// Constructor
116 GLSGEN_GLSDYNAMICPATH_EXPORT PathObjectPair();
117
118 /// Copy constructor
119 GLSGEN_GLSDYNAMICPATH_EXPORT PathObjectPair( const PathObjectPair& );
120
121 /// Destructor
122 GLSGEN_GLSDYNAMICPATH_EXPORT ~PathObjectPair();
123
124 /// Copy assignment
125 /// \return The resulting object (this).
126 GLSGEN_GLSDYNAMICPATH_EXPORT const PathObjectPair& operator=( const PathObjectPair& );
127
128 /// Populates the attribute dictionary for this object.
129 /// \note Not normally called by users.
130 GLSGEN_GLSDYNAMICPATH_EXPORT void MakeAttribDict();
131
132 /// \return A reference to the attribute dictionary for this object.
133 DistiAttribDict& Attributes()
134 {
135 if( !_attribDict )
136 MakeAttribDict();
137 return *_attribDict;
138 };
139
140 /// Assign a new GlsDynamicPath to this pair by name.
141 /// \param name The name of the new path to set.
142 void SetDynamicPathByName( const std::string& name )
143 {
144 _pathName = name;
145 }
146
147 /// \return The name of the path in this pair.
148 std::string GetDynamicPathName() const
149 {
150 return _path ? _path->InstanceName() : _pathName;
151 }
152
153 /// Assign a new GlsDynamicPath to this pair.
154 /// \param path The new path to set.
155 void SetDynamicPath( GlsDynamicPath* path )
156 {
157 _path = path;
158 }
159
160 /// \return The path in this pair.
161 GlsDynamicPath* GetDynamicPath() const
162 {
163 return _path;
164 }
165
166 /// Set the target object of this pair's animation.
167 /// \param object The new target object to set.
168 void SetObject( DisplayObject* object )
169 {
170 _object = object;
171 }
172
173 /// \return The target object of this pair.
174 DisplayObject* GetObject() const
175 {
176 return _object;
177 }
178#if !defined( GLES )
179 /// Assign a new GlsDynamicPath to this pair.
180 /// \deprecated Use single-pointer functions instead.
181 /// \param path The new path to set.
182 DISTI_DEPRECATED( "Use single-pointer functions instead." )
183 void SetDynamicPath( GlsDynamicPath** path )
184 {
185 _path = path ? *path : NULL;
186 }
187
188 /// Set the target object of this pair's animation.
189 /// \deprecated Use single-pointer functions instead.
190 /// \param object The new target object to set.
191 DISTI_DEPRECATED( "Use single-pointer functions instead." )
192 void SetObject( DisplayObject** object )
193 {
194 _object = object ? *object : NULL;
195 }
196#endif
197 /// Set the target object of this pair's animation by name.
198 /// \param name The name of the new target object to set.
199 void SetObjectByName( const std::string& name )
200 {
201 _objectName = name;
202 }
203
204 /// \return The name of the target object.
205 std::string GetObjectName() const
206 {
207 return _object ? _object->InstanceName() : _objectName;
208 }
209
210 protected:
211 // The *'s are for runtime (faster).
212 GlsDynamicPath* _path; ///< The path containing the animation data.
213 DisplayObject* _object; ///< The object to be animated by the path.
214
215 // the std::strings are for the editor (slower)
216 std::string _pathName; ///< The name of the path object.
217 std::string _objectName; ///< The name of the animation target object.
218
219 DistiAttribDict* _attribDict; ///< The attribute dictionary for the members of this object.
220 };
221
222 typedef DynamicArray<PathObjectPair> PathObjectPairArrayType; ///< Shorthand typedef for a list of path pairs.
223
224 /// Use this array to set which path goes with what object.
225 /// \return A modifiable reference to the PathObjectPairArray associated with this object.
226 PathObjectPairArrayType& PathObjectPairArray() { return _pathObjectPairArray; }
227
228 /// \return A const reference to the PathObjectPairArray associated with this object.
229 const PathObjectPairArrayType& PathObjectPairArray() const { return _pathObjectPairArray; }
230
231 /// Sets the animation value as a ratio of MinAnimationValue, MaxAnimationValue.
232 /// \param pct percent of animation (0.0 -> 1.0).
233 GLSGEN_GLSDYNAMICPATH_EXPORT void AnimationPct( double pct );
234
235 /// Move all of the objects in the PathObjectPairArray to the given value on the associated path.
236 /// \param value The value used to position the object on the path (see GlsDynamicPath::MoveObject).
237 GLSGEN_GLSDYNAMICPATH_EXPORT void SetAnimationValue( float value );
238
239 /// Backwards compatibility method.
240 /// \see SetAnimationValue
241 /// \param value The animation value to set.
242 DISTI_DEPRECATED( "Renamed for clarity, use SetAnimationValue instead." )
243 void CurrentTimeValue( float value ) { SetAnimationValue( value ); }
244
245 /** Causes the MinAnimationValue and MaxAnimationValue to be recalculated using
246 * the paths in the PathObjectPairArray.
247 */
248 GLSGEN_GLSDYNAMICPATH_EXPORT void RecalcMinMaxValue();
249
250 /** Returns the stored minimum animation value from the PathObjectPairArray.
251 * \see RecalcMinMaxValue
252 * \return The minimum animation value
253 */
254 GLSGEN_GLSDYNAMICPATH_EXPORT float MinAnimationValue();
255
256 /// Backwards compatibility method.
257 /// \see MinAnimationValue
258 /// \return The minimum animation value.
259 DISTI_DEPRECATED( "Renamed for clarity, use MinAnimationValue instead." )
260 float MinTimeValue() { return MinAnimationValue(); }
261
262 /** Returns the stored maximum animation value from the PathObjectPairArray.
263 * \see RecalcMinMaxValue
264 * \return The maximum animation value
265 */
266 GLSGEN_GLSDYNAMICPATH_EXPORT float MaxAnimationValue();
267
268 /// Backwards compatibility method.
269 /// \see MaxAnimationValue
270 /// \return The maximum animation value.
271 DISTI_DEPRECATED( "Renamed for clarity, use MaxAnimationValue instead." )
272 float MaxTimeValue() { return MaxAnimationValue(); }
273
274 protected:
275 PathObjectPairArrayType _pathObjectPairArray; ///< List of animation pairs to manage.
276
277 float _minValue; ///< The minimum animation key value.
278 float _maxValue; ///< The maximum animation key value.
279 bool _recalcValueBounds; ///< If true, _minValue and _maxValue will be recalculated.
280
281 /// Calculate the min and max value based on the animation pairs.
282 /// \note Not normally called by users.
283 void CalculateMinMaxValue();
284#ifdef GLES
285 /** Set a single attribute from the GLO file.
286 * \param data The attribute to set and its associated data.
287 */
288 virtual GLS_EXPORT void SetFromGloData( GlsGloFileAttribute& data ) DISTI_METHOD_OVERRIDE;
289#endif
290};
291
292} // namespace disti
293
294#endif
disti::DisplayObject
Definition: display.h:96
disti::DistiAttribDict
Definition: disti_metadata.h:750
disti::DistiAttributeBase
Definition: disti_metadata.h:220
disti::DynamicArray
Definition: dynamic_array.h:79
disti::GlsDynamicPath
Definition: gls_dynamic_path.h:86
disti::GlsGloFileAttribute
Definition: gls_glo_file.h:1243
disti::GlsPathManager::PathObjectPair
Definition: gls_path_manager.h:113
disti::GlsPathManager::PathObjectPair::GetObject
DisplayObject * GetObject() const
Definition: gls_path_manager.h:174
disti::GlsPathManager::PathObjectPair::_pathName
std::string _pathName
The name of the path object.
Definition: gls_path_manager.h:216
disti::GlsPathManager::PathObjectPair::GetObjectName
std::string GetObjectName() const
Definition: gls_path_manager.h:205
disti::GlsPathManager::PathObjectPair::operator=
const PathObjectPair & operator=(const PathObjectPair &)
disti::GlsPathManager::PathObjectPair::GetDynamicPath
GlsDynamicPath * GetDynamicPath() const
Definition: gls_path_manager.h:161
disti::GlsPathManager::PathObjectPair::PathObjectPair
PathObjectPair()
Constructor.
disti::GlsPathManager::PathObjectPair::SetDynamicPath
void SetDynamicPath(GlsDynamicPath *path)
Definition: gls_path_manager.h:155
disti::GlsPathManager::PathObjectPair::_path
GlsDynamicPath * _path
The path containing the animation data.
Definition: gls_path_manager.h:212
disti::GlsPathManager::PathObjectPair::SetDynamicPathByName
void SetDynamicPathByName(const std::string &name)
Definition: gls_path_manager.h:142
disti::GlsPathManager::PathObjectPair::SetObject
void SetObject(DisplayObject *object)
Definition: gls_path_manager.h:168
disti::GlsPathManager::PathObjectPair::~PathObjectPair
~PathObjectPair()
Destructor.
disti::GlsPathManager::PathObjectPair::GetDynamicPathName
std::string GetDynamicPathName() const
Definition: gls_path_manager.h:148
disti::GlsPathManager::PathObjectPair::MakeAttribDict
void MakeAttribDict()
disti::GlsPathManager::PathObjectPair::_object
DisplayObject * _object
The object to be animated by the path.
Definition: gls_path_manager.h:213
disti::GlsPathManager::PathObjectPair::PathObjectPair
PathObjectPair(const PathObjectPair &)
Copy constructor.
disti::GlsPathManager::PathObjectPair::Attributes
DistiAttribDict & Attributes()
Definition: gls_path_manager.h:133
disti::GlsPathManager::PathObjectPair::_objectName
std::string _objectName
The name of the animation target object.
Definition: gls_path_manager.h:217
disti::GlsPathManager::PathObjectPair::_attribDict
DistiAttribDict * _attribDict
The attribute dictionary for the members of this object.
Definition: gls_path_manager.h:219
disti::GlsPathManager::PathObjectPair::SetObjectByName
void SetObjectByName(const std::string &name)
Definition: gls_path_manager.h:199
disti::GlsPathManager
Definition: gls_path_manager.h:65
disti::GlsPathManager::CurrentTimeValue
void CurrentTimeValue(float value)
Definition: gls_path_manager.h:243
disti::GlsPathManager::CalculateMinMaxValue
void CalculateMinMaxValue()
disti::GlsPathManager::SetAvailableAttributes
virtual void SetAvailableAttributes(unsigned int value) DISTI_METHOD_OVERRIDE
disti::GlsPathManager::Draw
virtual void Draw() DISTI_METHOD_OVERRIDE
disti::GlsPathManager::SetAnimationValue
void SetAnimationValue(float value)
disti::GlsPathManager::MinTimeValue
float MinTimeValue()
Definition: gls_path_manager.h:260
disti::GlsPathManager::PathObjectPairArray
PathObjectPairArrayType & PathObjectPairArray()
Definition: gls_path_manager.h:226
disti::GlsPathManager::CloneObject
virtual DisplayObject * CloneObject(bool generateNames=false) DISTI_METHOD_OVERRIDE
disti::GlsPathManager::SetFromGloData
virtual GLS_EXPORT void SetFromGloData(GlsGloFileAttribute &data) DISTI_METHOD_OVERRIDE
disti::GlsPathManager::Hit
virtual bool Hit(float x, float y, float z, float scale, const Vector &directionVector, Vector *collisionPoint) DISTI_METHOD_OVERRIDE
disti::GlsPathManager::SetValue
virtual void SetValue(int spec, va_list &args) DISTI_METHOD_OVERRIDE
disti::GlsPathManager::MinAnimationValue
float MinAnimationValue()
disti::GlsPathManager::GetResources
virtual void GetResources(std::ostream &outstr, GlsResourceFilter *filter) DISTI_METHOD_OVERRIDE
disti::GlsPathManager::AnimationPct
void AnimationPct(double pct)
disti::GlsPathManager::_maxValue
float _maxValue
The maximum animation key value.
Definition: gls_path_manager.h:278
disti::GlsPathManager::CreateInstance
static DisplayObject * CreateInstance()
disti::GlsPathManager::PathObjectPairArrayType
DynamicArray< PathObjectPair > PathObjectPairArrayType
Shorthand typedef for a list of path pairs.
Definition: gls_path_manager.h:222
disti::GlsPathManager::MaxTimeValue
float MaxTimeValue()
Definition: gls_path_manager.h:272
disti::GlsPathManager::Resource
virtual DistiAttributeBase & Resource(const char *name) DISTI_METHOD_OVERRIDE
disti::GlsPathManager::_recalcValueBounds
bool _recalcValueBounds
If true, _minValue and _maxValue will be recalculated.
Definition: gls_path_manager.h:279
disti::GlsPathManager::PathObjectPairArray
const PathObjectPairArrayType & PathObjectPairArray() const
Definition: gls_path_manager.h:229
disti::GlsPathManager::RecalcMinMaxValue
void RecalcMinMaxValue()
disti::GlsPathManager::CopyProperties
virtual void CopyProperties(DisplayObject *src) DISTI_METHOD_OVERRIDE
disti::GlsPathManager::_minValue
float _minValue
The minimum animation key value.
Definition: gls_path_manager.h:277
disti::GlsPathManager::MaxAnimationValue
float MaxAnimationValue()
disti::GlsPathManager::_pathObjectPairArray
PathObjectPairArrayType _pathObjectPairArray
List of animation pairs to manage.
Definition: gls_path_manager.h:275
disti::GlsResourceFilter
Definition: gls_resources.h:51
disti::VertexNoColor
Definition: vertex.h:85
gls_cpp_lang_support.h
Macros and helper code to determine what subset of C++11/14/17 is available.
DISTI_SPECIAL_MEM_FUN_DELETE
#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:246
DISTI_DEPRECATED
#define DISTI_DEPRECATED(msg)
Defines whether this compiler supports the C++14 deprecated attribute.
Definition: gls_cpp_lang_support.h:488
DISTI_METHOD_OVERRIDE
#define DISTI_METHOD_OVERRIDE
Macro to wrap the override keyword, removed on compilers that don't support it.
Definition: gls_cpp_lang_support.h:222
gls_dynamic_path.h
The disti::GlsDynamicPath class and global enumerations.
GLSGEN_GLSDYNAMICPATH_EXPORT
#define GLSGEN_GLSDYNAMICPATH_EXPORT
Provides support for creating DLLs.
Definition: gls_dynamic_path.h:55
GLS_EXPORT
#define GLS_EXPORT
Macro denoting which functions should be visible from the runtime library.
Definition: gls_include.h:52
group.h
The disti::Group class. Implements groups of objects.
disti
Definition: bmpimage.h:47