1
0

Add lens shift support for the camera and the perspective projection functions

As Blender docs describe it so nicely: Using lens shift is equivalent to rendering an image with a larger FOV and cropping it off-center.
This can be quite useful for architecture renderings, but I guess also has it's use in other situations.
Note: Didn't make the ICameraSceneNode functions pure virtual so users don't have to update their cameras for this
Also some change in serialization - same as in other places by now, do use existing values as defaults values when they are not found instead of resetting them to 0.

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@6565 dfc29bdd-3216-0410-991c-e03cc46cb475
This commit is contained in:
cutealien
2023-10-19 16:04:43 +00:00
parent 567f8688e2
commit d4f6d8c17b
5 changed files with 65 additions and 27 deletions

View File

@@ -120,6 +120,13 @@ namespace scene
/** \return The field of view of the camera in radians. */
virtual f32 getFOV() const =0;
//! Get the horizontal and vertical lens/projection plane shift
/** \return Project plane offset */
virtual core::vector2df getLensShift() const
{
return core::vector2df(0.f, 0.f);
}
//! Sets the value of the near clipping plane. (default: 1.0f)
/** Also changes projection matrix and resets IsOrthogonal flag.
\param zn: New z near value. */
@@ -140,6 +147,16 @@ namespace scene
\param fovy: New field of view in radians. */
virtual void setFOV(f32 fovy) =0;
//! Set the horizontal and vertical lens/projection plane shift
/** Like rendering a larger field of view and then cropping
it off-center. Allows for things like 2-point perspective.
\param shift: Offset by which the projection plane is moved.
If you move by 1 or -1 it will move the center by half a screen.
Positive X go to the left and positive Y go down.
By default it will be 0,0 */
virtual void setLensShift(const core::vector2df& shift)
{}
//! Get the view frustum.
/** \return The current view frustum. */
virtual const SViewFrustum* getViewFrustum() const =0;