Visualization Library 2.1.0

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

VL     Star     Watch     Fork     Issue

[Download] [Tutorials] [All Classes] [Grouped Classes]
Public Member Functions | Protected Attributes | List of all members
vl::RaycastVolume Class Reference

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

#include <RaycastVolume.hpp>

+ Inheritance diagram for vl::RaycastVolume:

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. More...
 
void onActorDelete (Actor *)
 Event notifying that an Actor is being deleted. More...
 
void bindActor (Actor *)
 Binds a RaycastVolume to an Actor. More...
 
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. More...
 
Geometrygeometry ()
 Returns the Geometry associated to a RaycastVolume and its bound Actor. More...
 
const Geometrygeometry () const
 Returns the Geometry associated to a RaycastVolume and its bound Actor. More...
 
void setBox (const AABB &box)
 Defines the dimensions of the box in model coordinates enclosing the volume and generates the actual geometry of the box to be rendered. More...
 
const AABBbox () const
 The dimensions of the box enclosing the volume. More...
 
const fvec3vertCoords () const
 Returns the coordinates assigned to each of the 8 box corners of the volume. More...
 
fvec3vertCoords ()
 Returns the coordinates assigned to each of the 8 box corners of the volume. More...
 
const fvec3texCoords () const
 Returns the texture coordinates assigned to each of the 8 box corners of the volume. More...
 
fvec3texCoords ()
 Returns the texture coordinates assigned to each of the 8 box corners of the volume. More...
 
void generateTextureCoordinates (const ivec3 &img_size)
 Generates a default set of texture coordinates for the 8 box corners of the volume based on the given texture dimensions. More...
 
const std::vector< ref< Light > > & lights () const
 
std::vector< ref< Light > > & lights ()
 
- Public Member Functions inherited from vl::ActorEventCallback
 ActorEventCallback ()
 
void setEnabled (bool enabled)
 
bool isEnabled () const
 
- Public Member Functions inherited from vl::Object
 Object ()
 Constructor. More...
 
 Object (const Object &other)
 Copy constructor: copies the name, ref count mutex and user data. More...
 
Objectoperator= (const Object &other)
 Copy operator: copies the object's name, ref count mutex and user data. More...
 
const std::string & objectName () const
 The name of the object, by default set to the object's class name. More...
 
void setObjectName (const char *name)
 The name of the object, by default set to the object's class name in debug builds. More...
 
void setObjectName (const std::string &name)
 The name of the object, by default set to the object's class name in debug builds. More...
 
void setRefCountMutex (IMutex *mutex)
 The mutex used to protect the reference counting of an Object across multiple threads. More...
 
IMutexrefCountMutex ()
 The mutex used to protect the reference counting of an Object across multiple threads. More...
 
const IMutexrefCountMutex () const
 The mutex used to protect the reference counting of an Object across multiple threads. More...
 
int referenceCount () const
 Returns the number of references of an object. More...
 
void incReference () const
 Increments the reference count of an object. More...
 
void decReference ()
 Decrements the reference count of an object and deletes it if both automaticDelete() is true the count reaches 0. More...
 
void setAutomaticDelete (bool autodel_on)
 If set to true the Object is deleted when its reference count reaches 0. More...
 
bool automaticDelete () const
 If set to true the Object is deleted when its reference count reaches 0. More...
 
template<class T >
T * as ()
 Casts an Object to the specified class. More...
 
template<class T >
const T * as () const
 Casts an Object to the specified class. More...
 

Protected Attributes

ref< GeometrymGeometry
 
AABB mBox
 
ref< ArrayFloat3mTexCoord
 
ref< ArrayFloat3mVertCoord
 
std::vector< ref< Light > > mLights
 
- Protected Attributes inherited from vl::ActorEventCallback
bool mEnabled
 
- Protected Attributes inherited from vl::Object
std::string mObjectName
 
IMutexmRefCountMutex
 
int mReferenceCount
 
bool mAutomaticDelete
 

Additional Inherited Members

- Protected Member Functions inherited from vl::Object
virtual ~Object ()
 

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

Definition at line 41 of file RaycastVolume.hpp.

Constructor & Destructor Documentation

◆ RaycastVolume()

RaycastVolume::RaycastVolume ( )

Member Function Documentation

◆ bindActor()

void RaycastVolume::bindActor ( Actor actor)

Binds a RaycastVolume to an Actor.

Definition at line 196 of file RaycastVolume.cpp.

References vl::Actor::actorEventCallbacks(), mGeometry, and vl::Actor::setLod().

◆ box()

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().

◆ generateTextureCoordinates()

void RaycastVolume::generateTextureCoordinates ( const ivec3 img_size)

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

Parameters
img_sizeSize in texels of the volume texture.

Definition at line 215 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().

◆ geometry() [1/2]

Geometry* vl::RaycastVolume::geometry ( )
inline

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

Definition at line 59 of file RaycastVolume.hpp.

◆ geometry() [2/2]

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.

◆ lights() [1/2]

const std::vector< ref<Light> >& vl::RaycastVolume::lights ( ) const
inline

Definition at line 86 of file RaycastVolume.hpp.

◆ lights() [2/2]

std::vector< ref<Light> >& vl::RaycastVolume::lights ( )
inline

Definition at line 87 of file RaycastVolume.hpp.

◆ onActorDelete()

void vl::RaycastVolume::onActorDelete ( Actor actor)
inlinevirtual

Event notifying that an Actor is being deleted.

Implements vl::ActorEventCallback.

Definition at line 50 of file RaycastVolume.hpp.

◆ onActorRenderStarted()

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
actorThe Actor bound to this rendering callback.
frame_clockThe current rendering frame time, usually used for animation purposes.
camThe camera used for the current rendering.
renderableThe currently selected Actor LOD.
shaderThe currently active Shader.
passThe current Actor[s] rendering pass.

Implements vl::ActorEventCallback.

Definition at line 203 of file RaycastVolume.cpp.

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

◆ setBox()

void RaycastVolume::setBox ( const AABB box)

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

Definition at line 242 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().

◆ texCoords() [1/2]

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.

◆ texCoords() [2/2]

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.

◆ updateUniforms()

void RaycastVolume::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. These light values are computed based on the lights stored in RaycastVolume::lights().
  • 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 109 of file RaycastVolume.cpp.

References vl::Light::ambient(), vl::Light::boundTransform(), vl::Texture::depth(), vl::Light::diffuse(), vl::Shader::getGLSLProgram(), vl::Matrix4< T_Scalar >::getInverse(), vl::Matrix4< T_Scalar >::getT(), vl::Shader::getTextureImageUnit(), vl::GLSLProgram::getUniformLocation(), vl::Matrix4< T_Scalar >::getZ(), vl::Actor::gocUniform(), vl::Texture::height(), mLights, vl::Camera::modelingMatrix(), vl::Light::position(), vl::String::printf(), vl::Uniform::setUniform(), vl::Uniform::setUniformI(), vl::Light::specular(), vl::TextureImageUnit::texture(), vl::Actor::transform(), VL_CHECK, vl::Texture::width(), and vl::Transform::worldMatrix().

Referenced by onActorRenderStarted().

◆ vertCoords() [1/2]

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.

◆ vertCoords() [2/2]

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.

Member Data Documentation

◆ mBox

AABB vl::RaycastVolume::mBox
protected

Definition at line 91 of file RaycastVolume.hpp.

Referenced by setBox().

◆ mGeometry

ref<Geometry> vl::RaycastVolume::mGeometry
protected

Definition at line 90 of file RaycastVolume.hpp.

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

◆ mLights

std::vector< ref<Light> > vl::RaycastVolume::mLights
protected

Definition at line 94 of file RaycastVolume.hpp.

Referenced by updateUniforms().

◆ mTexCoord

ref<ArrayFloat3> vl::RaycastVolume::mTexCoord
protected

Definition at line 92 of file RaycastVolume.hpp.

Referenced by generateTextureCoordinates(), and RaycastVolume().

◆ mVertCoord

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: