BaseFCurve.h

00001 //***************************************************************************************
00002 //
00003 // File supervisor: Softimage 3D Games & 3D Bridge team
00004 //
00005 // (c) Copyright 2001-2002 Avid Technology, Inc. . All rights reserved.
00006 //
00007 //***************************************************************************************
00008 
00009 /****************************************************************************************
00010 THIS CODE IS PUBLISHED AS A SAMPLE ONLY AND IS PROVIDED "AS IS".
00011 IN NO EVENT SHALL SOFTIMAGE, AVID TECHNOLOGY, INC. AND/OR THEIR RESPECTIVE
00012 SUPPLIERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY
00013 DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
00014 ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
00015 CONNECTION WITH THE USE OR PERFORMANCE OF THIS CODE .
00016 
00017 COPYRIGHT NOTICE. Copyright © 1999-2002 Avid Technology Inc. . All rights reserved. 
00018 
00019 SOFTIMAGE is a registered trademark of Avid Technology Inc. or its subsidiaries 
00020 or divisions. Windows NT is a registered trademark of Microsoft Corp. All other
00021 trademarks contained herein are the property of their respective owners. 
00022 ****************************************************************************************/
00023 
00024 
00025 #ifndef _BASEFCURVE_H
00026 #define _BASEFCURVE_H
00027 
00028 #include "Template.h"
00029 
00030 extern CEnumDictionary<CSLTemplate::EFCurveInterpolationType, CSLTemplate::SI_CUBIC> g_FCurveInterpolationTypeDictionary;
00031 
00033 
00036 struct CSLBaseKey
00037 {
00038     SI_Float m_fTime;   
00039     SI_Float m_fValue;  
00040 };
00041 
00045 struct CSLConstantKey : public CSLBaseKey
00046 {
00047 };
00048 
00049 
00053 struct CSLLinearKey : public CSLBaseKey
00054 {
00055 };
00056 
00057 
00061 struct CSLHermiteKey : public CSLBaseKey
00062 {
00063     SI_Float m_fInTangent;
00064     SI_Float m_fOutTangent;
00065 };
00066 
00070 struct CSLBezierKey : public CSLBaseKey
00071 {
00072     SI_Float m_fInTangentX;
00073     SI_Float m_fInTangentY;
00074     SI_Float m_fOutTangentX;
00075     SI_Float m_fOutTangentY;
00076 };
00077 
00081 struct CSLCubicKey : public CSLBaseKey
00082 {
00083     SI_Float m_fLeftTanX;
00084     SI_Float m_fLeftTanY;
00085     SI_Float m_fRightTanX;
00086     SI_Float m_fRightTanY;
00087 };
00088 
00090 
00101 class XSIEXPORT CSLBaseFCurve
00102     : public CSLTemplate
00103 {
00104 public:
00107     typedef CSLArrayProxy<CSLConstantKey, SI_Float, 2> CSLConstantKeyArray;
00108 
00111     typedef CSLArrayProxy<CSLLinearKey, SI_Float, 2> CSLLinearKeyArray;
00112 
00115     typedef CSLArrayProxy<CSLHermiteKey, SI_Float, 4> CSLHermiteKeyArray;
00116 
00119     typedef CSLArrayProxy<CSLBezierKey, SI_Float, 6> CSLBezierKeyArray;
00120 
00123     typedef CSLArrayProxy<CSLCubicKey, SI_Float, 6> CSLCubicKeyArray;
00124 
00126     virtual ~CSLBaseFCurve();
00127 
00133     CSLConstantKeyArray* GetConstantKeyList();
00134 
00140     CSLCubicKeyArray* GetCubicKeyList();
00141 
00147     CSLHermiteKeyArray* GetHermiteKeyList();
00148 
00154     CSLBezierKeyArray* GetBezierKeyList();
00155 
00161     CSLLinearKeyArray* GetLinearKeyList();
00162 
00168     CSLConstantKey* GetConstantKeyListPtr();
00169 
00175     CSLCubicKey* GetCubicKeyListPtr();
00176 
00182     CSLHermiteKey* GetHermiteKeyListPtr();
00183 
00189     CSLBezierKey* GetBezierKeyListPtr();
00190 
00196     CSLLinearKey* GetLinearKeyListPtr();
00197 
00203     CSLTemplate::EFCurveInterpolationType GetInterpolationType();
00204 
00208     SI_Int GetKeyValueCount();
00209 
00214     SI_Int GetKeyCount();
00215 
00221     SI_Error Evaluate( SI_Float in_fTime );
00222 
00227     SI_Float GetLastEvaluation() { return m_fLastEvaluation; };
00228 
00233     SI_Float GetValueAtNextFrame ( SI_Float in_fFloat );
00234 
00239     SI_Float GetValueAtPrevFrame ( SI_Float in_fFloat );
00240 
00246     SI_Int  FindKeyAtOrBefore ( SI_Float in_fFloat );
00247 
00251     CSLAnimatableType* GetParameter();
00252 
00258     CSLAnimatableType* ConnectParameter(CSLAnimatableType* in_pNewParameter);
00259 
00260     virtual SI_Error Synchronize();
00261 
00262 protected:
00263 
00270     CSLBaseFCurve
00271     (
00272         CSLScene* in_pScene,
00273         CSLModel *in_pModel,
00274         CdotXSITemplate* in_pTemplate,
00275         EFCurveInterpolationType in_InterpolationType
00276     );
00277     CSLAnimatableType* m_pParameter;
00278 
00279 private:
00280     CSLStrEnumProxy<EFCurveInterpolationType, SI_CUBIC> m_InterpolationType;
00281     union
00282     {
00283         CSLConstantKeyArray* m_pConstantKeys;
00284         CSLLinearKeyArray* m_pLinearKeys;
00285         CSLHermiteKeyArray* m_pHermiteKeys;
00286         CSLBezierKeyArray* m_pBezierKeys;
00287         CSLCubicKeyArray* m_pCubicKeys;
00288     };
00289     
00290     SI_Int              m_iCurrentKey;      // for evaluation optimization
00291     SI_Float            m_fCurrentTime;     // @DEBUG
00292     SI_Float            m_fLastEvaluation;  // Hold the value of the last evaluation
00293 
00294     inline SI_Float GetTimeAtKey ( SI_Int );
00295 
00296     void *m_pReserved;  // reserved for future extension
00297 };
00298 
00299 #endif