absence_thelab

diff src/3deng/camera.h @ 0:1cffe3409164

initial commit
author John Tsiombikas <nuclear@member.fsf.org>
date Thu, 23 Oct 2014 01:46:07 +0300
parents
children
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/src/3deng/camera.h	Thu Oct 23 01:46:07 2014 +0300
     1.3 @@ -0,0 +1,77 @@
     1.4 +#ifndef _CAMERA_H_
     1.5 +#define _CAMERA_H_
     1.6 +
     1.7 +#include <string>
     1.8 +#include "switches.h"
     1.9 +#include "n3dmath.h"
    1.10 +#include "curves.h"
    1.11 +#include "typedefs.h"
    1.12 +
    1.13 +class Camera {
    1.14 +private:
    1.15 +	Vector3 Pos, LookAt, Up;
    1.16 +	float FOV;
    1.17 +	float NearClip, FarClip;
    1.18 +	// transformation matrices for each vector
    1.19 +	Matrix4x4 PosTranslate, LookTranslate, UpTranslate;
    1.20 +	Matrix4x4 PosRotate, LookRotate, UpRotate;
    1.21 +	Matrix4x4 PosScale, LookScale, UpScale;
    1.22 +
    1.23 +	bool FlipRight;
    1.24 +
    1.25 +	const Curve *path, *targpath;
    1.26 +	dword StartTime, EndTime;
    1.27 +
    1.28 +public:
    1.29 +	std::string name;
    1.30 +	Matrix4x4 CCSmat;
    1.31 +
    1.32 +	Camera();
    1.33 +	float GetFOV() const {return FOV;}
    1.34 +	void SetFOV(float FOV) {this->FOV = FOV;}
    1.35 +
    1.36 +	void SetClippingPlanes(float NearClip, float FarClip);
    1.37 +	void GetClippingPlanes(float *NearClip, float *FarClip) const;
    1.38 +
    1.39 +	void SetCamera(const Vector3 &pos, const Vector3 &lookat, const Vector3 &up);
    1.40 +	Matrix4x4 &GetCameraMatrix();
    1.41 +
    1.42 +	// camera controls
    1.43 +	void Move(float x, float y, float z);
    1.44 +	void MoveTo(float x, float y, float z);
    1.45 +	void Rotate(float x, float y, float z);
    1.46 +	void Zoom(float factor);
    1.47 +
    1.48 +	// haphazard additions
    1.49 +	void SetRightFlipping(bool enable);
    1.50 +	void SetPosition(const Vector3 &pos);
    1.51 +	void SetUpVector(const Vector3 &up);
    1.52 +	void SetTarget(const Vector3 &targ);
    1.53 +
    1.54 +	Vector3 GetViewVector() const;
    1.55 +	Vector3 GetPosition() const;
    1.56 +	Vector3 GetUpVector() const;
    1.57 +	Vector3 GetTargetPosition() const;
    1.58 +
    1.59 +	Base GetCameraBase() const;
    1.60 +		
    1.61 +	inline void MoveTarget(float x, float y, float z);
    1.62 +	inline void MoveTargetTo(float x, float y, float z);
    1.63 +	inline void RotateTarget(float x, float y, float z);
    1.64 +
    1.65 +	void ResetRotation();
    1.66 +
    1.67 +	void CreateCameraMatrix();
    1.68 +	void CreateCameraMatrix(Matrix4x4 *matrix, const Vector3 &Pos, const Vector3 &LookAt, const Vector3 &Up) const;
    1.69 +	
    1.70 +	void Spin(float rads);
    1.71 +
    1.72 +	void SetCameraPath(const Curve *path, const Curve *tpath, dword StartTime, dword EndTime);
    1.73 +	void FollowPath(dword time, bool Cycle = false);
    1.74 +	void FollowPath(float t);
    1.75 +
    1.76 +	dword GetStartTime() const;
    1.77 +	dword GetEndTime() const;
    1.78 +};
    1.79 +
    1.80 +#endif	// _CAMERA_H_
    1.81 \ No newline at end of file