00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012 #ifndef TA_FUNCSPLINE_H
00013 #define TA_FUNCSPLINE_H
00014
00015 #ifndef TA_TYPES_H
00016 #include "Types.h"
00017 #endif // TA_TYPES_H
00018
00019 #ifndef TA_FUNCTION_H
00020 #include "Function.h"
00021 #endif // TA_FUNCTION_H
00022
00023 namespace TA
00024 {
00025
00026 class Serialiser;
00027
00028 class TACOMMON_CLASS FuncSpline : public Function
00029 {
00030 public:
00031 typedef int PointHandle;
00032
00033
00034 class TACOMMON_CLASS Point
00035 {
00036 public:
00037 Point() {}
00038 virtual ~Point() {}
00039 virtual Serialise(Serialiser& serialiser);
00040 float fInput;
00041 float fOutput;
00042 Point* pNext;
00043 Point* pPrev;
00044 };
00045
00046 FuncSpline();
00047 virtual ~FuncSpline();
00048
00049 virtual void Initialise();
00050 void Initialise(const FuncSpline& that);
00051 virtual void Finalise();
00052 virtual void Serialise(Serialiser& serialiser);
00053
00054 PointHandle AddPoint(float fInput, float fOutput);
00055 PointHandle AddPoint(float fInput, float fOutput, float fMinInputSeparation);
00056 void SetPoint(PointHandle hPoint, float fInput, float fOutput);
00057 int GetNumPoints() const { return m_nNumPoints; }
00058 PointHandle GetPoint(float fInput);
00059 PointHandle GetPointWithInRange(float fInput, float fRange);
00060 void RemovePoint(PointHandle hPoint);
00061 float GetPointOutput(PointHandle hPoint) const;
00062 void SetPointOutput(PointHandle hPoint, float fOutPut);
00063 float GetPointInput(PointHandle hPoint) const;
00064 void SetPointInput(PointHandle hPoint, float fInput);
00065
00066 void SetLooped(bool bValue, float fLoopTime = 1.0f);
00067 bool IsLooped() const { return (m_nFlags & FLAG_LOOPED) != 0; }
00068
00069 PointHandle GetPointHandleFromIndex(int nIndex) const;
00070 bool HandleIsValid(PointHandle hPoint) const { return hPoint != 0; }
00071
00072 float GetOutput(float fInput) const;
00073 float GetGradient(float fInput) const;
00074
00075 protected:
00076 enum Flags
00077 {
00078 FLAG_AUTO_OPTIMISE = 0x1,
00079 FLAG_LOOPED = 0x2,
00080 };
00081
00082 int m_nNumPoints;
00083 Point m_pointListHeader;
00084 mutable Point* m_pLastOutputSegment;
00085 u32 m_nFlags;
00086 float m_fLoopTime;
00087
00088 static Point* TAC_CALL GetPointFromHandle(PointHandle hPoint) { return (Point*&)hPoint; }
00089 static PointHandle TAC_CALL GetHandleFromPoint(Point* pPoint) { return (PointHandle&)pPoint; }
00090 virtual float GetOutputInSegment(Point* pPoint, float fInput) const = 0;
00091 virtual float GetGradientInSegment(Point* pPoint, float fInput) const = 0;
00092
00093 virtual void Optimise() {}
00094 virtual Point* CreatePoint();
00095 virtual void DestroyPoint(Point* pPoint);
00096 void GetSegmentAndSegmentTime(float fInput, Point*& pSegment, float& fSegmentTime) const;
00097 };
00098
00099 }
00100
00101 #endif // TA_FUNCSPLINE_H
© Copyright 2004-2006 TRUE AXIS PTY LTD Australia. All rights reserved.