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