Material Class Reference

#include <c4d_material.h>

Inheritance diagram for Material:

Public Types

typedef BaseMaterial SUPER
 
- Public Types inherited from BaseMaterial
typedef BaseList2D SUPER
 
- Public Types inherited from BaseList2D
typedef GeListNode SUPER
 
- Public Types inherited from GeListNode
typedef PrivateChunk SUPER
 

Public Member Functions

virtual Bool IsInstanceOf (cineware::Int32 id) const
 
- Public Member Functions inherited from BaseMaterial
BaseContainerGetMaterialCache ()
 
virtual BaseList2DGetClone (COPYFLAGS flags, AliasTrans *trans)
 
BaseMaterialGetNext ()
 
BaseMaterialGetPred ()
 
virtual Int32 GetType () const
 
Bool HasNimbusRef () const
 
virtual Int32 GetDiskType () const
 
BaseBitmapGetPreview ()
 
- Public Member Functions inherited from BaseList2D
 BaseList2D ()
 
virtual ~BaseList2D ()
 
BaseList2DGetNext ()
 
BaseList2DGetPred ()
 
NodeDataGetNodeData ()
 
void SetNodeData (NodeData *data)
 
void SetBit (Int32 mask)
 
Bool GetBit (Int32 mask)
 
void DelBit (Int32 mask)
 
void ToggleBit (Int32 mask)
 
Int32 GetAllBits ()
 
void SetAllBits (Int32 bits)
 
BaseContainer GetData ()
 
BaseContainerGetDataInstance ()
 
BaseContainerGetDataInstanceRef ()
 
const StringGetName ()
 
void SetName (const String &new_name)
 
const GeMarkerGetMarker () const
 
void SetMarker (const GeMarker &m)
 
Bool AddUniqueID (Int32 appid, const Char *const mem, Int bytes)
 
Bool FindUniqueID (Int32 appid, const Char *&mem, Int &bytes) const
 
Int32 GetUniqueIDCount () const
 
Bool GetUniqueIDIndex (Int32 idx, Int32 &id, const Char *&mem, Int &bytes) const
 
BaseShaderGetFirstShader ()
 
Bool InsertShader (BaseShader *shader, BaseShader *pred=nullptr)
 
Bool InsertShaderLast (BaseShader *shader)
 
RootCTrackGetCTrackRoot ()
 
CTrackGetFirstCTrack ()
 
CTrackFindCTrack (const DescID &id)
 
Bool AppendCTrack (CTrack *t)
 
void InsertTrackSorted (CTrack *track)
 
LayerObjectGetLayerObject ()
 
void SetLayerObject (LayerObject *layer)
 
const LayerDataGetLayerData (BaseDocument *doc, Bool rawdata=false)
 
Bool SetLayerData (BaseDocument *doc, const LayerData &data)
 
DynamicDescriptionGetDynamicDescription ()
 
virtual Bool IsBaseList ()
 
virtual void Remove ()
 
Bool SetDescIDState (const DescID &id, DESCIDSTATE descidstate)
 
DESCIDSTATE GetDescIDState (const DescID &id, Bool tolerant) const
 
RootPluginNodeGetOverrideRoot ()
 
BaseOverrideGetFirstOverride ()
 
virtual Bool TranslateDescID (const DescID &id, DescID &res_id, GeListNode *&res_at)
 
- Public Member Functions inherited from GeListNode
 GeListNode ()
 
 ~GeListNode ()
 
virtual Bool GetNBit (Int32 bit) const
 
virtual Bool ChangeNBit (NBIT bit, NBITCONTROL bitmode)
 
BaseDocumentGetDocument ()
 
virtual Int32 GetInfo ()
 
GeListNodeGetPred ()
 
GeListNodeGetNext ()
 
GeListNodeGetUp ()
 
GeListNodeGetDown ()
 
GeListNodeGetDownLast ()
 
void InsertBefore (GeListNode *op)
 
void InsertAfter (GeListNode *op)
 
void Remove ()
 
void InsertUnder (GeListNode *op)
 
void InsertUnderLast (GeListNode *op)
 
RootList2DGetListHead ()
 
Int32 GetNodeID (Int32 index=0) const
 
- Public Member Functions inherited from PrivateChunk
 PrivateChunk ()
 
Bool ReadChunk (HyperFile *hf, Bool keepin=false, Bool noheader=false)
 
virtual Bool IsListHead ()
 
Bool ReadObject (HyperFile *hf, Bool readheader)
 
Bool WriteObject (HyperFile *hf, Int32 type)
 
Bool CopyTo (PrivateChunk *dest, COPYFLAGS flags, AliasTrans *trans)
 
Bool GetParameter (Int32 id, GeData &data)
 
Bool SetParameter (Int32 id, const GeData &data)
 
Bool GetParameter (const DescID &id, GeData &data)
 
Bool SetParameter (const DescID &id, const GeData &data)
 
- Public Member Functions inherited from GeTempPublicNode2D< PrivateChunk >
PrivateChunkGetNext () const
 
PrivateChunkGetPrev () const
 
void InsertBefore (PrivateChunk *n)
 
void InsertAfter (PrivateChunk *n)
 
void Remove ()
 

Protected Attributes

MaterialReflections reflections
 
- Protected Attributes inherited from BaseMaterial
Bool _hasNimbus
 
Int _nimbusXmlUnknownDataLength
 
void * _nimbusXmlUnknownData
 
Int _nimbusNodesUnknownDataLength
 
void * _nimbusNodesUnknownData
 
- Protected Attributes inherited from BaseList2D
Int32 m_id
 
RootShader mp_rootshader
 
RootShader mp_rootshader_hidden
 
RootShader root_shader_repository
 
Int32 l_bitfeld
 
RootCTrack mp_rootctrack
 
RootPluginNode root_override
 
NotifyListnotify_events
 
DescIdStorekeyframestore
 
DescIdStorepropstore
 
BaseContainer m_bc
 
NodeDatam_data
 
- Protected Attributes inherited from GeListNode
GeAliasGoal m_xgoal
 
UInt32 m_bits [4]
 
RootList2Dt_rootlist_parent
 
RootList2Dm_children
 
BaseDocumentparent_doc
 
void * unknownData
 
Int unknownDataSize
 
Int32 unknownDataLevel
 
Int32 pluginID
 

Private Member Functions

virtual Bool GetDParameter (const DescID &id, GeData &data)
 
virtual Bool SetDParameter (const DescID &id, const GeData &data)
 

Private Attributes

BaseChannel m_channel [14]
 
Bool m_on [14]
 

Friends

class ReflectionLayer
 

Constructor

 Material ()
 

Alloc/Free

static MaterialAlloc ()
 
static void Free (Material *&mat)
 

Channel State

Bool GetChannelState (Int32 id)
 
void SetChannelState (Int32 id, Bool state)
 

Reflection/Specular Layer Access

ReflectionLayerAddReflectionLayer ()
 
ReflectionLayerGetReflectionLayerID (Int32 id)
 
ReflectionLayerGetReflectionLayerIndex (Int32 index)
 
ReflectionLayerGetReflectionLayerTrans ()
 
Int32 GetReflectionLayerCount ()
 
void RemoveReflectionLayerID (Int32 id)
 
void RemoveReflectionLayerIndex (Int32 index)
 
void RemoveReflectionAllLayers ()
 
void GetAllReflectionShaders (BaseArray< BaseShader * > &shaders)
 
void GetReflectionPrimaryLayers (Int32 &reflection_layer, Int32 &specular_layer)
 

Shader

BaseShaderGetShader (Int32 id)
 
BaseShaderMakeBitmapShader (Int32 id, Filename filename)
 
BaseShaderMakeShader (Int32 channelID, Int32 shaderType)
 

Channel

BaseChannelGetChannel (Int32 id)
 

Alien Overload

virtual Bool Execute ()
 

Private

virtual Bool CopyToX (PrivateChunk *dst, COPYFLAGS flags, AliasTrans *trn)
 
virtual Bool HandleSubChunk (HyperFile *hf, Int32 id, Int32 level)
 
virtual Bool Write (HyperFile *hf)
 
virtual Bool IsParameterReflection (const DescID &id) const
 

Additional Inherited Members

- Static Public Member Functions inherited from BaseMaterial
static BaseMaterialAlloc (Int32 type)
 
static void Free (BaseMaterial *&bl)
 
- Protected Member Functions inherited from BaseMaterial
 BaseMaterial (Int32 typeID=NOTOK, Int32 pID=NOTOK)
 
virtual Int32 GetInstanceType () const
 
virtual Int32 GetChunkLevel ()
 
- Protected Member Functions inherited from BaseList2D
void SetID (Int32 id)
 

Detailed Description

The standard Cinema 4D material.

Note
Has to be created with Alloc() and destroyed with Free().

Member Typedef Documentation

◆ SUPER

Constructor & Destructor Documentation

◆ Material()

Material ( )

Default constructor.

Member Function Documentation

◆ IsInstanceOf()

virtual Bool IsInstanceOf ( cineware::Int32  id) const
virtual

Reimplemented from BaseMaterial.

◆ GetDParameter()

virtual Bool GetDParameter ( const DescID id,
GeData data 
)
privatevirtual

Reimplemented from BaseMaterial.

◆ SetDParameter()

virtual Bool SetDParameter ( const DescID id,
const GeData data 
)
privatevirtual

Reimplemented from BaseMaterial.

◆ Alloc()

static Material* Alloc ( )
static

Allocates a standard material. Destroy the allocated standard material with Free().

Returns
The allocated standard material, or nullptr if the allocation failed.

◆ Free()

static void Free ( Material *&  mat)
static

Destructs standard materials allocated with Alloc().

Parameters
[in,out]matThe standard material to destruct. If the pointer is nullptr nothing happens. The pointer is assigned nullptr afterwards.

◆ GetChannelState()

Bool GetChannelState ( Int32  id)

Gets the enable state of a channel.

Parameters
[in]idThe channel to check: CHANNEL.
Returns
The enable state of the channel.

◆ SetChannelState()

void SetChannelState ( Int32  id,
Bool  state 
)

Sets the enable state of a channel.

Parameters
[in]idThe channel to change: CHANNEL.
[in]stateThe enable state.

◆ AddReflectionLayer()

ReflectionLayer* AddReflectionLayer ( )

Adds a reflection/specular layer.

Returns
The added reflection/specular layer. Cineware SDK owns the pointed layer.

◆ GetReflectionLayerID()

ReflectionLayer* GetReflectionLayerID ( Int32  id)

Retrieves a reflection/specular layer by ID.

Parameters
[in]idThe layer ID.
Returns
The reflection/specular layer. Cineware SDK owns the pointed layer.

◆ GetReflectionLayerIndex()

ReflectionLayer* GetReflectionLayerIndex ( Int32  index)

Retrieves a reflection/specular layer by index.

Parameters
[in]indexThe layer index.
Returns
The reflection/specular layer. Cineware SDK owns the pointed layer.

◆ GetReflectionLayerTrans()

ReflectionLayer* GetReflectionLayerTrans ( )

Retrieves the transparency layer.

Returns
The transparency layer, or nullptr if not available. Cineware SDK owns the pointed layer.

◆ GetReflectionLayerCount()

Int32 GetReflectionLayerCount ( )

Retrieves the number of reflection/specular layers.

Returns
The reflection/specular layers' count.

◆ RemoveReflectionLayerID()

void RemoveReflectionLayerID ( Int32  id)

Removes a reflection/specular layer by ID.

Parameters
[in]idThe layer ID.

◆ RemoveReflectionLayerIndex()

void RemoveReflectionLayerIndex ( Int32  index)

Removes a reflection/specular layer by index.

Parameters
[in]indexThe layer index.

◆ RemoveReflectionAllLayers()

void RemoveReflectionAllLayers ( )

Deletes all reflection/specular layers.

◆ GetAllReflectionShaders()

void GetAllReflectionShaders ( BaseArray< BaseShader * > &  shaders)

Retrieves all the reflection/specular shaders.

Parameters
[out]shadersAssigned all the reflection/specular shaders. Cineware SDK owns the pointed shaders.

◆ GetReflectionPrimaryLayers()

void GetReflectionPrimaryLayers ( Int32 reflection_layer,
Int32 specular_layer 
)

Retrieves the indices to the primary reflection and specular layers (can be -1 for empty).

Parameters
[out]reflection_layerThe most significant reflection layer.
[out]specular_layerThe most significant specular layer.

◆ GetShader()

BaseShader* GetShader ( Int32  id)

Gets the shader of a channel.

Parameters
[in]idThe shader ID.
Returns
The shader, or nullptr if the channel does not contain a shader. The channel owns the pointed shader.

◆ MakeBitmapShader()

BaseShader* MakeBitmapShader ( Int32  id,
Filename  filename 
)

Creates a bitmap shader (Xbitmap) in a channel and load a texture into it.

Parameters
[in]idThe channel: CHANNEL.
[in]filenameThe filename of the texture to load.
Returns
The bitmap shader, or nullptr if no bitmap was loaded.

◆ MakeShader()

BaseShader* MakeShader ( Int32  channelID,
Int32  shaderType 
)

Creates a shader for a channel.

Parameters
[in]channelIDThe channel: CHANNEL.
[in]shaderTypeThe shader type, for instance Xnoise.
Returns
The shader, or nullptr if the creation failed.

◆ GetChannel()

BaseChannel& GetChannel ( Int32  id)

Gets a channel associated with the material, such as the color channel or bump channel.

Parameters
[in]idThe channel: CHANNEL.
Returns
The channel.

◆ Execute()

virtual Bool Execute ( )
virtual

Overload this for self defined materials.
Example:

Bool AlienMaterial::Execute()
{
if (pName)
{
printf("\n - AlienMaterial (%d): %s\n", (int)GetType(), pName);
DeleteMem(pChar);
}
else
printf("\n - AlienMaterial (%d): <noname>\n", (int)GetType());
PrintUniqueIDs(this);
// Assign a id to the material
id = tempmatid;
tempmatid++;
// Material preview custom datatype
GeData data;
{
MaterialPreviewData* pPreview = (MaterialPreviewData*)data.GetCustomDataType(CUSTOMDATATYPE_MATPREVIEW);
if (pPreview)
{
MatPreviewType previewType = pPreview->GetPreviewType();
MatPreviewSize previewSize = pPreview->GetPreviewSize();
printf("MaterialPreview: Type:%d Size:%d\n", previewType, previewSize);
}
}
PrintShaderInfo(GetShader(MATERIAL_COLOR_SHADER), 4);
PrintAnimInfo(this);
return true;
}
Returns
true if the material type is supported by the external application, otherwise false.

Reimplemented from BaseMaterial.

◆ CopyToX()

virtual Bool CopyToX ( PrivateChunk dst,
COPYFLAGS  flags,
AliasTrans trn 
)
virtual

Private.

Reimplemented from BaseMaterial.

◆ HandleSubChunk()

virtual Bool HandleSubChunk ( HyperFile hf,
Int32  id,
Int32  level 
)
virtual

Private.

Reimplemented from BaseMaterial.

◆ Write()

virtual Bool Write ( HyperFile hf)
virtual

Private.

Reimplemented from BaseMaterial.

◆ IsParameterReflection()

virtual Bool IsParameterReflection ( const DescID id) const
virtual

Private.

Friends And Related Function Documentation

◆ ReflectionLayer

friend class ReflectionLayer
friend

Member Data Documentation

◆ m_channel

BaseChannel m_channel[14]
private

◆ m_on

Bool m_on[14]
private

◆ reflections

MaterialReflections reflections
protected
DeleteMem
#define DeleteMem(x)
Definition: c4d_memory.h:96
cineware::BaseMaterial::GetType
virtual Int32 GetType() const
cineware::String::GetCStringCopy
Char * GetCStringCopy(STRINGENCODING type=STRINGENCODING_XBIT) const
cineware::Bool
bool Bool
Boolean type, possible values are only false/true, 8 bit.
Definition: c4d_system.h:192
MATERIAL_PREVIEW
#define MATERIAL_PREVIEW
Definition: customgui_matpreview.h:25
cineware::Material::GetShader
BaseShader * GetShader(Int32 id)
MATERIAL_COLOR_SHADER
@ MATERIAL_COLOR_SHADER
Definition: mmaterial.h:272
cineware::Char
char Char
Signed 8 bit character.
Definition: c4d_system.h:195
cineware::MatPreviewSize
MatPreviewSize
Definition: customgui_matpreview.h:132
CUSTOMDATATYPE_MATPREVIEW
#define CUSTOMDATATYPE_MATPREVIEW
Material preview custom data type ID.
Definition: customgui_matpreview.h:31
cineware::BaseList2D::GetName
const String & GetName()
cineware::PrivateChunk::GetParameter
Bool GetParameter(Int32 id, GeData &data)
cineware::MatPreviewType
MatPreviewType
Definition: customgui_matpreview.h:111