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 _GLSPATHMANAGER_H
41 #define _GLSPATHMANAGER_H
42 
43 #include "gls_cpp_lang_support.h"
44 #include "gls_dynamic_path.h"
45 #include "group.h"
46 
47 namespace disti
48 {
49 // SetValue enumerations
50 enum
51 {
52  GLS_PATHMANAGER_FIRST_VALUE = GLS_LAST_INITIALIZER + 1,
53  GLS_PATHMANAGER_PATHOBJPAIR_COUNT,
54  GLS_PATHMANAGER_PATHOBJPAIR
55 };
56 
57 /** Runtime implementation of a GlsPathManager */
59 {
60  friend class GlsPathManagerEditor;
61 
62 private:
63  GlsPathManager& operator=( const GlsPathManager& ) DISTI_SPECIAL_MEM_FUN_DELETE;
64  GlsPathManager( const GlsPathManager& ) DISTI_SPECIAL_MEM_FUN_DELETE;
65 
66 public:
67  typedef DisplayObject _BaseClass;
68 
69  /** Create a new GlsPathManager.
70  * \param generateInstanceName Whether or not to generate an instance name
71  * for this inputdevice */
72  GLSGEN_GLSDYNAMICPATH_EXPORT GlsPathManager( bool generateInstanceName = false );
73  GLSGEN_GLSDYNAMICPATH_EXPORT GlsPathManager( const GlsPathManager& that, const bool generateNames );
74 
75  /** Destructs a GlsPathManager object */
76  virtual GLSGEN_GLSDYNAMICPATH_EXPORT ~GlsPathManager();
77 
78  static GLSGEN_GLSDYNAMICPATH_EXPORT DisplayObject* CreateInstance();
79 
80  virtual GLSGEN_GLSDYNAMICPATH_EXPORT void SetAvailableAttributes( unsigned int value );
81 
82  virtual GLSGEN_GLSDYNAMICPATH_EXPORT DisplayObject* CloneObject( bool generateNames = false );
83 
84  virtual GLSGEN_GLSDYNAMICPATH_EXPORT void CopyProperties( DisplayObject* src );
85 
86 #ifndef GLES
87  virtual GLSGEN_GLSDYNAMICPATH_EXPORT InterfaceListType* GetCppInterfaceDescription( InterfaceListType* addToThisList = NULL );
88  virtual GLSGEN_GLSDYNAMICPATH_EXPORT void GetCppInterfaceDescriptionFree( InterfaceListType* array );
89 #endif
90 
91  virtual GLSGEN_GLSDYNAMICPATH_EXPORT void Draw( void );
92 
93  virtual GLSGEN_GLSDYNAMICPATH_EXPORT bool Hit( float x, float y, float z, float scale, const Vector& directionVector, Vector* collisionPoint );
94 
95  virtual GLSGEN_GLSDYNAMICPATH_EXPORT void SetValue( int spec, va_list& args );
96 
97  virtual GLSGEN_GLSDYNAMICPATH_EXPORT DistiAttributeBase& Resource( const char* name );
98  virtual GLSGEN_GLSDYNAMICPATH_EXPORT void GetResources( std::ostream& outstr, GlsResourceFilter* filter );
99 
100  //////////////////////////////////////////////////
101  // GlsPathManager specific operations
102  //////////////////////////////////////////////////
103 
104  // Contains a dynamic path and the object that path animates.
106  {
107  public:
108  GLSGEN_GLSDYNAMICPATH_EXPORT PathObjectPair();
109  GLSGEN_GLSDYNAMICPATH_EXPORT PathObjectPair( const PathObjectPair& );
110  GLSGEN_GLSDYNAMICPATH_EXPORT ~PathObjectPair();
111 
112  GLSGEN_GLSDYNAMICPATH_EXPORT const PathObjectPair& operator=( const PathObjectPair& );
113  GLSGEN_GLSDYNAMICPATH_EXPORT void MakeAttribDict();
114 
115  inline DistiAttribDict& Attributes()
116  {
117  if( !_attribDict )
118  MakeAttribDict();
119  return *_attribDict;
120  };
121 
122  inline void SetDynamicPathByName( const std::string& name )
123  {
124  _pathName = name;
125  }
126 
127  inline std::string GetDynamicPathName()
128  {
129  if( _path )
130  return std::string( GetDynamicPath()->InstanceName() );
131 
132  return _pathName;
133  }
134 
135 #ifdef GLES
136 
137  inline void SetDynamicPath( GlsDynamicPath* path )
138  {
139  _path = path;
140  }
141 
142  inline GlsDynamicPath* GetDynamicPath()
143  {
144  return _path;
145  }
146 
147  inline void SetObject( DisplayObject* object )
148  {
149  _object = object;
150  }
151 
152  inline DisplayObject* GetObject()
153  {
154  return _object;
155  }
156 #else
157  inline void SetDynamicPath( GlsDynamicPath** path )
158  {
159  _path = (GlsDynamicPath**)path;
160  }
161 
162  inline GlsDynamicPath* GetDynamicPath()
163  {
164  if( _path )
165  return *_path;
166 
167  return NULL;
168  }
169 
170  inline void SetObject( DisplayObject** object )
171  {
172  _object = object;
173  }
174 
175  inline DisplayObject* GetObject()
176  {
177  if( _object )
178  return *_object;
179 
180  return NULL;
181  }
182 #endif
183 
184  inline void SetObjectByName( const std::string& name )
185  {
186  _objectName = name;
187  }
188 
189  inline std::string GetObjectName()
190  {
191  if( _object )
192  return std::string( GetObject()->InstanceName() );
193 
194  return _objectName;
195  }
196 
197  protected:
198 #ifdef GLES
199  GlsDynamicPath* _path; // the *'s are for runtime...
200  DisplayObject* _object;
201 #else
202  GlsDynamicPath** _path; // the **'s are for runtime...
203  DisplayObject** _object;
204 #endif
205 
206  std::string _pathName; // the std::strings are for editing...
207  std::string _objectName;
208 
209  DistiAttribDict* _attribDict;
210  };
211 
213 
214  // Returns the PathObjectPairArray associated with this object.
215  // Use this array to set which path goes with what object.
216  inline PathObjectPairArrayType& PathObjectPairArray() { return _pathObjectPairArray; }
217  inline const PathObjectPairArrayType& PathObjectPairArray() const { return _pathObjectPairArray; }
218 
219  /** Sets the animation value as a ratio of MinAnimationValue, MaxAnimationValue
220  * \param pct percent of animation (0.0 -> 1.0).
221  */
222  GLSGEN_GLSDYNAMICPATH_EXPORT void AnimationPct( double pct );
223 
224  /** Move all of the objects in the PathObjectPairArray to the given value on the associated path.
225  * \param value The value used to position the object on the path (see GlsDynamicPath::MoveObject)
226  */
227  GLSGEN_GLSDYNAMICPATH_EXPORT void SetAnimationValue( float value );
228 
229  /** Backwards compatibility method
230  * \see SetAnimationValue */
231  inline void CurrentTimeValue( float value ) { SetAnimationValue( value ); }
232 
233  /** Causes the MinAnimationValue and MaxAnimationValue to be recalculated using
234  * the paths in the PathObjectPairArray.
235  */
236  GLSGEN_GLSDYNAMICPATH_EXPORT void RecalcMinMaxValue();
237 
238  /** Returns the stored minimum animation value from the PathObjectPairArray.
239  * \see RecalcMinMaxValue
240  * \return The minimum animation value
241  */
242  GLSGEN_GLSDYNAMICPATH_EXPORT float MinAnimationValue();
243 
244  /** Backwards compatibility method
245  * \see MinAnimationValue */
246  inline float MinTimeValue() { return MinAnimationValue(); }
247 
248  /** Returns the stored maximum animation value from the PathObjectPairArray.
249  * \see RecalcMinMaxValue
250  * \return The maximum animation value
251  */
252  GLSGEN_GLSDYNAMICPATH_EXPORT float MaxAnimationValue();
253 
254  /** Backwards compatibility method
255  * \see MaxAnimationValue */
256  inline float MaxTimeValue() { return MaxAnimationValue(); }
257 
258 protected:
259  PathObjectPairArrayType _pathObjectPairArray;
260 
261  float _minValue;
262  float _maxValue;
263  bool _recalcValueBounds;
264 
265  void CalculateMinMaxValue();
266 #ifdef GLES
267  /** Set a single attribute from the GLO file.
268  * \param data The attribute to set and its associated data.
269  */
270  virtual GLS_EXPORT void SetFromGloData( GlsGloFileAttribute& data );
271 #endif
272 };
273 
274 } // namespace disti
275 
276 #endif
virtual DisplayObject * CloneObject(bool generateNames=false)
virtual void GetResources(std::ostream &outstr, GlsResourceFilter *filter)
Definition: dynamic_array.h:62
The disti::Group class. Implements groups of objects.
virtual void SetValue(int spec, va_list &args)
float MinTimeValue()
Definition: gls_path_manager.h:246
Definition: display.h:97
virtual DistiAttributeBase & Resource(const char *name)
Definition: gls_glo_file.h:835
virtual InterfaceListType * GetCppInterfaceDescription(InterfaceListType *addToThisList=NULL)
The disti::GlsDynamicPath class and global enumerations.
Definition: gls_path_manager.h:105
Definition: gls_dynamic_path.h:84
Definition: disti_metadata.h:174
virtual void Draw(void)
virtual void GetCppInterfaceDescriptionFree(InterfaceListType *array)
char * InstanceName(void)
Definition: disti_metadata.h:667
void SetAnimationValue(float value)
Definition: gls_path_manager.h:58
virtual void CopyProperties(DisplayObject *src)
float MaxTimeValue()
Definition: gls_path_manager.h:256
Definition: vertex.h:83
virtual void SetAvailableAttributes(unsigned int value)
void CurrentTimeValue(float value)
Definition: gls_path_manager.h:231
virtual bool Hit(float x, float y, float z, float scale, const Vector &directionVector, Vector *collisionPoint)
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)