# Visualization Library

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

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

Public Member Functions | Protected Attributes

# vl::RaycastVolume Class Reference

A ActorEventCallback used to render a volume using GPU raycasting. More...

`#include <RaycastVolume.hpp>`

Inheritance diagram for vl::RaycastVolume:

List of all members.

## Public Member Functions

| RaycastVolume ()
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 RaycastVolume to an Actor.
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.
Geometry * | geometry ()
| Returns the Geometry associated to a RaycastVolume and its bound Actor.
const Geometry * | geometry () const
| Returns the Geometry associated to a RaycastVolume and its bound Actor.
void | setBox (const AABB &box)
| Defines the dimensions of the box enclosing the volume and generates the actual geometry of the box to be rendered.
const AABB & | box () const
| The dimensions of the box enclosing the volume.
const fvec3 * | vertCoords () const
| Returns the coordinates assigned to each of the 8 box corners of the volume.
fvec3 * | vertCoords ()
| Returns the coordinates assigned to each of the 8 box corners of 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

ref< Geometry > | mGeometry
AABB | mBox
ref< ArrayFloat3 > | mTexCoord
ref< ArrayFloat3 > | mVertCoord

## Detailed Description

A ActorEventCallback used to render a volume using GPU raycasting.

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

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

Definition at line 41 of file RaycastVolume.hpp.

## Constructor & Destructor Documentation

RaycastVolume::RaycastVolume | ( | ) |

Definition at line 65 of file RaycastVolume.cpp.

References vl::ref< T >::get(), mGeometry, mTexCoord, mVertCoord, vl::PT_QUADS, setBox(), and VL_DEBUG_SET_OBJECT_NAME.

## Member Function Documentation

void RaycastVolume::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 188 of file RaycastVolume.cpp.

References vl::Shader::getGLSLProgram(), and updateUniforms().

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

Event notifying that an Actor is being deleted.

Implements vl::ActorEventCallback.

Definition at line 50 of file RaycastVolume.hpp.

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

Binds a RaycastVolume to an Actor.

Definition at line 181 of file RaycastVolume.cpp.

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

void RaycastVolume::updateUniforms | ( | vl::Actor * | actor,
|  | vl::real | clock,
|  | const Camera * | camera,
|  | vl::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 `"uniform vec3 eye_position"` variable contains the camera position in object space, useful to compute specular highlights, raycast direction etc.
- The `"uniform vec3 eye_look"` variable contains the camera look vector in object space.

Definition at line 111 of file RaycastVolume.cpp.

References vl::Light::boundTransform(), vl::Shader::getGLSLProgram(), vl::Matrix4< T_Scalar >::getInverse(), vl::Shader::getLight(), vl::Matrix4< T_Scalar >::getT(), vl::GLSLProgram::getUniformLocation(), vl::Matrix4< T_Scalar >::getZ(), vl::Actor::gocUniform(), vl::Camera::modelingMatrix(), NULL, vl::Light::position(), vl::Uniform::setUniform(), vl::Uniform::setUniform1i(), vl::Actor::transform(), VL_CHECK, vl::Transform::worldMatrix(), and vl::Vector4< T_Scalar >::xyz().

Referenced by onActorRenderStarted().

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

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

Definition at line 59 of file RaycastVolume.hpp.

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

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

Definition at line 62 of file RaycastVolume.hpp.

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

Defines the dimensions of the box enclosing the volume and generates the actual geometry of the box to be rendered.

Definition at line 253 of file RaycastVolume.cpp.

References box(), vl::AABB::maxCorner(), mBox, mGeometry, vl::AABB::minCorner(), mVertCoord, vl::Vector3< T_Scalar >::x(), vl::Vector3< T_Scalar >::y(), and vl::Vector3< T_Scalar >::z().

Referenced by RaycastVolume().

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

The dimensions of the box enclosing the volume.

Definition at line 68 of file RaycastVolume.hpp.

Referenced by setBox().

const fvec3* vl::RaycastVolume::vertCoords | ( | ) | const`[inline]`

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

Definition at line 71 of file RaycastVolume.hpp.

fvec3* vl::RaycastVolume::vertCoords | ( | ) | `[inline]`

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

Definition at line 74 of file RaycastVolume.hpp.

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

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

Definition at line 77 of file RaycastVolume.hpp.

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

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

Definition at line 80 of file RaycastVolume.hpp.

void RaycastVolume::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 199 of file RaycastVolume.cpp.

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

void RaycastVolume::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 226 of file RaycastVolume.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

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

Definition at line 90 of file RaycastVolume.hpp.

Referenced by bindActor(), RaycastVolume(), and setBox().

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

Definition at line 91 of file RaycastVolume.hpp.

Referenced by setBox().

ref<ArrayFloat3> vl::RaycastVolume::mTexCoord`[protected]`

Definition at line 92 of file RaycastVolume.hpp.

Referenced by generateTextureCoordinates(), and RaycastVolume().

ref<ArrayFloat3> vl::RaycastVolume::mVertCoord`[protected]`

Definition at line 93 of file RaycastVolume.hpp.

Referenced by RaycastVolume(), and setBox().

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

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

Visualization Library v2011.09.1162 Reference Documentation
Copyright 2005-2011 Michele Bosi. All rights reserved.
Updated on Thu Jan 26 2012 00:44:59.
Permission is granted to use this page to write and publish articles regarding Visualization Library.