osgEarth 2.1.1
|
Public Member Functions | |
SkinResource (const Config &conf=Config()) | |
osg::StateSet * | createStateSet () const |
optional< URI > & | imageURI () |
const optional< URI > & | imageURI () const |
optional< float > & | imageWidth () |
const optional< float > & | imageWidth () const |
optional< float > & | imageHeight () |
const optional< float > & | imageHeight () const |
optional< float > & | minObjectHeight () |
const optional< float > & | minObjectHeight () const |
optional< float > & | maxObjectHeight () |
const optional< float > & | maxObjectHeight () const |
optional< bool > & | isTiled () |
const optional< bool > & | isTiled () const |
optional< osg::TexEnv::Mode > & | texEnvMode () |
const optional < osg::TexEnv::Mode > & | texEnvMode () const |
optional< unsigned > | maxTextureSpan () |
const optional< unsigned > | maxTextureSpan () const |
virtual Config | getConfig () const |
void | mergeConfig (const Config &conf) |
Protected Member Functions | |
osg::StateSet * | createStateSet (osg::Image *image) const |
osg::Image * | createImage () const |
Protected Attributes | |
optional< URI > | _imageURI |
optional< float > | _imageWidth |
optional< float > | _imageHeight |
optional< float > | _minObjHeight |
optional< float > | _maxObjHeight |
optional< bool > | _isTiled |
optional< osg::TexEnv::Mode > | _texEnvMode |
optional< unsigned > | _maxTexSpan |
A resource that points to a "skin", which is a Texture image paired with a collection of metadata that describes its suitability for use in a scene.
Constructs a new skin resource.
Definition at line 32 of file Skins.cpp.
: Resource ( conf ), _imageWidth ( 10.0f ), _imageHeight ( 3.0f ), _minObjHeight ( 0.0f ), _maxObjHeight ( FLT_MAX ), _isTiled( false ), _texEnvMode ( osg::TexEnv::MODULATE ), _maxTexSpan ( 1024 ) { mergeConfig( conf ); }
osg::Image * SkinResource::createImage | ( | ) | const [protected] |
Definition at line 124 of file Skins.cpp.
{ osg::ref_ptr<osg::Image> image; if ( HTTPClient::readImageFile( _imageURI->full(), image ) != HTTPClient::RESULT_OK ) { //TODO: hmm, perhaps create an "error image" here? or just return NULL // and let the caller do so. } return image.release(); }
osg::StateSet * SkinResource::createStateSet | ( | ) | const |
Creates a new StateSet containing a Texture based on this Skin. Takes an optional URI context for relative URI resolution.
Definition at line 85 of file Skins.cpp.
{ return createStateSet( createImage() ); }
osg::StateSet * SkinResource::createStateSet | ( | osg::Image * | image | ) | const [protected] |
Definition at line 91 of file Skins.cpp.
{ osg::StateSet* stateSet = 0L; if ( image ) { stateSet = new osg::StateSet(); osg::Texture* tex = new osg::Texture2D( image ); tex->setWrap( osg::Texture::WRAP_S, osg::Texture::REPEAT ); tex->setWrap( osg::Texture::WRAP_T, osg::Texture::REPEAT ); stateSet->setTextureAttributeAndModes( 0, tex, osg::StateAttribute::ON ); if ( _texEnvMode.isSet() ) { osg::TexEnv* texenv = new osg::TexEnv(); texenv = new osg::TexEnv(); texenv->setMode( *_texEnvMode ); stateSet->setTextureAttribute( 0, texenv, osg::StateAttribute::ON ); } if ( ImageUtils::hasAlphaChannel( image ) ) { osg::BlendFunc* blendFunc = new osg::BlendFunc(); blendFunc->setFunction( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA ); stateSet->setAttributeAndModes( blendFunc, osg::StateAttribute::ON ); stateSet->setRenderingHint( osg::StateSet::TRANSPARENT_BIN ); } } return stateSet; }
Config SkinResource::getConfig | ( | ) | const [virtual] |
Reimplemented from osgEarth::Symbology::Resource.
Definition at line 63 of file Skins.cpp.
{ Config conf = Resource::getConfig(); conf.key() = "skin"; conf.updateIfSet( "url", _imageURI ); conf.updateIfSet( "image_width", _imageWidth ); conf.updateIfSet( "image_height", _imageHeight ); conf.updateIfSet( "min_object_height", _minObjHeight ); conf.updateIfSet( "max_object_height", _maxObjHeight ); conf.updateIfSet( "tiled", _isTiled ); conf.updateIfSet( "max_texture_span", _maxTexSpan ); conf.updateIfSet( "texture_mode", "decal", _texEnvMode, osg::TexEnv::DECAL ); conf.updateIfSet( "texture_mode", "modulate", _texEnvMode, osg::TexEnv::MODULATE ); conf.updateIfSet( "texture_mode", "replace", _texEnvMode, osg::TexEnv::REPLACE ); conf.updateIfSet( "texture_mode", "blend", _texEnvMode, osg::TexEnv::BLEND ); return conf; }
optional<float>& osgEarth::Symbology::SkinResource::imageHeight | ( | ) | [inline] |
Real-world height of the image, in meters
Definition at line 59 of file Skins.
{ return _imageHeight; }
const optional<float>& osgEarth::Symbology::SkinResource::imageHeight | ( | ) | const [inline] |
Definition at line 60 of file Skins.
{ return _imageHeight; }
optional<float>& osgEarth::Symbology::SkinResource::imageWidth | ( | ) | [inline] |
Real-world width of the image, in meters
Definition at line 55 of file Skins.
{ return _imageWidth; }
const optional<float>& osgEarth::Symbology::SkinResource::imageWidth | ( | ) | const [inline] |
Definition at line 56 of file Skins.
{ return _imageWidth; }
optional<bool>& osgEarth::Symbology::SkinResource::isTiled | ( | ) | [inline] |
const optional<bool>& osgEarth::Symbology::SkinResource::isTiled | ( | ) | const [inline] |
optional<float>& osgEarth::Symbology::SkinResource::maxObjectHeight | ( | ) | [inline] |
Maximum acceptable real-world object height (meters) for which this image would make an appropriate texture
Definition at line 67 of file Skins.
{ return _maxObjHeight; }
const optional<float>& osgEarth::Symbology::SkinResource::maxObjectHeight | ( | ) | const [inline] |
Definition at line 68 of file Skins.
{ return _minObjHeight; }
optional<unsigned> osgEarth::Symbology::SkinResource::maxTextureSpan | ( | ) | [inline] |
The maximum allowable size of a texture (in either dimension) that uses this image.
Definition at line 79 of file Skins.
{ return _maxTexSpan; }
const optional<unsigned> osgEarth::Symbology::SkinResource::maxTextureSpan | ( | ) | const [inline] |
Definition at line 80 of file Skins.
{ return _maxTexSpan; }
void SkinResource::mergeConfig | ( | const Config & | conf | ) |
Reimplemented from osgEarth::Symbology::Resource.
Definition at line 46 of file Skins.cpp.
{ conf.getIfSet( "url", _imageURI ); conf.getIfSet( "image_width", _imageWidth ); conf.getIfSet( "image_height", _imageHeight ); conf.getIfSet( "min_object_height", _minObjHeight ); conf.getIfSet( "max_object_height", _maxObjHeight ); conf.getIfSet( "tiled", _isTiled ); conf.getIfSet( "max_texture_span", _maxTexSpan ); conf.getIfSet( "texture_mode", "decal", _texEnvMode, osg::TexEnv::DECAL ); conf.getIfSet( "texture_mode", "modulate", _texEnvMode, osg::TexEnv::MODULATE ); conf.getIfSet( "texture_mode", "replace", _texEnvMode, osg::TexEnv::REPLACE ); conf.getIfSet( "texture_mode", "blend", _texEnvMode, osg::TexEnv::BLEND ); }
optional<float>& osgEarth::Symbology::SkinResource::minObjectHeight | ( | ) | [inline] |
Minimum acceptable real-world object height (meters) for which this image would make an appropriate texture
Definition at line 63 of file Skins.
{ return _minObjHeight; }
const optional<float>& osgEarth::Symbology::SkinResource::minObjectHeight | ( | ) | const [inline] |
Definition at line 64 of file Skins.
{ return _minObjHeight; }
const optional<osg::TexEnv::Mode>& osgEarth::Symbology::SkinResource::texEnvMode | ( | ) | const [inline] |
Definition at line 76 of file Skins.
{ return _texEnvMode; }
optional<osg::TexEnv::Mode>& osgEarth::Symbology::SkinResource::texEnvMode | ( | ) | [inline] |
GL texture application mode
Definition at line 75 of file Skins.
{ return _texEnvMode; }
optional<float> osgEarth::Symbology::SkinResource::_imageHeight [protected] |
optional<URI> osgEarth::Symbology::SkinResource::_imageURI [protected] |
optional<float> osgEarth::Symbology::SkinResource::_imageWidth [protected] |
optional<bool> osgEarth::Symbology::SkinResource::_isTiled [protected] |
optional<float> osgEarth::Symbology::SkinResource::_maxObjHeight [protected] |
optional<unsigned> osgEarth::Symbology::SkinResource::_maxTexSpan [protected] |
optional<float> osgEarth::Symbology::SkinResource::_minObjHeight [protected] |
optional<osg::TexEnv::Mode> osgEarth::Symbology::SkinResource::_texEnvMode [protected] |