Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

osg::SimpleTexturedMaterial Class Reference
[Materials]

Simple textured Material wrapping standard OpenGL lighting and a single texture. See TexturedSimpleMaterial for a description. More...

#include <OSGSimpleTexturedMaterial.h>

Inheritance diagram for osg::SimpleTexturedMaterial:

osg::SimpleTexturedMaterialBase osg::SimpleMaterial osg::SimpleMaterialBase osg::ChunkMaterial osg::ChunkMaterialBase osg::Material osg::MaterialBase osg::AttachmentContainer osg::FieldContainer List of all members.

Rendering

StatePtr getState (void)
*typedef TypedFunctor1Base<
Action::ResultE, PtrCallArg<
DrawActionBase > > 
DrawFunctor

Public Types

typedef SimpleTexturedMaterialPtr Ptr
enum  {
  ImageFieldId = Inherited::NextFieldId, MinFilterFieldId = ImageFieldId + 1, MagFilterFieldId = MinFilterFieldId + 1, EnvModeFieldId = MagFilterFieldId + 1,
  EnvMapFieldId = EnvModeFieldId + 1, NextFieldId = EnvMapFieldId + 1
}

Public Member Functions

Sync
*virtual void changed (BitVector whichField, UInt32 origin)
Output
*virtual void dump (UInt32 uiIndent=0, const BitVector bvFlags=0) const
Rendering
*virtual StatePtr makeState (void)
virtual void rebuildState (void)
virtual bool isTransparent (void) const
Updates
*void imageChanged (void)
FieldContainer Get
*virtual FieldContainerTypegetType (void)
virtual const FieldContainerTypegetType (void) const
virtual UInt32 getContainerSize (void) const
Field Get
*SFImagePtrgetSFImage (void)
 Get the SimpleTexturedMaterial::_sfImage field.
SFGLenumgetSFMinFilter (void)
 Get the SimpleTexturedMaterial::_sfMinFilter field.
SFGLenumgetSFMagFilter (void)
 Get the SimpleTexturedMaterial::_sfMagFilter field.
SFGLenumgetSFEnvMode (void)
 Get the SimpleTexturedMaterial::_sfEnvMode field.
SFBoolgetSFEnvMap (void)
 Get the SimpleTexturedMaterial::_sfEnvMap field.
ImagePtrgetImage (void)
 Get the value of the SimpleTexturedMaterial::_sfImage field.
const ImagePtrgetImage (void) const
 Get the value of the SimpleTexturedMaterial::_sfImage field.
GLenumgetMinFilter (void)
 Get the value of the SimpleTexturedMaterial::_sfMinFilter field.
const GLenumgetMinFilter (void) const
 Get the value of the SimpleTexturedMaterial::_sfMinFilter field.
GLenumgetMagFilter (void)
 Get the value of the SimpleTexturedMaterial::_sfMagFilter field.
const GLenumgetMagFilter (void) const
 Get the value of the SimpleTexturedMaterial::_sfMagFilter field.
GLenumgetEnvMode (void)
 Get the value of the SimpleTexturedMaterial::_sfEnvMode field.
const GLenumgetEnvMode (void) const
 Get the value of the SimpleTexturedMaterial::_sfEnvMode field.
bool & getEnvMap (void)
 Get the value of the SimpleTexturedMaterial::_sfEnvMap field.
const bool & getEnvMap (void) const
 Get the value of the SimpleTexturedMaterial::_sfEnvMap field.
Field Set
*void setImage (const ImagePtr &value)
 Set the value of the SimpleTexturedMaterial::_sfImage field.
void setMinFilter (const GLenum &value)
 Set the value of the SimpleTexturedMaterial::_sfMinFilter field.
void setMagFilter (const GLenum &value)
 Set the value of the SimpleTexturedMaterial::_sfMagFilter field.
void setEnvMode (const GLenum &value)
 Set the value of the SimpleTexturedMaterial::_sfEnvMode field.
void setEnvMap (const bool &value)
 Set the value of the SimpleTexturedMaterial::_sfEnvMap field.
Binary Access
*virtual UInt32 getBinSize (const BitVector &whichField)
virtual void copyToBin (BinaryDataHandler &pMem, const BitVector &whichField)
virtual void copyFromBin (BinaryDataHandler &pMem, const BitVector &whichField)
Copy
*virtual FieldContainerPtr shallowCopy (void) const
Field Get
*SFColor3fgetSFAmbient (void)
 Get the SimpleMaterial::_sfAmbient field.
SFColor3fgetSFDiffuse (void)
 Get the SimpleMaterial::_sfDiffuse field.
SFColor3fgetSFSpecular (void)
 Get the SimpleMaterial::_sfSpecular field.
SFReal32getSFShininess (void)
 Get the SimpleMaterial::_sfShininess field.
SFColor3fgetSFEmission (void)
 Get the SimpleMaterial::_sfEmission field.
SFReal32getSFTransparency (void)
 Get the SimpleMaterial::_sfTransparency field.
SFBoolgetSFLit (void)
 Get the SimpleMaterial::_sfLit field.
SFGLenumgetSFColorMaterial (void)
 Get the SimpleMaterial::_sfColorMaterial field.
Color3fgetAmbient (void)
 Get the value of the SimpleMaterial::_sfAmbient field.
const Color3fgetAmbient (void) const
 Get the value of the SimpleMaterial::_sfAmbient field.
Color3fgetDiffuse (void)
 Get the value of the SimpleMaterial::_sfDiffuse field.
const Color3fgetDiffuse (void) const
 Get the value of the SimpleMaterial::_sfDiffuse field.
Color3fgetSpecular (void)
 Get the value of the SimpleMaterial::_sfSpecular field.
const Color3fgetSpecular (void) const
 Get the value of the SimpleMaterial::_sfSpecular field.
Real32getShininess (void)
 Get the value of the SimpleMaterial::_sfShininess field.
const Real32getShininess (void) const
 Get the value of the SimpleMaterial::_sfShininess field.
Color3fgetEmission (void)
 Get the value of the SimpleMaterial::_sfEmission field.
const Color3fgetEmission (void) const
 Get the value of the SimpleMaterial::_sfEmission field.
Real32getTransparency (void)
 Get the value of the SimpleMaterial::_sfTransparency field.
const Real32getTransparency (void) const
 Get the value of the SimpleMaterial::_sfTransparency field.
bool & getLit (void)
 Get the value of the SimpleMaterial::_sfLit field.
const bool & getLit (void) const
 Get the value of the SimpleMaterial::_sfLit field.
GLenumgetColorMaterial (void)
 Get the value of the SimpleMaterial::_sfColorMaterial field.
const GLenumgetColorMaterial (void) const
 Get the value of the SimpleMaterial::_sfColorMaterial field.
Field Set
*void setAmbient (const Color3f &value)
 Set the value of the SimpleMaterial::_sfAmbient field.
void setDiffuse (const Color3f &value)
 Set the value of the SimpleMaterial::_sfDiffuse field.
void setSpecular (const Color3f &value)
 Set the value of the SimpleMaterial::_sfSpecular field.
void setShininess (const Real32 &value)
 Set the value of the SimpleMaterial::_sfShininess field.
void setEmission (const Color3f &value)
 Set the value of the SimpleMaterial::_sfEmission field.
void setTransparency (const Real32 &value)
 Set the value of the SimpleMaterial::_sfTransparency field.
void setLit (const bool &value)
 Set the value of the SimpleMaterial::_sfLit field.
void setColorMaterial (const GLenum &value)
 Set the value of the SimpleMaterial::_sfColorMaterial field.
Rendering
*virtual void draw (DrawFunctor &func, DrawActionBase *action)
virtual void draw (Geometry *geo, DrawActionBase *action)
Access
*bool addChunk (StateChunkPtr chunk, Int32 slot=State::AutoSlotReplace)
bool subChunk (StateChunkPtr chunk, Int32 slot=State::AutoSlotReplace)
Int32 find (StateChunkPtr chunk)
StateChunkPtr find (const FieldContainerType &type, Int32 slot=State::AutoSlotReplace)
virtual bool operator== (const Material &other)
Comparison
virtual bool operator== (const Material &other) const
*virtual bool operator< (const Material &other) const
virtual bool operator!= (const Material &other) const
Field Get
*MFStateChunkPtrgetMFChunks (void)
 Get the ChunkMaterial::_mfChunks field.
MFInt32getMFSlots (void)
 Get the ChunkMaterial::_mfSlots field.
StateChunkPtrgetChunks (const UInt32 index)
 Get the value of the index element the ChunkMaterial::_mfChunks field.
MFStateChunkPtrgetChunks (void)
 Get the ChunkMaterial::_mfChunks field.
const MFStateChunkPtrgetChunks (void) const
 Get the ChunkMaterial::_mfChunks field.
Int32getSlots (const UInt32 index)
 Get the value of the index element the ChunkMaterial::_mfSlots field.
MFInt32getSlots (void)
 Get the ChunkMaterial::_mfSlots field.
const MFInt32getSlots (void) const
 Get the ChunkMaterial::_mfSlots field.
Field Get
*SFInt32getSFSortKey (void)
 Get the Material::_sfSortKey field.
Int32getSortKey (void)
 Get the value of the Material::_sfSortKey field.
const Int32getSortKey (void) const
 Get the value of the Material::_sfSortKey field.
Field Set
*void setSortKey (const Int32 &value)
 Set the value of the Material::_sfSortKey field.

Static Public Member Functions

Class Get
*static FieldContainerTypegetClassType (void)
 access the type of the class
static UInt32 getClassTypeId (void)
 access the numerical type of the class
Construction
*static SimpleTexturedMaterialPtr create (void)
 create a new instance of the class
static SimpleTexturedMaterialPtr createEmpty (void)
 create an empty new instance of the class, do not copy the prototype
Class Get
*static const char * getClassname (void)

Static Public Attributes

static const osg::BitVector ImageFieldMask
static const osg::BitVector MinFilterFieldMask
static const osg::BitVector MagFilterFieldMask
static const osg::BitVector EnvModeFieldMask
static const osg::BitVector EnvMapFieldMask
static const osg::BitVector MTInfluenceMask
static const osg::BitVector AmbientFieldMask
static const osg::BitVector DiffuseFieldMask
static const osg::BitVector SpecularFieldMask
static const osg::BitVector ShininessFieldMask
static const osg::BitVector EmissionFieldMask
static const osg::BitVector TransparencyFieldMask
static const osg::BitVector LitFieldMask
static const osg::BitVector ColorMaterialFieldMask
static const osg::BitVector ChunksFieldMask
static const osg::BitVector SlotsFieldMask
static const osg::BitVector SortKeyFieldMask
static const BitVector AttachmentsFieldMask
static const BitVector NextFieldMask
Constants
*static const Int32 NoStateSorting = 0x7fffffff

Protected Member Functions

Constructors
SimpleTexturedMaterial (void)
 SimpleTexturedMaterial (const SimpleTexturedMaterial &source)
Destructors
*virtual ~SimpleTexturedMaterial (void)
Helper
*void prepareLocalChunks (void)
Sync
*void executeSyncImpl (SimpleTexturedMaterialBase *pOther, const BitVector &whichField)
virtual void executeSync (FieldContainer &other, const BitVector &whichField)
Sync
*void executeSyncImpl (SimpleMaterialBase *pOther, const BitVector &whichField)
Sync
*void executeSyncImpl (ChunkMaterialBase *pOther, const BitVector &whichField)
Sync
*void executeSyncImpl (MaterialBase *pOther, const BitVector &whichField)

Protected Attributes

TextureChunkPtr _textureChunk
TexGenChunkPtr _texGenChunk
StatePtr _pState
Fields
*SFImagePtr _sfImage
SFGLenum _sfMinFilter
SFGLenum _sfMagFilter
SFGLenum _sfEnvMode
SFBool _sfEnvMap
Fields
*SFColor3f _sfAmbient
SFColor3f _sfDiffuse
SFColor3f _sfSpecular
SFReal32 _sfShininess
SFColor3f _sfEmission
SFReal32 _sfTransparency
SFBool _sfLit
SFGLenum _sfColorMaterial
Fields
*MFStateChunkPtr _mfChunks
MFInt32 _mfSlots
Fields
*SFInt32 _sfSortKey

Private Types

typedef SimpleTexturedMaterialBase Inherited

Private Member Functions

void operator= (const SimpleTexturedMaterial &source)

Static Private Member Functions

static void initMethod (void)

Friends

class FieldContainer
class SimpleTexturedMaterialBase

Detailed Description

The simple textured material class. See TexturedSimpleMaterial for a description.

A osg::SimpleMaterial with an added texture. It doesn't expose all features of the texture, just the ones needed most often.

osg::SimpleTexturedMaterial::_sfImage defines the texture, osg::SimpleTexturedMaterial::_sfMinFilter and osg::SimpleTexturedMaterial::_sfMagFilter the used filters and osg::SimpleTexturedMaterial::_sfEnvMode the environment mode. As a special case osg::SimpleTexturedMaterial::_sfEnvMap can be used to use the txture as a spherical environment map.

Definition at line 58 of file OSGSimpleTexturedMaterial.h.


Member Typedef Documentation

typedef SimpleTexturedMaterialBase osg::SimpleTexturedMaterial::Inherited [private]
 

Reimplemented from osg::SimpleTexturedMaterialBase.

Definition at line 131 of file OSGSimpleTexturedMaterial.h.

typedef SimpleTexturedMaterialPtr osg::SimpleTexturedMaterialBase::Ptr [inherited]
 

Reimplemented from osg::SimpleMaterialBase.

Definition at line 94 of file OSGSimpleTexturedMaterialBase.h.


Member Enumeration Documentation

anonymous enum [inherited]
 

Enumerator:
ImageFieldId 
MinFilterFieldId 
MagFilterFieldId 
EnvModeFieldId 
EnvMapFieldId 
NextFieldId 

Reimplemented from osg::SimpleMaterialBase.

Definition at line 96 of file OSGSimpleTexturedMaterialBase.h.

00097     {
00098         ImageFieldId     = Inherited::NextFieldId,
00099         MinFilterFieldId = ImageFieldId     + 1,
00100         MagFilterFieldId = MinFilterFieldId + 1,
00101         EnvModeFieldId   = MagFilterFieldId + 1,
00102         EnvMapFieldId    = EnvModeFieldId   + 1,
00103         NextFieldId      = EnvMapFieldId    + 1
00104     };


Constructor & Destructor Documentation

SimpleTexturedMaterial::SimpleTexturedMaterial void   )  [protected]
 

Definition at line 83 of file OSGSimpleTexturedMaterial.cpp.

00083                                                    :
00084     Inherited()
00085 {
00086 }

SimpleTexturedMaterial::SimpleTexturedMaterial const SimpleTexturedMaterial source  )  [protected]
 

Definition at line 88 of file OSGSimpleTexturedMaterial.cpp.

00089                                           :
00090 
00091     Inherited(source)
00092 {
00093 }

SimpleTexturedMaterial::~SimpleTexturedMaterial void   )  [protected, virtual]
 

Definition at line 95 of file OSGSimpleTexturedMaterial.cpp.

References _texGenChunk, _textureChunk, and osg::subRefCP().

00096 {
00097     subRefCP(_textureChunk);
00098     subRefCP(_texGenChunk);
00099 }


Member Function Documentation

void SimpleTexturedMaterial::changed BitVector  whichField,
UInt32  origin
[virtual]
 

Reimplemented from osg::SimpleMaterial.

Definition at line 111 of file OSGSimpleTexturedMaterial.cpp.

References _texGenChunk, _textureChunk, osg::beginEditCP(), osg::SimpleMaterial::changed(), osg::endEditCP(), osg::SimpleTexturedMaterialBase::EnvMapFieldMask, osg::TextureChunkBase::EnvModeFieldMask, osg::SimpleTexturedMaterialBase::EnvModeFieldMask, osg::TexGenChunkBase::GenFuncSFieldMask, osg::TexGenChunkBase::GenFuncTFieldMask, osg::SimpleTexturedMaterialBase::getEnvMap(), osg::SimpleTexturedMaterialBase::getEnvMode(), osg::SimpleTexturedMaterialBase::getImage(), osg::SimpleTexturedMaterialBase::getMagFilter(), osg::SimpleTexturedMaterialBase::getMinFilter(), osg::TextureChunkBase::ImageFieldMask, osg::SimpleTexturedMaterialBase::ImageFieldMask, osg::TextureChunkBase::MagFilterFieldMask, osg::SimpleTexturedMaterialBase::MagFilterFieldMask, osg::TextureChunkBase::MinFilterFieldMask, osg::SimpleTexturedMaterialBase::MinFilterFieldMask, and prepareLocalChunks().

00112 {
00113     prepareLocalChunks();
00114 
00115     // these two are very expensive, as they need to regenerate the
00116     // texture object, do only if really needed
00117 
00118     if(whichField & ImageFieldMask)
00119     {
00120         beginEditCP(_textureChunk, TextureChunk::ImageFieldMask);
00121 
00122         _textureChunk->setImage(getImage());
00123 
00124         endEditCP(_textureChunk, TextureChunk::ImageFieldMask);
00125     }
00126     if(whichField & MinFilterFieldMask || whichField & MagFilterFieldMask)
00127     {
00128         beginEditCP(_textureChunk, TextureChunk::MinFilterFieldMask |
00129                                    TextureChunk::MagFilterFieldMask);
00130 
00131         _textureChunk->setMinFilter(getMinFilter());
00132         _textureChunk->setMagFilter(getMagFilter());
00133 
00134         endEditCP(_textureChunk, TextureChunk::MinFilterFieldMask |
00135                                  TextureChunk::MagFilterFieldMask);
00136     }
00137     // this is not as expensive, but why do it more often then needed?
00138     if(whichField & EnvModeFieldMask)
00139     {
00140         beginEditCP(_textureChunk, TextureChunk::EnvModeFieldMask);
00141 
00142         _textureChunk->setEnvMode(getEnvMode());
00143 
00144         endEditCP(_textureChunk, TextureChunk::EnvModeFieldMask);
00145     }
00146     if(whichField & EnvMapFieldMask)
00147     {
00148         beginEditCP(_texGenChunk, TexGenChunk::GenFuncSFieldMask |
00149                                   TexGenChunk::GenFuncTFieldMask);
00150         
00151         if (getEnvMap())
00152         {
00153             _texGenChunk->setGenFuncS(GL_SPHERE_MAP);
00154             _texGenChunk->setGenFuncT(GL_SPHERE_MAP);
00155         }
00156         else
00157         {
00158             _texGenChunk->setGenFuncS(GL_NONE);
00159             _texGenChunk->setGenFuncT(GL_NONE);
00160         }
00161 
00162         endEditCP(_texGenChunk, TexGenChunk::GenFuncSFieldMask |
00163                                 TexGenChunk::GenFuncTFieldMask);
00164     }
00165 
00166     Inherited::changed(whichField, origin);
00167 }

void SimpleTexturedMaterial::dump UInt32  uiIndent = 0,
const BitVector  bvFlags = 0
const [virtual]
 

Reimplemented from osg::SimpleMaterial.

Definition at line 203 of file OSGSimpleTexturedMaterial.cpp.

References SLOG.

00205 {
00206     SLOG << "Dump SimpleTexturedMaterial NI" << std::endl;
00207 }

StatePtr SimpleTexturedMaterial::makeState void   )  [virtual]
 

Create a osg::State that represents this Material and return it.

Reimplemented from osg::SimpleMaterial.

Definition at line 173 of file OSGSimpleTexturedMaterial.cpp.

References _texGenChunk, _textureChunk, osg::SimpleMaterial::makeState(), and prepareLocalChunks().

00174 {
00175     StatePtr state = Inherited::makeState();
00176 
00177     prepareLocalChunks();
00178 
00179     state->addChunk(_textureChunk);
00180     state->addChunk(_texGenChunk);
00181 
00182     return state;
00183 }

void SimpleTexturedMaterial::rebuildState void   )  [virtual]
 

Rebuild the internal State. Just collects the chunks in the State.

Reimplemented from osg::SimpleMaterial.

Definition at line 185 of file OSGSimpleTexturedMaterial.cpp.

References osg::Material::_pState, _texGenChunk, _textureChunk, prepareLocalChunks(), and osg::SimpleMaterial::rebuildState().

00186 {
00187     Inherited::rebuildState();
00188 
00189     prepareLocalChunks();
00190 
00191     _pState->addChunk(_textureChunk);
00192     _pState->addChunk(_texGenChunk);
00193 }

bool SimpleTexturedMaterial::isTransparent void   )  const [virtual]
 

Check if the Material (i.e. any of its chunks) is transparent..

Reimplemented from osg::SimpleMaterial.

Definition at line 195 of file OSGSimpleTexturedMaterial.cpp.

References osg::SimpleTexturedMaterialBase::getEnvMode(), osg::SimpleTexturedMaterialBase::getImage(), osg::SimpleMaterial::isTransparent(), and osg::NullFC.

00196 {
00197     return Inherited::isTransparent() ||
00198            (getImage()!=NullFC &&
00199              (getImage()->hasAlphaChannel() && getEnvMode() != GL_DECAL)
00200           );
00201 }

void osg::SimpleTexturedMaterial::imageChanged void   )  [inline]
 

As the image data can be manipulated by the user at any time, the system cannot know when that happens. Thus it has to be informed by the application when the texture data has chnaged and the texture needs to be rebuild.

That's what imageChanged is for.

Definition at line 54 of file OSGSimpleTexturedMaterial.inl.

References _textureChunk.

00055 {
00056     _textureChunk->imageContentChanged();
00057 }

void SimpleTexturedMaterial::prepareLocalChunks void   )  [protected]
 

Reimplemented from osg::SimpleMaterial.

Definition at line 214 of file OSGSimpleTexturedMaterial.cpp.

References _texGenChunk, _textureChunk, osg::addRefCP(), osg::TexGenChunkBase::create(), osg::TextureChunkBase::create(), and osg::NullFC.

Referenced by changed(), makeState(), and rebuildState().

00215 {
00216     if(_textureChunk == NullFC)
00217     {
00218         _textureChunk = TextureChunk::create();
00219 
00220          addRefCP(_textureChunk);
00221     }
00222 
00223     if(_texGenChunk == NullFC)
00224     {
00225         _texGenChunk  = TexGenChunk::create();
00226 
00227         addRefCP(_texGenChunk);
00228     }
00229 }

void SimpleTexturedMaterial::initMethod void   )  [static, private]
 

Reimplemented from osg::SimpleMaterial.

Definition at line 103 of file OSGSimpleTexturedMaterial.cpp.

00104 {
00105 }

void osg::SimpleTexturedMaterial::operator= const SimpleTexturedMaterial source  )  [private]
 

osg::FieldContainerType & osg::SimpleTexturedMaterialBase::getClassType void   )  [inline, static, inherited]
 

Reimplemented from osg::SimpleMaterialBase.

Definition at line 58 of file OSGSimpleTexturedMaterialBase.inl.

References osg::SimpleTexturedMaterialBase::_type.

Referenced by osg::SimpleTexturedMaterialBase::create().

00059 {
00060     return _type; 
00061 } 

osg::UInt32 osg::SimpleTexturedMaterialBase::getClassTypeId void   )  [inline, static, inherited]
 

Reimplemented from osg::SimpleMaterialBase.

Definition at line 65 of file OSGSimpleTexturedMaterialBase.inl.

References osg::SimpleTexturedMaterialBase::_type, and osg::TypeBase::getId().

00066 {
00067     return _type.getId(); 
00068 } 

FieldContainerType & SimpleTexturedMaterialBase::getType void   )  [virtual, inherited]
 

Reimplemented from osg::SimpleMaterialBase.

Definition at line 153 of file OSGSimpleTexturedMaterialBase.cpp.

References osg::SimpleTexturedMaterialBase::_type.

00154 {
00155     return _type; 
00156 } 

const FieldContainerType & SimpleTexturedMaterialBase::getType void   )  const [virtual, inherited]
 

Reimplemented from osg::SimpleMaterialBase.

Definition at line 158 of file OSGSimpleTexturedMaterialBase.cpp.

References osg::SimpleTexturedMaterialBase::_type.

00159 {
00160     return _type;
00161 } 

UInt32 SimpleTexturedMaterialBase::getContainerSize void   )  const [virtual, inherited]
 

Reimplemented from osg::SimpleMaterialBase.

Definition at line 173 of file OSGSimpleTexturedMaterialBase.cpp.

00174 { 
00175     return sizeof(SimpleTexturedMaterial); 
00176 }