About
BaseMaterial is the base class for all materials in Cinema 4D. Materials are typically assigned to a BaseObject using a TextureTag. They can be configured like any other BaseList2D based entity. Materials often own BaseShader elements. The most often used material is the standard material (Material class).
BaseMaterial objects are an instance of Mbase
.
Access
Materials are stored in a BaseDocument. They can be accessed with:
See BaseDocument Materials
A TextureTag stores a reference to a material. This referenced material is accessed with:
if (ttag == nullptr)
if (material != nullptr)
{
}
See TextureTag Manual.
Allocation/Deallocation
BaseMaterial objects are created with the usual tools.
A newly created material is typically added to a BaseDocument that takes ownership:
A material is assigned to a BaseObject using a TextureTag. The referenced material is set with:
const Bool noCheen = cheen ==
nullptr;
const Bool noTextureTag = textureTag ==
nullptr;
if (noCheen || noTextureTag)
object->InsertTag(textureTag.
Release());
Navigation
The BaseMaterial elements of a BaseDocument are stored in a list:
while (material != nullptr)
{
}
Read-Only Properties
The following functions allow to access various properties of a BaseMaterial.
Update
In certain situations it is needed to manually trigger an update of the material previews. This may be for example needed in a custom material plugin.
Sample Material
Materials define the surface properties of objects. They are sampled in the rendering pipeline e.g. in a VideoPost, another material or a shader.
Internal material resources are initiated and freed with these functions:
If needed the material calculation is initiated with:
The material can now be sampled and used with:
These examples sample a BaseMaterial in a VideoPostData plugin:
volumeData->
tex = texData;
Compare Entity
Two BaseMaterial elements can be compared with:
if (firstMaterial == nullptr)
if (selectedMaterial->Compare(firstMaterial))
ApplicationOutput(
"The selected material has the same settings as the first material");
- Note
- The comparison is mostly based on the material's BaseContainer. Other internal data may not be compared.
Bits
If an element is copied it must mark the materials it uses so that these materials are copied along with the actual element.
- BIT_MATMARK: This bit defines the material as a "marked" material.
{
if (doc == nullptr)
return false;
if (data)
{
if (markMaterial->
omat == mat)
{
}
}
else
{
if (mat)
}
break;
}
Further Reading
Vector uvw
[READ ONLY] The surface UVW coordinates, this is invalid for volumetric shaders.
Definition: c4d_shader.h:955
Definition: c4d_baselist.h:756
void UnlockTextures()
Unlocks all textures used by the material.
Definition: c4d_basematerial.h:109
Ray * ray
[READ ONLY] The current eye ray. Always valid, not nullptr.
Definition: c4d_shader.h:948
BaseMaterial * omat
Original material. Cinema 4D owns the pointed material.
Definition: c4d_baselist.h:763
Definition: c4d_basetag.h:646
Vector64 n
[READ ONLY] The surface phong normal.
Definition: c4d_shader.h:950
@ OUTOFMEMORY
Not enough memory.
INITRENDERRESULT InitTextures(const InitRenderStruct &irs)
Definition: c4d_basematerial.h:104
Bool AddUndo(UNDOTYPE type, void *data, Bool allowFromThread=false)
BaseMaterial * GetFirstMaterial(void)
@ INITCALCULATION
Needs MaterialData::InitCalculation() call.
return OK
Definition: apibase.h:2620
BaseList2D * GetLink(const BaseDocument *doc, Int32 instanceof=0) const
@ CHANGE_SMALL
Change to local data only (e.g. data container). No substructures (e.g. no tags on an object) and no ...
#define MAXON_SOURCE_LOCATION
Definition: memoryallocationbase.h:67
#define MSG_MULTI_MARKMATERIALS
Definition: c4d_baselist.h:506
void CalcSurface(VolumeData *sd)
Definition: c4d_basematerial.h:139
void SetBit(Int32 mask)
Definition: c4d_baselist.h:2230
#define BIT_MATMARK
Marked material.
Definition: ge_prepass.h:871
#define Mcheen
Cheen.
Definition: ge_prepass.h:988
@ SURFACE
Called during rendering for surface calculation.
BaseBitmap * GetPreview(Int32 flags)
void InsertMaterial(BaseMaterial *mat, BaseMaterial *pred=nullptr, Bool checknames=false)
void SetMaterial(BaseMaterial *mat)
Bool SetParameter(const DescID &id, const GeData &t_data, DESCFLAGS_SET flags)
Vector col
[READ WRITE] Set the calculated color within MaterialData::CalcSurface() and MaterialData::CalcVolume...
Definition: c4d_shader.h:939
INITRENDERRESULT
Definition: ge_prepass.h:399
BaseMaterial * GetMaterial(Bool ignoredoc=false)
BaseDocument * doc
The active document.
Definition: c4d_videopostdata.h:91
Int32 calc_illum
Definition: c4d_shader.h:974
const TexData * tex
[READ ONLY] The surface texture, never change this pointer.
Definition: c4d_shader.h:959
Definition: c4d_gedata.h:82
Definition: c4d_tools.h:1299
VolumeData * vd
The current VolumeData. Only valid for VIDEOPOSTCALL::INNER and VIDEOPOSTCALL::RENDER calls.
Definition: c4d_videopostdata.h:90
BaseDocument * GetDocument()
Definition: c4d_baselist.h:1945
#define ApplicationOutput(formatString,...)
Definition: debugdiagnostics.h:210
Bool Message(Int32 type, void *data=nullptr)
Definition: c4d_baselist.h:1424
Bool ShowBitmap(const Filename &fn)
#define Ttexture
Texture - TextureTag.
Definition: ge_prepass.h:1270
VOLUMEINFO GetRenderInfo(void)
Definition: c4d_basematerial.h:210
BaseMaterial * nmat
New material. Cinema 4D owns the pointed material.
Definition: c4d_baselist.h:764
Definition: c4d_basebitmap.h:414
TYPE * Release()
Definition: ge_autoptr.h:120
Definition: ge_autoptr.h:36
BaseMaterial * GetNext(void)
Definition: c4d_basematerial.h:60
maxon::Bool Bool
Definition: ge_sys_math.h:55
#define MSG_CHANGE
Definition: c4d_baselist.h:343
Vector64 p
[READ WRITE] The surface point, this can only be modified by MaterialData::Displace().
Definition: c4d_shader.h:945
String GetName() const
Definition: c4d_baselist.h:2348
#define Mbase
Base material.
Definition: ge_prepass.h:980
void InitCalculation(VolumeData *sd, INITCALCULATION type)
Definition: c4d_basematerial.h:171
Definition: c4d_shader.h:215
Definition: c4d_basematerial.h:27
@ OK
Everything is OK, there was no error.
Bool GetParameter(const DescID &id, GeData &t_data, DESCFLAGS_GET flags)
Definition: c4d_basedocument.h:496