|
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. | |
| void | CircleAnim (const double &angle, const Vector &start_eye) |
| Rotates the camera around the look-at point by a given angle, starting from a given eye position. | |
| Vector | At () const |
| Returns the look-at point. | |
| Vector | Eye () const |
| Returns the eye point. | |
| Vector | Up () const |
| Returns the up vector. | |
| 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 | GetCameraApertureH () const |
| Returns the horizontal camera aperture (film gate width) in inches. | |
| double | GetCameraApertureV () const |
| Returns the vertical camera aperture (film gate height) in inches. | |
| double | GetFocalLength () const |
| Returns the focal length in millimetres. | |
| 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 &) |
| Rotates the view direction up or down around the eye, the look-at point moves while the eye remains fixed. | |
| 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 eye around the vertical axis passing through the look-at point. | |
| void | UpDownRound (const double &) |
| Rotates the eye up or down around the look-at point. | |
| void | LeftRightFPS (const double &) |
| Rotates the look-at point around the vertical axis passing through the eye, as in a first person view. | |
| void | UpDownRoundFPS (const double &) |
| Rotates the look-at point up or down around the eye, as in a first person view. | |
| 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 | SetCameraApertureH (const double &) |
| Set the horizontal camera aperture. | |
| void | SetCameraApertureV (const double &) |
| Set the vertical camera aperture. | |
| void | SetFocalLength (const double &) |
| Set the focal length. | |
| 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 | Lerp (const Camera &, const Camera &, const double &) |
| Linearly interpolates between two cameras. | |
| 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 | cah = 0.980 |
| Camera aperture horizontal. | |
| double | cav = 0.735 |
| Camera aperture vertical. | |
| double | fl = 35.0 |
| 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, currently ignored (the camera aperture and the focal length keep their default values). |
| 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. |
| void Camera::CircleAnim | ( | const double & | angle, |
| const Vector & | start_eye ) |
Rotates the camera around the look-at point by a given angle, starting from a given eye position.
| angle | Rotation angle in radians. |
| start_eye | Starting eye position, used to compute the radius and the initial angle of the circular animation. |
| 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. |
| double Camera::GetCameraApertureH | ( | ) | const |
Returns the horizontal camera aperture (film gate width) in inches.
This is the horizontal dimension of the film gate as used in Maya/RenderMan conventions. The default value is 0.980 inches (standard 35 mm full aperture). It is converted to millimetres internally when computing the angle of view:
| double Camera::GetCameraApertureV | ( | ) | const |
Returns the vertical camera aperture (film gate height) in inches.
This is the vertical dimension of the film gate as used in Maya/RenderMan conventions. The default value is 0.735 inches (standard 35 mm full aperture).
| double Camera::GetFocalLength | ( | ) | const |
Returns the focal length in millimetres.
Standard values range from 14 mm (wide angle) to 200 mm (telephoto). The default is 35 mm. Increasing the focal length narrows the angle of view; see GetAngleOfViewH().
| bool Camera::InsideFrustum | ( | const Box & | box | ) | const |
Check if the argument box lies in the view frustum.
Only a conservative test is performed: the bounding sphere of the box is checked against the half-space in front of the eye, the side, near and far planes are not tested.
| 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 look-at point around the vertical axis passing through the eye, as in a first person view.
| a | Rotation angle (radians). |
| 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 eye around the vertical axis passing through the look-at point.
| a | Rotation angle (radians). |
Linearly interpolates between two cameras.
All intrinsic and extrinsic parameters are interpolated: position, look-at point, up vector, screen dimensions, aperture, focal length, and clip planes. The up vector is re-normalised after blending to keep it unit-length.
| cA | First camera. |
| cB | Second camera. |
| alpha | Blend factor in [0,1]: 0 returns cA, 1 returns cB. |
| 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::SetCameraApertureH | ( | const double & | c | ) |
Set the horizontal camera aperture.
| c | Aperture, in inches. |
| void Camera::SetCameraApertureV | ( | const double & | c | ) |
Set the vertical camera aperture.
| c | Aperture, in inches. |
| void Camera::SetEye | ( | const Vector & | p | ) |
Sets the camera eye point.
| p | Eye point. |
| void Camera::SetFocalLength | ( | const double & | f | ) |
Set the focal length.
| f | Focal length, in millimeters. |
| 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 | ) |
Rotates the view direction up or down around the eye, the look-at point moves while the eye remains fixed.
| a | Rotation angle (radians). |
| void Camera::UpDownRound | ( | const double & | a | ) |
Rotates the eye up or down around the look-at point.
| a | Rotation angle (radians). |
| void Camera::UpDownRoundFPS | ( | const double & | a | ) |
Rotates the look-at point up or down around the eye, as in a first person view.
| a | Rotation angle (radians). |
| 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. |