Workspace 6.21.5
|
Defines a positionable, orientable camera for a scene. More...
#include <Rendering/SceneComponents/Cameras/camera.h>
Public Types | |
enum | ProjectionMode { Perspective , Orthographic } |
Protected Member Functions | |
virtual Mesh::TransformMatrix | getPerspectiveProjectionMatrix (int viewportWidth, int viewportHeight) const |
Protected Member Functions inherited from SceneItem | |
SceneItem (const QString &id) | |
SceneItem (const SceneItem &item) | |
virtual void | addToScene (Scene &scene, const QString &opIdPath="") |
bool | isTransformModified () const |
SceneItem & | operator= (const SceneItem &item) |
void | setTransformModified (bool b) |
Protected Member Functions inherited from Observable | |
Observable () | |
Observable (const Observable &) | |
The default transform of the camera results in it being initially:
The transform matrix can be manipulated to change the position and orientation of the camera, but scaling the camera will probably lead to unexpected effects.
Other camera properties such as the field of view and the near and far clipping planes can also be set to customize the image produced in the viewport during rendering.
enum ProjectionMode |
Camera | ( | const QString & | id = "" | ) |
|
override |
void calcGlobalVectors | ( | Mesh::Vector3d & | position, |
Mesh::Vector3d & | view, | ||
Mesh::Vector3d & | up, | ||
Mesh::Vector3d & | across | ||
) | const |
up | Upon exit, this will hold the camera's up vector in global co-ordinates. |
across | Upon exit, this will hold the camera's across vector in global co-ordinates (ie to the right) |
view | Upon exit, this will hold the camera's view vector in global co-ordinates (ie the direction in which the camera is looking) |
position | Upon exit, this will hold the global position of the camera. |
|
overridevirtual |
double getFarClippingPlane | ( | ) | const |
double getFieldOfViewX | ( | ) | const |
double getFieldOfViewY | ( | ) | const |
const CameraInteractionOptions & getInteractionOptions | ( | ) | const |
CameraInteractionsFactory::InteractionTypes getInteractionTypeFlags | ( | ) | const |
double getLodDistanceBias | ( | ) | const |
Set a LOD bias in order to modify the distance at which different LOD levels are selected for view for this particular camera. A larger value leads to a longer view distance before a lower resolution LOD is picked.
TransformMatrix getMatrix | ( | ) | const |
This function is thread-safe (which is related to why the matrix is returned by value instead of by reference).
|
overridevirtual |
Reimplemented from SceneItem.
|
overridevirtual |
Reimplemented from SceneItem.
double getNearClippingPlane | ( | ) | const |
Vector3d getOrientation | ( | ) | const |
A camera with no transformation points in the direction of the negative Z axis and has its up vector along the positive Y axis. This is the convention used by OpenGL.
double getOrthoViewVolume | ( | ) | const |
|
protectedvirtual |
viewportWidth | The width of the target viewport |
viewportHeight | The height of the target viewport |
Vector3d getPosition | ( | ) | const |
This is essentially the translation component of the result of multiplying the parent matrix by the local matrix.
|
virtual |
viewportWidth | The width of the target viewport |
viewportHeight | The height of the target viewport |
Camera::ProjectionMode getProjectionMode | ( | ) | const |
Shader * getSymbolShader | ( | ) | const |
const SceneItem * getTrackingTarget | ( | ) | const |
Mesh::TransformByComponents getTransform | ( | ) | const |
This function is thread-safe (which is related to why the result is returned by value instead of by reference).
Vector3d getUpVector | ( | ) | const |
A camera with no transformation points in the direction of the negative Z axis and has its up vector along the positive Y axis. This is the convention used by OpenGL.
bool getUseFieldOfViewX | ( | ) | const |
|
virtual |
void setFarClippingPlane | ( | double | zFar | ) |
zFar | The far clipping plane Z distance. It must always be positive and greater than the near clipping plane. |
The far clipping plane specifies the distance along the camera's line of sight from the camera to the furthest point to be kept visible. Anything further than this from the camera will be clipped and not rendered.
Specifying a far clipping plane that is too close can result in the scene being truncated or clipped away entirely. If set a little too close, it may seem that some parts of the scene are unexplainably missing, since closer objects still appear just fine. In such cases, their camera-facing surfaces may be close enough to be in front of the far clipping plane, but the rear-facing surfaces may be getting clipped without the viewer's knowledge. Objects towards the rear of the scene may be clipped away and thus appear to be missing from the scene.
Conversely, setting the far clipping plane too far away can degrade the calculation of the depth buffer during rendering, resulting in poor image quality where surfaces are close to each other or where they intersect.
The distance between the near and far clipping planes is very important from the point of view of rendering quality. The larger the distance between them, the greater the loss in precision when determining the depth ordering of pixels. A rough guide would be to aim to have the near and far distances no more than a few orders of magnitude apart.
void setFieldOfViewX | ( | double | fov | ) |
fov |
void setFieldOfViewY | ( | double | fov | ) |
fov | The vertical field of view to use for this camera, specified in degrees. It must be between 0 and 180 degrees, althought typical values would be somewhere around 20 degrees. |
Most people know of the field of view through things like a wide-angle lens. It defines how much of a scene should fit within a particular viewing window assumed to be of a particular size. Changing the field of view essentially corresponds to moving that fixed-size viewing window forward or back. Alternatively, if the viewing window is kept in a fixed position, changing the field of view is like changing the size of that window.
Mathematically, the field of view is the angle at the camera between the top and bottom of the viewing window. The larger the angle, the closer the viewer tends to feel to an object. A wide-angle lens would tend to have a large field of view. Note that having an unrealistically large field of view will distort the image.
For more information on the field of view, consult the OpenGL Programming Guide, Chapter 3: Viewing.
void setInteractionOptions | ( | const CameraInteractionOptions & | options | ) |
options | The options to limit camera interactions. |
void setLodDistanceBias | ( | double | bias | ) |
bias | The distance bias to add to the LOD distance computation. |
Set a LOD bias in order to modify the distance at which different LOD levels are selected for view for this particular camera. A larger value leads to a longer view distance before a lower resolution LOD is picked.
void setMatrix | ( | const Mesh::TransformMatrix & | m | ) |
m | The new local transform matrix. Any shear or scale components will be ignored. |
This function is thread-safe.
void setNearClippingPlane | ( | double | zNear | ) |
zNear | The near clipping plane Z distance. It must always be positive and less than the far clipping plane. |
The near clipping plane specifies the distance along the camera's line of sight from the camera to the closest point to be kept visible. Anything closer than this to the camera will be clipped and not rendered.
Specifying a near clipping plane that is too far away can result in the scene being truncated or clipped away entirely. Conversely, setting the near clipping plane too close can degrade the calculation of the depth buffer during rendering, resulting in poor image quality where surfaces are close to each other or where they intersect. See setFarClippingPlane() for more on this.
void setOrthoViewVolume | ( | double | size | ) |
size | The size of the view volume for an orthographic camera. |
void setProjectionMode | ( | ProjectionMode | mode | ) |
mode | The projection mode of the camera; Perspective or Orthographic. |
void setShowSymbol | ( | bool | show | ) |
void setSymbolShader | ( | Shader * | shader | ) |
shader |
void setTrackingTarget | ( | const SceneItem * | target | ) |
target |
void setTransform | ( | const Mesh::TransformByComponents & | t | ) |
t | The new local transform. |
This function is thread-safe.
void setUseFieldOfViewX | ( | bool | b | ) |
b | Whether or not to use the horizontal field of view. |
By default, renderers will only use the vertical field of view to compute the projection matrix. The horizontal field of view is automatically computed using the aspect ratio. There are occasions, however, when we do want to define a horizontal field of view, and instead derive the aspect ratio from that. Note that the aspect ratio of pixels is not the same aspect ratio between the vertical / horizontal field of views.
bool showSymbol | ( | ) | const |
|
overridevirtual |
Reimplemented from SceneItem.
|
overridevirtual |
Implements SceneItem.