5 #include "PerspectiveCamera.hxx"
7 PerspectiveCamera::PerspectiveCamera()
12 PerspectiveCamera::PerspectiveCamera(const Vec3f
& pos
,
24 // preprocess the values and fill the rest of the member variables here
28 // compute local coordinate system
30 m_xAxis
= dir
.cross(up
);
31 m_yAxis
= m_xAxis
.cross(m_zAxis
);
37 m_aspect
= resX
/static_cast<float>(resY
);
39 // derive focal length from opening angle
40 float angle_in_rad
= angle
* M_PI
/ 180.0f
;
41 m_focus
= 1.0 / tan(angle_in_rad
* 0.5);
44 PerspectiveCamera::~PerspectiveCamera()
48 PerspectiveCamera::PerspectiveCamera(const PerspectiveCamera
& )
54 PerspectiveCamera::operator=(const PerspectiveCamera
& )
56 assert(!"Not implemented!");
61 PerspectiveCamera::InitRay(float x
, //!< pixel x-coordinate
62 float y
, //!< pixel y-coordinate
63 Ray
& ray
//!< should be filled by this function
66 // define direction,position and maximum hit distance of Ray here
67 Vec3f dir
= m_xAxis
* ( 2.0f
* ((x
/static_cast<float>(m_resX
) - 0.5 ) * m_aspect
) )
68 + m_yAxis
* ( 2.0f
* (y
/static_cast<float>(m_resY
) - 0.5 ) )
69 + ( m_zAxis
* m_focus
);
74 float t
= std::numeric_limits
<float>::max();
This page took 0.058608 seconds and 5 git commands to generate.