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