About
A Material object represents a Cinema 4D standard material. It is based on BaseMaterial . A standard material offers multiple parameters organized in "channels".
Material objects are an instance of Mmaterial
.
Access
A Material is accessed like any other material.
See also BaseMaterial Manual .
Allocation/Deallocation
Material objects are created with the usual tools.
if (material == nullptr )
const Vector blue { 0.0, 0.0, 1.0 };
material->
SetName (
"Blue Material" _s);
Properties
The parameters of a Material can be edited as usual with C4DAtom::SetParameter() and C4DAtom::GetParameter() . The parameter IDs are defined in mmaterial.h
. For convenience the parameters of a group are often combined to a "channel".
Channel States
These utility functions allow to edit the state of a "channel":
Channels
Certain parameters and functionality of a parameter group are combined in a BaseChannel object:
The returned BaseChannel object can be used to handle the referenced shaders:
Between the call of InitTexture() and FreeTexture() the shader of the channel can be sampled:
Further operations are:
These functions are useful to get general settings of the channel and the settings of a used bitmap shader:
if (channel == nullptr )
if (shader != nullptr )
{
}
Reflection Layers
A standard material can manage multiple reflection layers. Such reflection layers can be created and edited. The used parameter IDs are defined in c4d_reflection.h
, see REFLECTION_LAYER .
The settings of a ReflectionLayer object are:
Note If a Material is created and configured in some import context (e.g. SceneLoaderData ) one has to set the material parameter REFLECTION_LAYER_IMPORTED to true.
and
for (
Int32 i = 0; i < layerCount; ++i)
{
if (layer == nullptr )
}
See also Blog post: Cinema 4D R16 Reflectance channel's API
Further Reading
static String FloatToString(Float32 v, Int32 vvk=-1, Int32 nnk=-3)
Definition: c4d_string.h:527
BaseShader * GetShader(void)
Definition: c4d_basechannel.h:31
#define Xbitmap
Bitmap.
Definition: ge_prepass.h:1157
Definition: c4d_reflection.h:457
#define BASECHANNEL_TEXTURE
String. The texture for this channel.
Definition: c4d_shader.h:116
Definition: lib_description.h:315
#define REFLECTION_FLAG_TAB
Tab.
Definition: c4d_reflection.h:21
#define REFLECTION_LAYER_FRESNEL_MODE
Int32 Fresnel mode: REFLECTION_FRESNEL
Definition: c4d_reflection.h:377
#define REFLECTION_LAYER_TRANS_BRIGHTNESS
Float Brightness.
Definition: c4d_reflection.h:334
BaseContainer GetData(void)
maxon::Float Float
Definition: ge_sys_math.h:51
#define REFLECTION_FRESNEL_METAL_GOLD
Gold.
Definition: c4d_reflection.h:187
Definition: mmaterial.h:60
#define MAXON_SOURCE_LOCATION
Definition: memoryallocationbase.h:66
#define REFLECTION_DISTRIBUTION_BECKMANN
Beckmann.
Definition: c4d_reflection.h:46
#define REFLECTION_LAYER_MAIN_DISTRIBUTION
Int32 Distribution type: REFLECTION_DISTRIBUTION
Definition: c4d_reflection.h:284
Definition: c4d_basechannel.h:233
void SetFlags(Int32 flags)
ReflectionLayer * GetReflectionLayerIndex(Int32 index)
Definition: c4d_basematerial.h:297
Definition: mmaterial.h:56
void InsertMaterial(BaseMaterial *mat, BaseMaterial *pred=nullptr, Bool checknames=false)
#define REFLECTION_FRESNEL_CONDUCTOR
Conductor.
Definition: c4d_reflection.h:150
Bool SetParameter(const DescID &id, const GeData &t_data, DESCFLAGS_SET flags)
Definition: c4d_basematerial.h:229
Int32 GetInt32(void) const
Definition: c4d_gedata.h:411
static Material * Alloc()
#define REFLECTION_FLAG_SELECTED
Selected.
Definition: c4d_reflection.h:19
#define REFLECTION_LAYER_FRESNEL_METAL
Int32 Metal preset: REFLECTION_FRESNEL_METAL
Definition: c4d_reflection.h:379
Definition: c4d_gedata.h:77
void SetName(const maxon::String &name)
Definition: c4d_baselist.h:2265
maxon::Int32 Int32
Definition: ge_sys_math.h:45
BaseChannel * GetChannel(Int32 id)
Definition: c4d_basematerial.h:88
#define ApplicationOutput(formatString,...)
Definition: debugdiagnostics.h:209
#define REFLECTION_FLAG_ACTIVE
Active.
Definition: c4d_reflection.h:20
#define REFLECTION_LAYER_MAIN_BLEND_MODE
Int32 Blend mode.
Definition: c4d_reflection.h:288
void SetName(const maxon::String &name)
String GetString(Int32 id, const maxon::String &preset=maxon::String()) const
Definition: c4d_basecontainer.h:383
maxon::Bool Bool
Definition: ge_sys_math.h:40
void SetChannelState(Int32 channel, Bool state)
Definition: c4d_basematerial.h:269
Bool IsInstanceOf(Int32 id) const
Definition: c4d_baselist.h:1329
ReflectionLayer * AddReflectionLayer()
Definition: c4d_basematerial.h:281
String GetName() const
Definition: c4d_baselist.h:2259
Int32 GetReflectionLayerCount()
Definition: c4d_basematerial.h:311
Definition: mmaterial.h:61
#define CHANNEL_COLOR
The color channel of a material.
Definition: c4d_shader.h:91
Bool GetParameter(const DescID &id, GeData &t_data, DESCFLAGS_GET flags)
Definition: c4d_basecontainer.h:42
Bool GetChannelState(Int32 channel)
Definition: c4d_basematerial.h:262
Float GetFloat(void) const
Definition: c4d_gedata.h:423