NL3D::CMaterialBase Class Reference

#include <animated_material.h>

Inheritance diagram for NL3D::CMaterialBase:

NLMISC::CRefCount

Detailed Description

An material Reference for Animated reference. This object is stored in the mesh, and is serialised. NB: formated for 3ds Max :). Emissive anim is a float, with a constant RGB factor.
Author:
Cyril 'Hulud' Corvazier

Nevrax France

Date:
2001

Definition at line 51 of file animated_material.h.

Public Member Functions

 CMaterialBase ()
void copyFromMaterial (CMaterial *pMat)
const sintgetRefCount () const
void serial (NLMISC::IStream &f)
 save/load.

Texture Animation mgt.
ITexturegetAnimatedTexture (uint32 id)
 return the texture for this Id. return NULL either if NULL texture for this id or if(!validAnimatedTexture()).

void setAnimatedTexture (uint32 id, CSmartPtr< ITexture > pText)
 assign a specific texture for an id (a uint32). It is a valid to give a NULL ptr (=> un textured). Sotred as a SmartPtr.

bool validAnimatedTexture (uint32 id)
 is this Id valid?


Data Fields

sint crefs
CTrackDefaultRGBA DefaultAmbient
CTrackDefaultRGBA DefaultDiffuse
CTrackDefaultRGBA DefaultEmissive
CTrackDefaultFloat DefaultOpacity
CTrackDefaultFloat DefaultShininess
CTrackDefaultRGBA DefaultSpecular
CTexAnimTracks DefaultTexAnimTracks [IDRV_MAT_MAXTEXTURES]
CTrackDefaultInt DefaultTexture
std::string Name
CPtrInfo * pinfo

Static Public Attributes

CPtrInfo NullPtrInfo

Private Types

typedef std::map< uint32,
CAnimatedTexture
TAnimatedTextureMap

Private Attributes

TAnimatedTextureMap _AnimatedTextures

Friends

struct CPtrInfo


Member Typedef Documentation

typedef std::map<uint32, CAnimatedTexture> NL3D::CMaterialBase::TAnimatedTextureMap [private]
 

Definition at line 143 of file animated_material.h.


Constructor & Destructor Documentation

NL3D::CMaterialBase::CMaterialBase  ) 
 

Definition at line 63 of file animated_material.cpp.

References DefaultAmbient, DefaultDiffuse, DefaultEmissive, DefaultOpacity, DefaultShininess, DefaultSpecular, DefaultTexAnimTracks, DefaultTexture, NL3D::IDRV_MAT_MAXTEXTURES, NL3D::CMaterialBase::CTexAnimTracks::setDefaultValue(), NL3D::CTrackDefaultBlendable< sint32 >::setValue(), NL3D::CTrackDefaultBlendable< float >::setValue(), NL3D::CTrackDefaultBlendable< T >::setValue(), and uint.

00064 {
00065         DefaultAmbient.setValue(CRGBA(64,64,64));
00066         DefaultDiffuse.setValue(CRGBA(128,128,128));
00067         DefaultSpecular.setValue(CRGBA(0,0,0));
00068         DefaultShininess.setValue(10);
00069         DefaultEmissive.setValue(CRGBA(128,128,128));
00070         DefaultOpacity.setValue(1);
00071         DefaultTexture.setValue(0x7FFFFFFF);
00072         for (uint k = 0; k < IDRV_MAT_MAXTEXTURES; ++k)
00073         {
00074                 DefaultTexAnimTracks[k].setDefaultValue();
00075         }
00076 }


Member Function Documentation

void NL3D::CMaterialBase::copyFromMaterial CMaterial pMat  ) 
 

setup the default tracks from a material This method:

  • copy the material contents into the Defaults tracks values.

NB: for emissive part, emissive defaut track value is set to 1, and emissive factor is set to the RGB emissive value stored into pMat.

Definition at line 99 of file animated_material.cpp.

References NLMISC::CRGBA::A, NL3D::CMaterial::decompUserTexMat(), DefaultAmbient, DefaultDiffuse, DefaultEmissive, DefaultOpacity, DefaultShininess, DefaultSpecular, DefaultTexAnimTracks, NL3D::CMaterialBase::CTexAnimTracks::DefaultUScale, NL3D::CMaterialBase::CTexAnimTracks::DefaultUTrans, NL3D::CMaterialBase::CTexAnimTracks::DefaultVScale, NL3D::CMaterialBase::CTexAnimTracks::DefaultVTrans, NL3D::CMaterialBase::CTexAnimTracks::DefaultWRot, NL3D::CMaterial::getAmbient(), NL3D::CMaterial::getDiffuse(), NL3D::CMaterial::getEmissive(), NL3D::CMaterial::getShininess(), NL3D::CMaterial::getSpecular(), NL3D::IDRV_MAT_MAXTEXTURES, NL3D::CMaterial::isUserTexMatEnabled(), NL3D::CTrackDefaultBlendable< float >::setValue(), NL3D::CTrackDefaultBlendable< T >::setValue(), and uint.

00100 {
00101         DefaultAmbient.setValue(pMat->getAmbient());
00102         DefaultDiffuse.setValue(pMat->getDiffuse());
00103         DefaultSpecular.setValue(pMat->getSpecular());
00104         DefaultShininess.setValue(pMat->getShininess());
00105         DefaultEmissive.setValue(pMat->getEmissive());
00106         DefaultOpacity.setValue(pMat->getDiffuse().A/255.f);
00107 
00109         for (uint k = 0; k < IDRV_MAT_MAXTEXTURES; ++k)
00110         {
00111                 if (pMat->isUserTexMatEnabled(k))
00112                 {
00113                         float uTrans, vTrans, uScale, vScale, wRot;
00114                         pMat->decompUserTexMat(k, uTrans, vTrans, wRot, uScale, vScale);                        
00115                         DefaultTexAnimTracks[k].DefaultUTrans.setValue(uTrans);
00116                         DefaultTexAnimTracks[k].DefaultVTrans.setValue(vTrans);
00117                         DefaultTexAnimTracks[k].DefaultUScale.setValue(uScale);
00118                         DefaultTexAnimTracks[k].DefaultVScale.setValue(vScale);
00119                         DefaultTexAnimTracks[k].DefaultWRot.setValue(wRot);
00120                 }      
00121         }
00122 }

ITexture * NL3D::CMaterialBase::getAnimatedTexture uint32  id  ) 
 

return the texture for this Id. return NULL either if NULL texture for this id or if(!validAnimatedTexture()).

Definition at line 139 of file animated_material.cpp.

References _AnimatedTextures, and uint32.

00140 {
00141         TAnimatedTextureMap::iterator   it;
00142         it= _AnimatedTextures.find(id);
00143         if( it!=_AnimatedTextures.end() )
00144                 return it->second.Texture;
00145         else
00146                 return NULL;
00147 }

const sint& NLMISC::CRefCount::getRefCount  )  const [inline, inherited]
 

Definition at line 70 of file smart_ptr.h.

References NLMISC::CRefCount::crefs, and sint.

00071         {
00072                 return  crefs;
00073         }

void NL3D::CMaterialBase::serial NLMISC::IStream f  ) 
 

save/load.

Definition at line 80 of file animated_material.cpp.

References _AnimatedTextures, DefaultAmbient, DefaultDiffuse, DefaultEmissive, DefaultOpacity, DefaultShininess, DefaultSpecular, DefaultTexAnimTracks, DefaultTexture, NL3D::IDRV_MAT_MAXTEXTURES, Name, NLMISC::IStream::serial(), NLMISC::IStream::serialCont(), NLMISC::IStream::serialVersion(), sint, and uint.

00081 {
00082         sint    ver= f.serialVersion(1);
00083 
00084         f.serial(Name);
00085         f.serial(DefaultAmbient, DefaultDiffuse, DefaultSpecular);
00086         f.serial(DefaultShininess, DefaultEmissive, DefaultOpacity, DefaultTexture);
00087         f.serialCont(_AnimatedTextures);
00088         if (ver > 0)
00089         {
00090                 for (uint k = 0; k < IDRV_MAT_MAXTEXTURES; ++k)
00091                 {
00092                         f.serial(DefaultTexAnimTracks[k]);
00093                 }
00094         }
00095 }

void NL3D::CMaterialBase::setAnimatedTexture uint32  id,
CSmartPtr< ITexture pText
 

assign a specific texture for an id (a uint32). It is a valid to give a NULL ptr (=> un textured). Sotred as a SmartPtr.

Animated materials support Texture animation. This is the place where you define your list of texture. This list of animated texture is serialised. AnimatedMaterial animate texture with sint32 Tracks. If the id is not found in CMaterialBase, then the CMaterial texture is left as before.

NB: id 0x7FFFFFFF is a reserved id, used as default to indicate no valid Animated texture.

Definition at line 126 of file animated_material.cpp.

References _AnimatedTextures, and uint32.

00127 {
00128         // add or replace the texture.
00129         _AnimatedTextures[id].Texture= pText;
00130 }

bool NL3D::CMaterialBase::validAnimatedTexture uint32  id  ) 
 

is this Id valid?

Definition at line 132 of file animated_material.cpp.

References _AnimatedTextures, and uint32.

00133 {
00134         TAnimatedTextureMap::iterator   it;
00135         it= _AnimatedTextures.find(id);
00136         return it!=_AnimatedTextures.end();
00137 }


Friends And Related Function Documentation

friend struct CPtrInfo [friend, inherited]
 

Definition at line 67 of file smart_ptr.h.


Field Documentation

TAnimatedTextureMap NL3D::CMaterialBase::_AnimatedTextures [private]
 

Definition at line 144 of file animated_material.h.

Referenced by getAnimatedTexture(), serial(), setAnimatedTexture(), and validAnimatedTexture().

sint NLMISC::CRefCount::crefs [mutable, inherited]
 

Definition at line 79 of file smart_ptr.h.

Referenced by NLMISC::CRefCount::CRefCount(), NLMISC::CRefCount::getRefCount(), and NLMISC::CRefCount::~CRefCount().

CTrackDefaultRGBA NL3D::CMaterialBase::DefaultAmbient
 

Definition at line 72 of file animated_material.h.

Referenced by CMaterialBase(), copyFromMaterial(), and serial().

CTrackDefaultRGBA NL3D::CMaterialBase::DefaultDiffuse
 

Definition at line 73 of file animated_material.h.

Referenced by CMaterialBase(), copyFromMaterial(), and serial().

CTrackDefaultRGBA NL3D::CMaterialBase::DefaultEmissive
 

Definition at line 76 of file animated_material.h.

Referenced by CMaterialBase(), copyFromMaterial(), and serial().

CTrackDefaultFloat NL3D::CMaterialBase::DefaultOpacity
 

Definition at line 77 of file animated_material.h.

Referenced by CMaterialBase(), copyFromMaterial(), and serial().

CTrackDefaultFloat NL3D::CMaterialBase::DefaultShininess
 

Definition at line 75 of file animated_material.h.

Referenced by CMaterialBase(), copyFromMaterial(), and serial().

CTrackDefaultRGBA NL3D::CMaterialBase::DefaultSpecular
 

Definition at line 74 of file animated_material.h.

Referenced by CMaterialBase(), copyFromMaterial(), and serial().

CTexAnimTracks NL3D::CMaterialBase::DefaultTexAnimTracks[IDRV_MAT_MAXTEXTURES]
 

Definition at line 109 of file animated_material.h.

Referenced by CMaterialBase(), copyFromMaterial(), and serial().

CTrackDefaultInt NL3D::CMaterialBase::DefaultTexture
 

Definition at line 78 of file animated_material.h.

Referenced by CMaterialBase(), and serial().

std::string NL3D::CMaterialBase::Name
 

Definition at line 68 of file animated_material.h.

Referenced by serial(), and NL3D::CSegRemanenceShape::setAnimatedMaterial().

CRefCount::CPtrInfo NLMISC::CRefCount::NullPtrInfo [static, inherited]
 

Referenced by NLMISC::CRefCount::CRefCount().

CPtrInfo* NLMISC::CRefCount::pinfo [mutable, inherited]
 

Definition at line 80 of file smart_ptr.h.

Referenced by NLMISC::CRefCount::CRefCount(), and NLMISC::CRefCount::~CRefCount().


The documentation for this class was generated from the following files:
Generated on Tue Mar 16 06:50:34 2004 for NeL by doxygen 1.3.6