Visualization Library 2.1.0
A lightweight C++ OpenGL middleware for 2D/3D graphics
|
[Download] [Tutorials] [All Classes] [Grouped Classes] |
A ActorEventCallback used to render a volume using viewport aligned slices. More...
#include <SlicedVolume.hpp>
Public Member Functions | |
SlicedVolume () | |
Constructor. More... | |
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 SlicedVolume to an Actor so that the SlicedVolume can generate the viewport aligned slices' geometry for the Actor as appropriate. 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... | |
void | setSliceCount (int count) |
Defines the number of slices used to render the volume: more slices generate a better (and slower) rendering. More... | |
int | sliceCount () const |
Returns the number of slices used to render the volume. More... | |
Geometry * | geometry () |
Returns the Geometry associated to a SlicedVolume and its bound Actor. More... | |
const Geometry * | geometry () const |
Returns the Geometry associated to a SlicedVolume and its bound Actor. More... | |
void | setBox (const AABB &box) |
Defines the dimensions of the box enclosing the volume. More... | |
const AABB & | box () const |
The dimensions of the box enclosing the volume. More... | |
const fvec3 * | texCoords () const |
Returns the texture coordinates assigned to each of the 8 box corners of the volume. More... | |
fvec3 * | texCoords () |
Returns the texture coordinates assigned to each of the 8 box corners of the volume. More... | |
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. More... | |
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. More... | |
const Actor * | actor () const |
Returns the currently bound actor. More... | |
Actor * | actor () |
Returns the currently bound actor. More... | |
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... | |
Object & | operator= (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... | |
IMutex * | refCountMutex () |
The mutex used to protect the reference counting of an Object across multiple threads. More... | |
const IMutex * | refCountMutex () 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 | |
int | mSliceCount |
ref< Geometry > | mGeometry |
AABB | mBox |
fmat4 | mCache |
fvec3 | mTexCoord [8] |
Actor * | mActor |
Protected Attributes inherited from vl::ActorEventCallback | |
bool | mEnabled |
Protected Attributes inherited from vl::Object | |
std::string | mObjectName |
IMutex * | mRefCountMutex |
int | mReferenceCount |
bool | mAutomaticDelete |
Additional Inherited Members | |
Protected Member Functions inherited from vl::Object | |
virtual | ~Object () |
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.
Definition at line 42 of file SlicedVolume.hpp.
SlicedVolume::SlicedVolume | ( | ) |
Constructor.
Definition at line 79 of file SlicedVolume.cpp.
References mActor, mGeometry, mSliceCount, mTexCoord, and NULL.
|
inline |
Returns the currently bound actor.
Definition at line 94 of file SlicedVolume.hpp.
|
inline |
Returns the currently bound actor.
Definition at line 96 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 168 of file SlicedVolume.cpp.
References vl::Actor::actorEventCallbacks(), mGeometry, and vl::Actor::setLod().
|
inline |
The dimensions of the box enclosing the volume.
Definition at line 78 of file SlicedVolume.hpp.
Referenced by onActorRenderStarted(), and setBox().
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 345 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 372 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().
|
inline |
Returns the Geometry associated to a SlicedVolume and its bound Actor.
Definition at line 69 of file SlicedVolume.hpp.
|
inline |
Returns the Geometry associated to a SlicedVolume and its bound Actor.
Definition at line 72 of file SlicedVolume.hpp.
|
inlinevirtual |
Event notifying that an Actor is being deleted.
Implements vl::ActorEventCallback.
Definition at line 52 of file SlicedVolume.hpp.
References NULL.
|
virtual |
Event generated just before an Actor is rendered but after the render states are ready and setup.
Reimplement to react to this event.
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 174 of file SlicedVolume.cpp.
References box(), vl::ArrayAbstract::bufferObject(), vl::Buffer::bytesUsed(), vl::dot(), vl::ref< T >::get(), vl::Shader::getGLSLProgram(), vl::Matrix4< T_Scalar >::getInverse(), vl::Viewport::height(), vl::max(), mCache, mGeometry, vl::PT_TRIANGLES, vl::ArrayAbstract::ptr(), vl::Array< T_VectorType, T_Scalar, T_GL_Size, T_GL_Type >::resize(), sliceCount(), texCoords(), vl::Actor::transform(), updateUniforms(), vl::Camera::viewMatrix(), vl::Camera::viewport(), VL_CHECK, vl::Viewport::width(), vl::Transform::worldMatrix(), and vl::Vector3< T_Scalar >::z().
void SlicedVolume::setBox | ( | const AABB & | box | ) |
Defines the dimensions of the box enclosing the volume.
Definition at line 399 of file SlicedVolume.cpp.
References box(), vl::Matrix4< T_Scalar >::fill(), mBox, mCache, and mGeometry.
|
inline |
Defines the number of slices used to render the volume: more slices generate a better (and slower) rendering.
Default is 0. If equal to 0 the number of slices is computed automatically as max(viewport.width, viewport.height).
Definition at line 62 of file SlicedVolume.hpp.
|
inline |
Returns the number of slices used to render the volume.
If equal to 0 the number of slices is computed automatically as max(viewport.width, viewport.height).
Definition at line 66 of file SlicedVolume.hpp.
Referenced by onActorRenderStarted().
|
inline |
Returns the texture coordinates assigned to each of the 8 box corners of the volume.
Definition at line 81 of file SlicedVolume.hpp.
Referenced by onActorRenderStarted().
|
inline |
Returns the texture coordinates assigned to each of the 8 box corners of the volume.
Definition at line 84 of file SlicedVolume.hpp.
|
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 103 of file SlicedVolume.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::Actor::gocUniform(), vl::Camera::modelingMatrix(), NULL, vl::Light::position(), vl::Uniform::setUniform(), vl::Uniform::setUniform1i(), vl::Actor::transform(), vl::Transform::worldMatrix(), and vl::Vector4< T_Scalar >::xyz().
Referenced by onActorRenderStarted().
|
protected |
Definition at line 105 of file SlicedVolume.hpp.
Referenced by SlicedVolume().
|
protected |
Definition at line 101 of file SlicedVolume.hpp.
Referenced by setBox().
|
protected |
Definition at line 102 of file SlicedVolume.hpp.
Referenced by onActorRenderStarted(), and setBox().
Definition at line 100 of file SlicedVolume.hpp.
Referenced by bindActor(), onActorRenderStarted(), setBox(), and SlicedVolume().
|
protected |
Definition at line 99 of file SlicedVolume.hpp.
Referenced by SlicedVolume().
|
protected |
Definition at line 103 of file SlicedVolume.hpp.
Referenced by generateTextureCoordinates(), and SlicedVolume().
Visualization Library 2.1.0 Reference Documentation
Updated on Wed Mar 10 2021 16:02:54.
© Copyright Michele Bosi. All rights reserved.