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. More... | |
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. More... | |
void | Translate (const Vector &) |
Translates a camera by a given vector. More... | |
void | Rotate (const Matrix &) |
Rotates the camera with a rotation matrix. More... | |
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. More... | |
double | GetAngleOfViewV (double, double) const |
Returns the vertical angle of view. More... | |
void | Step (const double &) |
Steps forward or backward by a given distance. More... | |
bool | InsideFrustum (const Vector &) const |
Check if the point lies in the view frustum. More... | |
bool | InsideFrustum (const Box &) const |
Check if the argument box lies in the view frustum. More... | |
void | LeftRight (const double &) |
Rotates the camera around the up vector by a given angle. More... | |
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. More... | |
void | SideWay (const double &) |
Moves the camera sideway. More... | |
void | BackForth (const double &, bool=false) |
Moves the eye point towards or away from the look at point. More... | |
void | LeftRightRound (const double &) |
Rotates the camera relatively to the look-at point. More... | |
void | UpDownRound (const double &) |
Rotates the camera relatively to the look-at point. More... | |
void | LeftRightFPS (const double &) |
Rotates the camera relatively to the look-at point. More... | |
void | UpDownRoundFPS (const double &) |
Rotates the camera relatively to the look-at point. More... | |
void | SlideHorizontal (const double &) |
Moves the camera left or right in the horizontal plane. More... | |
void | SetAt (const Vector &) |
Sets the camera target vector. More... | |
void | SetEye (const Vector &) |
Sets the camera eye point. More... | |
void | SetPlanes (const double &, const double &) |
Set the near and far planes. More... | |
void | UpDownVertical (const double &) |
Moves the camera vertically. More... | |
void | LeftRightHorizontal (const double &) |
Moves the camera left or right, preserving its height. More... | |
QString | ToString (int=6) const |
Create a QString form a camera. More... | |
Ray | PixelToRay (int, int, int, int) const |
Compute the equation of a ray given a pixel in the camera plane. More... | |
Ray | PixelToRay (int, int, int, int, int, int, int) const |
Compute the equation of a ray given a pixel in the camera plane. More... | |
bool | VectorToPixel (const Vector &, double &, double &, int, int) const |
Compute coordinates of a point in the camera plane. More... | |
Static Public Member Functions | |
static Camera | View (const Box &) |
Create a default camera focusing on a given box. More... | |
Protected Attributes | |
Vector | eye |
Eye. | |
Vector | at |
Look at point. | |
Vector | up |
Up vector. | |
Vector | view |
View unit vector. | |
double | width |
Screen width. | |
double | height |
Screen height. | |
double | cah |
Camera aperture horizontal. | |
double | cav |
Camera aperture vertical. | |
double | fl |
Focal length. | |
double | nearplane |
Near plane. | |
double | farplane |
Far plane. | |
Friends | |
std::ostream & | operator<< (std::ostream &, const Camera &) |
Overloaded. More... | |
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. |