PF_API 0.52

Android/jni/Libs/Math_LIB/MInterpolator.h

Go to the documentation of this file.
00001 
00002 //    Copyright (C) 2004-2006 Dylan Blair
00003 //
00004 //    email: dblair@alumni.cs.utexas.edu
00005 //
00006 //    This library is free software; you can redistribute it and/or
00007 //    modify it under the terms of the GNU Lesser General Public
00008 //    License as published by the Free Software Foundation; either
00009 //    version 2.1 of the License, or (at your option) any later version.
00010 //
00011 //    This library is distributed in the hope that it will be useful,
00012 //    but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 //    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014 //    Lesser General Public License for more details.
00015 //
00016 //    You should have received a copy of the GNU Lesser General Public
00017 //    License along with this library; if not, write to the Free Software
00018 //    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00020 
00021 #ifndef MINTERPOLATOR_H
00022 #define MINTERPOLATOR_H
00023 
00024 #include "MMatrix3x3.h"
00025 
00026 namespace OpenSkyNet {
00027     namespace Math {
00035         class Interpolator {
00036         public:
00037             enum TYPE {
00038                 BOUNCE_F,
00039                 BOUNCE_B,
00040                 LOOP,
00041                 END
00042             } _type;
00043             float _value;
00044 
00045             Interpolator() : _type(LOOP), _value(0.0f) {}
00046             Interpolator(TYPE type_) : _type(type_), _value(0.0f) {}
00047             bool operator+(float amount_);
00048             operator float() { return _value; }
00049         };
00050 
00053         struct ILerpOverTime {
00054             float _percentAdditive;
00055             Math::Interpolator _interpolator;
00056 
00057             ILerpOverTime() {}
00058             virtual bool update(float dt_) = 0;
00059             virtual ~ILerpOverTime() {}
00060         };
00061 
00063         struct LerpOverTime1 : public ILerpOverTime {
00064             float* _control;
00065             float _begin, _end;
00066 
00067             virtual void init(float& begin_, float end_, float speed_);
00068             virtual bool update(float dt_);
00069         };
00070 
00072         struct LerpOverTime3 : public ILerpOverTime {
00073             Math::Point<>* _control;
00074             Math::Point<> _begin, _end;
00075 
00076             static const float _minSqrdDistToUpdate;
00077 
00078             virtual void init(Math::Point<>& begin_, const Math::Point<>& end_, float speed_);
00079             virtual bool update(float dt_);
00080         };
00081 
00083         struct LerpOverTime3x3 : public ILerpOverTime {
00084             Math::Matrix3x3* _control;
00085             Math::Matrix3x3 _begin;
00086             Math::Point<> _rotAxis;
00087             float _endRads;
00088 
00089             static const float _minRadsToUpdate;
00090 
00091             virtual void init(Math::Matrix3x3& begin_, const Math::Point<>& axis_, float radians_, float speed_);
00092             virtual void init(Math::Matrix3x3& begin_, const Math::Matrix3x3& end_, float speed_);
00093             virtual bool update(float dt_);
00094         };
00095     }
00096 }
00097 
00098 #endif //MINTERPOLATOR_H
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines