|
Core 1.0
|
A simple camera. More...
#include <camera.h>
Public Member Functions | |
| Camera () | |
| Create a default camera. | |
| Camera (const Vector &, const Vector &=Vector::Null, const Vector &=Vector::Z, const double &=1.0, const double &=1.0, const double &=1.0, const double &=100000.0) | |
| Create a camera given its location and look-at point. | |
| Camera (const Vector &, const Vector &, const Vector &, const double &, const double &=1.0, const double &=100000.0) | |
| Create a camera given its location and look at point. | |
| void | Translate (const Vector &) |
| Translates a camera by a given vector. | |
| void | Rotate (const Matrix &) |
| Rotates the camera with a rotation matrix. | |
| Vector | At () const |
| Returns the look-at point. | |
| Vector | Eye () const |
| Returns the eye point. | |
| Vector | Up () const |
| Returns the up point. | |
| Vector | View () const |
| Returns the viewing direction (not normalized). | |
| Frame | GetFrame () const |
| Get the frame of the camera. | |
| double | GetNear () const |
| Get the near distance. | |
| double | GetFar () const |
| Get the far distance. | |
| double | GetAngleOfViewH () const |
| Returns the horizontal angle of view. | |
| double | GetAngleOfViewV (double, double) const |
| Returns the vertical angle of view. | |
| void | Step (const double &) |
| Steps forward or backward by a given distance. | |
| bool | InsideFrustum (const Vector &) const |
| Check if the point lies in the view frustum. | |
| bool | InsideFrustum (const Box &) const |
| Check if the argument box lies in the view frustum. | |
| void | LeftRight (const double &) |
| Rotates the camera around the up vector by a given angle. | |
| void | Vertical () |
| Reset the camera so that the up vector should point to the sky. | |
| void | UpDown (const double &) |
| Move camera up and down according to the up vector. | |
| void | SideWay (const double &) |
| Moves the camera sideway. | |
| void | BackForth (const double &, bool=false) |
| Moves the eye point towards or away from the look at point. | |
| void | LeftRightRound (const double &) |
| Rotates the camera relatively to the look-at point. | |
| void | UpDownRound (const double &) |
| Rotates the camera relatively to the look-at point. | |
| void | LeftRightFPS (const double &) |
| Rotates the camera relatively to the look-at point. | |
| void | UpDownRoundFPS (const double &) |
| Rotates the camera relatively to the look-at point. | |
| void | SlideHorizontal (const double &) |
| Moves the camera left or right in the horizontal plane. | |
| void | SetAt (const Vector &) |
| Sets the camera target vector. | |
| void | SetEye (const Vector &) |
| Sets the camera eye point. | |
| void | SetPlanes (const double &, const double &) |
| Set the near and far planes. | |
| void | UpDownVertical (const double &) |
| Moves the camera vertically. | |
| void | LeftRightHorizontal (const double &) |
| Moves the camera left or right, preserving its height. | |
| QString | ToString (int=6) const |
| Create a QString form a camera. | |
| Ray | PixelToRay (int, int, int, int) const |
| Compute the equation of a ray given a pixel in the camera plane. | |
| Ray | PixelToRay (int, int, int, int, int, int, int) const |
| Compute the equation of a ray given a pixel in the camera plane. | |
| bool | VectorToPixel (const Vector &, double &, double &, int, int) const |
| Compute coordinates of a point in the camera plane. | |
Static Public Member Functions | |
| static Camera | View (const Box &) |
| Create a default camera focusing on a given box. | |
Protected Attributes | |
| Vector | eye = -Vector::X |
| Eye. | |
| Vector | at = Vector::Null |
| Look at point. | |
| Vector | up = Vector::Z |
| Up vector. | |
| Vector | view = Vector::X |
| View unit vector. | |
| double | width = 1.0 |
| Screen width. | |
| double | height = 1.0 |
| Screen height. | |
| double | cah |
| Camera aperture horizontal. | |
| double | cav |
| Camera aperture vertical. | |
| double | fl |
| Focal length. | |
| double | nearplane = 1.0 |
| Near plane. | |
| double | farplane = 100000.0 |
| Far plane. | |
Friends | |
| std::ostream & | operator<< (std::ostream &s, const Camera &camera) |
| Overloaded. | |
A simple camera.
|
explicit |
Create a camera given its location and look-at point.
If no upward vector is provided, it is defined as z-axis.
The view vector is defined as the vector between the eye point and the look at point. The right vector, which is always computed as a cross product between the view vector and the up vector.
| eye | Eye point. |
| at | Look-at point. |
| up | Up vector. |
| width,height | Width and height of virtual screen. |
| near,far | Near and far planes. |
|
explicit |
Create a camera given its location and look at point.
| eye | Eye point. |
| at | Look-at point. |
| up | Up vector. |
| field | Field of view, should be in [0,Math::Pi/2.0]. |
| near,far | Near and far planes. |
| void Camera::BackForth | ( | const double & | a, |
| bool | t = false ) |
Moves the eye point towards or away from the look at point.
The look-at point does not change.
| a | Distance. |
| t | Boolean, set to true if look-at point should also be moved in the direction. |
| double Camera::GetAngleOfViewH | ( | ) | const |
Returns the horizontal angle of view.
Angle is in radian.
| double Camera::GetAngleOfViewV | ( | double | w, |
| double | h ) const |
Returns the vertical angle of view.
Angle is in radian.
| w,h | Width and height of the screen. |
| bool Camera::InsideFrustum | ( | const Box & | box | ) | const |
Check if the argument box lies in the view frustum.
| box | The box. |
| bool Camera::InsideFrustum | ( | const Vector & | p | ) | const |
Check if the point lies in the view frustum.
Simply check if the point is on the right side of the camera.
| p | The point. |
| void Camera::LeftRight | ( | const double & | a | ) |
Rotates the camera around the up vector by a given angle.
| a | Rotation angle. |
| void Camera::LeftRightFPS | ( | const double & | a | ) |
Rotates the camera relatively to the look-at point.
| a | Distance. |
| void Camera::LeftRightHorizontal | ( | const double & | a | ) |
Moves the camera left or right, preserving its height.
| a | Distance. |
| void Camera::LeftRightRound | ( | const double & | a | ) |
Rotates the camera relatively to the look-at point.
| a | Distance. |
| Ray Camera::PixelToRay | ( | int | px, |
| int | py, | ||
| int | w, | ||
| int | h ) const |
Compute the equation of a ray given a pixel in the camera plane.
| px,py | Pixel coordinates. |
| w,h | Size of the viewing window. |
| Ray Camera::PixelToRay | ( | int | px, |
| int | py, | ||
| int | w, | ||
| int | h, | ||
| int | a, | ||
| int | xa, | ||
| int | ya ) const |
Compute the equation of a ray given a pixel in the camera plane.
| px,py | Pixel coordinates. |
| w,h | Size of the viewing window. |
| a | Anti-aliasing sub-pixels. |
| xa,ya | Integer coordinates of the sub-pixel. |
| void Camera::Rotate | ( | const Matrix & | r | ) |
Rotates the camera with a rotation matrix.
The rotation is centered at the eye, so the eye location is preserved. Other parameters are preserved.
| r | Rotation matrix. |
| void Camera::SetAt | ( | const Vector & | a | ) |
Sets the camera target vector.
| a | Look-at point. |
| void Camera::SetEye | ( | const Vector & | p | ) |
Sets the camera eye point.
| p | Eye point. |
| void Camera::SetPlanes | ( | const double & | n, |
| const double & | f ) |
Set the near and far planes.
| n,f | Near and far planes distance to th eye. |
| void Camera::SideWay | ( | const double & | a | ) |
Moves the camera sideway.
| a | Distance. |
| void Camera::SlideHorizontal | ( | const double & | a | ) |
Moves the camera left or right in the horizontal plane.
| a | Distance. |
| void Camera::Step | ( | const double & | r | ) |
Steps forward or backward by a given distance.
| r | Stepping distance. |
| QString Camera::ToString | ( | int | n = 6 | ) | const |
Create a QString form a camera.
| n | Number of digits used in the representation of reals. |
| void Camera::Translate | ( | const Vector & | t | ) |
Translates a camera by a given vector.
| t | Translation vector. |
| void Camera::UpDown | ( | const double & | a | ) |
Move camera up and down according to the up vector.
| a | Rotation angle. |
| void Camera::UpDownRound | ( | const double & | a | ) |
Rotates the camera relatively to the look-at point.
| a | Distance. |
| void Camera::UpDownRoundFPS | ( | const double & | a | ) |
Rotates the camera relatively to the look-at point.
| a | Distance. |
| void Camera::UpDownVertical | ( | const double & | a | ) |
Moves the camera vertically.
This function keeps the left vector horizontal.
| a | Distance. |
| bool Camera::VectorToPixel | ( | const Vector & | p, |
| double & | u, | ||
| double & | v, | ||
| int | w, | ||
| int | h ) const |
Compute coordinates of a point in the camera plane.
| p | Point. |
| u,v | Coordinates in the screen. |
| w,h | Size of the viewing window. |
Create a default camera focusing on a given box.
THe camera is located outside of the box and focuses on the center of the target box.
| box | The box. |
|
friend |
Overloaded.
| s | Stream. |
| camera | The camera. |