![]() |
ImFusion SDK 4.3
|
#include <ImFusion/Core/GL/ViewState.h>
Encapsulates the OpenGL view state defined by the viewport, a projection matrix and a model-view matrix. More...
Encapsulates the OpenGL view state defined by the viewport, a projection matrix and a model-view matrix.
Instances of this class are passed around to provide model-view-projection configuration to consumers such as GL::FixedFunctionPipeline or the GlView framework. Furthermore, it provides a couple of helper functions to convert points/locations between world coordinates and viewport coordinates.
Classes | |
struct | PixelIncrementWorld |
Helper struct to store the result of unprojectPixelIncrementOrtho() and unprojectPixelIncrementPerspective(). More... | |
Public Member Functions | |
ViewState (const Viewport &viewport, const mat4 &projectionMatrix=mat4::Identity(), const mat4 &modelViewMatrix=mat4::Identity()) | |
ViewState (const mat4 &projectionMatrix, const mat4 &modelViewMatrix=mat4::Identity()) | |
Properties | |
const Viewport & | viewport () const |
Returns the viewport. | |
Viewport & | viewport () |
Returns the viewport. | |
void | setViewport (const Viewport &value) |
Sets the viewport. | |
const mat4 & | projectionMatrix () const |
Returns the projection matrix. | |
void | setProjectionMatrix (const mat4 &value) |
Sets the projection matrix. | |
const mat4 & | modelViewMatrix () const |
Returns the model-view matrix. | |
void | setModelViewMatrix (const mat4 &value) |
Sets the model-view matrix. | |
const mat4 & | modelViewProjectionMatrix () const |
Returns the full model-view-projection matrix. | |
const mat4 & | modelViewProjectionMatrixInverse () const |
Returns the inverse of the full model-view-projection matrix. | |
Convert between world space and viewport space | |
vec3 | project (const vec3 &worldCoord, bool *outOnCameraPlane=nullptr) const |
Project the given point from world space to viewport space. | |
vec3 | unproject (const vec3 &viewportCoord) const |
Unprojects the given point from viewport space to world space. | |
PixelIncrementWorld | unprojectPixelIncrement (const vec3 &worldCoord) const |
Unprojects a single 2D pixel increment into 3D space. | |
PixelIncrementWorld | unprojectPixelIncrementOrtho () const |
Unprojects a single 2D pixel increment into 3D space assuming an orthographic projection. | |
PixelIncrementWorld | unprojectPixelIncrementPerspective (const vec3 &worldCoord) const |
Unprojects a single 2D pixel increment into 3D space relative to the given world coordinate assuming a perspective projection. | |
vec3 | xDir () const |
Return 3D space unit vector pointing in the direction of viewport x-axis. | |
vec3 | yDir () const |
Return 3D space unit vector pointing in the direction of viewport y-axis. | |
vec3 | zDir () const |
Return 3D space unit vector pointing in the direction of viewport z-axis. | |
Legacy methods | |
void | setLegacyGlMatrixStack () const |
Sets the legacy GL_PROJECTION and GL_MODELVIEW matrices to the matrices stored in this instance. | |
vec3 project | ( | const vec3 & | worldCoord, |
bool * | outOnCameraPlane = nullptr ) const |
Project the given point from world space to viewport space.
(modelViewProjectionMatrix() * worldCoord.homogeneous())[3] != 0.0
If worldCorld lies on the camera plane, then *outOnCameraPlane is set to true, else it is set to false. PixelIncrementWorld unprojectPixelIncrement | ( | const vec3 & | worldCoord | ) | const |
Unprojects a single 2D pixel increment into 3D space.
This function will choose between unprojectPixelIncrementOrtho() and unprojectPixelIncrementPerspective() based on the underlying projection matrix.
void setLegacyGlMatrixStack | ( | ) | const |
Sets the legacy GL_PROJECTION and GL_MODELVIEW matrices to the matrices stored in this instance.