Visualization LibraryA lightweight C++ OpenGL middleware for 2D/3D graphics |
[Home] [Tutorials] [All Classes] [Grouped Classes] |
#include <SlicedVolume.hpp>

Public Member Functions | |
| SlicedVolume () | |
| Constructor. | |
| void | update (int, vl::Camera *camera, vl::Real) |
| Virtual function used to update or animate an Actor during the rendering. | |
| virtual void | updateUniforms (vl::Camera *camera) |
| Updates the uniforms used by the vl::GLSLProgram to render the volume each time the update() function is called. | |
| void | setSliceCount (int count) |
| Defines the number of slices used to render the volume: more slices generate a better rendering. | |
| int | sliceCount () const |
| Returns the number of slices used to render the volume. | |
| vl::Geometry * | geometry () |
| Returns the vl::Geometry associated to a SlicedVolume actor. | |
| const vl::Geometry * | geometry () const |
| Returns the vl::Geometry associated to a SlicedVolume actor. | |
| vl::Effect * | effect () |
| Returns the vl::Effect associated to a SlicedVolume actor. | |
| const vl::Effect * | effect () const |
| Returns the vl::Effect associated to a SlicedVolume actor. | |
| void | setBox (const vl::AABB &box) |
| Defines the dimensions of the box enclosing the volume. | |
| const vl::AABB & | box () const |
| Defines the dimensions of the box enclosing the volume. | |
| const vl::fvec3 * | texCoords () const |
| Returns the texture coordinates assigned to each of the 8 box corners. | |
| vl::fvec3 * | texCoords () |
| Returns the texture coordinates assigned to each of the 8 box corners. | |
| void | generateTextureCoordinates (const vl::ivec3 &size) |
| Generates a default set of texture coordinates based on the give texture dimensions. | |
| void | generateTextureCoordinates (int width, int height, int depth) |
| Generates a default set of texture coordinates based on the give texture dimensions. | |
| void | setVolumeImage (vl::Image *volume) |
| Defines the image containing the volume to be rendered. | |
| const vl::Image * | transferFunction () const |
| Returns the 1D image used as transfer function for the volume rendering. | |
| vl::Image * | transferFunction () |
| Returns the 1D image used as transfer function for the volume rendering. | |
| void | setTransferFunction (vl::Image *tfunc) |
| Sets the 1D image used as transfer function for the volume rendering. Pass NULL to remove the transfer function. | |
| const vl::Light * | light () const |
| Returns the light used to illuminate the volume. | |
| vl::Light * | light () |
| Returns the light used to illuminate the volume. | |
| void | setLight (vl::Light *light) |
| Defines the light used to illuminate the volume. | |
| const vl::GLSLProgram * | glslProgram () const |
| Returns the GLSL program used for IF_LUMINANCE volume images. | |
| vl::GLSLProgram * | glslProgram () |
| Returns the GLSL program used for IF_LUMINANCE volume images. | |
Static Public Member Functions | |
| static vl::ref< vl::Image > | genRGBAVolume (vl::Image *data, vl::Image *trfunc, const vl::fvec3 &light_dir, bool alpha_from_data=true) |
| Generates an RGBA image that can be passed to setVolumeImage() based on the given data source and transfer function. | |
| static vl::ref< vl::Image > | genRGBAVolume (vl::Image *data, vl::Image *trfunc, bool alpha_from_data=true) |
| Generates an RGBA image that can be passed to setVolumeImage() based on the given data source and transfer function. | |
Protected Attributes | |
| int | mSliceCount |
| vl::ref< vl::Geometry > | mGeometry |
| vl::ref< vl::Effect > | mEffect |
| vl::AABB | mBox |
| vl::fmat4 | mCache |
| vl::fvec3 | mTexCoord [8] |
| vl::ref< vl::Image > | mTransferFunction |
| vl::ref< vl::Light > | mLight |
| vl::ref< vl::GLSLProgram > | mGLSLProgram |
Pictures from the Volume Rendering tutorial.
|
|
|
|
|
|
|
|
By default the constructor installs the following shaders /glsl/volume_luminance_light.fs and /glsl/volume_luminance_light.vs and sets the val_threshold uniform variable to 0.5f.
You can change the GLSLProgram settings in the following way:
glslProgram()->detachAllShaders(); glslProgram()->attachShader( new vl::GLSLFragmentShader("/mypath/my_fragment_shader.fs") ); glslProgram()->attachShader( new vl::GLSLVertexShader("/mypath/my_vertex_shader.fs") ); glslProgram()->gocUniform("my_uniform")->setUniform(value);
You can also reimplement the updateUniforms() method to update your own uniform variables before every rendering frame.
vl::ref<vlVolume::SlicedVolume> volume = new SlicedVolume; // loads an IF_RGBA volume (no transfer function is needed in this case) vl::ref<vl::Image> rgba_img = vl::loadImage("myvolume.dat"); // installs the IF_RGBA volume volume->setVolumeImage(rgba_img.get()); // disable GLSL shader volume->setTransferFunction(NULL);
vl::ref<vlVolume::SlicedVolume> volume = new SlicedVolume; // loads an IF_LUMINANCE volume vl::ref<vl::Image> img = vl::loadImage("myvolume.dat"); // generates a transfer function vl::ref<vl::Image> trfunc = vl::Image::makeColorSpectrum(128, vlut::black, vlut::blue, vlut::green, vlut::yellow, vlut::red); // computes an IF_RGBA volume using the transfer function and with lighting vl::ref<vl::Image> rgba_img = vlVolume::SlicedVolume::genRGBAVolume(img.get(), trfunc.get(), vl::fvec3(1.0f,1.0f,0.0f)); // installs the IF_RGBA volume volume->setVolumeImage(rgba_img.get()); // disable GLSL shader volume->setTransferFunction(NULL);
vl::ref<vlVolume::SlicedVolume> volume = new SlicedVolume; // generates and install a transfer function to be used with an IF_LUMINANCE volume. vl::ref<vl::Image> trfunc = vl::Image::makeColorSpectrum(128, vlut::black, vlut::blue, vlut::green, vlut::yellow, vlut::red); // setTransferFunction() also enables the GLSL shader volume->setTransferFunction(trfunc.get()); // loads and install an IF_LUMINANCE volume. vl::ref<vl::Image> img = vl::loadImage("myvolume.dat"); volume->setVolumeImage(img.get());
| SlicedVolume::SlicedVolume | ( | ) |
Constructor.
| void vlVolume::SlicedVolume::update | ( | int | , | |
| vl::Camera * | , | |||
| vl::Real | ||||
| ) | [virtual] |
Virtual function used to update or animate an Actor during the rendering.
| lod | the LOD (level of detail) currently selected for the rendering. | |
| camera | the camera used for the current rendering. | |
| cur_t | the current animation time. |
Reimplemented from vl::Actor.
| void SlicedVolume::updateUniforms | ( | vl::Camera * | camera | ) | [virtual] |
Updates the uniforms used by the vl::GLSLProgram to render the volume each time the update() function is called.
You can reimplement this function in order to setup your own uniform variable for your GLSLProgram.
The default implementation of this function updates the following two uniforms:
light_position Light position in object space, used to compute Blinn-Phong lighting in /glsl/volume_luminance_light.fseye_position Camera position in object space, used to compute Blinn-Phong lighting in /glsl/volume_luminance_light.fs | void vlVolume::SlicedVolume::setSliceCount | ( | int | count | ) | [inline] |
Defines the number of slices used to render the volume: more slices generate a better rendering.
| int vlVolume::SlicedVolume::sliceCount | ( | ) | const [inline] |
Returns the number of slices used to render the volume.
| vl::Geometry* vlVolume::SlicedVolume::geometry | ( | ) | [inline] |
Returns the vl::Geometry associated to a SlicedVolume actor.
| const vl::Geometry* vlVolume::SlicedVolume::geometry | ( | ) | const [inline] |
Returns the vl::Geometry associated to a SlicedVolume actor.
| vl::Effect* vlVolume::SlicedVolume::effect | ( | ) | [inline] |
| const vl::Effect* vlVolume::SlicedVolume::effect | ( | ) | const [inline] |
| void SlicedVolume::setBox | ( | const vl::AABB & | box | ) |
Defines the dimensions of the box enclosing the volume.
| const vl::AABB& vlVolume::SlicedVolume::box | ( | ) | const [inline] |
Defines the dimensions of the box enclosing the volume.
| const vl::fvec3* vlVolume::SlicedVolume::texCoords | ( | ) | const [inline] |
Returns the texture coordinates assigned to each of the 8 box corners.
| vl::fvec3* vlVolume::SlicedVolume::texCoords | ( | ) | [inline] |
Returns the texture coordinates assigned to each of the 8 box corners.
| void SlicedVolume::generateTextureCoordinates | ( | const vl::ivec3 & | size | ) |
Generates a default set of texture coordinates based on the give texture dimensions.
The texture coordinate generated by this function should be used with TexParameter wrap mode vl::TPW_REPEAT, ie:.
vl::ref<vl::Texture> texture = new vl::Texture; texture->getTexParameter()->setWrapS(vl::TPW_REPEAT); texture->getTexParameter()->setWrapT(vl::TPW_REPEAT); texture->getTexParameter()->setWrapR(vl::TPW_REPEAT);
| void vlVolume::SlicedVolume::generateTextureCoordinates | ( | int | width, | |
| int | height, | |||
| int | depth | |||
| ) | [inline] |
Generates a default set of texture coordinates based on the give texture dimensions.
| void SlicedVolume::setVolumeImage | ( | vl::Image * | volume | ) |
Defines the image containing the volume to be rendered.
This function also generates a 3D texture based on the given image and generates an appropriate set of texture coordinates.
| const vl::Image* vlVolume::SlicedVolume::transferFunction | ( | ) | const [inline] |
Returns the 1D image used as transfer function for the volume rendering.
| vl::Image* vlVolume::SlicedVolume::transferFunction | ( | ) | [inline] |
Returns the 1D image used as transfer function for the volume rendering.
| void SlicedVolume::setTransferFunction | ( | vl::Image * | tfunc | ) |
Sets the 1D image used as transfer function for the volume rendering. Pass NULL to remove the transfer function.
Selecting a transfer function != NULL automatically enables the GLSL shader returned by glslProgram().
Call setTransferFunction(NULL) to disable the GLSL program. Based on the img format an appropriate rendering method is selected:
tfunc is NULL then it is assumed that the image set by setVolumeImage() contains already the appropriate colors and alpha values as a result of a transfer function and/or lighting computations (see genRGBAVolume()). This is the preferred method for legacy hardware as it does not require GLSL support but can require 4 times more memory and cannot perform realtime-animated lighting.tfunc is non-NULL then the image set by setVolumeImage() should have IF_LUMINANCE format() and contains the raw volume data. A GLSL program is used in order to execute the transfer function and the lighting computations. In this case the tranfer function tfunc is used. This method requires GLSL support, needs less memory and can perform realtime-animated Blinn-Phong lighting. | const vl::Light* vlVolume::SlicedVolume::light | ( | ) | const [inline] |
Returns the light used to illuminate the volume.
| vl::Light* vlVolume::SlicedVolume::light | ( | ) | [inline] |
Returns the light used to illuminate the volume.
| void vlVolume::SlicedVolume::setLight | ( | vl::Light * | light | ) | [inline] |
Defines the light used to illuminate the volume.
| const vl::GLSLProgram* vlVolume::SlicedVolume::glslProgram | ( | ) | const [inline] |
Returns the GLSL program used for IF_LUMINANCE volume images.
| vl::GLSLProgram* vlVolume::SlicedVolume::glslProgram | ( | ) | [inline] |
Returns the GLSL program used for IF_LUMINANCE volume images.
| ref< Image > SlicedVolume::genRGBAVolume | ( | vl::Image * | data, | |
| vl::Image * | trfunc, | |||
| const vl::fvec3 & | light_dir, | |||
| bool | alpha_from_data = true | |||
| ) | [static] |
Generates an RGBA image that can be passed to setVolumeImage() based on the given data source and transfer function.
| data | The vl::Image used as the volume data source. It must have format() equal to IF_LUMINANCE and type() equal to IT_UNSIGNED_BYTE, IT_UNSIGNED_SHORT or IT_UNSIGNED_FLOAT. | |
| trfunc | An 1D vl::Image used as transfer function that is used to assign to each value in data an RGBA quadruplets in the new image. The vl::Image pointed by trfunc must mast have type() IT_UNSIGNED_BYTE and format() IF_RGBA. | |
| light_dir | The direction of the light in object space. | |
| alpha_from_data | If set to true the alpha channel of the generated image will be taken from data otherwise from the transfer function. |
| ref< Image > SlicedVolume::genRGBAVolume | ( | vl::Image * | data, | |
| vl::Image * | trfunc, | |||
| bool | alpha_from_data = true | |||
| ) | [static] |
Generates an RGBA image that can be passed to setVolumeImage() based on the given data source and transfer function.
| data | The vl::Image used as the volume data source. It must have format() equal to IF_LUMINANCE and type() equal to IT_UNSIGNED_BYTE, IT_UNSIGNED_SHORT or IT_UNSIGNED_FLOAT. | |
| trfunc | An 1D vl::Image used as transfer function that is used to assign to each value in data an RGBA quadruplets in the new image. The vl::Image pointed by trfunc must mast have type() IT_UNSIGNED_BYTE and format() IF_RGBA. | |
| alpha_from_data | If set to true the alpha channel of the generated image will be taken from data otherwise from the transfer function. |
int vlVolume::SlicedVolume::mSliceCount [protected] |
vl::ref<vl::Geometry> vlVolume::SlicedVolume::mGeometry [protected] |
vl::ref<vl::Effect> vlVolume::SlicedVolume::mEffect [protected] |
Reimplemented from vl::Actor.
vl::AABB vlVolume::SlicedVolume::mBox [protected] |
vl::fmat4 vlVolume::SlicedVolume::mCache [protected] |
vl::fvec3 vlVolume::SlicedVolume::mTexCoord[8] [protected] |
vl::ref<vl::Image> vlVolume::SlicedVolume::mTransferFunction [protected] |
vl::ref<vl::Light> vlVolume::SlicedVolume::mLight [protected] |
vl::ref<vl::GLSLProgram> vlVolume::SlicedVolume::mGLSLProgram [protected] |