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