00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014 #ifndef __DEMOPAJA_CONTROLLERC_H__
00015 #define __DEMOPAJA_CONTROLLERC_H__
00016
00017
00018 #include "PajaTypes.h"
00019 #include "DataBlockI.h"
00020 #include "EditableI.h"
00021 #include "UndoC.h"
00022 #include "KeyC.h"
00023 #include "ColorC.h"
00024 #include "Vector2C.h"
00025 #include "Vector3C.h"
00026 #include "FileIO.h"
00027
00028
00029 namespace Composition {
00030
00032 enum ControllerOrtE {
00033 CONT_ORT_NONE = 0,
00034 CONT_ORT_CONSTANT,
00035 CONT_ORT_REPEAT,
00036 CONT_ORT_LOOP,
00037 };
00038
00040 enum ControllerTypeE {
00041 CONT_TYPE_NONE = 0,
00042 CONT_TYPE_INT,
00043 CONT_TYPE_FLOAT,
00044 CONT_TYPE_VECTOR2,
00045 CONT_TYPE_VECTOR3,
00046 CONT_TYPE_COLOR,
00047 CONT_TYPE_FILE,
00048 };
00049
00050
00052
00062 class ControllerC : public Edit::EditableI
00063 {
00064 public:
00066
00071 static ControllerC* create_new( ControllerTypeE eType );
00072
00074
00077 virtual Edit::DataBlockI* create();
00079 virtual Edit::DataBlockI* create( Edit::EditableI* pOriginal );
00081 virtual void copy( Edit::EditableI* pEditable );
00083 virtual void restore( Edit::EditableI* pEditable );
00084
00085
00087 virtual PajaTypes::int32 get_key_count();
00088
00090 virtual KeyC* get_key( PajaTypes::int32 i32Index );
00091
00093 virtual void del_key( PajaTypes::int32 i32Index );
00094
00096 virtual KeyC* get_key_at_time( PajaTypes::int32 i32Time );
00097
00099 virtual KeyC* add_key_at_time( PajaTypes::int32 i32Time );
00100
00102 virtual void set_start_ort( PajaTypes::uint32 ui32Ort );
00103
00105 virtual void set_end_ort( PajaTypes::uint32 ui32Ort );
00106
00108 virtual PajaTypes::uint32 get_start_ort();
00109
00111 virtual PajaTypes::uint32 get_end_ort();
00112
00114
00117 virtual void sort_keys();
00118
00120
00126 virtual void prepare();
00127
00129
00138 virtual void get_value( PajaTypes::float32* pValues, PajaTypes::int32 i32Time );
00139
00141 virtual void get_value( PajaTypes::int32& i32Val, PajaTypes::int32 i32Time );
00143 virtual void get_value( PajaTypes::float32& f32Val, PajaTypes::int32 i32Time );
00145 virtual void get_value( PajaTypes::Vector2C& rVal, PajaTypes::int32 i32Time );
00147 virtual void get_value( PajaTypes::Vector3C& rVal, PajaTypes::int32 i32Time );
00149 virtual void get_value( PajaTypes::ColorC& rVal, PajaTypes::int32 i32Time );
00150
00152
00155 virtual void get_value( Import::FileHandleC*& pHandle, PajaTypes::int32& i32FileTime, PajaTypes::int32 i32Time );
00156
00158 virtual PajaTypes::int32 get_min_time();
00159
00161 virtual PajaTypes::int32 get_max_time();
00162
00164 virtual PajaTypes::uint32 get_type();
00165
00167
00171 virtual void set_type( PajaTypes::uint32 ui32Type );
00172
00174
00176 virtual PajaTypes::uint32 get_num_channels();
00177
00178
00179 virtual PajaTypes::uint32 save( FileIO::SaveC* pSave );
00180
00181 virtual PajaTypes::uint32 load( FileIO::LoadC* pLoad );
00182
00183 protected:
00185 ControllerC( ControllerTypeE eType );
00187 ControllerC( Edit::EditableI* pOriginal );
00189 ~ControllerC();
00190
00191 private:
00192
00193
00194 void compute_hermite_basis( PajaTypes::float32 f32U, PajaTypes::float32* pV );
00195 PajaTypes::float32 ease( PajaTypes::float32 f32U, PajaTypes::float32 f32A, PajaTypes::float32 f32B );
00196 void comp_first_deriv( PajaTypes::uint32 ui32CurIndex, PajaTypes::uint32 ui32NextIndex );
00197 void comp_last_deriv( PajaTypes::uint32 ui32CurIndex, PajaTypes::uint32 ui32NextIndex );
00198 void comp_2key_deriv( PajaTypes::uint32 ui32CurIndex, PajaTypes::uint32 ui32NextIndex );
00199 void comp_middle_deriv( PajaTypes::uint32 ui32PrevIndex, PajaTypes::uint32 ui32Index, PajaTypes::uint32 ui32NextIndex );
00200 void copy_value( PajaTypes::float32* pOut, PajaTypes::float32* pIn, PajaTypes::uint32 ui32NumCh );
00201
00202
00203 std::vector<KeyC*> m_rKeys;
00204 PajaTypes::uint32 m_ui32StartOrt;
00205 PajaTypes::uint32 m_ui32EndOrt;
00206 PajaTypes::uint32 m_ui32NumChannels;
00207 PajaTypes::uint32 m_ui32Type;
00208 };
00209
00210 };
00211
00212 #endif // __DEMOPAJA_CONTROLLERC_H__