osgEarth 2.1.1
Public Member Functions | Protected Member Functions | Protected Attributes

osgEarth::Symbology::SkinResource Class Reference

Inheritance diagram for osgEarth::Symbology::SkinResource:
Collaboration diagram for osgEarth::Symbology::SkinResource:

List of all members.

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

Detailed Description

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.

Definition at line 37 of file Skins.


Constructor & Destructor Documentation

SkinResource::SkinResource ( const Config conf = Config())

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

Here is the call graph for this function:


Member Function Documentation

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

Here is the call graph for this function:

Here is the caller graph for this function:

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

Here is the call graph for this function:

Here is the caller graph for this function:

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

Here is the call graph for this function:

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

Here is the call graph for this function:

optional<float>& osgEarth::Symbology::SkinResource::imageHeight ( ) [inline]

Real-world height of the image, in meters

Definition at line 59 of file Skins.

{ return _imageHeight; }

Here is the caller graph for this function:

const optional<float>& osgEarth::Symbology::SkinResource::imageHeight ( ) const [inline]

Definition at line 60 of file Skins.

{ return _imageHeight; }
optional<URI>& osgEarth::Symbology::SkinResource::imageURI ( ) [inline]

Source location of the actual texture image.

Definition at line 51 of file Skins.

{ return _imageURI; }
const optional<URI>& osgEarth::Symbology::SkinResource::imageURI ( ) const [inline]

Definition at line 52 of file Skins.

{ return _imageURI; }
optional<float>& osgEarth::Symbology::SkinResource::imageWidth ( ) [inline]

Real-world width of the image, in meters

Definition at line 55 of file Skins.

{ return _imageWidth; }

Here is the caller graph for this function:

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]

Whether this image is suitable for use as a vertically repeating texture

Definition at line 71 of file Skins.

{ return _isTiled; }

Here is the caller graph for this function:

const optional<bool>& osgEarth::Symbology::SkinResource::isTiled ( ) const [inline]

Definition at line 72 of file Skins.

{ return _isTiled; }
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; }

Here is the caller graph for this function:

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

Here is the call graph for this function:

Here is the caller graph for this function:

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

Here is the caller graph for this function:

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

Here is the caller graph for this function:


Member Data Documentation

Definition at line 97 of file Skins.

Definition at line 95 of file Skins.

Definition at line 96 of file Skins.

Definition at line 100 of file Skins.

Definition at line 99 of file Skins.

Definition at line 102 of file Skins.

Definition at line 98 of file Skins.

Definition at line 101 of file Skins.


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines