fluidvis
Public Member Functions | List of all members
sx::Volume Class Reference

#include <SXCore.h>

Inheritance diagram for sx::Volume:
sx::Uniform sx::SXResource

Public Member Functions

EX Volume (const string &id)
 
EX ~Volume ()
 
EX void unload ()
 
EX void load ()
 
EX bool isLoaded () const
 
EX void save (const string &filenamepart)
 
EX void use (Shader &shader, const string &id)
 
EX unsigned int getTextureID () const
 
EX void addPath (const string &path)
 
EX void setPaths (const vector< string > &paths)
 
EX void setWidth (int width)
 
EX int getWidth () const
 
EX void setHeight (int height)
 
EX int getHeight () const
 
EX void setDepth (int depth)
 
EX int getDepth ()
 
EX void setPixelFormat (PixelFormat pixelFormat)
 
EX PixelFormat getPixelFormat () const
 
EX void setByteBuffer (const vector< unsigned char > &buffer)
 
EX void setFloatBuffer (const vector< float > &buffer)
 
- Public Member Functions inherited from sx::Uniform
virtual EX ~Uniform ()
 
EX void setUniformName (const string &name, const string &id)
 
EX const string & getUniformName (const string &id) const
 
- Public Member Functions inherited from sx::SXResource
virtual EX ~SXResource ()
 
EX const string & getID () const
 

Additional Inherited Members

- Protected Member Functions inherited from sx::Uniform
EX Uniform (const string &id)
 
- Protected Attributes inherited from sx::Uniform
string idToken
 
unordered_map< string, string > uniformNames
 
- Protected Attributes inherited from sx::SXResource
string id
 

Detailed Description

A 3D texture. Additionally to dimensions width and height it also has dimension depth.

Constructor & Destructor Documentation

EX sx::Volume::Volume ( const string &  id)

constructor initializing this with identifier id

EX sx::Volume::~Volume ( )

deconstructor

Member Function Documentation

EX void sx::Volume::addPath ( const string &  path)

Adds a path, from which the n. layer will be loaded by load(), if n-1 layer's paths have been added already. If path is set, the setters for width, height, pixelFormat, byteBuffer and floatBuffer are ignored. width and height of the volume are equal to width and height of the first image, the other images are scaled to those dimensions.

Currently bmp, jpg and png files are supported. If path points to file with 24 or 32 bits per pixel, method load() will initialize a BYTE_RGBA volume. If path points to a png file with 64 bits per pixel, method load() will initialize a FLOAT16_RGBA volume.

EX int sx::Volume::getDepth ( )

getter of the loaded texture, if no texture is loaded, the return value isn't specified

EX int sx::Volume::getHeight ( ) const

getter of the loaded texture, if no texture is loaded, the return value isn't specified

EX PixelFormat sx::Volume::getPixelFormat ( ) const

getter of the loaded texture, if no texture is loaded, the return value isn't specified

EX unsigned int sx::Volume::getTextureID ( ) const

Returns the texture ID, which is internally used to access the shader program. If the shader is not initialized, the return value is not specified.

EX int sx::Volume::getWidth ( ) const

getter of the loaded texture, if no texture is loaded, the return value isn't specified

EX bool sx::Volume::isLoaded ( ) const
virtual

returns true if a texture is loaded

Implements sx::SXResource.

EX void sx::Volume::load ( )
virtual

Deletes the last texture, and loads new layers from the specified paths, or from a buffer with the specified width, height, depth and pixelFormat, or with specified width, height, depth and pixelFormat, but without a buffer. If the layers are loaded from the added paths, width and height of the volume are equal to width and height of the first image, and the other images are scaled to those dimensions. If nothing has been specified, the method has no effect.

Implements sx::SXResource.

EX void sx::Volume::save ( const string &  filenamepart)

Saves the texture in a set of files. Each layer of the volume is stored in a separate file. The name of each file representing the i. layer is generated by appending number i to the filename in filenamepart. Currently bmp, jpg and png files are supported.

If the volume is saved in a bmp or jpg file, the saved images will have 24 bits per pixel regardless of the pixelFormat of the texture. If the texture is saved in png files, and the pixelFormat is equal to BYTE_RGBA, the saved images will have 32 bits per pixel, and if the pixelFormat is equal to FLOAT16_RGBA or FLOAT_RGBA, the saved images will have 64 bits per pixel.

An Exception is thrown, if the volume can't be saved.

EX void sx::Volume::setByteBuffer ( const vector< unsigned char > &  buffer)

Specifies what the texture will look like after the load() operation. Changes the pixelFormat of the next texture to BYTE_RGBA. If a path was set, or the buffer doesn't have size width * height * depth * 4, the buffer is ignored.

EX void sx::Volume::setDepth ( int  depth)

Specifies the depth of the next texture loaded by load(). If a path was set, this parameter is ignored.

EX void sx::Volume::setFloatBuffer ( const vector< float > &  buffer)

Specifies what the texture will look like after the load() operation. Changes the pixelFormat of the next texture to FLOAT_RGBA. If a path was set, or the buffer doesn't have size width * height * depth * 4, the buffer is ignored.

EX void sx::Volume::setHeight ( int  height)

Specifies the height of the next texture loaded by load(). If a path was set, this parameter is ignored.

EX void sx::Volume::setPaths ( const vector< string > &  paths)

Sets the paths, from which the layers will be loaded by load(). The path's specify the layers in ascending order. If path is set, the setters for width, height, pixelFormat, byteBuffer and floatBuffer are ignored. width and height of the volume are equal to width and height of the first image, the other images are scaled to those dimensions.

EX void sx::Volume::setPixelFormat ( PixelFormat  pixelFormat)

Specifies the pixel format of the next texture loaded by load(). If a path was set, this parameter is ignored.

EX void sx::Volume::setWidth ( int  width)

Specifies the width of the next texture loaded by load(). If a path was set, this parameter is ignored.

EX void sx::Volume::unload ( )

if a texture has been loaded, it's unloaded by this operation, leaving this unloaded

EX void sx::Volume::use ( Shader shader,
const string &  id 
)
virtual

Binds the current texture to the next free texture slot of the shader. If the texture is not loaded, the method has no effect.

See also
Uniform::use(Shader &shader, const string &id)

Implements sx::Uniform.


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