4 #include "PerspectiveCamera.hxx"
6 PerspectiveCamera::PerspectiveCamera()
11 PerspectiveCamera::PerspectiveCamera(const Vec3f
& pos
,
23 // preprocess the values and fill the rest of the member variables here
25 // compute local coordinate system
27 m_xAxis
= dir
.cross(up
);
28 m_yAxis
= m_xAxis
.cross(m_zAxis
);
34 m_aspect
= resX
/static_cast<float>(resY
);
36 // derive focal length from opening angle
37 float angle_in_rad
= angle
* M_PI
/ 180.0f
;
38 m_focus
= 1.0 / tan(angle_in_rad
* 0.5);
41 PerspectiveCamera::~PerspectiveCamera()
45 PerspectiveCamera::PerspectiveCamera(const PerspectiveCamera
& )
51 PerspectiveCamera::operator=(const PerspectiveCamera
& )
57 PerspectiveCamera::InitRay(float x
, //!< pixel x-coordinate
58 float y
, //!< pixel y-coordinate
59 Ray
& ray
//!< should be filled by this function
62 // define direction,position and maximum hit distance of Ray here
63 Vec3f dir
= m_xAxis
* ( 2.0f
* ((x
/static_cast<float>(m_resX
) - 0.5 ) * m_aspect
) )
64 + m_yAxis
* ( 2.0f
* (y
/static_cast<float>(m_resY
) - 0.5 ) )
65 + ( m_zAxis
* m_focus
);
70 float t
= std::numeric_limits
<float>::max();
This page took 0.040778 seconds and 5 git commands to generate.