Main Index : Reference :

BaseMaterial


Description

A material base class.

Definition

[BaseMaterial] AllocMaterial([int] type);

class BaseMaterial : BaseList2D
{
public:
  BaseMaterial();

  [BaseDocument] GetDocument();
  [string] GetName();
  [bool] SetName([string] name);
  
  [BaseContainer] GetMainData();
  [bool] SetMainData([BaseContainer] data);
  
  [BaseChannel] GetChannel([int] channel);
  
  [bool] GetChannelState();
  [bool] SetChannelState([bool] on);

  [bool] Update();

  [bool] CopyTo([BaseMaterial] dest);
  [BaseMaterial] GetClone();
}

Explanation

This is the material base class that all materials in CINEMA 4D are derived from.

Allocation

AllocMaterial( type )

[BaseMaterial] AllocMaterial([int] type);

Allocates a BaseMaterial of the specified type:

TypeDescription

Mbase

Base material.

Mmaterial

Standard material.

Mplugin

Plugin material.

Mfog

Fog.

Mterrain

Terrain.

Mdanel

Danel.

Mbanji

Banji.

Mbanzi

Banzi.

Mcheen

Cheen.

Mmabel

Mabel.

Mnukei

Nukei.

Members

GetDocument()

[BaseDocument] GetDocument();

Returns the document that the material belongs to, or NULL if the material is loose.

GetName()

[string] GetName();

Returns the name of the material.

SetName( name )

[bool] SetName([string] name);

Sets the name of the material to name. Returns TRUE if successful.


GetMainData()

[BaseContainer] GetMainData();

Returns a container containing various settings for the material. It contains the following container values:

Container ID Type Explanation
DIFFUSION_AFFECT_SPECULAR [bool] Affect specular
DIFFUSION_AFFECT_REFLECTION [bool] Affect reflection
DIFFUSION_AFFECT_LUMINANCE [bool] Affect luminance
TRANSPARENCY_FRESNEL [bool] Fresnel
TRANSPARENCY_ADDITIVE [bool] Additive transparency
TRANSPARENCY_N [float] Refraction index
ENVIRONMENT_TILESX [float] Environment tiles X
ENVIRONMENT_TILESY [float] Environment tiles Y
FOG_DISTANCE [float] Fog distance
BUMP_STRENGTH [float] Bump strength
BUMP_MIPFALLOFF [bool] MIP Falloff
ALPHA_DELTA [vector] Delta color
ALPHA_SOFT [bool] Soft alpha
ALPHA_IMAGEALPHA [bool] Image alpha
ALPHA_INVERT [bool] Invert alpha
SPECULAR_WIDTH [float] Highlight width
SPECULAR_HEIGHT [float] Highlight height
SPECULAR_MODE [int] Highlight mode (see dialog)
GLOW_INNER [float] Inner strength
GLOW_OUTER [float] Outer strength
GLOW_RADIUS [float] Radius
GLOW_RANDOM [float] Randomness
GLOW_FREQUENCY [float] Frequency
GLOW_USEMATERIAL [bool] Use material color
DISPLACEMENT_STRENGTH [float] Displacement strength
DISPLACEMENT_HEIGHT [float] Displacement height

SetMainData( data )

[bool] SetMainData([BaseContainer] data);

Sets various settings of the material according to the container data. For a list of the container values that it contains, please see GetMainData().


GetChannel( channel )

[BaseChannel] GetChannel([int] channel);

Returns the specified channel. Possible values for channel are:

Channel Explanation
CHANNEL_COLOR Color channel
CHANNEL_LUMINANCE Luminance channel
CHANNEL_TRANSPARENCY Transparency channel
CHANNEL_REFLECTION Reflection channel
CHANNEL_ENVIRONMENT Environment channel
CHANNEL_FOG Fog channel
CHANNEL_BUMP Bump channel
CHANNEL_ALPHA Alpha channel
CHANNEL_SPECULAR Highlight channel
CHANNEL_SPECULARCOLOR Highlight color channel
CHANNEL_GLOW Glow channel
CHANNEL_DISPLACEMENT Displacement channel
CHANNEL_DIFFUSION Diffusion channel


GetChannelState( channel )

[bool] GetChannelState([int] channel);

Returns the state of the specified channel. For a list of channel values, please see GetChannel().

SetChannelState( channel, on )

[bool] SetChannelState([int] channel, [bool] on);

Sets the state of the specified channel to on. For a list of channel values, please see GetChannel().


Update()

[bool] Update();

Recalculates the material's thumbnail and updates internal values. Returns TRUE if successful.


CopyTo( dest )

[bool] CopyTo([BaseMaterial] dest);

Copies the material to dest. Returns TRUE if successful.

GetClone()

[BaseMaterial] GetClone();

Returns a copy of the material.

Example

// Activates the bump channel for a material
var mat = doc->GetFirstMaterial();
mat->SetChannelState(CHANNEL_BUMP, TRUE);

// Sets a texture for it
var bump = doc->GetChannel(CHANNEL_BUMP);
var bumpBc = bump->GetContainer();
bumpBc->SetData(CH_TEXTURE, "foo.tif");
bump->SetContainer(bumpBc);