![]() |
ImFusion SDK 4.3
|
#include <ImFusion/GL/GlVolumeView.h>
OpenGL view for 3D rendering and correct compositing of direct volume rendering and classic geometry-based GlObjects. More...
OpenGL view for 3D rendering and correct compositing of direct volume rendering and classic geometry-based GlObjects.
GlVolumeView employs a GlVolumeRenderer instance for performing direct volume rendering (DVR) of 3D image data and integrating the regular render scene based on registered GlObjects. Use the Camera class to configure view matrix and projection settings in a comfortable fashion. Furthermore, the renderer offers the following extra functionality:
Classes | |
class | PickingToken |
GlVolumeView uses tokens to handle access to object picking. The token enables picking and keeps it active until the last associated token gets destroyed. More... | |
class | RenderBufferWrapper |
Helper class to allow the injection of custom render buffers surrounding the entire render pipeline. More... | |
Public Types | |
enum | LodMode { LOD_OFF , LOD_ON , LOD_AUTO_VOLUME_SIZE } |
Possible settings for Level of detail (LOD) rendering. More... | |
enum class | SSAOMode { Disabled , GeometryOnly , Full } |
Enumeration of Screen Space Ambient Occlusion (SSAO) working modes. More... | |
![]() | |
enum | Type { SLICE2D = 0 , SLICE3D = 1 , SPACE3D = 2 , OTHER = 3 } |
Type of the view. More... | |
Public Member Functions | |
GlVolumeView (std::unique_ptr< GlVolumeRenderer > volumeRenderer=nullptr) | |
Type | type () const override |
Return the type of this view. | |
bool | render () override |
Render the view and if required the volume rendering. | |
bool | render (const GL::ViewState &state) |
Render the view using the given state, overriding internal camera. | |
void | setCamera (const Camera &camera) |
const Camera & | camera () const |
void | setMatrix (const mat4 &m) override |
Set view matrix from OpenGL camera to world coordinate system. | |
const mat4 & | matrix () const override |
Returns the current view matrix (view coordinates to world coordinates). | |
LodMode | lodMode () const |
Returns the current setting of the Level of Detail rendering. | |
void | setLodMode (LodMode value) |
Sets the current setting of the Level of Detail rendering. | |
void | setDirty () |
Set the dirty flag to issue re-rendering. | |
GlVolumeRenderer * | vr () |
Return volume renderer instance. | |
void | setVr (std::unique_ptr< GlVolumeRenderer > vr) |
Sets the volume renderer instance, vr must not be null. | |
void | setMode (int mode) |
Set the volume rendering mode. | |
int | mode () const |
Return the volume rendering mode. | |
void | setClipOrientation (bool flag) |
Set the orientation of the chosen clip plane. | |
void | setClipPlane (int clipping) |
Set which clip plane shall be used. | |
void | setCustomClipPlane (GlSlice *plane) |
Specify a custom clip plane for the volume rendering. | |
int | clipPlane () const |
Return which is the current clip plane. | |
bool | clipOrientation () const |
Return the clip plane orientation. | |
mat4 | computeDefaultMatrix (std::optional< Geometry::AlignedBox > sceneBounds=std::nullopt) const |
Set the default view matrix for the given scene. | |
void | setDefaultMatrix () |
Set the default view position and orientation. | |
void | setDefaultMatrix (const vec3 ¢er, const vec3 &extent) |
vec3 | sceneCenter () const |
Return center of shown volume if available, or further objects such as meshes otherwise. | |
Geometry::AlignedBox | sceneBounds () const |
Return axis-aligned bounding box of all shown images and annotations. | |
void | setRenderBufferWrapper (RenderBufferWrapper *w) |
Sets a custom render buffer wrapper around the entire render pipeline. | |
RenderBufferWrapper * | renderBufferWrapper () const |
Returns the custom render buffer wrapper if defined. | |
std::optional< vec3 > | firstHitpointLocation (vec2i pixel) const |
Return the world coordinate of the front-most object rendered in the view. | |
std::optional< vec3 > | firstHitpointLocation (vec2i pixel, int filterKernelSize) const |
Return the filtered world coordinate of the front-most object rendered in the view. | |
std::optional< std::pair< vec3, vec3 > > | firstHitpointLocationAndNormal (vec2i pixel, int filterKernelSize) const |
Return the filtered world coordinate of the front-most object rendered in the view and the normal at that location. | |
std::unique_ptr< PickingToken > | createPickingToken () |
Returns a picking token, enabling the picking if necessary. Picking is guaranteed to stay on while at least one of the tokens lives. | |
const GL::ObjectPicking * | objectPicking () const |
Returns access to a pre-existing object picking. Consider using createPickingToken instead, unless you only want to check if picking is active right now. | |
bool | isOrderIndependentTransparencyEnabled () const |
Returns true if order-independent transparency support is enabled. | |
void | setOrderIndependentTransparencyEnabled (bool value) |
Specify whether order-independent transparency support should be enabled. | |
const GL::OrderIndependentTransparency * | orderIndependentTransparency () const override |
Returns the order-independent transparency handling object used by this view if supported and enabled. | |
SSAOMode | ssaoMode () const |
Returns whether and when to apply SSAO post-processing. | |
void | setSsaoMode (SSAOMode value) |
Sets whether and when to apply SSAO post-processing. | |
GlScreenSpaceAmbientOcclusion * | ssao () |
Returns the SSAO instance in case SSAO is enabled. | |
void | applyTransformation (const vec3 &translation, const vec3 &rotation, const vec3 *center=0) |
Applies the given transformation to the view's matrix. | |
bool | usesAutoClipDistance () const |
Returns the flag whether to compute OpenGL near/far clip distance automatically based on scene contents. | |
void | setUseAutoClipDistance (bool value) |
Sets the flag whether to compute OpenGL near/far clip distance automatically based on scene contents. | |
double | nearClipDistance () const |
Return the OpenGL near clip distance. | |
void | setNearClipDistance (double val) |
Set the OpenGL near clip distance, will have no effect if setUseAutoClipDistance() is enabled. | |
double | farClipDistance () const |
Return the OpenGL far clip distance. | |
void | setFarClipDistance (double val) |
Set the OpenGL far clip distance, will have no effect if setUseAutoClipDistance() is enabled. | |
void | setShowWorldCoordinateSystem (bool v) |
Visualizes the world coordinate system. | |
bool | showsWorldCoordinateSystem () const |
void | setApplyClipPlaneToGlObjects (bool v) |
Defines if the clipping plane defined by m_clipping or m_customClipPlane (or the absence of that) should automatically be applied to GL objects rendered in this view as well, e.g. | |
bool | appliesClipPlaneToGlObjects () const |
bool | flipsY () const |
Returns the flag whether to flip the rendered image vertically. | |
void | setFlipY (bool value) |
Sets the flag whether to flip the rendered image vertically. | |
void | renderObjectsOnly () |
Renders only the GlObjects attached to the view. | |
![]() | |
virtual void | resize (int width, int height) |
Set a new viewport size for this view. | |
int | height () const |
Current viewport height of the view. | |
int | width () const |
Current viewport width of the view. | |
void | addObject (GlObject *object) |
Add a reference to a GlObject to be drawn by this view. | |
void | removeObject (GlObject *object) |
Remove a reference to a GlObject drawn by this view. | |
const std::vector< GlObject * > & | objects () const |
Return the set of GlObjects that are drawn by this view. | |
const GL::ViewState & | state () const |
Return the view state that was set during the last render() call. | |
Public Attributes | |
Signal< GlVolumeView * > | matrixChanged |
Additional Inherited Members | |
![]() | |
GL::OrderIndependentTransparency * | sharedOitInstance () const |
Offers support for GlViews sharing GL::OrderIndependentTransparency instances to reduce GPU memory consumption. | |
![]() | |
std::vector< GlObject * > | m_objects |
Other objects to consider during rendering. | |
mat4 | m_matrix = mat4::Identity() |
Matrix converting view coordinates to world coords (inverse of a traditional OpenGL view matrix) | |
GL::ViewState | m_state |
OpenGL state describing viewport, projection and model-view matrix of last render call. | |
int | m_width = 0 |
int | m_height = 0 |
enum LodMode |
|
strong |
Enumeration of Screen Space Ambient Occlusion (SSAO) working modes.
Enumerator | |
---|---|
Disabled | SSAO is disabled. |
GeometryOnly | SSAO is applied after the geometry rendering pass (before DVR pass) |
Full | SSAO to the final scene (after DVR pass) |
|
overridevirtual |
Render the view and if required the volume rendering.
Implements GlView.
|
overridevirtual |
Set view matrix from OpenGL camera to world coordinate system.
Reimplemented from GlView.
|
overridevirtual |
Returns the current view matrix (view coordinates to world coordinates).
Reimplemented from GlView.
void setClipPlane | ( | int | clipping | ) |
Set which clip plane shall be used.
Here, a value of 0-2 means that the corresponding standard MPR slice is used as clip plane, 3 disables the clip plane, and 4 means that a custom clip plane is used if available.
mat4 computeDefaultMatrix | ( | std::optional< Geometry::AlignedBox > | sceneBounds = std::nullopt | ) | const |
Set the default view matrix for the given scene.
If sceneBounds is null it will use sceneBounds().
std::optional< vec3 > firstHitpointLocation | ( | vec2i | pixel | ) | const |
Return the world coordinate of the front-most object rendered in the view.
pixel | Lookup location in the view's pixel space (0, 0)..(width, height). |
std::optional< vec3 > firstHitpointLocation | ( | vec2i | pixel, |
int | filterKernelSize ) const |
Return the filtered world coordinate of the front-most object rendered in the view.
pixel | Lookup location in the view's pixel space (0, 0)..(width, height). |
filterKernelSize | Filter kernel size in terms of number of pixels in each direction. |
std::optional< std::pair< vec3, vec3 > > firstHitpointLocationAndNormal | ( | vec2i | pixel, |
int | filterKernelSize ) const |
Return the filtered world coordinate of the front-most object rendered in the view and the normal at that location.
pixel | Lookup location in the view's pixel space (0, 0)..(width, height). |
filterKernelSize | Filter kernel size in terms of number of pixels in each direction. \ret Location of the intersection and normal to the surface |
|
overridevirtual |
Returns the order-independent transparency handling object used by this view if supported and enabled.
GlObjects can use this instance to support correct blending of their semi-transparent surfaces with the ones from the other GlObjects.
Reimplemented from GlView.
void applyTransformation | ( | const vec3 & | translation, |
const vec3 & | rotation, | ||
const vec3 * | center = 0 ) |
Applies the given transformation to the view's matrix.
First rotation
is performed around center
, then translation
is added. Scene center will be used if center
is zero.
void setShowWorldCoordinateSystem | ( | bool | v | ) |
Visualizes the world coordinate system.
For the case of meshes and point clouds, the lengths of the axes are adjusted according to the data.
void setApplyClipPlaneToGlObjects | ( | bool | v | ) |
Defines if the clipping plane defined by m_clipping or m_customClipPlane (or the absence of that) should automatically be applied to GL objects rendered in this view as well, e.g.
meshes.