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