This calls serves a simple purpose: have a texture and its scaling information together which allows very easy binding of textures to nodes with associated shaders. More...
#include <WGETexture.h>
Public Member Functions | |
WGETexture (double scale=1.0, double min=0.0) | |
Default constructor. | |
WGETexture (osg::Image *image, double scale=1.0, double min=0.0) | |
Creates texture from given image. | |
WGETexture (const WGETexture< TextureType > &texture, const osg::CopyOp ©op=osg::CopyOp::SHALLOW_COPY) | |
Copy the texture. | |
virtual | ~WGETexture () |
Destructor. | |
WPropString | name () const |
Returns the name property of the texture. | |
WPropDouble | minimum () const |
Get the minimum in the de-scaled value space. | |
WPropDouble | scale () const |
Get the scaling factor for de-scaling the texture. | |
WPropDouble | alpha () const |
Returns the alpha property. | |
WPropDouble | threshold () const |
Returns the threshold property. | |
WPropBool | thresholdEnabled () const |
Returns the property responsible for enabling threshold based clipping. | |
WPropBool | interpolation () const |
Returns the interpolation property. | |
WPropSelection | colormap () const |
Returns the colormap property. | |
WPropBool | active () const |
Returns the active property. | |
WPropMatrix4X4 | transformation () const |
Returns the texture transformation matrix. | |
void | bind (osg::ref_ptr< osg::Node > node, size_t unit=0) |
Binds the texture to the specified node and texture unit. | |
boost::shared_ptr< WProperties > | getProperties () const |
Return a pointer to the properties object of the dataset. | |
boost::shared_ptr< WProperties > | getInformationProperties () const |
Return a pointer to the information properties object of the dataset. | |
virtual void | applyUniforms (std::string prefix, osg::StateSet *states) const |
Applies some custom uniforms to the specified state-set which directly relate to this texture. | |
void | setFilterMinMag (osg::Texture::FilterMode mode) |
For all the lazy guys to set the filter MIN and MAG at once. | |
void | setWrapSTR (osg::Texture::WrapMode mode) |
For all the lazy guys to set the wrapping for s,t and r directions at once. | |
virtual WBoundingBox | getBoundingBox () const |
Returns the texture's bounding box. | |
Static Public Attributes | |
static std::size_t const | MAX_NUMBER_OF_TEXTURES = 8 |
We support only 8 textures because some known hardware does not support more texture coordinates. | |
static std::size_t const | MAX_TEXTURE_DIMENSION = 2048 |
The maximum texture dimension. | |
Protected Member Functions | |
virtual void | handleUpdate () |
Handles all property updates. | |
virtual void | create () |
Creates the texture data. | |
virtual void | updateCallback (osg::StateAttribute *state) |
This method implements an update callback which updates the texture image if needed and several other properties like texture matrix. | |
Static Protected Member Functions | |
static void | initTextureSize (osg::Texture1D *texture, int width, int height, int depth) |
Initialize the size of the texture properly according to real texture type (1D,2D,3D). | |
static void | initTextureSize (osg::Texture2D *texture, int width, int height, int depth) |
Initialize the size of the texture properly according to real texture type (1D,2D,3D). | |
static void | initTextureSize (osg::Texture3D *texture, int width, int height, int depth) |
Initialize the size of the texture properly according to real texture type (1D,2D,3D). | |
Private Member Functions | |
void | setupProperties (double scale, double min) |
Creates and assigns all properties. | |
Private Attributes | |
boost::shared_ptr< WCondition > | m_propCondition |
A condition used to notify about changes in several properties. | |
boost::shared_ptr< WProperties > | m_properties |
The property object for the dataset. | |
boost::shared_ptr< WProperties > | m_infoProperties |
The property object for the dataset containing only props whose purpose is "PV_PURPOSE_INFORMNATION". | |
bool | m_needCreate |
If true, the texture gets created. | |
WPropString | m_name |
The texture name. | |
WPropDouble | m_min |
The minimum of each value in the texture in unscaled space. | |
WPropDouble | m_scale |
The scaling factor to de-scale a [0-1] texture to original space. | |
boost::shared_ptr< WItemSelection > | m_colorMapSelectionsList |
A list of color map selection types. | |
WPropSelection | m_colorMap |
Selection property for color map. | |
WPropDouble | m_alpha |
Alpha blending value. | |
WPropDouble | m_threshold |
Threshold for clipping areas. | |
WPropBool | m_thresholdEnabled |
Threshold-enable flag. | |
WPropBool | m_interpolation |
True if interpolation should be used. | |
WPropBool | m_active |
True if the texture is active. | |
WPropMatrix4X4 | m_texMatrix |
The texture transformation matrix. |
This calls serves a simple purpose: have a texture and its scaling information together which allows very easy binding of textures to nodes with associated shaders.
When this texture gets bind using the bindTo methods, uniforms get added containing needed scaling information.
Definition at line 54 of file WGETexture.h.
WGETexture< TextureType >::WGETexture | ( | double | scale = 1.0 , |
|
double | min = 0.0 | |||
) |
Default constructor.
Creates an empty instance of the texture.
scale | the scaling factor needed for de-scaling the texture values | |
min | the minimum value allowing negative values too. |
Definition at line 378 of file WGETexture.h.
References WGETexture< TextureType >::setupProperties().
WGETexture< TextureType >::WGETexture | ( | osg::Image * | image, | |
double | scale = 1.0 , |
|||
double | min = 0.0 | |||
) |
Creates texture from given image.
Scaling is set to identity.
image | the image to use as texture | |
scale | the scaling factor needed for de-scaling the texture values | |
min | the minimum value allowing negative values too. |
Definition at line 389 of file WGETexture.h.
References WGETexture< TextureType >::initTextureSize(), and WGETexture< TextureType >::setupProperties().
WGETexture< TextureType >::WGETexture | ( | const WGETexture< TextureType > & | texture, | |
const osg::CopyOp & | copyop = osg::CopyOp::SHALLOW_COPY | |||
) |
Copy the texture.
texture | the texture to copy | |
copyop |
Definition at line 401 of file WGETexture.h.
WGETexture< TextureType >::~WGETexture | ( | ) | [virtual] |
Destructor.
Definition at line 467 of file WGETexture.h.
WPropBool WGETexture< TextureType >::active | ( | ) | const [inline] |
Returns the active property.
The property can be changed. A change affects all colormaps using this texture.
Definition at line 533 of file WGETexture.h.
References WGETexture< TextureType >::m_active.
Referenced by WGETexture< TextureType >::applyUniforms().
WPropDouble WGETexture< TextureType >::alpha | ( | ) | const [inline] |
Returns the alpha property.
The property can be changed. A change affects all colormaps using this texture.
Definition at line 503 of file WGETexture.h.
References WGETexture< TextureType >::m_alpha.
Referenced by WGETexture< TextureType >::applyUniforms().
void WGETexture< TextureType >::applyUniforms | ( | std::string | prefix, | |
osg::StateSet * | states | |||
) | const [virtual] |
Applies some custom uniforms to the specified state-set which directly relate to this texture.
prefix | the prefix used for the uniforms | |
states | the state where to add the uniforms |
Definition at line 555 of file WGETexture.h.
References WGETexture< TextureType >::active(), WGETexture< TextureType >::alpha(), WGETexture< TextureType >::colormap(), WGETexture< TextureType >::minimum(), WGETexture< TextureType >::scale(), WGETexture< TextureType >::threshold(), and WGETexture< TextureType >::thresholdEnabled().
void WGETexture< TextureType >::bind | ( | osg::ref_ptr< osg::Node > | node, | |
size_t | unit = 0 | |||
) |
Binds the texture to the specified node and texture unit.
It also adds two uniforms: u_textureXMin and u_textureXScale, where X is the unit number. This can be used in shaders to unscale it.
node | the node where to bind the texture to | |
unit | the unit, by default 0 |
Definition at line 567 of file WGETexture.h.
References wge::bindTexture().
WPropSelection WGETexture< TextureType >::colormap | ( | ) | const [inline] |
Returns the colormap property.
The property can be changed. A change affects all colormaps using this texture.
Definition at line 527 of file WGETexture.h.
References WGETexture< TextureType >::m_colorMap.
Referenced by WGETexture< TextureType >::applyUniforms().
void WGETexture< TextureType >::create | ( | ) | [protected, virtual] |
Creates the texture data.
Overwrite this method if you want to provide a custom texture creation procedure.
Reimplemented in WDataTexture3D.
Definition at line 574 of file WGETexture.h.
Referenced by WGETexture< TextureType >::updateCallback().
WBoundingBox WGETexture< TextureType >::getBoundingBox | ( | ) | const [virtual] |
Returns the texture's bounding box.
This is const. Although there exists the transformation() property, it is an information property and can't be changed.
Reimplemented in WDataTexture3D.
Definition at line 625 of file WGETexture.h.
boost::shared_ptr< WProperties > WGETexture< TextureType >::getInformationProperties | ( | ) | const |
Return a pointer to the information properties object of the dataset.
The dataset intends these properties to not be modified.
Definition at line 479 of file WGETexture.h.
References WGETexture< TextureType >::m_infoProperties.
boost::shared_ptr< WProperties > WGETexture< TextureType >::getProperties | ( | ) | const |
Return a pointer to the properties object of the dataset.
Add all the modifiable settings here. This allows the user to modify several properties of a dataset.
Definition at line 473 of file WGETexture.h.
References WGETexture< TextureType >::m_properties.
void WGETexture< TextureType >::handleUpdate | ( | ) | [protected, virtual] |
Handles all property updates.
Called by m_propCondition.
Definition at line 545 of file WGETexture.h.
References WGETexture< TextureType >::m_interpolation.
void WGETexture< TextureType >::initTextureSize | ( | osg::Texture1D * | texture, | |
int | width, | |||
int | height, | |||
int | depth | |||
) | [static, protected] |
Initialize the size of the texture properly according to real texture type (1D,2D,3D).
texture | the texture where to set the size | |
width | the new width | |
height | the new height | |
depth | the new depth |
Definition at line 607 of file WGETexture.h.
Referenced by WDataTexture3D::WDataTexture3D(), and WGETexture< TextureType >::WGETexture().
void WGETexture< TextureType >::initTextureSize | ( | osg::Texture2D * | texture, | |
int | width, | |||
int | height, | |||
int | depth | |||
) | [static, protected] |
Initialize the size of the texture properly according to real texture type (1D,2D,3D).
texture | the texture where to set the size | |
width | the new width | |
height | the new height | |
depth | the new depth |
Definition at line 613 of file WGETexture.h.
void WGETexture< TextureType >::initTextureSize | ( | osg::Texture3D * | texture, | |
int | width, | |||
int | height, | |||
int | depth | |||
) | [static, protected] |
Initialize the size of the texture properly according to real texture type (1D,2D,3D).
texture | the texture where to set the size | |
width | the new width | |
height | the new height | |
depth | the new depth |
Definition at line 619 of file WGETexture.h.
WPropBool WGETexture< TextureType >::interpolation | ( | ) | const [inline] |
Returns the interpolation property.
The property can be changed. A change affects all colormaps using this texture.
Definition at line 521 of file WGETexture.h.
References WGETexture< TextureType >::m_interpolation.
WPropDouble WGETexture< TextureType >::minimum | ( | ) | const [inline] |
Get the minimum in the de-scaled value space.
The property can be changed. A change affects all colormaps using this texture. But be careful as the texture creating depends on these values.
Definition at line 491 of file WGETexture.h.
References WGETexture< TextureType >::m_min.
Referenced by WGETexture< TextureType >::applyUniforms(), and WDataTexture3D::createTexture().
WPropString WGETexture< TextureType >::name | ( | ) | const [inline] |
Returns the name property of the texture.
You should set it if you create a texture.
Definition at line 485 of file WGETexture.h.
References WGETexture< TextureType >::m_name.
WPropDouble WGETexture< TextureType >::scale | ( | ) | const [inline] |
Get the scaling factor for de-scaling the texture.
The property can be changed. A change affects all colormaps using this texture. But be careful as the texture creating depends on these values.
Definition at line 497 of file WGETexture.h.
References WGETexture< TextureType >::m_scale.
Referenced by WGETexture< TextureType >::applyUniforms(), WDataTexture3D::createTexture(), and WDataTexture3D::WDataTexture3D().
void WGETexture< TextureType >::setFilterMinMag | ( | osg::Texture::FilterMode | mode | ) |
For all the lazy guys to set the filter MIN and MAG at once.
mode | the new mode for MIN_FILTER and MAG_FILTER. |
Definition at line 592 of file WGETexture.h.
void WGETexture< TextureType >::setupProperties | ( | double | scale, | |
double | min | |||
) | [private] |
Creates and assigns all properties.
min | the min value of the texture | |
scale | the scale value of the texture |
Definition at line 410 of file WGETexture.h.
References WPropertyHelper::PC_SELECTONLYONE::addTo(), WMatrixFixed< double, 4, 4 >::identity(), WGETexture< TextureType >::m_active, WGETexture< TextureType >::m_alpha, WGETexture< TextureType >::m_colorMap, WGETexture< TextureType >::m_colorMapSelectionsList, WGETexture< TextureType >::m_interpolation, WGETexture< TextureType >::m_min, WGETexture< TextureType >::m_name, WGETexture< TextureType >::m_propCondition, WGETexture< TextureType >::m_properties, WGETexture< TextureType >::m_scale, WGETexture< TextureType >::m_texMatrix, WGETexture< TextureType >::m_threshold, and WGETexture< TextureType >::m_thresholdEnabled.
Referenced by WGETexture< TextureType >::WGETexture().
void WGETexture< TextureType >::setWrapSTR | ( | osg::Texture::WrapMode | mode | ) |
For all the lazy guys to set the wrapping for s,t and r directions at once.
mode | the new mode for WRAP_S, WRAP_T and WRAP_R. |
Definition at line 599 of file WGETexture.h.
WPropDouble WGETexture< TextureType >::threshold | ( | ) | const [inline] |
Returns the threshold property.
The property can be changed. A change affects all colormaps using this texture.
Definition at line 509 of file WGETexture.h.
References WGETexture< TextureType >::m_threshold.
Referenced by WGETexture< TextureType >::applyUniforms(), and WDataTexture3D::WDataTexture3D().
WPropBool WGETexture< TextureType >::thresholdEnabled | ( | ) | const [inline] |
Returns the property responsible for enabling threshold based clipping.
If this is false, the threshold is ignored.
Definition at line 515 of file WGETexture.h.
References WGETexture< TextureType >::m_thresholdEnabled.
Referenced by WGETexture< TextureType >::applyUniforms().
WPropMatrix4X4 WGETexture< TextureType >::transformation | ( | ) | const [inline] |
Returns the texture transformation matrix.
The property can be changed. A change affects all colormaps using this texture. This matrix converts an world-space coordinate to an texture coordinate! This can be seen as a scaled inverse matrix of the grid's transformation.
Definition at line 539 of file WGETexture.h.
References WGETexture< TextureType >::m_texMatrix.
Referenced by WDataTexture3D::WDataTexture3D().
void WGETexture< TextureType >::updateCallback | ( | osg::StateAttribute * | state | ) | [protected, virtual] |
This method implements an update callback which updates the texture image if needed and several other properties like texture matrix.
state | the state to update |
Definition at line 580 of file WGETexture.h.
References WGETexture< TextureType >::create(), and WGETexture< TextureType >::m_needCreate.
WPropBool WGETexture< TextureType >::m_active [private] |
True if the texture is active.
Definition at line 351 of file WGETexture.h.
Referenced by WGETexture< TextureType >::active(), and WGETexture< TextureType >::setupProperties().
WPropDouble WGETexture< TextureType >::m_alpha [private] |
Alpha blending value.
Definition at line 331 of file WGETexture.h.
Referenced by WGETexture< TextureType >::alpha(), and WGETexture< TextureType >::setupProperties().
WPropSelection WGETexture< TextureType >::m_colorMap [private] |
Selection property for color map.
Definition at line 326 of file WGETexture.h.
Referenced by WGETexture< TextureType >::colormap(), and WGETexture< TextureType >::setupProperties().
boost::shared_ptr< WItemSelection > WGETexture< TextureType >::m_colorMapSelectionsList [private] |
A list of color map selection types.
Definition at line 321 of file WGETexture.h.
Referenced by WGETexture< TextureType >::setupProperties().
boost::shared_ptr< WProperties > WGETexture< TextureType >::m_infoProperties [private] |
The property object for the dataset containing only props whose purpose is "PV_PURPOSE_INFORMNATION".
It is useful to define some property to only be of informational nature. The GUI does not modify them. As it is a WProperties instance, you can use it the same way as m_properties.
Definition at line 296 of file WGETexture.h.
Referenced by WGETexture< TextureType >::getInformationProperties().
WPropBool WGETexture< TextureType >::m_interpolation [private] |
True if interpolation should be used.
Definition at line 346 of file WGETexture.h.
Referenced by WGETexture< TextureType >::handleUpdate(), WGETexture< TextureType >::interpolation(), and WGETexture< TextureType >::setupProperties().
WPropDouble WGETexture< TextureType >::m_min [private] |
The minimum of each value in the texture in unscaled space.
Definition at line 311 of file WGETexture.h.
Referenced by WGETexture< TextureType >::minimum(), and WGETexture< TextureType >::setupProperties().
WPropString WGETexture< TextureType >::m_name [private] |
The texture name.
This might be useful to identify textures.
Definition at line 306 of file WGETexture.h.
Referenced by WGETexture< TextureType >::name(), and WGETexture< TextureType >::setupProperties().
bool WGETexture< TextureType >::m_needCreate [private] |
If true, the texture gets created.
This is used to create texture on demand.
Definition at line 301 of file WGETexture.h.
Referenced by WGETexture< TextureType >::updateCallback().
boost::shared_ptr< WCondition > WGETexture< TextureType >::m_propCondition [private] |
A condition used to notify about changes in several properties.
Definition at line 284 of file WGETexture.h.
Referenced by WGETexture< TextureType >::setupProperties().
boost::shared_ptr< WProperties > WGETexture< TextureType >::m_properties [private] |
The property object for the dataset.
Definition at line 289 of file WGETexture.h.
Referenced by WGETexture< TextureType >::getProperties(), and WGETexture< TextureType >::setupProperties().
WPropDouble WGETexture< TextureType >::m_scale [private] |
The scaling factor to de-scale a [0-1] texture to original space.
Definition at line 316 of file WGETexture.h.
Referenced by WGETexture< TextureType >::scale(), and WGETexture< TextureType >::setupProperties().
WPropMatrix4X4 WGETexture< TextureType >::m_texMatrix [private] |
The texture transformation matrix.
Definition at line 356 of file WGETexture.h.
Referenced by WGETexture< TextureType >::setupProperties(), and WGETexture< TextureType >::transformation().
WPropDouble WGETexture< TextureType >::m_threshold [private] |
Threshold for clipping areas.
Definition at line 336 of file WGETexture.h.
Referenced by WGETexture< TextureType >::setupProperties(), and WGETexture< TextureType >::threshold().
WPropBool WGETexture< TextureType >::m_thresholdEnabled [private] |
Threshold-enable flag.
Definition at line 341 of file WGETexture.h.
Referenced by WGETexture< TextureType >::setupProperties(), and WGETexture< TextureType >::thresholdEnabled().
std::size_t const WGETexture< TextureType >::MAX_NUMBER_OF_TEXTURES = 8 [static] |
We support only 8 textures because some known hardware does not support more texture coordinates.
Definition at line 58 of file WGETexture.h.
std::size_t const WGETexture< TextureType >::MAX_TEXTURE_DIMENSION = 2048 [static] |
The maximum texture dimension.
Definition at line 61 of file WGETexture.h.