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 );