// CameraEvent.cpp: Implementierung der Klasse CCameraEvent.
//
//////////////////////////////////////////////////////////////////////

#include "CameraEvent.h"
#include <math.h>
#include <iostream>

//////////////////////////////////////////////////////////////////////
// Konstruktion/Destruktion
//////////////////////////////////////////////////////////////////////

CCameraEvent::CCameraEvent(double lasttime, double duration)
{
	for (int i = 0; i < 4; i++) {
		endvalue[0][i] = 0.0;
		endvalue[1][i] = 0.0;
		endvalue[2][i] = 0.0;
		endvalue[3][i] = 0.0;
	}
	for (i = 0; i < 6; i++) {
		pos_z[i] = 0.0;
		rot_x[i] = 0.0;
		rot_y[i] = 0.0;
		rot_z[i] = 0.0;
	}
	t_start	= lasttime;
	t_duration = duration;
	pos_z[0] = -15.0;
	values[CAMVALUE_POS_Z] = pos_z;
	values[CAMVALUE_ROT_X] = rot_x;
	values[CAMVALUE_ROT_Y] = rot_y;
	values[CAMVALUE_ROT_Z] = rot_z;
}

CCameraEvent::~CCameraEvent()
{

}

double CCameraEvent::GetValue(int camvalue, double time) {
	double a = values[camvalue][0];
	double b = values[camvalue][1];
	double c = values[camvalue][2];
	double d = values[camvalue][3];
	double e = values[camvalue][4];
	double f = values[camvalue][5];
	double t = time;
	if ((t < 0) || (t > t_duration)) {
		std::cout << "FEHLER IN CAMERAEVENT !!!";
	}
	return (a+
			b * t+
			c * t*t+
			d * t*t*t+
			e * t*t*t*t+
			f * t*t*t*t*t);
}

double CCameraEvent::GetEndTime() {
	return (t_start + t_duration);
}

double CCameraEvent::GetEndValue(int camvalue, int ableit) {
	return endvalue[camvalue][ableit];
}
