On 19/08/2016 at 07:10, xxxxxxxx wrote:
User Information:
Cinema 4D Version: R17
Platform: Windows ;
Language(s) : C++ ;
---------
Hi everyone,
Currently I am using the code to catch a message asking for material preview image and fill it. Here it is:
Bool mymat::Message(GeListNode * node, Int32 type, void * msgdat)
{
//...
switch (type)
{
//...
case MATPREVIEW_GENERATE_IMAGE:
{
MatPreviewGenerateImage * image = (MatPreviewGenerateImage* )msgdat;
if (image != 0)
{
if (image->pDest != 0)
{
RenderPreview(image->pDest, mat);
image->lResult = RENDERRESULT_OK;
}
}
return true;
// break;
}
Later, the call to RenderPreview leads to traversal of the structure of material which may have the links to the other materials or shaders like here:
for (int param_link = IDD_PARAMS_LINK_BEGIN + 1, param_x = IDD_PARAMS_X_BEGIN + 1, param_const = IDD_PARAMS_CONST_BEGIN + 1;
param_link < IDD_PARAMS_LINK_END;
param_link++, param_x++, param_const++)
{
BaseMaterial * material_child = (BaseMaterial * )data->GetLink(param_link, doc, PID_MY_MAT);
But the problem is that on the stage of MATPREVIEW_GENERATE_IMAGE message these links to other materials are empty! The return zero. I just don't know how to get the full structure of material.
Simple material with constant properties (without links to other shaders or material) assemble this information just fine.
Same happens with shader previews where I traverse the structure of the shader at InitRender call and get the image and then output each pixel in Output call. It is a bad slow way but I haven't yet realised the way of doing it like in material preview.
Btw, this code works as expected when I assemble the main scene and send it to renderer.