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 */
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;
75  typedef DisplayObject BaseClass;
76 
77  /** Create a new GlsPathManager.
78  * \param generateInstanceName Whether or not to generate an instance name
79  * for this inputdevice */
80  GLSGEN_GLSDYNAMICPATH_EXPORT GlsPathManager( bool generateInstanceName = false );
81  GLSGEN_GLSDYNAMICPATH_EXPORT GlsPathManager( const GlsPathManager& that, const bool generateNames );
82 
83  /** Destructs a GlsPathManager object */
84  virtual GLSGEN_GLSDYNAMICPATH_EXPORT ~GlsPathManager();
85 
86  static GLSGEN_GLSDYNAMICPATH_EXPORT DisplayObject* CreateInstance();
87 
88  virtual GLSGEN_GLSDYNAMICPATH_EXPORT void SetAvailableAttributes( unsigned int value ) DISTI_METHOD_OVERRIDE;
89 
90  virtual GLSGEN_GLSDYNAMICPATH_EXPORT DisplayObject* CloneObject( bool generateNames = false ) DISTI_METHOD_OVERRIDE;
91 
92  virtual GLSGEN_GLSDYNAMICPATH_EXPORT void CopyProperties( DisplayObject* src ) DISTI_METHOD_OVERRIDE;
93 
94 #ifndef GLES
95  virtual GLSGEN_GLSDYNAMICPATH_EXPORT InterfaceListType* GetCppInterfaceDescription( InterfaceListType* addToThisList = NULL ) DISTI_METHOD_OVERRIDE;
96  virtual GLSGEN_GLSDYNAMICPATH_EXPORT void GetCppInterfaceDescriptionFree( InterfaceListType* array ) DISTI_METHOD_OVERRIDE;
97 #endif
98 
99  virtual GLSGEN_GLSDYNAMICPATH_EXPORT void Draw( void ) DISTI_METHOD_OVERRIDE;
100 
101  virtual GLSGEN_GLSDYNAMICPATH_EXPORT bool Hit( float x, float y, float z, float scale, const Vector& directionVector, Vector* collisionPoint ) DISTI_METHOD_OVERRIDE;
102 
103  virtual GLSGEN_GLSDYNAMICPATH_EXPORT void SetValue( int spec, va_list& args ) DISTI_METHOD_OVERRIDE;
104 
105  virtual GLSGEN_GLSDYNAMICPATH_EXPORT DistiAttributeBase& Resource( const char* name ) DISTI_METHOD_OVERRIDE;
106  virtual GLSGEN_GLSDYNAMICPATH_EXPORT void GetResources( std::ostream& outstr, GlsResourceFilter* filter ) DISTI_METHOD_OVERRIDE;
107 
108  //////////////////////////////////////////////////
109  // GlsPathManager specific operations
110  //////////////////////////////////////////////////
111 
112  /// Contains a dynamic path and the object that path animates.
114  {
115  public:
116  /// Constructor
117  GLSGEN_GLSDYNAMICPATH_EXPORT PathObjectPair();
118  /// Copy constructor
119  GLSGEN_GLSDYNAMICPATH_EXPORT PathObjectPair( const PathObjectPair& );
120  /// Destructor
121  GLSGEN_GLSDYNAMICPATH_EXPORT ~PathObjectPair();
122 
123  /// Copy assignment
124  GLSGEN_GLSDYNAMICPATH_EXPORT const PathObjectPair& operator=( const PathObjectPair& );
125  GLSGEN_GLSDYNAMICPATH_EXPORT void MakeAttribDict();
126 
127  DistiAttribDict& Attributes()
128  {
129  if( !_attribDict )
130  MakeAttribDict();
131  return *_attribDict;
132  };
133 
134  void SetDynamicPathByName( const std::string& name )
135  {
136  _pathName = name;
137  }
138 
139  std::string GetDynamicPathName() const
140  {
141  return _path ? _path->InstanceName() : _pathName;
142  }
143 
144  void SetDynamicPath( GlsDynamicPath* path )
145  {
146  _path = path;
147  }
148 
149  GlsDynamicPath* GetDynamicPath() const
150  {
151  return _path;
152  }
153 
154  void SetObject( DisplayObject* object )
155  {
156  _object = object;
157  }
158 
159  DisplayObject* GetObject() const
160  {
161  return _object;
162  }
163 #if !defined( GLES )
164  DISTI_DEPRECATED( "Use single-pointer functions instead." )
165  void SetDynamicPath( GlsDynamicPath** path )
166  {
167  _path = path ? *path : NULL;
168  }
169 
170  DISTI_DEPRECATED( "Use single-pointer functions instead." )
171  void SetObject( DisplayObject** object )
172  {
173  _object = object ? *object : NULL;
174  }
175 #endif
176 
177  void SetObjectByName( const std::string& name )
178  {
179  _objectName = name;
180  }
181 
182  std::string GetObjectName() const
183  {
184  return _object ? _object->InstanceName() : _objectName;
185  }
186 
187  protected:
188  GlsDynamicPath* _path; // the *'s are for runtime (faster)
189  DisplayObject* _object;
190  std::string _pathName; // the std::strings are for the editor (slower)
191  std::string _objectName;
192 
193  DistiAttribDict* _attribDict;
194  };
195 
197 
198  // Returns the PathObjectPairArray associated with this object.
199  // Use this array to set which path goes with what object.
200  PathObjectPairArrayType& PathObjectPairArray() { return _pathObjectPairArray; }
201  const PathObjectPairArrayType& PathObjectPairArray() const { return _pathObjectPairArray; }
202 
203  /** Sets the animation value as a ratio of MinAnimationValue, MaxAnimationValue
204  * \param pct percent of animation (0.0 -> 1.0).
205  */
206  GLSGEN_GLSDYNAMICPATH_EXPORT void AnimationPct( double pct );
207 
208  /** Move all of the objects in the PathObjectPairArray to the given value on the associated path.
209  * \param value The value used to position the object on the path (see GlsDynamicPath::MoveObject)
210  */
211  GLSGEN_GLSDYNAMICPATH_EXPORT void SetAnimationValue( float value );
212 
213  /** Backwards compatibility method
214  * \see SetAnimationValue */
215  void CurrentTimeValue( float value ) { SetAnimationValue( value ); }
216 
217  /** Causes the MinAnimationValue and MaxAnimationValue to be recalculated using
218  * the paths in the PathObjectPairArray.
219  */
220  GLSGEN_GLSDYNAMICPATH_EXPORT void RecalcMinMaxValue();
221 
222  /** Returns the stored minimum animation value from the PathObjectPairArray.
223  * \see RecalcMinMaxValue
224  * \return The minimum animation value
225  */
226  GLSGEN_GLSDYNAMICPATH_EXPORT float MinAnimationValue();
227 
228  /** Backwards compatibility method
229  * \see MinAnimationValue */
230  float MinTimeValue() { return MinAnimationValue(); }
231 
232  /** Returns the stored maximum animation value from the PathObjectPairArray.
233  * \see RecalcMinMaxValue
234  * \return The maximum animation value
235  */
236  GLSGEN_GLSDYNAMICPATH_EXPORT float MaxAnimationValue();
237 
238  /** Backwards compatibility method
239  * \see MaxAnimationValue */
240  float MaxTimeValue() { return MaxAnimationValue(); }
241 
242 protected:
243  PathObjectPairArrayType _pathObjectPairArray;
244 
245  float _minValue;
246  float _maxValue;
247  bool _recalcValueBounds;
248 
249  void CalculateMinMaxValue();
250 #ifdef GLES
251  /** Set a single attribute from the GLO file.
252  * \param data The attribute to set and its associated data.
253  */
254  virtual GLS_EXPORT void SetFromGloData( GlsGloFileAttribute& data ) DISTI_METHOD_OVERRIDE;
255 #endif
256 };
257 
258 } // namespace disti
259 
260 #endif
#define DISTI_DEPRECATED(msg)
Defines whether this compiler supports the C++14 deprecated attribute.
Definition: gls_cpp_lang_support.h:436
Definition: dynamic_array.h:66
The disti::Group class. Implements groups of objects.
float MinTimeValue()
Definition: gls_path_manager.h:230
virtual InterfaceListType * GetCppInterfaceDescription(InterfaceListType *addToThisList=NULL) DISTI_METHOD_OVERRIDE
Definition: display.h:98
virtual DisplayObject * CloneObject(bool generateNames=false) DISTI_METHOD_OVERRIDE
virtual void GetResources(std::ostream &outstr, GlsResourceFilter *filter) DISTI_METHOD_OVERRIDE
virtual DistiAttributeBase & Resource(const char *name) DISTI_METHOD_OVERRIDE
Definition: gls_glo_file.h:988
virtual void GetCppInterfaceDescriptionFree(InterfaceListType *array) DISTI_METHOD_OVERRIDE
virtual bool Hit(float x, float y, float z, float scale, const Vector &directionVector, Vector *collisionPoint) DISTI_METHOD_OVERRIDE
virtual void CopyProperties(DisplayObject *src) DISTI_METHOD_OVERRIDE
The disti::GlsDynamicPath class and global enumerations.
Contains a dynamic path and the object that path animates.
Definition: gls_path_manager.h:113
Definition: gls_dynamic_path.h:84
Definition: disti_metadata.h:186
virtual void Draw(void) DISTI_METHOD_OVERRIDE
const PathObjectPair & operator=(const PathObjectPair &)
Copy assignment.
char * InstanceName(void)
Definition: disti_metadata.h:668
void SetAnimationValue(float value)
Definition: gls_path_manager.h:64
virtual void SetAvailableAttributes(unsigned int value) DISTI_METHOD_OVERRIDE
virtual void SetValue(int spec, va_list &args) DISTI_METHOD_OVERRIDE
float MaxTimeValue()
Definition: gls_path_manager.h:240
Definition: vertex.h:84
void CurrentTimeValue(float value)
Definition: gls_path_manager.h:215
Definition: gls_resources.h:50
Macros and helper code to determine what subset of C++11/14/17 is available.
Definition: bmpimage.h:46
void AnimationPct(double pct)