# Visualization Library

A lightweight C++ OpenGL middleware for 2D/3D graphics

[Home] [Tutorials] [All Classes] [Grouped Classes]

Public Member Functions | Protected Attributes

# vl::SlicedVolume Class Reference

A ActorEventCallback used to render a volume using viewport aligned slices. More...

`#include <SlicedVolume.hpp>`

Inheritance diagram for vl::SlicedVolume:

List of all members.

## Public Member Functions

virtual const char * | className ()
| Returns the name of the class.
| SlicedVolume ()
| Constructor.
void | onActorRenderStarted (Actor *actor, Real frame_clock, const Camera *cam, Renderable *renderable, const Shader *shader, int pass)
| Event generated just before an Actor is rendered but after the render states are ready and setup.
void | onActorDelete (Actor *)
| Event notifying that an Actor is being deleted.
void | bindActor (Actor *)
| Binds a SlicedVolume to an Actor so that the SlicedVolume can generate the viewport aligned slices' geometry for the Actor as appropriate.
virtual void | updateUniforms (Actor *actor, Real clock, const Camera *camera, Renderable *rend, const Shader *shader)
| Updates the uniforms used by the GLSLProgram to render the volume each time the onActorRenderStarted() method is called.
void | setSliceCount (int count)
| Defines the number of slices used to render the volume: more slices generate a better (and slower) rendering.
int | sliceCount () const
| Returns the number of slices used to render the volume.
Geometry * | geometry ()
| Returns the Geometry associated to a SlicedVolume and its bound Actor.
const Geometry * | geometry () const
| Returns the Geometry associated to a SlicedVolume and its bound Actor.
void | setBox (const AABB &box)
| Defines the dimensions of the box enclosing the volume.
const AABB & | box () const
| The dimensions of the box enclosing the volume.
const fvec3 * | texCoords () const
| Returns the texture coordinates assigned to each of the 8 box corners of the volume.
fvec3 * | texCoords ()
| Returns the texture coordinates assigned to each of the 8 box corners of the volume.
void | generateTextureCoordinates (const ivec3 &size)
| Generates a default set of texture coordinates for the 8 box corners of the volume based on the given texture dimensions.
void | generateTextureCoordinates (const ivec3 &img_size, const ivec3 &min_corner, const ivec3 &max_corner)
| Generates a default set of texture coordinates for the 8 box corners of the volume based on the given texture dimensions.

## Protected Attributes

int | mSliceCount
ref< Geometry > | mGeometry
AABB | mBox
fmat4 | mCache
fvec3 | mTexCoord [8]

## Detailed Description

A ActorEventCallback used to render a volume using viewport aligned slices.

Pictures from: Sliced Volume Rendering with Transfer Functions and Lighting Tutorial tutorial.

Using the SlicedVolume class is very simple, see Sliced Volume Rendering with Transfer Functions and Lighting Tutorial for a complete example.

Basically all SlicedVolume does is to compute the correct texture coordinates and generates on the fly N viewport aligned slices, where N can be specified by the user with setSliceCount(). Such slices then can be rendered using a GLSLProgram specified by the user, thus you can achieve virtually any kind of visual effect with it.

The user can reimplement the updateUniforms() method to update his own uniform variables before the volume is rendered. By default updateUniforms() updates the position of up to 4 lights in object space. Such positions are stored in the `"uniform vec3 light_position[4]"` variable. The updateUniforms() method also fills the `"uniform bool light_enable[4]"` variable with a flag marking if the Nth light is active or not. These light values are computed based on the lights bound to the current Shader. The updateUniforms() method also fills the `"uniform vec3 eye_position"` variable which contains the camera position in object space, useful to compute specular highlights etc.

See also:
  - Sliced Volume Rendering with Transfer Functions and Lighting Tutorial
  - GPU Raycast Volume Rendering with Transfer Functions and Lighting Tutorial
  - RaycastVolume

Definition at line 42 of file SlicedVolume.hpp.

## Constructor & Destructor Documentation

SlicedVolume::SlicedVolume | ( | ) |

Constructor.

Definition at line 79 of file SlicedVolume.cpp.

References mGeometry, mSliceCount, mTexCoord, and VL_DEBUG_SET_OBJECT_NAME.

## Member Function Documentation

virtual const char* vl::SlicedVolume::className | ( | ) | `[inline, virtual]`

Returns the name of the class.

Reimplemented from vl::Object.

Definition at line 45 of file SlicedVolume.hpp.

void SlicedVolume::onActorRenderStarted | ( | Actor * | actor,
|  | Real | frame_clock,
|  | const Camera * | cam,
|  | Renderable * | renderable,
|  | const Shader * | shader,
|  | int | pass
| ) |  | `[virtual]`

Event generated just before an Actor is rendered but after the render states are ready and setup.

Reimplement to react to this event.

Parameters:

  actor | The Actor bound to this rendering callback.
  frame_clock | The current rendering frame time, usually used for animation purposes.
  cam | The camera used for the current rendering.
  renderable | The currently selected Actor LOD.
  shader | The currently active Shader.
  pass | The current Actor[s] rendering pass.

Implements vl::ActorEventCallback.

Definition at line 167 of file SlicedVolume.cpp.

References box(), vl::dot(), vl::ref< T >::get(), vl::Shader::getGLSLProgram(), vl::Matrix4< T_Scalar >::getInverse(), mCache, mGeometry, vl::PT_TRIANGLES, sliceCount(), texCoords(), vl::Actor::transform(), updateUniforms(), vl::Camera::viewMatrix(), VL_CHECK, vl::ITransform::worldMatrix(), and vl::Vector3< T_Scalar >::z().

void vl::SlicedVolume::onActorDelete | ( | Actor * | actor ) | `[inline, virtual]`

Event notifying that an Actor is being deleted.

Implements vl::ActorEventCallback.

Definition at line 52 of file SlicedVolume.hpp.

void SlicedVolume::bindActor | ( | Actor * | actor ) |

Binds a SlicedVolume to an Actor so that the SlicedVolume can generate the viewport aligned slices' geometry for the Actor as appropriate.

Definition at line 161 of file SlicedVolume.cpp.

References vl::Actor::actorEventCallbacks(), vl::ref< T >::get(), mGeometry, vl::Collection< T >::push_back(), and vl::Actor::setLod().

void SlicedVolume::updateUniforms | ( | Actor * | actor,
|  | Real | clock,
|  | const Camera * | camera,
|  | Renderable * | rend,
|  | const Shader * | shader
| ) |  | `[virtual]`

Updates the uniforms used by the GLSLProgram to render the volume each time the onActorRenderStarted() method is called.

Reimplement this method to update the uniform variables of your GLSL program before the volume is rendered.

By default updateUniforms() updates the position of up to 4 lights in object space. Such positions are stored in the `"uniform vec3 light_position[4]"` variable. The updateUniforms() method also fills the `"uniform bool light_enable[4]"` variable with a flag marking if the Nth light is active or not. These light values are computed based on the lights bound to the current Shader. The updateUniforms() method also fills the `"uniform vec3 eye_position"` variable which contains the camera position in object space, useful to compute specular highlights etc.

Definition at line 101 of file SlicedVolume.cpp.

References vl::Light::followedTransform(), vl::Shader::getGLSLProgram(), vl::Matrix4< T_Scalar >::getInverse(), vl::Shader::getLight(), vl::Matrix4< T_Scalar >::getT(), vl::GLSLProgram::getUniformLocation(), vl::Actor::gocUniform(), vl::Camera::inverseViewMatrix(), vl::Light::position(), vl::Uniform::setUniform(), vl::Uniform::setUniform1i(), vl::Actor::transform(), vl::ITransform::worldMatrix(), and vl::Vector4< T_Scalar >::xyz().

Referenced by onActorRenderStarted().

void vl::SlicedVolume::setSliceCount | ( | int | count ) | `[inline]`

Defines the number of slices used to render the volume: more slices generate a better (and slower) rendering.

Definition at line 61 of file SlicedVolume.hpp.

int vl::SlicedVolume::sliceCount | ( | ) | const`[inline]`

Returns the number of slices used to render the volume.

Definition at line 64 of file SlicedVolume.hpp.

Referenced by onActorRenderStarted().

Geometry* vl::SlicedVolume::geometry | ( | ) | `[inline]`

Returns the Geometry associated to a SlicedVolume and its bound Actor.

Definition at line 67 of file SlicedVolume.hpp.

const Geometry* vl::SlicedVolume::geometry | ( | ) | const`[inline]`

Returns the Geometry associated to a SlicedVolume and its bound Actor.

Definition at line 70 of file SlicedVolume.hpp.

void SlicedVolume::setBox | ( | const AABB & | box ) |

Defines the dimensions of the box enclosing the volume.

Definition at line 388 of file SlicedVolume.cpp.

References box(), vl::Matrix4< T_Scalar >::fill(), mBox, mCache, and mGeometry.

const AABB& vl::SlicedVolume::box | ( | ) | const`[inline]`

The dimensions of the box enclosing the volume.

Definition at line 76 of file SlicedVolume.hpp.

Referenced by onActorRenderStarted(), and setBox().

const fvec3* vl::SlicedVolume::texCoords | ( | ) | const`[inline]`

Returns the texture coordinates assigned to each of the 8 box corners of the volume.

Definition at line 79 of file SlicedVolume.hpp.

Referenced by onActorRenderStarted().

fvec3* vl::SlicedVolume::texCoords | ( | ) | `[inline]`

Returns the texture coordinates assigned to each of the 8 box corners of the volume.

Definition at line 82 of file SlicedVolume.hpp.

void SlicedVolume::generateTextureCoordinates | ( | const ivec3 & | size ) |

Generates a default set of texture coordinates for the 8 box corners of the volume based on the given texture dimensions.

Definition at line 334 of file SlicedVolume.cpp.

References vl::Log::error(), mTexCoord, vl::Vector3< T_Scalar >::x(), vl::Vector3< T_Scalar >::y(), and vl::Vector3< T_Scalar >::z().

void SlicedVolume::generateTextureCoordinates | ( | const ivec3 & | img_size,
|  | const ivec3 & | min_corner,
|  | const ivec3 & | max_corner
| ) |  |

Generates a default set of texture coordinates for the 8 box corners of the volume based on the given texture dimensions.

Use this function to visualize a subset of the volume. The subset is defined by `min_corner` and `max_corner`.

Definition at line 361 of file SlicedVolume.cpp.

References vl::Log::error(), mTexCoord, vl::Vector3< T_Scalar >::x(), vl::Vector3< T_Scalar >::y(), and vl::Vector3< T_Scalar >::z().

## Member Data Documentation

int vl::SlicedVolume::mSliceCount`[protected]`

Definition at line 92 of file SlicedVolume.hpp.

Referenced by SlicedVolume().

ref<Geometry> vl::SlicedVolume::mGeometry`[protected]`

Definition at line 93 of file SlicedVolume.hpp.

Referenced by bindActor(), onActorRenderStarted(), setBox(), and SlicedVolume().

AABB vl::SlicedVolume::mBox`[protected]`

Definition at line 94 of file SlicedVolume.hpp.

Referenced by setBox().

fmat4 vl::SlicedVolume::mCache`[protected]`

Definition at line 95 of file SlicedVolume.hpp.

Referenced by onActorRenderStarted(), and setBox().

fvec3 vl::SlicedVolume::mTexCoord[8]`[protected]`

Definition at line 96 of file SlicedVolume.hpp.

Referenced by generateTextureCoordinates(), and SlicedVolume().

The documentation for this class was generated from the following files:

- D:/VL/BuildSystem/VL_DISTRO/Visualization_Library_SDK/src/vlVolume/SlicedVolume.hpp
- D:/VL/BuildSystem/VL_DISTRO/Visualization_Library_SDK/src/vlVolume/SlicedVolume.cpp

Visualization Library v2011.05.1142 Reference Documentation
Copyright 2005-2011 Michele Bosi. All rights reserved.
Updated on Thu May 26 2011 22:51:48.
Permission is granted to use this page to write and publish articles regarding Visualization Library.