| 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/// Automatically link the runtime library plugin (on Windows).
61#define LIB_BASE_NAME "gls_advanced_mesh"
62#include "gls_auto_lib.h"
63#undef LIB_BASE_NAME
64
65 namespace disti
66{
67/// \details IFloatController allows working with all float controllers through a common interface.
68 class IFloatController
69{
70 public:
71 /** Destructor */
72 virtual ~IFloatController() {}
73
74 /// Get the output value for a given input.
75 /// \param input The given input value.
76 /// \return 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
90/// \details The GlsLinearFloatController class. Interpolates incoming values based on its stored keyframes.
91 class GlsLinearFloatController : public DisplayObject
92 , public IFloatController
93{
94 friend class GlsLinearFloatControllerEditor;
95
96 private:
97 GlsLinearFloatController& operator=( const GlsLinearFloatController& );
98 GlsLinearFloatController( const GlsLinearFloatController& );
99
100 public:
101 DISTI_DEPRECATED( "This identifier is forbidden by the C++ standard. Use BaseClass instead." )
102 typedef DisplayObject _BaseClass; ///< Deprecated typedef for the base class.
103 typedef DisplayObject BaseClass; ///< Typedef for the base class.
104
105 /** Create a new GlsLinearFloatController
106 * \param generateInstanceName Whether or not to generate an instance name */
107 GLSGEN_GlsLinearFloatController_EXPORT GlsLinearFloatController( bool generateInstanceName = false );
108
109 /// Copy constructor
110 /// \param that The object to copy from.
111 /// \param generateNames Whether or not to generate an instance name.
112 GLSGEN_GlsLinearFloatController_EXPORT GlsLinearFloatController( const GlsLinearFloatController& that, const bool generateNames );
113
114 virtual GLSGEN_GlsLinearFloatController_EXPORT ~GlsLinearFloatController();
115
116 /// \return A pointer to a new GlsLinearFloatController object.
117 static GLSGEN_GlsLinearFloatController_EXPORT DisplayObject* CreateInstance();
118
119 // DisplayObject methods
120
121 virtual GLSGEN_GlsLinearFloatController_EXPORT void SetAvailableAttributes( unsigned int value ) DISTI_METHOD_OVERRIDE;
122 virtual GLSGEN_GlsLinearFloatController_EXPORT DisplayObject* CloneObject( bool generateNames = false ) DISTI_METHOD_OVERRIDE;
123 virtual GLSGEN_GlsLinearFloatController_EXPORT void CopyProperties( DisplayObject* src ) DISTI_METHOD_OVERRIDE;
124
125#ifndef GLES
126 virtual GLSGEN_GlsLinearFloatController_EXPORT InterfaceListType* GetCppInterfaceDescription( InterfaceListType* addToThisList = NULL ) DISTI_METHOD_OVERRIDE;
127 virtual GLSGEN_GlsLinearFloatController_EXPORT void GetCppInterfaceDescriptionFree( InterfaceListType* array ) DISTI_METHOD_OVERRIDE;
128#endif
129 virtual GLSGEN_GlsLinearFloatController_EXPORT void PreDraw( const OpenGLMatrices& parentMatrices, Culler& culler ) DISTI_METHOD_OVERRIDE;
130 virtual GLSGEN_GlsLinearFloatController_EXPORT void Draw() DISTI_METHOD_OVERRIDE;
131 virtual GLSGEN_GlsLinearFloatController_EXPORT DisplayObject* handle( DisplayEvent* ev ) DISTI_METHOD_OVERRIDE;
132 virtual GLSGEN_GlsLinearFloatController_EXPORT bool Hit( float x, float y, float z, float scale, const Vector& directionVector, Vector* collisionPoint ) DISTI_METHOD_OVERRIDE;
133
134 // IFloatController methods
135
136 virtual GLSGEN_GlsLinearFloatController_EXPORT float GetOutputForInput( float input ) DISTI_METHOD_OVERRIDE;
137 virtual GLSGEN_GlsLinearFloatController_EXPORT float GetFirstInputValue() DISTI_METHOD_OVERRIDE;
138 virtual GLSGEN_GlsLinearFloatController_EXPORT float GetLastInputValue() DISTI_METHOD_OVERRIDE;
139
140 // GlsLinearFloatController methods
141
142 /// \details The KeyData class. Contains a single keyframe of animation.
143 class KeyData
144 {
145 float _input; ///< The input (key) value.
146 float _output; ///< The output value.
147
148 public:
149 KeyData()
150 : _input( 0 )
151 , _output( 0 )
152 {}
153
154 /// Sets the input (key) value.
155 /// \param value The new value to set.
156 inline void SetInputValue( float value ) { _input = value; }
157
158 /// \return The input (key) value.
159 inline float GetInputValue() const { return _input; }
160
161 /// Set the output value.
162 /// \param value The new value to set.
163 inline void SetOutputValue( float value ) { _output = value; }
164
165 /// \return The output value.
166 inline float GetOutputValue() const { return _output; }
167 };
168
169 typedef DynamicArray<KeyData> KeyArrayType; ///< Typedef for a list of animation keys.
170
171 /// \return The KeyArray associated with this object. Use this array to modify the keys that make up the animation.
172 inline KeyArrayType& KeyArray() { return _keyArray; }
173
174 /// Iterates through the path segments and returns the first one found that contains the given value.
175 /// \param value The value to search for.
176 /// \param index1 Returns the index of the state at the start of the segment or -1 if no segments are found.
177 /// \param index2 Returns the index of the state at the end the segment or -1 if no segments are found.
178 /// Special cases:
179 /// value is before start of the path: index1 == index2 == 0
180 /// value is past the end of the path: index1 == index2 == (KeyArray().Count()-1)
181 GLSGEN_GlsLinearFloatController_EXPORT void FindFirstPathSegmentContainingValue( float value, int* index1, int* index2 );
182
183 /// Initialize the key array.
184 /// Used by code generator.
185 /// \param numKeys The number of keys.
186 /// \param keyPairArray Array of numKey*2 values that are used to initialize the keys.
187 GLSGEN_GlsLinearFloatController_EXPORT void InitializeKeys( unsigned int numKeys, const float* keyPairArray );
188
189#ifdef GLES
190 /** Set a single attribute from the GLO file.
191 * \param data The attribute to set and its associated data.
192 */
193 virtual GLSGEN_GlsLinearFloatController_EXPORT void SetFromGloData( GlsGloFileAttribute& data ) DISTI_METHOD_OVERRIDE;
194#endif
195
196 protected:
197 KeyArrayType _keyArray; ///< The list of key values for interpolation.
198};
199
200/// Stream out operator
201/// \param outstr The stream to write to.
202/// \param key The value to write to the stream.
203/// \return The stream in its current state.
204 GLSGEN_GlsLinearFloatController_EXPORT std::ostream& operator<<( std::ostream& outstr, const GlsLinearFloatController::KeyData& key );
205
206/// Stream in operator
207/// \param instr The stream to read from.
208/// \param key The returned value read from the stream.
209/// \return The stream in its current state.
210 GLSGEN_GlsLinearFloatController_EXPORT std::istream& operator>>( std::istream& instr, GlsLinearFloatController::KeyData& key );
211
212} // namespace disti
213
214#endif
disti::Culler
Definition: cull.h:50
disti::DisplayEvent
Definition: events.h:113
disti::DisplayObject
Definition: display.h:96
disti::DynamicArray
Definition: dynamic_array.h:79
disti::GlsGloFileAttribute
Definition: gls_glo_file.h:1243
disti::GlsLinearFloatController::KeyData
Definition: gls_linear_float_controller.h:144
disti::GlsLinearFloatController::KeyData::SetInputValue
void SetInputValue(float value)
Definition: gls_linear_float_controller.h:156
disti::GlsLinearFloatController::KeyData::GetInputValue
float GetInputValue() const
Definition: gls_linear_float_controller.h:159
disti::GlsLinearFloatController::KeyData::GetOutputValue
float GetOutputValue() const
Definition: gls_linear_float_controller.h:166
disti::GlsLinearFloatController::KeyData::SetOutputValue
void SetOutputValue(float value)
Definition: gls_linear_float_controller.h:163
disti::GlsLinearFloatController
Definition: gls_linear_float_controller.h:93
disti::GlsLinearFloatController::KeyArrayType
DynamicArray< KeyData > KeyArrayType
Typedef for a list of animation keys.
Definition: gls_linear_float_controller.h:169
disti::GlsLinearFloatController::SetAvailableAttributes
virtual void SetAvailableAttributes(unsigned int value) DISTI_METHOD_OVERRIDE
disti::GlsLinearFloatController::FindFirstPathSegmentContainingValue
void FindFirstPathSegmentContainingValue(float value, int *index1, int *index2)
disti::GlsLinearFloatController::Draw
virtual void Draw() DISTI_METHOD_OVERRIDE
disti::GlsLinearFloatController::InitializeKeys
void InitializeKeys(unsigned int numKeys, const float *keyPairArray)
disti::GlsLinearFloatController::CloneObject
virtual DisplayObject * CloneObject(bool generateNames=false) DISTI_METHOD_OVERRIDE
disti::GlsLinearFloatController::SetFromGloData
virtual void SetFromGloData(GlsGloFileAttribute &data) DISTI_METHOD_OVERRIDE
disti::GlsLinearFloatController::Hit
virtual bool Hit(float x, float y, float z, float scale, const Vector &directionVector, Vector *collisionPoint) DISTI_METHOD_OVERRIDE
disti::GlsLinearFloatController::PreDraw
virtual void PreDraw(const OpenGLMatrices &parentMatrices, Culler &culler) DISTI_METHOD_OVERRIDE
disti::GlsLinearFloatController::handle
virtual DisplayObject * handle(DisplayEvent *ev) DISTI_METHOD_OVERRIDE
disti::GlsLinearFloatController::GetLastInputValue
virtual float GetLastInputValue() DISTI_METHOD_OVERRIDE
disti::GlsLinearFloatController::CreateInstance
static DisplayObject * CreateInstance()
disti::GlsLinearFloatController::GetFirstInputValue
virtual float GetFirstInputValue() DISTI_METHOD_OVERRIDE
disti::GlsLinearFloatController::_keyArray
KeyArrayType _keyArray
The list of key values for interpolation.
Definition: gls_linear_float_controller.h:197
disti::GlsLinearFloatController::GetOutputForInput
virtual float GetOutputForInput(float input) DISTI_METHOD_OVERRIDE
disti::GlsLinearFloatController::CopyProperties
virtual void CopyProperties(DisplayObject *src) DISTI_METHOD_OVERRIDE
disti::GlsLinearFloatController::KeyArray
KeyArrayType & KeyArray()
Definition: gls_linear_float_controller.h:172
disti::IFloatController
Definition: gls_linear_float_controller.h:69
disti::IFloatController::GetOutputForInput
virtual float GetOutputForInput(float input)=0
disti::IFloatController::GetFirstInputValue
virtual float GetFirstInputValue()=0
disti::IFloatController::~IFloatController
virtual ~IFloatController()
Definition: gls_linear_float_controller.h:72
disti::IFloatController::GetLastInputValue
virtual float GetLastInputValue()=0
disti::OpenGLMatrices
Class to contain current OpenGL view, projection and draw matrices.
Definition: util.h:544
disti::VertexNoColor
Definition: vertex.h:85
display.h
The disti::DisplayObject class and global enumerations.
gls_auto_lib.h
The gls_auto_lib.
gls_cpp_lang_support.h
Macros and helper code to determine what subset of C++11/14/17 is available.
DISTI_DEPRECATED
#define DISTI_DEPRECATED(msg)
Defines whether this compiler supports the C++14 deprecated attribute.
Definition: gls_cpp_lang_support.h:488
DISTI_METHOD_OVERRIDE
#define DISTI_METHOD_OVERRIDE
Macro to wrap the override keyword, removed on compilers that don't support it.
Definition: gls_cpp_lang_support.h:222
GLSGEN_GlsLinearFloatController_EXPORT
#define GLSGEN_GlsLinearFloatController_EXPORT
Provides support for creating DLLs.
Definition: gls_linear_float_controller.h:56
disti
Definition: bmpimage.h:47
disti::operator<<
std::ostream & operator<<(std::ostream &outstr, const AttributeName &name)
disti::operator>>
std::istream & operator>>(std::istream &instr, GlsColor &color)