#pragma once

#include "renderer.h"
#include "math.h"
extern rMath *m;
extern long curFrame;

class rInterpolator
{
public:
	rInterpolator();
	void attachVar(vector3 *xi);
	virtual void setStartPoint(float startframe) = 0;
	virtual void attachPath(vector3 *xArray, float *sfArray, int Size) = 0;
	virtual bool Update() = 0;
	float getStartFrame(){return startFrame;}
protected:
	vector3 *x;
	float t;
	float startFrame;
	float endFrame;
	bool finished;
};

class rBezier : public rInterpolator
{
public:
	rBezier();
	~rBezier();

	void setStartPoint(float startframe);
	virtual void attachPath(vector3 *xArray, float *sfArray, int Size);
	bool Update();	//return false if we reached the end
private:
	void CalcMidPoints(vector3 *p);
	int curPoint;
	
	vector3 c;
	vector3 b;
	vector3 a;

	vector3 *xA;
	float *sfA;
	int size;
};

