25 #include "../common/math/linearAlgebra/WLinearAlgebra.h"
27 #include "WValueSet.h"
29 #include "../graphicsEngine/WGETextureUtils.h"
31 #include "WDataTexture3D.h"
34 WGETexture3D( static_cast< float >( valueSet->getMaximumValue() - valueSet->getMinimumValue() ),
35 static_cast< float >( valueSet->getMinimumValue() ) ),
36 m_valueSet( valueSet ),
37 m_boundingBox( grid->getBoundingBox() )
40 setTextureSize( grid->getNbCoordsX(), grid->getNbCoordsY(), grid->getNbCoordsZ() );
43 setWrap( osg::Texture::WRAP_S, osg::Texture::CLAMP_TO_BORDER );
44 setWrap( osg::Texture::WRAP_T, osg::Texture::CLAMP_TO_BORDER );
45 setWrap( osg::Texture::WRAP_R, osg::Texture::CLAMP_TO_BORDER );
47 threshold()->setMin( valueSet->getMinimumValue() );
48 threshold()->setMax( valueSet->getMaximumValue() );
49 threshold()->set( valueSet->getMinimumValue() );
53 scale( 0, 0 ) = 1.0 / grid->getNbCoordsX();
54 scale( 1, 1 ) = 1.0 / grid->getNbCoordsY();
55 scale( 2, 2 ) = 1.0 / grid->getNbCoordsZ();
60 offset( 0, 3 ) = 0.5 / grid->getNbCoordsX();
61 offset( 1, 3 ) = 0.5 / grid->getNbCoordsY();
62 offset( 2, 3 ) = 0.5 / grid->getNbCoordsZ();
64 transformation()->set( invert( static_cast< WMatrix4d >( grid->getTransform() ) ) * scale * offset );
77 osg::ref_ptr< osg::Image > ima;
81 wlog::debug(
"WDataTexture3D" ) <<
"Creating Texture of type W_DT_UINT8";
83 uint8_t* source =
const_cast< uint8_t*
> ( vs->rawData() );
86 else if(
m_valueSet->getDataType() == W_DT_INT8 )
88 wlog::debug(
"WDataTexture3D" ) <<
"Creating Texture of type W_DT_INT8";
90 int8_t* source =
const_cast< int8_t*
> ( vs->rawData() );
93 else if(
m_valueSet->getDataType() == W_DT_INT16 )
95 wlog::debug(
"WDataTexture3D" ) <<
"Creating Texture of type W_DT_INT16";
97 int16_t* source =
const_cast< int16_t*
> ( vs->rawData() );
100 else if(
m_valueSet->getDataType() == W_DT_UINT16 )
102 wlog::debug(
"WDataTexture3D" ) <<
"Creating Texture of type W_DT_UINT16";
104 uint16_t* source =
const_cast< uint16_t*
> ( vs->rawData() );
107 else if(
m_valueSet->getDataType() == W_DT_SIGNED_INT )
109 wlog::debug(
"WDataTexture3D" ) <<
"Creating Texture of type W_DT_SIGNED_INT";
111 int* source =
const_cast< int*
> ( vs->rawData() );
114 else if(
m_valueSet->getDataType() == W_DT_FLOAT )
116 wlog::debug(
"WDataTexture3D" ) <<
"Creating Texture of type W_DT_FLOAT";
118 float* source =
const_cast< float*
> ( vs->rawData() );
121 else if(
m_valueSet->getDataType() == W_DT_DOUBLE )
123 wlog::debug(
"WDataTexture3D" ) <<
"Creating Texture of type W_DT_DOUBLE";
125 double* source =
const_cast< double*
> ( vs->rawData() );
131 wlog::error(
"WDataTexture3D" ) <<
"Conversion of this data type to texture not supported yet.";
138 dirtyTextureObject();
146 void wge::bindTexture( osg::ref_ptr< osg::Node > node, osg::ref_ptr< WDataTexture3D > texture,
size_t unit, std::string prefix )
148 wge::bindTexture( node, osg::ref_ptr< WGETexture3D >( texture ), unit, prefix );