6#if !defined(AFX_3DMaterial_H__CA6BC29F_FAC2_11D1_A0DE_000000000000__INCLUDED_)
7#define AFX_3DMaterial_H__CA6BC29F_FAC2_11D1_A0DE_000000000000__INCLUDED_
19BEGIN_MOOTOOLS_NAMESPACE
21#define MATERIAL_GUID_CLASS MAKE_CUSTOM_ID('M', 'A', 'T', 'R')
27 MATERIAL_COPY_DEFAULT = 0x00,
28 MATERIAL_COPY_KEEP_ID = 0x01,
29 MATERIAL_COPY_REMOVE_ALL = 0x02,
30 MATERIAL_COPY_USE_HASH = 0x04,
38 MATERIAL_FLAGS_MASK = 0x000FFFFF,
39 MATERIAL_IS_HIDDEN = 0x01,
42 MATERIAL_INVALIDATION_MASK = 0xFFF00000,
43 MATERIAL_NAME_CHANGED = 0x00100000,
44 MATERIAL_MAPS_CHANGED = 0x00200000,
45 MATERIAL_COLORS_CHANGED = 0x00400000,
46 MATERIAL_OTHERS_CHANGED = 0x00800000,
47 MATERIAL_MAPS_DOWNLOADED = 0x01000000,
54 MATERIAL_CLASS_UNDEFINED = 0,
73 typedef enum _faceModeEnum
XEnumType(
unsigned int)
75 FACE_DEFAULT_MODE = 0,
91 MATERIAL_ALPHA_MODE = MAKE_CUSTOM_ID(
'A',
'P',
'M',
'D'),
92 MATERIAL_FACE_CULLMODE = MAKE_CUSTOM_ID(
'F',
'C',
'C',
'M'),
93 MAT_VC_CHANNEL_ID = MAKE_CUSTOM_ID(
'V',
'C',
'I',
'D'),
94 MAT_VC_CHANNEL_FLAGS = MAKE_CUSTOM_ID(
'V',
'C',
'F',
'G'),
111 unsigned int materialFlags;
120 MaterialID materialID;
121 faceModeEnum faceMode;
123 unsigned int vertexColorFlags;
127 virtual unsigned int GetHashValue()
const;
139 CMaterials* GetMaterials()
const {
return materials; };
143 return materialClass;
147 MaterialID GetMaterialID()
const;
149 unsigned int GetFlags() {
return materialFlags; }
150 void SetFlags(
unsigned int flags,
bool set);
152 bool IsOneFlagSet(
unsigned int flags)
const;
174 void SetTransparencyFactor(
unsigned int time,
float value);
175 float GetTransparencyFactor(
unsigned int time)
const;
189 void SetDiffuseColor(
unsigned int time,
const CRGBColor& color);
193 void SetDiffuseFactor(
unsigned int time,
float value);
194 float GetDiffuseFactor(
unsigned int time)
const;
202 bool RemoveVertexColor();
213 ADJUST_DIFFUSE_IF_NO_MODULATION = 0x01,
214 } AdjustMaterialFlags;
230 ChannelID GetVCChannelID(
const CGeomInfo* info,
unsigned int time,
float& value)
const;
239 HashPos GetFirstMap();
242 bool RemoveMaterialMap(
MapType type);
285 void SetAmbientColor(
unsigned int time,
const CRGBColor& color);
287 void FloatGetAmbientColor(
unsigned int time,
float color[4]);
293 void SetSpecularColor(
unsigned int time,
const CRGBColor& color);
294 CRGBColor GetSpecularColor(
unsigned int time)
const;
295 void FloatGetSpecularColor(
unsigned int time,
float color[4])
const;
298 void SetBumpFactor(
unsigned int time,
float value);
299 float GetBumpFactor(
unsigned int time)
const;
302 void SetAmbientFactor(
unsigned int time,
float value);
303 float GetAmbientFactor(
unsigned int time)
const;
305 void SetSpecularFactor(
unsigned int time,
float value);
306 float GetSpecularFactor(
unsigned int time)
const;
311 float GetReflectionFactor(
unsigned int time)
const;
314 float GetRefractionFactor(
unsigned int time)
const;
329 typedef enum PbrInputFormat
331 UNDEFINED_INPUT_FORMAT = -1,
340 PBR_INPUT_FORMAT = MAKE_CUSTOM_ID(
'P',
'B',
'F',
'M'),
341 OCCLUSION_STRENGTH = MAKE_CUSTOM_ID(
'S',
'T',
'R',
'N'),
342 EMISSIVE_COLOR = MAKE_CUSTOM_ID(
'E',
'M',
'C',
'R'),
366 void SetMetallicFactor(
unsigned int time,
float value);
367 float GetMetallicFactor(
unsigned int time)
const;
368 void SetRoughnessFactor(
unsigned int time,
float value);
369 float GetRoughnessFactor(
unsigned int time)
const;
371 void SetEmissiveColor(
unsigned int time,
const CRGBColor& color);
372 void SetEmissiveFactor(
unsigned int time,
float value);
374 CRGBColor GetEmissiveColor(
unsigned int time)
const;
375 float GetEmissiveFactor(
unsigned int time)
const;
377 void SetOcclusionStrengthFactor(
unsigned int time,
float value);
378 float GetOcclusionStrengthFactor(
unsigned int time)
const;
381class CMaterialNameMap;
388 friend void C3DMaterial::HashRemove();
389 friend void C3DMaterial::HashInsert();
398 C3DScene* GetScene()
const {
return scene; };
403 HashPos
GetFirst()
const {
return hashMaterials.GetFirst(); }
404 void GetNext(HashPos& pos, MaterialID&
id,
C3DMaterial*& mat)
const { hashMaterials.GetNext(pos,
id, mat); };
422 unsigned int CreateMissingUVWBackChannels(
const CGeomInfo* info, MaterialID matid = MATERIAL_UNDEFINED,
MapType type = MAPTYPE_UNDEFINED, CHANNEL_PROPERTIES
channelTagFlag = CHANNEL_NONE)
const;
452END_MOOTOOLS_NAMESPACE
454#ifdef MOOTOOLS_MFC_PRODUCT_BUILD
455#ifdef MOOTOOLS_NO_BITMAP
456#pragma message("Build Warning: MOOTOOLS_NO_BITMAP defined in a product build. CMaterialMap might differ between dll resulting in impredicable behavior\n")
C3DKeyframable class for handling keyframes.
MATERIAL_CLASS
Definition 3DMaterial.h:53
@ MATERIAL_CLASS_PBR
The material is a C3DPbrMaterial.
Definition 3DMaterial.h:56
@ MATERIAL_CLASS_STANDARD
The material is a C3DStandardMaterial.
Definition 3DMaterial.h:55
MATERIAL_COPY_FLAGS
Definition 3DMaterial.h:26
MATERIAL_FLAGS
Definition 3DMaterial.h:36
@ MATERIAL_USE_FRONT_CHANNEL_WHEN_BACK_MISSING
For the material maps, use the front UV on the back side (the flag is not active if front & back mate...
Definition 3DMaterial.h:41
@ MATERIAL_DISABLE_DIFFUSE_MODULATION
This means that the diffuse color has no effect on texturing (does not modulate texture)
Definition 3DMaterial.h:40
CDependentChannels class definition which handles a CChannel array.
MapProjection
Projection type of the texture map.
Definition MaterialMap.h:53
MapType
This enum allows to know the kind of texture map.
Definition MaterialMap.h:26
CRGBColor is a class that handles RGBA colors.
This is the base class for any object that can be animated using C3DKeyframe.
Definition 3DAnimatable.h:51
@ KEYFRAME_TYPE_FLOAT
C3DFloatKey keyframe.
Definition 3DKeyframe.h:70
@ KEYFRAME_TYPE_COLOR
C3DColorKey keyframe.
Definition 3DKeyframe.h:74
C3DMaterial is the base class for materials. There is currently two kinds of materials: C3DPbrMateria...
Definition 3DMaterial.h:69
AdjustMaterialFlags
Definition 3DMaterial.h:211
void AdjustPaths(const CXString &targetPath, bool relativePathAllowed)
Make internal filenames used by materials relative to provided path.
CXString GetName(void) const
Get material name.
float GetAlphaModeCutoffCoef(unsigned int time) const
Get cutoff coef.
void SetSmoothAngle(unsigned int time, float value)
Set normal break angle.
virtual bool IsTransparent(unsigned int time, bool checkDiffuseAlpha=false) const
C3DMaterial()
Use CMaterials::CreateNewMaterial if the material is intended to belong to a material scene list.
bool IsGenerateUVWNeeded(MapType type=MAPTYPE_UNDEFINED) const
Return true if one of the map has a projection mode that require UVW to be generated,...
virtual bool HasSameParameters(const C3DMaterial &refmat) const
Compare only settings.
void SetName(const CXString &)
Set material name.
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,...
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 whe...
virtual CRGBColor GetDiffuseColor(unsigned int time, bool modulateByDiffuseFactor=false) const
This can be overidden as derived class might have a different computation for this.
bool AdjustMaterial(unsigned int flags)
flags is one or more AdjustMaterialFlags. return true if the material changed
static C3DMaterial * Create(MATERIAL_CLASS materialClass)
Create a C3DMaterial. Equivalent to xNew(C3DMaterial)
void SetFaceMode(faceModeEnum mode)
Set single / double face material mode.
void Inherit(const C3DMaterial *refmat)
Inherit basic information from refmat (mainly C3DMaterial information such name, materialID,...
MaterialID SetMaterialID(MaterialID refID=MATERIAL_UNDEFINED)
Create a new material with the given MaterialID. If material is not attached to a material list,...
faceModeEnum GetFaceMode(void) const
Get single / double face material mode.
void SetAlphaMode(unsigned int time, alphaModeEnum mode, float cutOffCoef=0.0f)
Set alpha cut and cutoff coef.
virtual C3DStandardMaterial * ConvertToStandardMaterial(bool replaceCurrentByStandardMaterial)
Must be overidden Return a standard material from the given material. If deleteCurrentAndReplaceByNew...
Definition 3DMaterial.h:165
_alphaModeEnum
Definition 3DMaterial.h:81
bool CopyTextures(const CXString &dstfolder, bool overwriteIfExists=false)
Copy all material maps to the given path and update pathss.
bool operator==(const C3DMaterial &refmat) const
Compare 2 materials (name and settings)
alphaModeEnum GetAlphaMode() const
Get alpha mode.
C3DScene * GetScene() const
The materials to which the material is attached. NULL if material not already attached to anything.
float GetSmoothAngle(unsigned int time) const
Get normal break angle.
C3DPbrMaterial defines a PBR material which is used by different file formats such GLTF or FBX.
Definition 3DMaterial.h:327
virtual C3DStandardMaterial * ConvertToStandardMaterial(bool replaceCurrentByStandardMaterial)
Return a standard material from the given material. If deleteCurrentAndReplaceByNewOne = false,...
virtual bool HasSameParameters(const C3DMaterial &refmat) const
Compare only the settings (not the name)
DataID
This enum is used in the serialization process to load/save specific C3DPbrMaterial properties.
Definition 3DMaterial.h:339
The class allows to get access to the scene graph, node hierarchy, material.
Definition 3DScene.h:306
C3DStandardMaterial is a basic material that defines ambient, specular, bump and other coefficients.
Definition 3DMaterial.h:259
void SetReflectionFactor(unsigned int time, float value)
Reflection coef between 0.0 and 1.0f (default 0.0)
void SetRefractionFactor(unsigned int time, float value)
IOR refraction indice >= 1.0 (default 1.0)
CMaterialMap * GetDiffuseMaps()
CMaterialMap * GetAmbientMaps()
virtual C3DStandardMaterial * ConvertToStandardMaterial(bool replaceCurrentByStandardMaterial)
Must be overidden Return a standard material from the given material. If deleteCurrentAndReplaceByNew...
Definition 3DMaterial.h:316
CMaterialMap * GetNormalMaps()
The class defines an x, y, z 3D point which can use int, float or double.
Definition 3DPoint.h:27
CCustomData is a handly class for storing any kind of data.
Definition CustomData.h:106
CGeomInfo is an helper class oftenly required by different methods.
Definition GeomInfo.h:71
CMaterialMap handles material texture map.
Definition MaterialMap.h:95
@ MAPCHANNEL_UNSPECIFIED
This means that existing flags are kept and not replaced by the new one.
Definition MaterialMap.h:108
CMaterials stores scene materials. CMaterials::CreateNewMaterial allows to create a material and inse...
Definition 3DMaterial.h:387
C3DMaterial * CreateNewMaterial(MaterialID &refid, MATERIAL_CLASS materialClass)
Create and add a new material of the specified material class with the provided refid....
unsigned int GetMaterials(C3DMaterialArray &mats, bool resetArray=true, MATERIAL_CLASS matclass=MATERIAL_CLASS_UNDEFINED) const
if defined matclass should be the same than the one use in GetFirstMaterial
C3DMaterial * CreateNewMaterial(MATERIAL_CLASS materialClass)
Create and add a new material of the specified material class.
CGuidMgr * GetGuidMgr() const
The scene that own the materials.
Definition 3DMaterial.h:399
void AdjustPaths(const CXString &targetPath, bool relativePathAllowed)
Make internal filenames used by materials relative to provided path.
bool ReplaceMaterial(C3DMaterial *newMat, bool deletePrevious=true)
Replace an existing material with newMat->GetMaterialID() by the newMat provided material....
C3DMaterial * Find(const C3DMaterial &material, bool sameName) const
Find a material that have similar properties and optionally the same name.
MaterialID AddNewMaterial(C3DMaterial *mat)
Add the new material which has not been assigned to any materials. Return its MaterialId definitive w...
unsigned int IsGenerateUVWNeeded(MaterialID matid=MATERIAL_UNDEFINED, MapType type=MAPTYPE_UNDEFINED) const
If matid == MATERIAL_UNDEFINED, it returns the number of materials that have a projection that requir...
HashPos GetFirst() const
if matclass = MATERIAL_CLASS_UNDEFINED, return all type of materials, otherwise return materials of t...
Definition 3DMaterial.h:403
C3DMaterial * FindByID(MaterialID refID, bool createIfMissing=false) const
Find the material that have the given MaterialID. Return NULL if none is found. (no material is creat...
virtual void Serialize(CXArchive &ar)
If scene is defined then guidMgr is the scene guidMgr. The material list handles scene materials....
unsigned int FilterByText(const CXString &filter, bool matchCase, C3DMaterialIDArray &matids, bool resetHash)
Advanced search: find all materials that match the given text. Return the number of element in matids...
C3DMaterial * FindByName(const CXString &name) const
Find the first material with the given name (beware: there can be several different materials with th...
C3DMaterial * SetDefaultMaterial(C3DStandardMaterial *defaultMat=NULL)
Return the default material. defaultMat is optional and can define specific color properties.
CRGBColor handles an r, g, b, a color that can be initialized in different way.
Definition RGBColor.h:22
Definition XThreadSync.h:20