27 #include "../common/math/linearAlgebra/WLinearAlgebra.h"
28 #include "../graphicsEngine/WGETextureUtils.h"
29 #include "WDataTexture3D.h"
30 #include "WValueSet.h"
33 WGETexture3D( static_cast< float >( valueSet->getMaximumValue() - valueSet->getMinimumValue() ),
34 static_cast< float >( valueSet->getMinimumValue() ) ),
35 m_valueSet( valueSet ),
36 m_boundingBox( grid->getBoundingBox() )
39 setTextureSize( grid->getNbCoordsX(), grid->getNbCoordsY(), grid->getNbCoordsZ() );
42 setWrap( osg::Texture::WRAP_S, osg::Texture::CLAMP_TO_BORDER );
43 setWrap( osg::Texture::WRAP_T, osg::Texture::CLAMP_TO_BORDER );
44 setWrap( osg::Texture::WRAP_R, osg::Texture::CLAMP_TO_BORDER );
46 threshold()->setMin( valueSet->getMinimumValue() );
47 threshold()->setMax( valueSet->getMaximumValue() );
48 threshold()->set( valueSet->getMinimumValue() );
52 scale( 0, 0 ) = 1.0 / grid->getNbCoordsX();
53 scale( 1, 1 ) = 1.0 / grid->getNbCoordsY();
54 scale( 2, 2 ) = 1.0 / grid->getNbCoordsZ();
59 offset( 0, 3 ) = 0.5 / grid->getNbCoordsX();
60 offset( 1, 3 ) = 0.5 / grid->getNbCoordsY();
61 offset( 2, 3 ) = 0.5 / grid->getNbCoordsZ();
63 transformation()->set( invert( static_cast< WMatrix4d >( grid->getTransform() ) ) * scale * offset );
76 osg::ref_ptr< osg::Image > ima;
80 wlog::debug(
"WDataTexture3D" ) <<
"Creating Texture of type W_DT_UINT8";
82 uint8_t* source =
const_cast< uint8_t*
> ( vs->rawData() );
85 else if(
m_valueSet->getDataType() == W_DT_INT8 )
87 wlog::debug(
"WDataTexture3D" ) <<
"Creating Texture of type W_DT_INT8";
89 int8_t* source =
const_cast< int8_t*
> ( vs->rawData() );
92 else if(
m_valueSet->getDataType() == W_DT_INT16 )
94 wlog::debug(
"WDataTexture3D" ) <<
"Creating Texture of type W_DT_INT16";
96 int16_t* source =
const_cast< int16_t*
> ( vs->rawData() );
99 else if(
m_valueSet->getDataType() == W_DT_UINT16 )
101 wlog::debug(
"WDataTexture3D" ) <<
"Creating Texture of type W_DT_UINT16";
103 uint16_t* source =
const_cast< uint16_t*
> ( vs->rawData() );
106 else if(
m_valueSet->getDataType() == W_DT_UINT32 )
108 wlog::debug(
"WDataTexture3D" ) <<
"Creating Texture of type W_DT_UINT32";
110 uint32_t* source =
const_cast< uint32_t*
> ( vs->rawData() );
113 else if(
m_valueSet->getDataType() == W_DT_INT64 )
115 wlog::debug(
"WDataTexture3D" ) <<
"Creating Texture of type W_DT_INT64";
117 int64_t* source =
const_cast< int64_t*
> ( vs->rawData() );
120 else if(
m_valueSet->getDataType() == W_DT_UINT64 )
122 wlog::debug(
"WDataTexture3D" ) <<
"Creating Texture of type W_DT_UINT64";
124 uint64_t* source =
const_cast< uint64_t*
> ( vs->rawData() );
127 else if(
m_valueSet->getDataType() == W_DT_SIGNED_INT )
129 wlog::debug(
"WDataTexture3D" ) <<
"Creating Texture of type W_DT_SIGNED_INT";
131 int* source =
const_cast< int*
> ( vs->rawData() );
134 else if(
m_valueSet->getDataType() == W_DT_FLOAT )
136 wlog::debug(
"WDataTexture3D" ) <<
"Creating Texture of type W_DT_FLOAT";
138 float* source =
const_cast< float*
> ( vs->rawData() );
141 else if(
m_valueSet->getDataType() == W_DT_DOUBLE )
143 wlog::debug(
"WDataTexture3D" ) <<
"Creating Texture of type W_DT_DOUBLE";
145 double* source =
const_cast< double*
> ( vs->rawData() );
148 else if(
m_valueSet->getDataType() == W_DT_FLOAT128 )
150 wlog::debug(
"WDataTexture3D" ) <<
"Creating Texture of type W_DT_FLOAT128";
152 long double* source =
const_cast< long double*
> ( vs->rawData() );
158 wlog::error(
"WDataTexture3D" ) <<
"Conversion of this data type to texture not supported yet.";
165 dirtyTextureObject();
173 void wge::bindTexture( osg::ref_ptr< osg::Node > node, osg::ref_ptr< WDataTexture3D > texture,
size_t unit, std::string prefix )
175 wge::bindTexture( node, osg::ref_ptr< WGETexture3D >( texture ), unit, prefix );