Camera
The Camera class is used to create a new camera, set it up (set all the required matrices, field of view, masks and so on) and then pass it to an instance of the Viewport class to render an image from this camera.
An instance of this class is not a node.
Camera Class
Members
Camera ()
Constructor. Creates a new camera with default settings:- Modelview, inverse modelview and offset matrices are 4×4 identity matrices.
- FOV is 60 degrees.
- Distance to the near clipping plane is 0.1 unit.
- Distance to the far clipping plane is 10000 units.
- Up direction vector is (0,0,1).
- Viewport, reflection, source and reverb masks are set to 00000001.
Ptr<Camera> clone ()
Clones the current camera and saves it to the given camera instance.Return value
Copy of the camera.void setPosition (const Math::Vec3 & position)
Sets a new position of the camera and updates the modelview and inverse modelview (its 3rd column) matrices.Arguments
- const Math::Vec3 & position - Camera position in the world space.
Math::Vec3 getPosition ()
Returns the current position of the camera. The position vector is stored in the 3rd column of the inverse modelview matrix.Return value
Camera position in the world space.void setReverbMask (int mask)
Updates a bit mask that determines what reverberation zones can be heard. For sound to reverberate, at least one bit of this mask should match a reverb mask of the sound source and a reverb mask of the reverberation zone. Masks of a sound source and reverberation zone can match the camera's one in several bits, not necessarily one.Arguments
- int mask - Integer, each bit of which is a mask for reverberating sound sources and reverberation zones.
int getReverbMask ()
Returns the current bit mask that determines what reverberation zones can be heard. For sound to reverberate, at least one bit of this mask should match a reverb mask of the sound source and a reverb mask of the reverberation zone. Masks of a sound source and reverberation zone can match with the camera's one in several bits, not necessarily one.Return value
Integer, each bit of which is used to set a mask for reverberating sound sources and reverberation zones.void setSourceMask (int mask)
Updates a bit mask that determines what sound sources can be heard. For a sound source to be heard, its mask should match this one in at least one bit. Plus, the volume of sound channel in which the sound plays (its number also depends on this mask) should not be equal to 0.Arguments
- int mask - Integer, each bit of which specifies a sound channel.
void setProjection (const Math::mat4 & projection)
Updates the current projection matrix.Arguments
- const Math::mat4 & projection - Projection matrix.
Math::mat4 getProjection ()
Returns the current projection matrix with unit (1.0) aspect ratio.Return value
Projection matrix.void setModelview (const Math::Mat4 & modelview)
Updates a modelview and inverse modelaview matrices for the camera.Arguments
- const Math::Mat4 & modelview - New modelview matrix.
Math::Mat4 getModelview ()
Returns the modelview matrix of the camera.Return value
Modelview matrix.Math::Mat4 getIModelview ()
Returns the inverted modelview matrix of the camera.Return value
Inverse modelview matrix.int getSourceMask ()
Returns a bit mask that determines what sound channels can be heard. For a sound source to be heard, its mask should match this one in at least one bit. Plus, the volume of sound channel in which the sound plays (its number also depends on this mask) should not be equal to 0.Return value
Integer, each bit of which specifies a sound channel.void setViewportMask (int mask)
Sets a bit mask for rendering into the viewport. Object surfaces, materials, decals, lights and GUI objects will be rendered into the viewport only if their viewport masks match the camera's one (one matching bit is enough).Arguments
- int mask - Integer, each bit of which is used to set a mask.
int getViewportMask ()
Returns the current bit mask for rendering into the viewport. Object surfaces, materials, decals, lights and GUI objects will be rendered into the viewport only if their viewport mask matches the camera's one (one matching bit is enough).Return value
Integer, each bit of which is used to set a mask.void setReflectionMask (int mask)
Sets a bit mask for rendering reflections into the viewport. Reflections are rendered in the viewport if masks of reflective materials match this one.Arguments
- int mask - Integer, each bit of which is used to set a mask.
int getReflectionMask ()
Returns the current bit mask for rendering reflections into the camera viewport. Reflections are rendered in the camera viewport if masks of reflective materials match this one.Return value
Integer, each bit of which is used to set a mask.void setUp (const Math::vec3 & up)
Sets an up direction of the camera's viewport (i.e. tilt of the camera's viewport).Arguments
- const Math::vec3 & up - New upward direction vector. The vector is normalized to 1.
Math::vec3 getUp ()
Returns the current up direction of the camera's viewport (i.e. tilt of the camera's viewport).Return value
Upward direction vector.void setOffset (const Math::mat4 & offset)
Sets an additional transformation (an offset matrix) for the camera. This transformation is applied after the modelview transformation. The offset matrix does not affect the modelview matrix or the position of the camera. For example, the offset matrix can be used to simulate camera shaking from an explosion.Arguments
- const Math::mat4 & offset - Offset matrix.
Math::mat4 getOffset ()
Returns an additional transformation (an offset matrix) set for the camera. This transformation is applied after modelview transformation. The offset matrix does not affect the modelview matrix or the position of the camera. For example, it can be used to simulate camera shake from an explosion.Return value
Offset matrix.void setFov (float fov)
Sets a vertical field of view of the camera and updates the projection matrix. Horizontal FOV cannot be used since it varies depending on the viewport's aspect ratio.Arguments
- float fov - New vertical field of view in degrees. The provided value will be saturated in the range [0;180].
float getFov ()
Returns the current vertical field of view of the camera. Horizontal FOV cannot be used since it varies depending on the viewport's aspect ratio.Return value
Vertical field of view in degrees.void setZNear (float znear)
Sets a distance to the near clipping plane of the camera's viewing frustum and updates the projection matrix.Arguments
- float znear - New distance in units. If a negative value is provided, 0 will be used instead.
float getZNear ()
Returns the current distance to the near clipping plane of the camera's viewing frustum.Return value
Distance in units.void setZFar (float zfar)
Sets a distance to the far clipping plane of the camera's viewing frustum and updates the projection matrix.Arguments
- float zfar - New distance in units. If a negative value is provided, 0 will be used instead.
float getZFar ()
Returns the current distance to the far clipping plane of the camera's viewing frustum.Return value
Distance in units.void setPostMaterials (const char * materials)
Sets post postprocess materials that are applied after all other postprocess are rendered. They are used after engine.render.setPostMaterials(), if any.Arguments
- const char * materials - Comma-separated names of postprocess materials.
const char * getPostMaterials ()
Returns names of the current post postprocess materials that are applied after all other postprocess are rendered. They are used after engine.render.getPostMaterials(), if any.Return value
Name of the current post postprocess materials.Last update: 03.07.2017
Помогите сделать статью лучше
Была ли эта статья полезной?
(или выберите слово/фразу и нажмите Ctrl+Enter