openscenegraph
Public Types | Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
osg::Material Class Reference

#include <Material>

Inheritance diagram for osg::Material:
osg::StateAttribute osg::Object osg::Referenced

Public Types

enum  Face { FRONT = GL_FRONT , BACK = GL_BACK , FRONT_AND_BACK = GL_FRONT_AND_BACK }
 
enum  ColorMode {
  AMBIENT = GL_AMBIENT , DIFFUSE = GL_DIFFUSE , SPECULAR = GL_SPECULAR , EMISSION = GL_EMISSION ,
  AMBIENT_AND_DIFFUSE = GL_AMBIENT_AND_DIFFUSE , OFF
}
 
- Public Types inherited from osg::StateAttribute
enum  Values {
  OFF = 0x0 , ON = 0x1 , OVERRIDE = 0x2 , PROTECTED = 0x4 ,
  INHERIT = 0x8
}
 
enum  Type {
  TEXTURE , POLYGONMODE , POLYGONOFFSET , MATERIAL ,
  ALPHAFUNC , ANTIALIAS , COLORTABLE , CULLFACE ,
  FOG , FRONTFACE , LIGHT , POINT ,
  LINEWIDTH , LINESTIPPLE , POLYGONSTIPPLE , SHADEMODEL ,
  TEXENV , TEXENVFILTER , TEXGEN , TEXMAT ,
  LIGHTMODEL , BLENDFUNC , BLENDEQUATION , LOGICOP ,
  STENCIL , COLORMASK , DEPTH , VIEWPORT ,
  SCISSOR , BLENDCOLOR , MULTISAMPLE , CLIPPLANE ,
  COLORMATRIX , VERTEXPROGRAM , FRAGMENTPROGRAM , POINTSPRITE ,
  PROGRAM , CLAMPCOLOR , HINT , SAMPLEMASKI ,
  PRIMITIVERESTARTINDEX , CLIPCONTROL , VALIDATOR , VIEWMATRIXEXTRACTOR ,
  OSGNV_PARAMETER_BLOCK , OSGNVEXT_TEXTURE_SHADER , OSGNVEXT_VERTEX_PROGRAM , OSGNVEXT_REGISTER_COMBINERS ,
  OSGNVCG_PROGRAM , OSGNVSLANG_PROGRAM , OSGNVPARSE_PROGRAM_PARSER , UNIFORMBUFFERBINDING ,
  TRANSFORMFEEDBACKBUFFERBINDING , ATOMICCOUNTERBUFFERBINDING , PATCH_PARAMETER , FRAME_BUFFER_OBJECT ,
  VERTEX_ATTRIB_DIVISOR , SHADERSTORAGEBUFFERBINDING , INDIRECTDRAWBUFFERBINDING , VIEWPORTINDEXED ,
  DEPTHRANGEINDEXED , SCISSORINDEXED , BINDIMAGETEXTURE , SAMPLER ,
  CAPABILITY = 100
}
 
typedef GLenum GLMode
 
typedef unsigned int GLModeValue
 
typedef unsigned int OverrideValue
 
typedef std::pair< Type, unsigned int > TypeMemberPair
 
typedef std::vector< StateSet * > ParentList
 
typedef osg::StateAttributeCallback Callback
 
- Public Types inherited from osg::Object
enum  DataVariance { DYNAMIC , STATIC , UNSPECIFIED }
 

Public Member Functions

 Material ()
 
 Material (const Material &mat, const CopyOp &copyop=CopyOp::SHALLOW_COPY)
 
 META_StateAttribute (osg, Material, MATERIAL)
 
virtual int compare (const StateAttribute &sa) const
 
Material & operator= (const Material &rhs)
 
virtual bool getModeUsage (StateAttribute::ModeUsage &) const
 
virtual void apply (State &state) const
 
void setColorMode (ColorMode mode)
 
ColorMode getColorMode () const
 
void setAmbient (Face face, const Vec4 &ambient)
 
const Vec4 & getAmbient (Face face) const
 
bool getAmbientFrontAndBack () const
 
void setDiffuse (Face face, const Vec4 &diffuse)
 
const Vec4 & getDiffuse (Face face) const
 
bool getDiffuseFrontAndBack () const
 
void setSpecular (Face face, const Vec4 &specular)
 
const Vec4 & getSpecular (Face face) const
 
bool getSpecularFrontAndBack () const
 
void setEmission (Face face, const Vec4 &emission)
 
const Vec4 & getEmission (Face face) const
 
bool getEmissionFrontAndBack () const
 
void setShininess (Face face, float shininess)
 
float getShininess (Face face) const
 
bool getShininessFrontAndBack () const
 
void setTransparency (Face face, float trans)
 
void setAlpha (Face face, float alpha)
 
- Public Member Functions inherited from osg::StateAttribute
 StateAttribute ()
 
 StateAttribute (const StateAttribute &sa, const CopyOp &copyop=CopyOp::SHALLOW_COPY)
 
virtual Object * cloneType () const =0
 
virtual Object * clone (const CopyOp &) const =0
 
virtual bool isSameKindAs (const Object *obj) const
 
virtual const char * libraryName () const
 
virtual const char * className () const
 
virtual StateAttribute * asStateAttribute ()
 
virtual const StateAttribute * asStateAttribute () const
 
virtual Texture * asTexture ()
 
virtual const Texture * asTexture () const
 
virtual Type getType () const =0
 
virtual unsigned int getMember () const
 
TypeMemberPair getTypeMemberPair () const
 
virtual bool isTextureAttribute () const
 
bool operator< (const StateAttribute &rhs) const
 
bool operator== (const StateAttribute &rhs) const
 
bool operator!= (const StateAttribute &rhs) const
 
const ParentList & getParents () const
 
StateSet * getParent (unsigned int i)
 
const StateSet * getParent (unsigned int i) const
 
unsigned int getNumParents () const
 
void setShaderComponent (ShaderComponent *sc)
 
ShaderComponent * getShaderComponent ()
 
const ShaderComponent * getShaderComponent () const
 
virtual bool checkValidityOfAssociatedModes (osg::State &) const
 
void setUpdateCallback (StateAttributeCallback *uc)
 
StateAttributeCallback * getUpdateCallback ()
 
const StateAttributeCallback * getUpdateCallback () const
 
void setEventCallback (StateAttributeCallback *ec)
 
StateAttributeCallback * getEventCallback ()
 
const StateAttributeCallback * getEventCallback () const
 
virtual void compileGLObjects (State &) const
 
virtual void resizeGLObjectBuffers (unsigned int)
 
virtual void releaseGLObjects (State *=0) const
 
- Public Member Functions inherited from osg::Object
 Object ()
 
 Object (bool threadSafeRefUnref)
 
 Object (const Object &, const CopyOp &copyop=CopyOp::SHALLOW_COPY)
 
std::string getCompoundClassName () const
 
virtual Node * asNode ()
 
virtual const Node * asNode () const
 
virtual NodeVisitor * asNodeVisitor ()
 
virtual const NodeVisitor * asNodeVisitor () const
 
virtual StateSet * asStateSet ()
 
virtual const StateSet * asStateSet () const
 
virtual Uniform * asUniform ()
 
virtual const Uniform * asUniform () const
 
virtual Camera * asCamera ()
 
virtual const Camera * asCamera () const
 
virtual Drawable * asDrawable ()
 
virtual const Drawable * asDrawable () const
 
virtual Callback * asCallback ()
 
virtual const Callback * asCallback () const
 
virtual CallbackObject * asCallbackObject ()
 
virtual const CallbackObject * asCallbackObject () const
 
virtual UserDataContainer * asUserDataContainer ()
 
virtual const UserDataContainer * asUserDataContainer () const
 
virtual ValueObject * asValueObject ()
 
virtual const ValueObject * asValueObject () const
 
virtual Image * asImage ()
 
virtual const Image * asImage () const
 
virtual void setThreadSafeRefUnref (bool threadSafe)
 
virtual void setName (const std::string &name)
 
void setName (const char *name)
 
const std::string & getName () const
 
void setDataVariance (DataVariance dv)
 
DataVariance getDataVariance () const
 
virtual void computeDataVariance ()
 
void setUserDataContainer (osg::UserDataContainer *udc)
 
template<class T >
void setUserDataContainer (const ref_ptr< T > &udc)
 
osg::UserDataContainer * getUserDataContainer ()
 
const osg::UserDataContainer * getUserDataContainer () const
 
osg::UserDataContainer * getOrCreateUserDataContainer ()
 
virtual void setUserData (Referenced *obj)
 
template<class T >
void setUserData (const ref_ptr< T > &ud)
 
virtual Referenced * getUserData ()
 
virtual const Referenced * getUserData () const
 
template<typename T >
bool getUserValue (const std::string &name, T &value) const
 
template<typename T >
void setUserValue (const std::string &name, const T &value)
 
template<typename T >
BoolValueObject UCharValueObject UShortValueObject UIntValueObject DoubleValueObject Vec3fValueObject Vec2dValueObject Vec4dValueObject PlaneValueObject MatrixdValueObject BoundingBoxdValueObject BoundingSpheredValueObject bool getUserValue (const std::string &name, T &value) const
 
- Public Member Functions inherited from osg::Referenced
 Referenced ()
 
 Referenced (bool threadSafeRefUnref)
 
 Referenced (const Referenced &)
 
Referenced & operator= (const Referenced &)
 
bool getThreadSafeRefUnref () const
 
OpenThreads::Mutex * getRefMutex () const
 
int ref () const
 
int unref () const
 
int unref_nodelete () const
 
int referenceCount () const
 
ObserverSet * getObserverSet () const
 
ObserverSet * getOrCreateObserverSet () const
 
void addObserver (Observer *observer) const
 
void removeObserver (Observer *observer) const
 

Protected Member Functions

virtual ~Material ()
 
- Protected Member Functions inherited from osg::StateAttribute
virtual ~StateAttribute ()
 
void addParent (osg::StateSet *object)
 
void removeParent (osg::StateSet *object)
 
- Protected Member Functions inherited from osg::Object
virtual ~Object ()
 
- Protected Member Functions inherited from osg::Referenced
virtual ~Referenced ()
 
void signalObserversAndDelete (bool signalDelete, bool doDelete) const
 
void deleteUsingDeleteHandler () const
 

Protected Attributes

ColorMode _colorMode
 
bool _ambientFrontAndBack
 
Vec4 _ambientFront
 
Vec4 _ambientBack
 
bool _diffuseFrontAndBack
 
Vec4 _diffuseFront
 
Vec4 _diffuseBack
 
bool _specularFrontAndBack
 
Vec4 _specularFront
 
Vec4 _specularBack
 
bool _emissionFrontAndBack
 
Vec4 _emissionFront
 
Vec4 _emissionBack
 
bool _shininessFrontAndBack
 
float _shininessFront
 
float _shininessBack
 
- Protected Attributes inherited from osg::StateAttribute
ParentList _parents
 
ref_ptr< ShaderComponent > _shaderComponent
 
ref_ptr< StateAttributeCallback > _updateCallback
 
ref_ptr< StateAttributeCallback > _eventCallback
 
- Protected Attributes inherited from osg::Object
std::string _name
 
DataVariance _dataVariance
 
osg::UserDataContainer * _userDataContainer
 
- Protected Attributes inherited from osg::Referenced
OpenThreads::AtomicPtr _observerSet
 
OpenThreads::Atomic _refCount
 

Additional Inherited Members

- Static Public Member Functions inherited from osg::Referenced
static OpenThreads::Mutex * getGlobalReferencedMutex ()
 
static void setDeleteHandler (DeleteHandler *handler)
 
static DeleteHandler * getDeleteHandler ()
 

Detailed Description

Material - encapsulates OpenGL glMaterial state.

Member Enumeration Documentation

◆ ColorMode

Enumerator
AMBIENT 
DIFFUSE 
SPECULAR 
EMISSION 
AMBIENT_AND_DIFFUSE 
OFF 

◆ Face

Enumerator
FRONT 
BACK 
FRONT_AND_BACK 

Constructor & Destructor Documentation

◆ Material() [1/2]

osg::Material::Material ( )

◆ Material() [2/2]

osg::Material::Material ( const Material &  mat,
const CopyOp &  copyop = CopyOp::SHALLOW_COPY 
)
inline

Copy constructor using CopyOp to manage deep vs shallow copy.

◆ ~Material()

virtual osg::Material::~Material ( )
protectedvirtual

Member Function Documentation

◆ apply()

virtual void osg::Material::apply ( State &  ) const
virtual

apply the OpenGL state attributes. The render info for the current OpenGL context is passed in to allow the StateAttribute to obtain details on the the current context and state.

Reimplemented from osg::StateAttribute.

◆ compare()

virtual int osg::Material::compare ( const StateAttribute &  sa) const
inlinevirtual

return -1 if *this < *rhs, 0 if *this==*rhs, 1 if *this>*rhs.

Implements osg::StateAttribute.

◆ getAmbient()

const Vec4 & osg::Material::getAmbient ( Face  face) const

◆ getAmbientFrontAndBack()

bool osg::Material::getAmbientFrontAndBack ( ) const
inline

◆ getColorMode()

ColorMode osg::Material::getColorMode ( ) const
inline

◆ getDiffuse()

const Vec4 & osg::Material::getDiffuse ( Face  face) const

◆ getDiffuseFrontAndBack()

bool osg::Material::getDiffuseFrontAndBack ( ) const
inline

◆ getEmission()

const Vec4 & osg::Material::getEmission ( Face  face) const

Get the emission value for specified face.

◆ getEmissionFrontAndBack()

bool osg::Material::getEmissionFrontAndBack ( ) const
inline

Return whether emission values are equal for front and back faces or not.

◆ getModeUsage()

virtual bool osg::Material::getModeUsage ( StateAttribute::ModeUsage &  ) const
inlinevirtual

Return the modes associated with this StateAttribute.

Reimplemented from osg::StateAttribute.

◆ getShininess()

float osg::Material::getShininess ( Face  face) const

Get the shininess value for specified face.

◆ getShininessFrontAndBack()

bool osg::Material::getShininessFrontAndBack ( ) const
inline

Return whether shininess values are equal for front and back faces or not.

◆ getSpecular()

const Vec4 & osg::Material::getSpecular ( Face  face) const

Get the specular value for specified face.

◆ getSpecularFrontAndBack()

bool osg::Material::getSpecularFrontAndBack ( ) const
inline

Return whether specular values are equal for front and back faces or not.

◆ META_StateAttribute()

osg::Material::META_StateAttribute ( osg  ,
Material  ,
MATERIAL   
)

◆ operator=()

Material & osg::Material::operator= ( const Material &  rhs)

◆ setAlpha()

void osg::Material::setAlpha ( Face  face,
float  alpha 
)

Set the alpha value of ambient, diffuse, specular and emission colors. Valid transparency range is 0.0 to 1.0.

◆ setAmbient()

void osg::Material::setAmbient ( Face  face,
const Vec4 &  ambient 
)

◆ setColorMode()

void osg::Material::setColorMode ( ColorMode  mode)
inline

◆ setDiffuse()

void osg::Material::setDiffuse ( Face  face,
const Vec4 &  diffuse 
)

◆ setEmission()

void osg::Material::setEmission ( Face  face,
const Vec4 &  emission 
)

Set emission value of specified face(s) of the material, valid emission[0..3] range is 0.0 to 1.0.

◆ setShininess()

void osg::Material::setShininess ( Face  face,
float  shininess 
)

Set shininess of specified face(s) of the material. valid shininess range is 0.0 to 128.0.

◆ setSpecular()

void osg::Material::setSpecular ( Face  face,
const Vec4 &  specular 
)

Set specular value of specified face(s) of the material, valid specular[0..3] range is 0.0 to 1.0.

◆ setTransparency()

void osg::Material::setTransparency ( Face  face,
float  trans 
)

Set the alpha value of ambient, diffuse, specular and emission colors of specified face, to 1-transparency. Valid transparency range is 0.0 to 1.0.

Member Data Documentation

◆ _ambientBack

Vec4 osg::Material::_ambientBack
protected

◆ _ambientFront

Vec4 osg::Material::_ambientFront
protected

◆ _ambientFrontAndBack

bool osg::Material::_ambientFrontAndBack
protected

◆ _colorMode

ColorMode osg::Material::_colorMode
protected

◆ _diffuseBack

Vec4 osg::Material::_diffuseBack
protected

◆ _diffuseFront

Vec4 osg::Material::_diffuseFront
protected

◆ _diffuseFrontAndBack

bool osg::Material::_diffuseFrontAndBack
protected

◆ _emissionBack

Vec4 osg::Material::_emissionBack
protected

◆ _emissionFront

Vec4 osg::Material::_emissionFront
protected

◆ _emissionFrontAndBack

bool osg::Material::_emissionFrontAndBack
protected

◆ _shininessBack

float osg::Material::_shininessBack
protected

◆ _shininessFront

float osg::Material::_shininessFront
protected

◆ _shininessFrontAndBack

bool osg::Material::_shininessFrontAndBack
protected

◆ _specularBack

Vec4 osg::Material::_specularBack
protected

◆ _specularFront

Vec4 osg::Material::_specularFront
protected

◆ _specularFrontAndBack

bool osg::Material::_specularFrontAndBack
protected

The documentation for this class was generated from the following file: