30 #include <boost/shared_ptr.hpp>
33 #include <osg/StateSet>
34 #include <osg/Texture>
35 #include <osg/Texture1D>
36 #include <osg/Texture2D>
37 #include <osg/Texture3D>
39 #include "callbacks/WGEFunctorCallback.h"
40 #include "../common/WBoundingBox.h"
41 #include "../common/WProperties.h"
42 #include "../common/WPropertyHelper.h"
43 #include "../common/math/linearAlgebra/WLinearAlgebra.h"
45 #include "WGETextureUtils.h"
51 template <
typename TextureType = osg::Texture >
96 WPropString
name()
const;
112 WPropDouble
scale()
const;
119 WPropDouble
alpha()
const;
171 void bind( osg::ref_ptr< osg::Node > node,
size_t unit = 0 );
194 virtual void applyUniforms( std::string prefix, osg::StateSet* states )
const;
208 void setWrapSTR( osg::Texture::WrapMode mode );
245 static void initTextureSize( osg::Texture1D* texture,
int width,
int height,
int depth );
256 static void initTextureSize( osg::Texture2D* texture,
int width,
int height,
int depth );
267 static void initTextureSize( osg::Texture3D* texture,
int width,
int height,
int depth );
374 template <
typename TextureType >
378 m_properties( boost::shared_ptr<
WProperties >( new
WProperties(
"Texture Properties",
"Properties of a texture." ) ) ),
379 m_infoProperties( boost::shared_ptr<
WProperties >( new
WProperties(
"Texture Info Properties",
"Texture's information properties." ) ) ),
385 template <
typename TextureType >
389 m_properties( boost::shared_ptr<
WProperties >( new
WProperties(
"Texture Properties",
"Properties of a texture." ) ) ),
390 m_infoProperties( boost::shared_ptr<
WProperties >( new
WProperties(
"Texture Info Properties",
"Texture's information properties." ) ) ),
397 template <
typename TextureType >
400 m_min( texture.m_min ),
401 m_scale( texture.m_scale )
406 template <
typename TextureType >
411 m_name = m_properties->addProperty(
"Name",
"The name of the texture.", std::string(
"Unnamed" ) );
414 m_min = m_properties->addProperty(
"Minimum",
"The minimum value in the original space.", min,
true );
415 m_min->removeConstraint( m_min->getMin() );
416 m_min->removeConstraint( m_min->getMax() );
418 m_scale = m_properties->addProperty(
"Scale",
"The scaling factor to un-scale the texture values to the original space.", scale,
true );
419 m_scale->removeConstraint( m_scale->getMin() );
420 m_scale->removeConstraint( m_scale->getMax() );
422 m_alpha = m_properties->addProperty(
"Alpha",
"The alpha blending value.", 1.0 );
423 m_alpha->setMin( 0.0 );
424 m_alpha->setMax( 1.0 );
426 m_thresholdEnabled = m_properties->addProperty(
"Enable Threshold",
427 "If enabled, threshold based clipping is used. If not, threshold is ignored.",
false );
429 m_threshold = m_properties->addProperty(
"Threshold",
"The threshold used to clip areas.", 0.0 );
430 m_threshold->setMin( min );
431 m_threshold->setMax( min + scale );
433 m_interpolation = m_properties->addProperty(
"Interpolate",
"Interpolation of the volume data.",
true, m_propCondition );
435 m_colorMapSelectionsList = boost::shared_ptr< WItemSelection >(
new WItemSelection() );
436 m_colorMapSelectionsList->addItem(
"Grayscale",
"" );
437 m_colorMapSelectionsList->addItem(
"Rainbow",
"" );
438 m_colorMapSelectionsList->addItem(
"Hot iron",
"" );
439 m_colorMapSelectionsList->addItem(
"Negative to positive",
"" );
440 m_colorMapSelectionsList->addItem(
"Atlas",
"" );
441 m_colorMapSelectionsList->addItem(
"Blue-Green-Purple",
"" );
442 m_colorMapSelectionsList->addItem(
"Vector",
"" );
444 m_colorMap = m_properties->addProperty(
"Colormap",
"The colormap of this texture.", m_colorMapSelectionsList->getSelectorFirst() );
447 m_active = m_properties->addProperty(
"Active",
"Can dis-enable a texture.",
true );
450 m_texMatrix = m_properties->addProperty(
"Texture Transformation",
"Usable to transform the texture.", m );
451 m_texMatrix->setPurpose( PV_PURPOSE_INFORMATION );
453 TextureType::setResizeNonPowerOfTwoHint(
false );
459 TextureType::setFilter( osg::Texture::MIN_FILTER, m_interpolation->get(
true ) ? osg::Texture::LINEAR : osg::Texture::NEAREST );
460 TextureType::setFilter( osg::Texture::MAG_FILTER, m_interpolation->get(
true ) ? osg::Texture::LINEAR : osg::Texture::NEAREST );
463 template <
typename TextureType >
469 template <
typename TextureType >
475 template <
typename TextureType >
478 return m_infoProperties;
481 template <
typename TextureType >
487 template <
typename TextureType >
493 template <
typename TextureType >
499 template <
typename TextureType >
505 template <
typename TextureType >
511 template <
typename TextureType >
514 return m_thresholdEnabled;
517 template <
typename TextureType >
520 return m_interpolation;
523 template <
typename TextureType >
529 template <
typename TextureType >
535 template <
typename TextureType >
541 template <
typename TextureType >
544 if( m_interpolation->changed() )
546 TextureType::setFilter( osg::Texture::MIN_FILTER, m_interpolation->get(
true ) ? osg::Texture::LINEAR : osg::Texture::NEAREST );
547 TextureType::setFilter( osg::Texture::MAG_FILTER, m_interpolation->get(
true ) ? osg::Texture::LINEAR : osg::Texture::NEAREST );
551 template <
typename TextureType >
563 template <
typename TextureType >
570 template <
typename TextureType >
576 template <
typename TextureType >
582 m_needCreate =
false;
584 TextureType::dirtyTextureObject();
588 template <
typename TextureType >
591 this->setFilter( osg::Texture2D::MIN_FILTER, mode );
592 this->setFilter( osg::Texture2D::MAG_FILTER, mode );
595 template <
typename TextureType >
598 this->setWrap( osg::Texture2D::WRAP_S, mode );
599 this->setWrap( osg::Texture2D::WRAP_T, mode );
600 this->setWrap( osg::Texture2D::WRAP_R, mode );
603 template <
typename TextureType >
606 texture->setTextureWidth( width );
609 template <
typename TextureType >
612 texture->setTextureSize( width, height );
615 template <
typename TextureType >
618 texture->setTextureSize( width, height, depth );
621 template <
typename TextureType >
627 #endif // WGETEXTURE_H