MaterialData Class Reference

#include <c4d_materialdata.h>

Inheritance diagram for MaterialData:

详细描述

A data class for creating material plugins.

另请参阅
ShaderData

使用 RegisterMaterialPlugin() to register a material plugin.

General notes
Here are some general comments on the material API:

Optimization
CalcSurface , CalcVolumetric , ChangeNormal , CalcTransparency and CalcAlpha are the speed critical routines; concentrate efforts optimizing them.
Do not allocate new classes in those routines; only if absolutely necessary! Most of classes can be pre-allocated in InitRender.
Avoid ANY function calls there. For instance to access the global render settings store the pointer in InitRender for later use. This can save a tremendous amount of time.

公共成员函数

virtual Bool   Draw ( BaseMaterial *mat, BaseObject *op, BaseTag *tag, BaseDraw *bd, BaseDrawHelp *bh)
virtual VOLUMEINFO   GetRenderInfo ( BaseMaterial *mat)
virtual INITRENDERRESULT   InitRender ( BaseMaterial *mat, const InitRenderStruct &irs)
virtual void  FreeRender ( BaseMaterial *mat)
virtual void  InitCalculation ( BaseMaterial *mat, VolumeData *vd, INITCALCULATION type)
virtual void  Displace ( BaseMaterial *mat, VolumeData *vd)
virtual void  ChangeNormal ( BaseMaterial *mat, VolumeData *vd)
virtual void  CalcSurface ( BaseMaterial *mat, VolumeData *vd)
virtual void  CalcTransparency ( BaseMaterial *mat, VolumeData *vd)
virtual void  CalcAlpha ( BaseMaterial *mat, VolumeData *vd)
virtual void  CalcVolumetric ( BaseMaterial *mat, VolumeData *vd)
virtual Bool   InitGLImage ( BaseMaterial *mat, BaseDocument *doc, BaseThread *th, BaseBitmap *bmp, Int32 doccolorspace, Bool linearworkflow)
virtual UInt32   GlMessageDummy ( BaseMaterial *mat, Int32 type, void *data)
virtual Bool   HasEditorTransparency ( BaseMaterial *mat)
-  Public Member Functions inherited from NodeData
  NodeData ()
GeListNode Get (void) const
virtual Bool   消息 ( GeListNode *node, Int32 type, void *data)
virtual void  GetBubbleHelp ( GeListNode *node, maxon::String &str)
virtual BaseDocument GetDocument ( GeListNode *node)
virtual Int32   GetBranchInfo ( GeListNode *node, BranchInfo *info, Int32 max, GETBRANCHINFO flags)
virtual Bool   IsInstanceOf (const GeListNode *node, Int32 type) const
virtual Bool   IsDocumentRelated (const GeListNode *node, Bool &docrelated) const
virtual Bool   Init ( GeListNode *node)
virtual void  Free ( GeListNode *node)
virtual Bool   读取 ( GeListNode *node, HyperFile *hf, Int32 level)
virtual Bool   Write ( GeListNode *node, HyperFile *hf)
virtual Bool   CopyTo ( NodeData *dest, GeListNode *snode, GeListNode *dnode, COPYFLAGS flags, AliasTrans *trn)
virtual Bool   GetDDescription ( GeListNode *node, 描述 *description, DESCFLAGS_DESC &flags)
virtual Bool   GetDParameter ( GeListNode *node, const DescID &id, GeData &t_data, DESCFLAGS_GET &flags)
virtual Bool   SetDParameter ( GeListNode *node, const DescID &id, const GeData &t_data, DESCFLAGS_SET &flags)
virtual Bool   GetDEnabling ( GeListNode *node, const DescID &id, const GeData &t_data, DESCFLAGS_ENABLE flags, const BaseContainer *itemdesc)
virtual Bool   TranslateDescID ( GeListNode *node, const DescID &id, DescID &res_id, C4DAtom *&res_at)
-  Public Member Functions inherited from BaseData
  BaseData ()
virtual  ~BaseData (void)
void  Destructor (void)

Additional Inherited Members

-  Protected Attributes inherited from NodeData
GeListNode private_link

成员函数文档编制

◆  Draw()

virtual Bool Draw ( BaseMaterial mat ,
BaseObject op ,
BaseTag tag ,
BaseDraw bd ,
BaseDrawHelp bh  
)
virtual

Called to draw additional information for the material in the editor. Called for every op / tag pair that references the material.

参数
[in] mat The BaseMaterial connected with the MaterialData instance. Equal to static_cast < BaseMaterial *> Get() . Provided for speed and convenience. Cinema 4D owns the pointed material.
[in] op The object associated with the material. Cinema 4D owns the pointed object.
[in] tag The material tag. The caller owns the pointed tag.
[in] bd The editor's view. The caller owns the pointed view.
[in] bh The helper for the editor's view. The caller owns the pointed base draw helper.
返回
true if successful, otherwise false .

◆  GetRenderInfo()

virtual VOLUMEINFO GetRenderInfo ( BaseMaterial mat )
virtual

Called to get information about what the material plugin requires from the raytracer and what it returns.

参数
[in] mat The BaseMaterial connected with the MaterialData instance. Equal to static_cast < BaseMaterial *> Get() . Provided for speed and convenience. Cinema 4D owns the pointed material.
返回
The volume info: VOLUMEINFO

◆  InitRender()

virtual INITRENDERRESULT InitRender ( BaseMaterial mat ,
const InitRenderStruct irs  
)
virtual

Called to initialize resources for rendering.

参数
[in] mat The BaseMaterial connected with the MaterialData instance. Equal to static_cast < BaseMaterial *> Get() . Provided for speed and convenience. Cinema 4D owns the pointed material.
[in] irs A struct with information about the upcoming rendering.
返回
The result of the initialization: INITRENDERRESULT

◆  FreeRender()

virtual void FreeRender ( BaseMaterial mat )
virtual

Called to free any resources allocated in InitRender .

参数
[in] mat The BaseMaterial connected with the MaterialData instance. Equal to static_cast < BaseMaterial *> Get() . Provided for speed and convenience. Cinema 4D owns the pointed material.

◆  InitCalculation()

virtual void InitCalculation ( BaseMaterial mat ,
VolumeData vd ,
INITCALCULATION   type  
)
virtual

Called every time a new series of shader calls is made.
InitCalculation precalculate values for the following calls. Store the resulting data for each processor ( vd -> GetCurrentCPU() ) separately because InitCalculation may be entered multiple times on a MP thread contexts.
If all the routines are overridden and the flags are set properly Cinema 4D calls them in this order:

Before rendering:

During rendering:

During rendering for e.g. shadow rays:

◆  Displace()

virtual void Displace ( BaseMaterial mat ,
VolumeData vd  
)
virtual

Called to displace a point on the surface.
修改 vd -> p . Usually it elevates the point along its normal a certain extent such as vd -> p += vd -> dispn * factor .
Called after the render initialization ( InitRender ) but during the beginning phase.

警告
No OS calls are allowed during this function. Doing so could cause a crash, since it can be called in a multi-processor context.
参数
[in] mat The BaseMaterial connected with the MaterialData instance. Equal to static_cast < BaseMaterial *> Get() . Provided for speed and convenience. Cinema 4D owns the pointed material.
[in,out] vd The volume data to use and modify. The caller owns the pointed volume data.

◆  ChangeNormal()

virtual void ChangeNormal ( BaseMaterial mat ,
VolumeData vd  
)
virtual

Called to create a bump effect.
修改 vd -> bumpn 。若 VOLUMEINFO::DUDVREQUIRED was set for the material registration then use vd -> ddu and vd -> ddv as modification directions perpendicular to the face normal.
Called during rendering. See InitCalculation for the order of calls.

警告
No OS calls are allowed during this function. Doing so could cause a crash, since it can be called in a multi-processor context.
参数
[in] mat The BaseMaterial connected with the MaterialData instance. Equal to static_cast < BaseMaterial *> Get() . Provided for speed and convenience. Cinema 4D owns the pointed material.
[in,out] vd The volume data to use and modify. The caller owns the pointed volume data.

◆  CalcSurface()

virtual void CalcSurface ( BaseMaterial mat ,
VolumeData vd  
)
virtual

Called to calculate the surface color.
Set vd -> col , vd -> trans and vd -> refl . Also vd -> rray and vd -> tray (the reflecting and transparent rays) can be modified.
Called during rendering. See InitCalculation for the order of calls.

注意
vd -> tray is only valid if VOLUMEINFO::TRANSPARENCY was set for the material registration, and vd -> rray is only valid if VOLUMEINFO::REFLECTION or VOLUMEINFO::ENVREQUIRED was set.
警告
No OS calls are allowed during this function. Doing so could cause a crash, since it can be called in a multi-processor context.
参数
[in] mat The BaseMaterial connected with the MaterialData instance. Equal to static_cast < BaseMaterial *> Get() . Provided for speed and convenience. Cinema 4D owns the pointed material.
[in,out] vd The volume data to use and modify. The caller owns the pointed volume data.

◆  CalcTransparency()

virtual void CalcTransparency ( BaseMaterial mat ,
VolumeData vd  
)
virtual

Called to speed up the transparency calculation.
Several times Cinema 4D needs the transparency information, for example for fast shadow calculation.
Set vd -> trans 。使用 vd -> xlight to find out which light is being evaluated.
If this routine is not supplied then the result will be slower shadow calculations.
Called during rendering. See InitCalculation for the order of calls.

注意
vd -> tray is not valid and must not be modified.
警告
No OS calls are allowed during this function. Doing so could cause a crash, since it can be called in a multi-processor context.
参数
[in] mat The BaseMaterial connected with the MaterialData instance. Equal to static_cast < BaseMaterial *> Get() . Provided for speed and convenience. Cinema 4D owns the pointed material.
[in,out] vd The volume data to use and modify. The caller owns the pointed volume data.

◆  CalcAlpha()

virtual void CalcAlpha ( BaseMaterial mat ,
VolumeData vd  
)
virtual

Called to calculate the alpha.
Set vd -> alpha .

警告
No OS calls are allowed during this function. Doing so could cause a crash, since it can be called in a multi-processor context.
参数
[in] mat The BaseMaterial connected with the MaterialData instance. Equal to static_cast < BaseMaterial *> Get() . Provided for speed and convenience. Cinema 4D owns the pointed material.
[in,out] vd The volume data to use and modify. The caller owns the pointed volume data.

◆  CalcVolumetric()

virtual void CalcVolumetric ( BaseMaterial mat ,
VolumeData vd  
)
virtual

Called to calculate volumetric information.

注意
VOLUMEINFO::VOLUMETRIC is not set for the material registration this function is not needed. If VOLUMEINFO::VOLUMETRIC is set this function is required.
Set vd -> col and vd -> trans .
Called for spans; vd -> ray -> p to vd -> p where vd -> ray -> p is the entry point and vd -> p is the exit point.
Volumetric shaders that do not have a surface calculation can set vd -> trans = vector(1.0) in CalcSurface and CalcTransparency.
Called during rendering. See InitCalculation for the order of calls.
警告
No OS calls are allowed during this function. Doing so could cause a crash, since it can be called in a multi-processor context.
参数
[in] mat The BaseMaterial connected with the MaterialData instance. Equal to static_cast < BaseMaterial *> Get() . Provided for speed and convenience. Cinema 4D owns the pointed material.
[in,out] vd The volume data to use and modify. The caller owns the pointed volume data.

◆  InitGLImage()

virtual Bool InitGLImage ( BaseMaterial mat ,
BaseDocument doc ,
BaseThread th ,
BaseBitmap bmp ,
Int32   doccolorspace ,
Bool   linearworkflow  
)
virtual

Called to return a 2D representation of the material for use in the editor.
The image is shown both in OpenGL and Software mode.

注意
After you set the content of the image you have to call BaseBitmap::SetDirty() .
参数
[in] mat The BaseMaterial connected with the MaterialData instance. Equal to static_cast < BaseMaterial *> Get() . Provided for speed and convenience. Cinema 4D owns the pointed material.
[in] doc The document. The caller owns the pointed document.
[in] th The thread. The caller owns the pointed thread.
[in,out] bmp The bitmap to fill, initialized to the right size. The caller owns the pointed bitmap.
[in] doccolorspace The document's color space: DOCUMENT_COLORPROFILE
[in] linearworkflow true if Linear Workflow is enabled, otherwise false .
返回
true if successful, otherwise false .

◆  GlMessageDummy()

virtual UInt32 GlMessageDummy ( BaseMaterial mat ,
Int32   type ,
void *  data  
)
virtual

To ensure SDK compatibility Private .

◆  HasEditorTransparency()

virtual Bool HasEditorTransparency ( BaseMaterial mat )
virtual

Called to check if the material has editor transparency.

由于
R17.032
返回
true if if the material supports editor transparency, otherwise false .