27 #include "../graphicsEngine/WGETextureUtils.h"
28 #include "WDataTexture3D.h"
29 #include "WValueSet.h"
32 WGETexture3D( static_cast< float >( valueSet->getMaximumValue() - valueSet->getMinimumValue() ),
33 static_cast< float >( valueSet->getMinimumValue() ) ),
34 m_valueSet( valueSet ),
35 m_boundingBox( grid->getBoundingBoxIncludingBorder() )
38 setTextureSize( grid->getNbCoordsX(), grid->getNbCoordsY(), grid->getNbCoordsZ() );
41 setWrap( osg::Texture::WRAP_S, osg::Texture::CLAMP_TO_BORDER );
42 setWrap( osg::Texture::WRAP_T, osg::Texture::CLAMP_TO_BORDER );
43 setWrap( osg::Texture::WRAP_R, osg::Texture::CLAMP_TO_BORDER );
52 window()->set( make_interval( valueSet->getMinimumValue(),
53 valueSet->getMaximumValue() ) );
57 scale( 0, 0 ) = 1.0 / grid->getNbCoordsX();
58 scale( 1, 1 ) = 1.0 / grid->getNbCoordsY();
59 scale( 2, 2 ) = 1.0 / grid->getNbCoordsZ();
64 offset( 0, 3 ) = 0.5 / grid->getNbCoordsX();
65 offset( 1, 3 ) = 0.5 / grid->getNbCoordsY();
66 offset( 2, 3 ) = 0.5 / grid->getNbCoordsZ();
68 transformation()->set( invert( static_cast< WMatrix4d >( grid->getTransform() ) ) * scale * offset );
81 osg::ref_ptr< osg::Image > ima;
85 wlog::debug(
"WDataTexture3D" ) <<
"Creating Texture of type W_DT_UINT8";
87 uint8_t* source =
const_cast< uint8_t*
> ( vs->rawData() );
90 else if(
m_valueSet->getDataType() == W_DT_INT8 )
92 wlog::debug(
"WDataTexture3D" ) <<
"Creating Texture of type W_DT_INT8";
94 int8_t* source =
const_cast< int8_t*
> ( vs->rawData() );
97 else if(
m_valueSet->getDataType() == W_DT_INT16 )
99 wlog::debug(
"WDataTexture3D" ) <<
"Creating Texture of type W_DT_INT16";
101 int16_t* source =
const_cast< int16_t*
> ( vs->rawData() );
104 else if(
m_valueSet->getDataType() == W_DT_UINT16 )
106 wlog::debug(
"WDataTexture3D" ) <<
"Creating Texture of type W_DT_UINT16";
108 uint16_t* source =
const_cast< uint16_t*
> ( vs->rawData() );
111 else if(
m_valueSet->getDataType() == W_DT_UINT32 )
113 wlog::debug(
"WDataTexture3D" ) <<
"Creating Texture of type W_DT_UINT32";
115 uint32_t* source =
const_cast< uint32_t*
> ( vs->rawData() );
118 else if(
m_valueSet->getDataType() == W_DT_INT64 )
120 wlog::debug(
"WDataTexture3D" ) <<
"Creating Texture of type W_DT_INT64";
122 int64_t* source =
const_cast< int64_t*
> ( vs->rawData() );
125 else if(
m_valueSet->getDataType() == W_DT_UINT64 )
127 wlog::debug(
"WDataTexture3D" ) <<
"Creating Texture of type W_DT_UINT64";
129 uint64_t* source =
const_cast< uint64_t*
> ( vs->rawData() );
132 else if(
m_valueSet->getDataType() == W_DT_SIGNED_INT )
134 wlog::debug(
"WDataTexture3D" ) <<
"Creating Texture of type W_DT_SIGNED_INT";
136 int* source =
const_cast< int*
> ( vs->rawData() );
139 else if(
m_valueSet->getDataType() == W_DT_FLOAT )
141 wlog::debug(
"WDataTexture3D" ) <<
"Creating Texture of type W_DT_FLOAT";
143 float* source =
const_cast< float*
> ( vs->rawData() );
146 else if(
m_valueSet->getDataType() == W_DT_DOUBLE )
148 wlog::debug(
"WDataTexture3D" ) <<
"Creating Texture of type W_DT_DOUBLE";
150 double* source =
const_cast< double*
> ( vs->rawData() );
153 else if(
m_valueSet->getDataType() == W_DT_FLOAT128 )
155 wlog::debug(
"WDataTexture3D" ) <<
"Creating Texture of type W_DT_FLOAT128";
157 long double* source =
const_cast< long double*
> ( vs->rawData() );
163 wlog::error(
"WDataTexture3D" ) <<
"Conversion of this data type to texture not supported yet.";
170 dirtyTextureObject();
178 void wge::bindTexture( osg::ref_ptr< osg::Node > node, osg::ref_ptr< WDataTexture3D > texture,
size_t unit, std::string prefix )
180 wge::bindTexture( node, osg::ref_ptr< WGETexture3D >( texture ), unit, prefix );
WStreamedLogger error(const std::string &source)
Logging an error message.
boost::shared_ptr< WValueSetBase > m_valueSet
The value set from which the texture gets created.
WPropInterval window() const
Returns the window level definition for the colormap.
osg::ref_ptr< osg::Image > createTexture(T *source, int components=1)
Creates a properly sized osg::Image from the specified source data.
virtual ~WDataTexture3D()
Destructor.
virtual WBoundingBox getBoundingBox() const
Returns the texture's bounding box.
WPropDouble thresholdUpper() const
Returns the threshold property.
static MatrixType zero()
Returns a zero-initialized matrix.
This calls serves a simple purpose: have a texture and its scaling information together which allows ...
WBoundingBox m_boundingBox
The bounding box of the underlying grid.
virtual void create()
Creates the texture data.
WPropDouble thresholdLower() const
Returns the threshold property.
WDataTexture3D(boost::shared_ptr< WValueSetBase > valueSet, boost::shared_ptr< WGridRegular3D > grid)
Constructor.
static MatrixType identity()
Returns an identity matrix.
Base Class for all value set types.
WPropDouble scale() const
Get the scaling factor for de-scaling the texture.
void bindTexture(osg::ref_ptr< osg::Node > node, osg::ref_ptr< WDataTexture3D > texture, size_t unit=0, std::string prefix="")
Binds the specified texture to the specified unit.
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).
WStreamedLogger debug(const std::string &source)
Logging a debug message.
WPropMatrix4X4 transformation() const
Returns the texture transformation matrix.