GL Studio API
gls_dynamic_path.h
Go to the documentation of this file.
1 /*! \file
2  \brief The disti::GlsDynamicPath 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 _GLSDYNAMICPATH_H
41 #define _GLSDYNAMICPATH_H
42 
43 #include "group.h"
44 #include "gls_cpp_lang_support.h"
45 
46 //////////////////// Provides support for creating DLLs ////////////////////////
47 #if (defined(GLSGEN_EXPORT_GLSDYNAMICPATH) || \
48  defined(GLSGEN_IMPORT_GLSDYNAMICPATH) || \
49  defined(GLS_EXPORT_GENERATED) || \
50  defined(GLS_IMPORT_GENERATED)) \
51  && defined(_MSC_VER)
52 # if defined(GLSGEN_EXPORT_GLSDYNAMICPATH) || defined(GLS_EXPORT_GENERATED)
53 # define GLSGEN_GLSDYNAMICPATH_EXPORT __declspec(dllexport)
54 # else
55 # define GLSGEN_GLSDYNAMICPATH_EXPORT __declspec(dllimport)
56 # endif
57 #else
58 # define GLSGEN_GLSDYNAMICPATH_EXPORT
59 #endif
60 ///////////////////////////////////////////////////////////////////////////////
61 
62 #define LIB_BASE_NAME "gls_dynamic_path"
63 #include "gls_auto_lib.h"
64 #undef LIB_BASE_NAME
65 
66 namespace disti
67 {
68 
69 // SetValue enumerations
70 enum {
71  GLS_DYNAMICPATH_FIRST_VALUE = GLS_LAST_INITIALIZER+1,
72  GLS_DYNAMICPATH_AFFECTS_LOCATION_X,
73  GLS_DYNAMICPATH_AFFECTS_LOCATION_Y,
74  GLS_DYNAMICPATH_AFFECTS_LOCATION_Z,
75  GLS_DYNAMICPATH_AFFECTS_ROTATION_X,
76  GLS_DYNAMICPATH_AFFECTS_ROTATION_Y,
77  GLS_DYNAMICPATH_AFFECTS_ROTATION_Z,
78  GLS_DYNAMICPATH_AFFECTS_SCALE_X,
79  GLS_DYNAMICPATH_AFFECTS_SCALE_Y,
80  GLS_DYNAMICPATH_AFFECTS_SCALE_Z,
81  GLS_DYNAMICPATH_USE_SHORT_ROTATION_PATHS,
82  GLS_DYNAMICPATH_STATE_COUNT,
83  GLS_DYNAMICPATH_STATE
84  };
85 
86 /** Runtime implementation of a GlsDynamicPath */
88 {
89  friend class GlsDynamicPathEditor;
90 
91 private:
92  GlsDynamicPath& operator=( const GlsDynamicPath& ) DISTI_SPECIAL_MEM_FUN_DELETE;
93  GlsDynamicPath( const GlsDynamicPath& ) DISTI_SPECIAL_MEM_FUN_DELETE;
94 
95 public:
96  typedef DisplayObject _BaseClass;
97 
98  /** Create a new GlsDynamicPath.
99  * \param generateInstanceName Whether or not to generate an instance name
100  * for this inputdevice */
101  GLSGEN_GLSDYNAMICPATH_EXPORT GlsDynamicPath(bool generateInstanceName=false);
102 
103  /** The copy constructor for GlsDynamicPath
104  *
105  * \param that The GlsDynamicPath object that is being copied
106  * \param generateNames Whether or not to generate a new instance name
107  */
108  GLSGEN_GLSDYNAMICPATH_EXPORT GlsDynamicPath( const GlsDynamicPath& that, const bool generateNames );
109 
110  /** Destructs a GlsDynamicPath object */
111  virtual GLSGEN_GLSDYNAMICPATH_EXPORT ~GlsDynamicPath();
112 
113  static GLSGEN_GLSDYNAMICPATH_EXPORT DisplayObject* CreateInstance();
114 
115  virtual GLSGEN_GLSDYNAMICPATH_EXPORT void SetAvailableAttributes(unsigned int value);
116 
117  virtual GLSGEN_GLSDYNAMICPATH_EXPORT DisplayObject* CloneObject(bool generateNames = false);
118 
119  virtual GLSGEN_GLSDYNAMICPATH_EXPORT void CopyProperties(DisplayObject *src);
120 
121 #ifndef GLES
122  virtual GLSGEN_GLSDYNAMICPATH_EXPORT InterfaceListType* GetCppInterfaceDescription(InterfaceListType* addToThisList= NULL );
123  virtual GLSGEN_GLSDYNAMICPATH_EXPORT void GetCppInterfaceDescriptionFree(InterfaceListType* array);
124 #endif
125 
126  virtual GLSGEN_GLSDYNAMICPATH_EXPORT void PreDraw( const OpenGLMatrices& parentMatrices,Culler &culler );
127  virtual GLSGEN_GLSDYNAMICPATH_EXPORT void Draw(void);
128 
129  virtual GLSGEN_GLSDYNAMICPATH_EXPORT DisplayObject* handle(DisplayEvent *ev);
130 
131  virtual GLSGEN_GLSDYNAMICPATH_EXPORT bool Hit(float x,float y,float z,float scale, const Vector& directionVector,Vector* collisionPoint);
132 
133  virtual GLSGEN_GLSDYNAMICPATH_EXPORT void SetValue(int spec,va_list &args);
134 
135  virtual GLSGEN_GLSDYNAMICPATH_EXPORT DistiAttributeBase& Resource(const char* name);
136  virtual GLSGEN_GLSDYNAMICPATH_EXPORT void GetResources(std::ostream& outstr, GlsResourceFilter* filter);
137 
138  //////////////////////////////////////////////////
139  // GlsDynamicPath specific operations
140  //////////////////////////////////////////////////
141 
142  // Controls whether the path will affect the X component of the object's dynamic translation.
143  GLSGEN_GLSDYNAMICPATH_EXPORT void AffectsLocationX( const bool& value );
144  GLSGEN_GLSDYNAMICPATH_EXPORT bool AffectsLocationX() const { return _affectsLocationX; }
145 
146  // Controls whether the path will affect the Y component of the object's dynamic translation.
147  GLSGEN_GLSDYNAMICPATH_EXPORT void AffectsLocationY( const bool& value );
148  GLSGEN_GLSDYNAMICPATH_EXPORT bool AffectsLocationY() const { return _affectsLocationY; }
149 
150  // Controls whether the path will affect the Z component of the object's dynamic translation.
151  GLSGEN_GLSDYNAMICPATH_EXPORT void AffectsLocationZ( const bool& value );
152  GLSGEN_GLSDYNAMICPATH_EXPORT bool AffectsLocationZ() const { return _affectsLocationZ; }
153 
154  // Controls whether the path will affect the X component of the object's dynamic rotation.
155  GLSGEN_GLSDYNAMICPATH_EXPORT void AffectsRotationX( const bool& value );
156  GLSGEN_GLSDYNAMICPATH_EXPORT bool AffectsRotationX() const { return _affectsRotationX; }
157 
158  // Controls whether the path will affect the Y component of the object's dynamic rotation.
159  GLSGEN_GLSDYNAMICPATH_EXPORT void AffectsRotationY( const bool& value );
160  GLSGEN_GLSDYNAMICPATH_EXPORT bool AffectsRotationY() const { return _affectsRotationY; }
161 
162  // Controls whether the path will affect the Z component of the object's dynamic rotation.
163  GLSGEN_GLSDYNAMICPATH_EXPORT void AffectsRotationZ( const bool& value );
164  GLSGEN_GLSDYNAMICPATH_EXPORT bool AffectsRotationZ() const { return _affectsRotationZ; }
165 
166  // Controls whether the path will affect the X component of the object's dynamic scale.
167  GLSGEN_GLSDYNAMICPATH_EXPORT void AffectsScaleX( const bool& value );
168  GLSGEN_GLSDYNAMICPATH_EXPORT bool AffectsScaleX() const { return _affectsScaleX; }
169 
170  // Controls whether the path will affect the Y component of the object's dynamic scale.
171  GLSGEN_GLSDYNAMICPATH_EXPORT void AffectsScaleY( const bool& value );
172  GLSGEN_GLSDYNAMICPATH_EXPORT bool AffectsScaleY() const { return _affectsScaleY; }
173 
174  // Controls whether the path will affect the Z component of the object's dynamic scale.
175  GLSGEN_GLSDYNAMICPATH_EXPORT void AffectsScaleZ( const bool& value );
176  GLSGEN_GLSDYNAMICPATH_EXPORT bool AffectsScaleZ() const { return _affectsScaleZ; }
177 
178  // If true, the shortest path between rotations is taken (360 degrees = no net rotation). If false, the long path is taken.
179  GLSGEN_GLSDYNAMICPATH_EXPORT void UseShortRotationPaths( const bool& value );
180  GLSGEN_GLSDYNAMICPATH_EXPORT bool UseShortRotationPaths() const { return _useShortRotationPaths; }
181 
182  // Contains the data for a state along the path
183  class State {
184  friend class GlsDynamicPath;
185  public:
186  GLSGEN_GLSDYNAMICPATH_EXPORT State();
187  GLSGEN_GLSDYNAMICPATH_EXPORT State(const State&);
188  GLSGEN_GLSDYNAMICPATH_EXPORT ~State();
189 
190  GLSGEN_GLSDYNAMICPATH_EXPORT const State& operator=(const State&);
191  GLSGEN_GLSDYNAMICPATH_EXPORT void MakeAttribDict();
192 
193  DistiAttribDict& Attributes()
194  {
195  if(!_attribDict) MakeAttribDict();
196  return *_attribDict;
197  };
198 
199  void Location( const Vector& value ) { _location = value; }
200  Vector Location() { return _location; }
201  Vector Location() const { return _location; }
202  void Rotation( const Vector& value ) {_rotation = value; }
203  Vector Rotation() { return _rotation; }
204  Vector Rotation() const { return _rotation; }
205  void Scale( const Vector& value ) {_scale = value; }
206  Vector Scale() { return _scale; }
207  Vector Scale() const { return _scale; }
208  void Value( const float& value ) { _value = value; }
209  float Value() { return _value; }
210  float Value() const { return _value; }
211  protected:
212  Vector _location;
213  Vector _rotation;
214  Vector _scale;
215  float _value;
216  DistiAttribDict* _attribDict;
217  };
218 
220 
221  // Returns the StateArray associated with this object. Use this array to modify the states that make up the path.
222  StateArrayType& StateArray() { return _stateArray; }
223  const StateArrayType& StateArray() const { return _stateArray; }
224 
225  // Iterates through the path segments and returns the first one found
226  // that contains the given value.
227  // \param value The value to search for
228  // \param index1 returns the index of the state at the start of the segment or -1 if no segments are found
229  // \param index2 returns the index of the state at the end the segment or -1 if no segments are found
230  // Special cases:
231  // value is before start of the path: index1 == index2 == 0
232  // value is past the end of the path: index1 == index2 == (StateArray().Count()-1)
233  GLSGEN_GLSDYNAMICPATH_EXPORT void FindFirstPathSegmentContainingValue(float value, int* index1, int* index2);
234 
235  // \returns the Value for the first state or 0 if there are no states
236  float FirstStateValue()
237  {
238  if(_stateArray.Count())
239  { return _stateArray.InternalArray()[0].Value(); }
240  else
241  { return 0; }
242  }
243 
244  // \returns the Value for the last state or 0 if there are no states
245  float LastStateValue()
246  {
247  if(_stateArray.Count())
248  { return _stateArray.InternalArray()[_stateArray.Count()-1].Value(); }
249  else
250  { return 0; }
251  }
252 
253  /** Get the linearly interpolated location along the path for the given value.
254  * \param value The value used to get the path location
255  */
256  GLSGEN_GLSDYNAMICPATH_EXPORT Vector GetPathLocation(float value);
257 
258  /** Get the linearly interpolated rotation along the path for the given value.
259  * \param value The value used to get the path rotation
260  */
261  GLSGEN_GLSDYNAMICPATH_EXPORT Vector GetPathRotation(float value);
262 
263  /** Get the linearly interpolated scale along the path for the given value.
264  * \param value The value used to get the path scale
265  */
266  GLSGEN_GLSDYNAMICPATH_EXPORT Vector GetPathScale(float value);
267 
268  /** Moves a DisplayObject to the position along the path corresponding with the given value.
269  * \param obj the DisplayObject to move
270  * \param value The value used to position the object on the path
271  */
272  GLSGEN_GLSDYNAMICPATH_EXPORT void MoveObject(DisplayObject* obj, float value);
273 
274  /** Sets the object to the position corresponding with the given state.
275  * Which values are applied is controlled by the AffectsLocation* and AffectsRotation* properties.
276  * \param obj Pointer to the object to move.
277  * \param stateNumber The index of the state to set the object to. If this value is outside the range [0,StateArray().Count()-1] nothing is done.
278  */
279  GLSGEN_GLSDYNAMICPATH_EXPORT void MoveObjectToState(DisplayObject* obj, int stateNumber);
280 
281 protected:
282 
283 #ifdef GLES
284  /** Set a single attribute from the GLO file.
285  * \param data The attribute to set and its associated data.
286  */
287  virtual GLS_EXPORT void SetFromGloData(GlsGloFileAttribute &data);
288 #endif
289 
290  bool _affectsLocationX;
291  bool _affectsLocationY;
292  bool _affectsLocationZ;
293  bool _affectsRotationX;
294  bool _affectsRotationY;
295  bool _affectsRotationZ;
296  bool _affectsScaleX;
297  bool _affectsScaleY;
298  bool _affectsScaleZ;
299 
300  bool _useShortRotationPaths;
301 
302  StateArrayType _stateArray;
303 };
304 
305 } // namespace disti
306 
307 #endif
Definition: cull.h:50
void MoveObjectToState(DisplayObject *obj, int stateNumber)
Definition: dynamic_array.h:63
The disti::Group class. Implements groups of objects.
Class to contain current OpenGL view, projection and draw matrices.
Definition: util.h:281
Vector GetPathLocation(float value)
Definition: gls_dynamic_path.h:183
virtual bool Hit(float x, float y, float z, float scale, const Vector &directionVector, Vector *collisionPoint)
Definition: display.h:98
DisplayObject(float x, float y, float z)
virtual void GetCppInterfaceDescriptionFree(InterfaceListType *array)
virtual DisplayObject * CloneObject(bool generateNames=false)
VertexNoColor Vector
Definition: gls_font_base.h:68
void Count(const unsigned int count)
Definition: dynamic_array.h:120
virtual InterfaceListType * GetCppInterfaceDescription(InterfaceListType *addToThisList=NULL)
Definition: gls_dynamic_path.h:87
virtual DistiAttributeBase & Resource(const char *name)
virtual void SetAvailableAttributes(unsigned int value)
Definition: disti_metadata.h:179
Definition: events.h:111
T * InternalArray(void)
Definition: dynamic_array.h:394
virtual void PreDraw(const OpenGLMatrices &parentMatrices, Culler &culler)
Definition: disti_metadata.h:676
The gls_auto_lib.
void MoveObject(DisplayObject *obj, float value)
Definition: vertex.h:84
virtual void SetValue(int spec, va_list &args)
virtual void GetResources(std::ostream &outstr, GlsResourceFilter *filter)
virtual DisplayObject * handle(DisplayEvent *ev)
Definition: gls_resources.h:50
Vector GetPathScale(float value)
Macros and helper code to determine what subset of C++11/14/17 is available.
Definition: bmpimage.h:46
virtual void CopyProperties(DisplayObject *src)
virtual void Draw(void)
Vector GetPathRotation(float value)