Polygon Crucher SDK - Documentation
Documentation
Loading...
Searching...
No Matches
C3DPbrMaterial Class Reference

C3DPbrMaterial defines a PBR material which is used by different file formats such GLTF or FBX. More...

Detailed Description

C3DPbrMaterial defines a PBR material which is used by different file formats such GLTF or FBX.

#include <3DMaterial.h>

Inheritance diagram for C3DPbrMaterial:
C3DMaterial C3DKeyframable C3DAnimatable

Public Types

enum  PbrInputFormat { UNDEFINED_INPUT_FORMAT = -1 , FROM_3DSMAX = 0 , FROM_MAYA }
 
enum  DataID { PBR_INPUT_FORMAT = MAKE_CUSTOM_ID('P', 'B', 'F', 'M') , OCCLUSION_STRENGTH = MAKE_CUSTOM_ID('S', 'T', 'R', 'N') , EMISSIVE_COLOR = MAKE_CUSTOM_ID('E', 'M', 'C', 'R') }
 This enum is used in the serialization process to load/save specific C3DPbrMaterial properties.
 
typedef enum C3DPbrMaterial::PbrInputFormat PbrInputFormat
 
typedef enum C3DPbrMaterial::DataID DataID
 
- Public Types inherited from C3DMaterial
enum  _faceModeEnum { FACE_DEFAULT_MODE = 0 , SINGLE_SIDE , DOUBLE_SIDE }
 
enum  _alphaModeEnum { ALPHA_BLEND = 0x01 , ALPHA_OPAQUE = 0x02 }
 
enum  AdjustMaterialFlags { ADJUST_NONE = 0 , ADJUST_DIFFUSE_IF_NO_MODULATION = 0x01 }
 
typedef enum C3DMaterial::_faceModeEnum faceModeEnum
 
typedef enum C3DMaterial::_alphaModeEnum alphaModeEnum
 
typedef enum C3DMaterial::AdjustMaterialFlags AdjustMaterialFlags
 
- Public Types inherited from C3DKeyframable
enum  TimeStamp { INVALID_TIME = -1 }
 
enum  KeyframeFlags { KEYFRAME_NONE = 0x00 , KEYFRAME_REPLACE_KEY = 0x01 , KEYFRAME_DONT_EVALUATE = 0x02 }
 
typedef enum C3DKeyframable::TimeStamp TimeStamp
 
- Public Types inherited from C3DAnimatable
enum  FindKey { KEYFRAME_PREV = 0x01 , KEYFRAME_NEXT = 0x02 , KEYFRAME_SAME = 0x04 }
 

Public Member Functions

virtual C3DStandardMaterialConvertToStandardMaterial (bool replaceCurrentByStandardMaterial)
 Return a standard material from the given material. If deleteCurrentAndReplaceByNewOne = false, the returned materials must be attached to CMaterials list, or deleted when no more need. If deleteCurrentAndReplaceByNewOne = true, the current material is destroyed (if not already a standard material) and the new standard is added to materials list to which the material is attached.
 
virtual void Serialize (CXArchive &ar)
 
virtual C3DMaterialoperator= (const C3DMaterial &refmat)
 
virtual bool HasSameParameters (const C3DMaterial &refmat) const
 Compare only the settings (not the name)
 
void SetMetallicFactor (unsigned int time, float value)
 
float GetMetallicFactor (unsigned int time) const
 
void SetRoughnessFactor (unsigned int time, float value)
 
float GetRoughnessFactor (unsigned int time) const
 
void SetEmissiveColor (unsigned int time, const CRGBColor &color)
 
void SetEmissiveFactor (unsigned int time, float value)
 
CRGBColor GetEmissiveColor (unsigned int time) const
 
float GetEmissiveFactor (unsigned int time) const
 
void SetOcclusionStrengthFactor (unsigned int time, float value)
 
float GetOcclusionStrengthFactor (unsigned int time) const
 
- Public Member Functions inherited from C3DMaterial
 C3DMaterial ()
 Use CMaterials::CreateNewMaterial if the material is intended to belong to a material scene list.
 
CMaterialsGetMaterials () const
 
C3DSceneGetScene () const
 The materials to which the material is attached. NULL if material not already attached to anything.
 
MATERIAL_CLASS GetClass () const
 
MaterialID SetMaterialID (MaterialID refID=MATERIAL_UNDEFINED)
 Create a new material with the given MaterialID. If material is not attached to a material list, then provided id is always used. If the material is already attached to a material list, provided id might be modified if it is already used by the materials list. Note: if you intend to change a materialID which is already in the material list, you should remove it from the list before.
 
MaterialID GetMaterialID () const
 
unsigned int GetFlags ()
 
void SetFlags (unsigned int flags, bool set)
 
void SetFlag (MATERIAL_FLAGS flag, bool set)
 
bool IsOneFlagSet (unsigned int flags) const
 
bool IsFlagSet (MATERIAL_FLAGS flag) const
 
CCustomDataGetCustomData ()
 
const CCustomDataGetCustomData () const
 
void Inherit (const C3DMaterial *refmat)
 Inherit basic information from refmat (mainly C3DMaterial information such name, materialID, flags, KeyframableID, DataID,...). The material should not be attached to any material list (materialid.
 
virtual void ChangeChannelID (CHashMap< CChannelInfo, const CChannelInfo &, CChannelInfo > &channelMap)
 Remap the materialmap channel ID to the new channelID provided by the map. Used mainly internally when concatenating different mesh for example.
 
CXString GetName (void) const
 Get material name.
 
void SetName (const CXString &)
 Set material name.
 
void SetAlphaMode (unsigned int time, alphaModeEnum mode, float cutOffCoef=0.0f)
 Set alpha cut and cutoff coef.
 
float GetAlphaModeCutoffCoef (unsigned int time) const
 Get cutoff coef.
 
alphaModeEnum GetAlphaMode () const
 Get alpha mode.
 
void SetTransparencyFactor (unsigned int time, float value)
 
float GetTransparencyFactor (unsigned int time) const
 
virtual bool IsTransparent (unsigned int time, bool checkDiffuseAlpha=false) const
 
void SetFaceMode (faceModeEnum mode)
 Set single / double face material mode.
 
faceModeEnum GetFaceMode (void) const
 Get single / double face material mode.
 
void SetSmoothAngle (unsigned int time, float value)
 Set normal break angle.
 
float GetSmoothAngle (unsigned int time) const
 Get normal break angle.
 
bool operator== (const C3DMaterial &refmat) const
 Compare 2 materials (name and settings)
 
bool AdjustMaterial (unsigned int flags)
 flags is one or more AdjustMaterialFlags. return true if the material changed
 
bool CopyTextures (const CXString &dstfolder, bool overwriteIfExists=false)
 Copy all material maps to the given path and update pathss.
 
bool IsGenerateUVWNeeded (MapType type=MAPTYPE_UNDEFINED) const
 Return true if one of the map has a projection mode that require UVW to be generated, for all the map type (type == MAPTYPE_UNDEFINED) or for the specific MapType (type = MAPTYPE_DIFFUSE for example)
 
unsigned int CreateMissingUVWBackChannels (const CGeomInfo *info, MapType type=MAPTYPE_UNDEFINED, CHANNEL_PROPERTIES channelTagFlag=CHANNEL_NONE) const
 Copy front UVW channels to back channels if back are missing. If type = MAPTYPE_UNDEFINED, then all maps are checked, otherwise only the provided map.
 
void AdjustPaths (const CXString &targetPath, bool relativePathAllowed)
 Make internal filenames used by materials relative to provided path.
 
void SetDiffuseColor (unsigned int time, const CRGBColor &color)
 
virtual CRGBColor GetDiffuseColor (unsigned int time, bool modulateByDiffuseFactor=false) const
 This can be overidden as derived class might have a different computation for this.
 
void FloatGetDiffuseColor (unsigned int time, float color[4], bool modulateByDiffuseFactor=false) const
 
void SetDiffuseFactor (unsigned int time, float value)
 
float GetDiffuseFactor (unsigned int time) const
 
void SetVertexColor (unsigned int time, ChannelID channel, float modulationCoef=1.0f, unsigned int channelFlags=CMaterialMap::MAPCHANNEL_UNSPECIFIED)
 
ChannelID GetVertexColor (unsigned int time, float &modulationCoef, unsigned int *channelFlags=NULL) const
 
bool RemoveVertexColor ()
 
ChannelID GetUVWChannelID (const CGeomInfo *info, MapType maptype, bool front=true) const
 
int GetRequiredUVWChannelID (const CGeomInfo *info, CHashTable< ChannelID > &channels, MapType maptype=MAPTYPE_UNDEFINED, bool clearMap=true) const
 
ChannelID GetVCChannelID (const CGeomInfo *info, unsigned int time, float &value) const
 
int GetRequiredVCChannelID (const CGeomInfo *info, CHashTable< ChannelID > &channels, MapType maptype=MAPTYPE_UNDEFINED, bool clearMap=true) const
 
CMaterialMapAddMaterialMap (MapType type)
 
CMaterialMapAddMaterialMap (const CXString &filename, ChannelID id, MapType type, MapProjection projection, unsigned int channelFlags=CMaterialMap::MAPCHANNEL_NONE)
 
HashPos GetFirstMap ()
 
CMaterialMapGetNextMap (HashPos &pos, MapType &type)
 
bool RemoveMaterialMap (MapType type)
 
CMaterialMapGetMaterialMap (MapType type)
 
const CMaterialMapGetMaterialMap (MapType type) const
 
- Public Member Functions inherited from C3DKeyframable
int AddKey (int time, C3DKeyframe *newkey)
 Return -1 if fails or keyframe number.
 
int AddKey (int time, const C3DKeyframe &newkey)
 Return keyframe number.
 
int DeleteKey (int time, longuint classid=KEYFRAME_NULLID)
 If time = INVALID_TIME, then all key of classid are deleted or all keys are deleted if classid = KEYFRAME_NULLID.
 
void DeleteAllKeys ()
 
C3DKeyframeCreateKey (int time, longuint classid, unsigned int flags=KEYFRAME_NONE)
 Create key of the given classid. flags is one or more KeyframeFlags.
 
C3DKeyframeGetKeyByIndex (unsigned int index, int *time=NULL, longuint classid=KEYFRAME_NULLID)
 This invalidate the cache, and can lead to slower computation.
 
const C3DKeyframeGetConstKeyByIndex (unsigned int index, int *time=NULL, longuint classid=KEYFRAME_NULLID) const
 
int GetKeyNbr (longuint classid=KEYFRAME_NULLID) const
 
bool Evaluate (int time, C3DKeyframe &findkey) const
 This method evaluate the key at the given time. Same but slower that the following method that return a pointer.
 
const C3DKeyframeEvaluate (int time, longuint classid) const
 This method evaluate the key at the given time. This is the fastest method. The key content cannot be changed.
 
int CopyKeys (const C3DKeyframable *srckeys, longuint classid=KEYFRAME_NULLID, CTimeRange range=CTimeRange(0, CTimeRange::MAX_TIME))
 Copy key of the given classid in the given time range.
 
bool operator== (const C3DKeyframable &refkeys) const
 
bool operator= (const C3DKeyframable &key)
 
virtual void OnKeyframesChanged (longuint classID) const
 
virtual CTimeRange GetTimeRange (longuint classid=KEYFRAME_NULLID) const
 
virtual const C3DKeyframeGetConstKey (int time, unsigned int findKeyFlag, longuint classid=KEYFRAME_NULLID, int *findKeyTime=NULL) const
 Retrieve a keyframe at / before or after the specified time depending on findKeyFlag.
 
- Public Member Functions inherited from C3DAnimatable
int GetKeyTime (int time, unsigned int pos, longuint classid=KEYFRAME_NULLID)
 

Additional Inherited Members

- Static Public Member Functions inherited from C3DMaterial
static C3DMaterialCreate (MATERIAL_CLASS materialClass)
 Create a C3DMaterial. Equivalent to xNew(C3DMaterial)
 

Member Function Documentation

◆ ConvertToStandardMaterial()

virtual C3DStandardMaterial * C3DPbrMaterial::ConvertToStandardMaterial ( bool  replaceCurrentByStandardMaterial)
virtual

Return a standard material from the given material. If deleteCurrentAndReplaceByNewOne = false, the returned materials must be attached to CMaterials list, or deleted when no more need. If deleteCurrentAndReplaceByNewOne = true, the current material is destroyed (if not already a standard material) and the new standard is added to materials list to which the material is attached.

Reimplemented from C3DMaterial.

◆ HasSameParameters()

virtual bool C3DPbrMaterial::HasSameParameters ( const C3DMaterial refmat) const
virtual

Compare only the settings (not the name)

Reimplemented from C3DMaterial.

◆ operator=()

virtual C3DMaterial & C3DPbrMaterial::operator= ( const C3DMaterial refmat)
virtual

Reimplemented from C3DMaterial.

◆ Serialize()

virtual void C3DPbrMaterial::Serialize ( CXArchive ar)
virtual

Reimplemented from C3DMaterial.


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