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