include/scene.h
branchpyrit
changeset 72 7c3f38dff082
parent 69 303583d2fb97
child 73 a5127346fbcd
equal deleted inserted replaced
71:4fedf7290929 72:7c3f38dff082
    62  */
    62  */
    63 class Camera
    63 class Camera
    64 {
    64 {
    65 public:
    65 public:
    66 	Vector3 eye, p, u, v;
    66 	Vector3 eye, p, u, v;
    67 	Float f,F;
    67 	Float F;
    68 
    68 
    69 	Camera(): eye(0,0,10), p(0,0,-1), u(-1,0,0), v(0,1,0), f(3.14/4.0), F(0.5/f) {};
    69 	Camera(): eye(0,0,10), p(0,0,-1), u(-1,0,0), v(0,1,0), F(0.7071) {};
    70 	Camera(const Vector3 &C, const Vector3 &ap, const Vector3 &au, const Vector3 &av):
    70 	Camera(const Vector3 &C, const Vector3 &ap, const Vector3 &au, const Vector3 &av):
    71 		eye(C), p(ap), u(au), v(av), f(3.14/4.0), F(0.5/f) {};
    71 		eye(C), p(ap), u(au), v(av), F(0.7071) {};
       
    72 	Camera(const Vector3 &from, const Vector3 &lookat, const Vector3 &up):
       
    73 		eye(from), F(0.7071)
       
    74 	{
       
    75 		p = lookat - from; u = cross(up, p);
       
    76 		p.normalize(); u.normalize();
       
    77 		v = cross(p, u);
       
    78 	};
    72 	void setEye(const Vector3 &aeye) { eye = aeye; };
    79 	void setEye(const Vector3 &aeye) { eye = aeye; };
    73 	void setFocalLength(const Float af) { f = af; F = 0.5/f; };
    80 	void setAngle(const Float angle) { F = sin(angle); };
    74 	void rotate(const Quaternion &q);
    81 	void rotate(const Quaternion &q);
    75 	void move(const Float fw, const Float left, const Float up);
    82 	void move(const Float fw, const Float left, const Float up);
    76 
    83 
    77 	Ray makeRay(Sample &samp)
    84 	Ray makeRay(Sample &samp)
    78 	{
    85 	{
    79 		Vector3 dir = p + (u*samp.x - v*samp.y)*F;
    86 		Vector3 dir = p - (u*samp.x + v*samp.y)*F;
    80 		dir.normalize();
    87 		dir.normalize();
    81 		return Ray(eye, dir);
    88 		return Ray(eye, dir);
    82 	};
    89 	};
    83 };
    90 };
    84 
    91