GL Studio API
gls_linear_float_controller.h
Go to the documentation of this file.
1 /*! \file
2  \brief Implementation of GlsLinearFloatController.
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 
41 #ifndef GLS_LINEAR_FLOAT_CONTROLLER_H_INCLUDED
42 #define GLS_LINEAR_FLOAT_CONTROLLER_H_INCLUDED
43 
44 #include "display.h"
45 #include "gls_cpp_lang_support.h"
46 
47 //////////////////// Provides support for creating DLLs ////////////////////////
48 #if (defined(GLSGEN_EXPORT_GLSADVANCEDMESH) || \
49  defined(GLSGEN_IMPORT_GLSADVANCEDMESH) || \
50  defined(GLS_EXPORT_GENERATED) || \
51  defined(GLS_IMPORT_GENERATED)) \
52  && defined(_MSC_VER)
53 # if defined(GLSGEN_EXPORT_GLSADVANCEDMESH) || defined(GLS_EXPORT_GENERATED)
54 # define GLSGEN_GlsLinearFloatController_EXPORT __declspec(dllexport)
55 # else
56 # define GLSGEN_GlsLinearFloatController_EXPORT __declspec(dllimport)
57 # endif
58 #else
59 # define GLSGEN_GlsLinearFloatController_EXPORT
60 #endif
61 ///////////////////////////////////////////////////////////////////////////////
62 
63 #define LIB_BASE_NAME "gls_advanced_mesh"
64 #include "gls_auto_lib.h"
65 #undef LIB_BASE_NAME
66 
67 
68 namespace disti {
69 
70 
71 // IFloatController allows working with all float controllers
72 // through a common interface
74 public:
75  /** Get the output value for a given input
76  * \returns The output value for the given input */
77  virtual float GetOutputForInput(float input) = 0;
78 
79  /** The caller may use this method to determine the valid input range for the animation
80  * Note: Some controllers may always return -FLT_MAX
81  * \returns The first input value in the animation */
82  virtual float GetFirstInputValue() = 0;
83 
84  /** The caller may use this method to determine the valid input range for the animation
85  * Note: Some controllers may always return FLT_MAX
86  * \returns The last input value in the animation */
87  virtual float GetLastInputValue() = 0;
88 };
89 
91  friend class GlsLinearFloatControllerEditor;
92 
93 private:
96 
97 public:
98  typedef DisplayObject _BaseClass;
99 
100  /** Create a new GlsLinearFloatController
101  * \param generateInstanceName Whether or not to generate an instance name */
102  GLSGEN_GlsLinearFloatController_EXPORT GlsLinearFloatController(bool generateInstanceName=false);
103  GLSGEN_GlsLinearFloatController_EXPORT GlsLinearFloatController( const GlsLinearFloatController& that, const bool generateNames );
104 
105  virtual GLSGEN_GlsLinearFloatController_EXPORT ~GlsLinearFloatController();
106 
107  static GLSGEN_GlsLinearFloatController_EXPORT DisplayObject* CreateInstance();
108 
109  // DisplayObject methods
110 
111  virtual GLSGEN_GlsLinearFloatController_EXPORT void SetAvailableAttributes(unsigned int value);
112 
113  virtual GLSGEN_GlsLinearFloatController_EXPORT DisplayObject* CloneObject(bool generateNames = false);
114 
115  virtual GLSGEN_GlsLinearFloatController_EXPORT void CopyProperties(DisplayObject *src);
116 
117 #ifndef GLES
118  virtual GLSGEN_GlsLinearFloatController_EXPORT InterfaceListType* GetCppInterfaceDescription(InterfaceListType* addToThisList= NULL );
119  virtual GLSGEN_GlsLinearFloatController_EXPORT void GetCppInterfaceDescriptionFree(InterfaceListType* array);
120 #endif
121 
122  virtual GLSGEN_GlsLinearFloatController_EXPORT void PreDraw( const OpenGLMatrices& parentMatrices,Culler &culler );
123  virtual GLSGEN_GlsLinearFloatController_EXPORT void Draw(void);
124 
125  virtual GLSGEN_GlsLinearFloatController_EXPORT DisplayObject* handle(DisplayEvent *ev);
126 
127  virtual GLSGEN_GlsLinearFloatController_EXPORT bool Hit(float x,float y,float z,float scale, const Vector& directionVector,Vector* collisionPoint);
128 
129  // IFloatController methods
130 
131  virtual GLSGEN_GlsLinearFloatController_EXPORT float GetOutputForInput(float input);
132 
133  virtual GLSGEN_GlsLinearFloatController_EXPORT float GetFirstInputValue();
134 
135  virtual GLSGEN_GlsLinearFloatController_EXPORT float GetLastInputValue();
136 
137  // GlsLinearFloatController methods
138 
139  class KeyData
140  {
141  float _input;
142  float _output;
143  public:
144  KeyData():
145  _input(0),
146  _output(0)
147  {}
148 
149  inline void SetInputValue(float value) { _input = value; }
150  inline float GetInputValue() const { return _input; }
151 
152  inline void SetOutputValue(float value) { _output = value; }
153  inline float GetOutputValue() const { return _output; }
154  };
155 
157 
158  // Returns the KeyArray associated with this object. Use this array to modify the keys that make up the animation.
159  inline KeyArrayType& KeyArray() { return _keyArray; }
160 
161  // Iterates through the path segments and returns the first one found
162  // that contains the given value.
163  // \param value The value to search for
164  // \param index1 returns the index of the state at the start of the segment or -1 if no segments are found
165  // \param index2 returns the index of the state at the end the segment or -1 if no segments are found
166  // Special cases:
167  // value is before start of the path: index1 == index2 == 0
168  // value is past the end of the path: index1 == index2 == (KeyArray().Count()-1)
169  GLSGEN_GlsLinearFloatController_EXPORT void FindFirstPathSegmentContainingValue(float value, int* index1, int* index2);
170 
171  // Initialize the key array
172  // Used by code generator
173  // \param numKeys The number of keys
174  // \param keyPairArray array of numKey*2 values that are used to initialize the keys
175  GLSGEN_GlsLinearFloatController_EXPORT void InitializeKeys(unsigned int numKeys, const float* keyPairArray);
176 
177 #ifdef GLES
178  /** Set a single attribute from the GLO file.
179  * \param data The attribute to set and its associated data.
180  */
181  virtual GLSGEN_GlsLinearFloatController_EXPORT void SetFromGloData(GlsGloFileAttribute &data);
182 #endif
183 
184 protected:
185  KeyArrayType _keyArray;
186 
187 };
188 
189 GLSGEN_GlsLinearFloatController_EXPORT std::ostream& operator<<(std::ostream& outstr, const GlsLinearFloatController::KeyData& key);
190 GLSGEN_GlsLinearFloatController_EXPORT std::istream& operator>>(std::istream& instr, GlsLinearFloatController::KeyData& key);
191 
192 } // namespace disti
193 
194 
195 #endif
Definition: cull.h:50
virtual void PreDraw(const OpenGLMatrices &parentMatrices, Culler &culler)
virtual DisplayObject * CloneObject(bool generateNames=false)
virtual float GetFirstInputValue()=0
virtual void CopyProperties(DisplayObject *src)
Definition: dynamic_array.h:63
Class to contain current OpenGL view, projection and draw matrices.
Definition: util.h:289
Definition: display.h:98
virtual InterfaceListType * GetCppInterfaceDescription(InterfaceListType *addToThisList=NULL)
virtual DisplayObject * handle(DisplayEvent *ev)
virtual void GetCppInterfaceDescriptionFree(InterfaceListType *array)
virtual float GetOutputForInput(float input)=0
The disti::DisplayObject class and global enumerations.
virtual float GetOutputForInput(float input)
Definition: events.h:111
virtual void SetAvailableAttributes(unsigned int value)
virtual bool Hit(float x, float y, float z, float scale, const Vector &directionVector, Vector *collisionPoint)
virtual float GetLastInputValue()=0
The gls_auto_lib.
Definition: gls_linear_float_controller.h:73
Definition: vertex.h:84
virtual float GetFirstInputValue()
Macros and helper code to determine what subset of C++11/14/17 is available.
Definition: gls_linear_float_controller.h:139
Definition: gls_linear_float_controller.h:90
Definition: bmpimage.h:46