On 04/08/2016 at 07:07, xxxxxxxx wrote:
User Information:
Cinema 4D Version: 16
Platform: Windows ;
Language(s) : C++ ;
---------
Hello everybody!
I am currently working on my own custom renderer which only supports my custom material (let's call it MyMaterial).
What I'm trying to do is to render the material preview of MyMaterial with my custom renderer.
My first attempt was to set RDATA_RENDERENGINE to the plugin id of my renderer in MyMaterial's Message method as described here: https://developers.maxon.net/docs/Cinema4DCOFFEESDK/help/pages/RenderData/class_RenderData204.html
Bool MyMaterial::Message(GeListNode* node, Int32 type, void* data)
{
...
if (type == MATPREVIEW_GENERATE_IMAGE)
{
MatPreviewGenerateImage* image = (MatPreviewGenerateImage* )data;
if (image->pDoc)
{
BaseContainer bcRender = image->pDoc->GetActiveRenderData()->GetData();
bcRender.SetFloat(RDATA_XRES, image->pDest->GetBw());
bcRender.SetFloat(RDATA_YRES, image->pDest->GetBh());
bcRender.SetInt32(RDATA_ANTIALIASING, ANTI_GEOMETRY);
**bcRender.SetInt32(RDATA_RENDERENGINE, MY_RENDERER_ID);**
image->pDest->Clear(0, 0, 0);
image->lResult = RenderDocument(image->pDoc, bcRender, nullptr, nullptr, image->pDest, RENDERFLAGS_EXTERNAL | RENDERFLAGS_PREVIEWRENDER, image->pThread);
}
return true;
}
...
}
I thought this would be enough to tell Cinema to use my renderer but apparently I was wrong.
In fact it seems to ignore RDATA_RENDERENGINE completely as I can assign any long value to it and it will still use the default renderer.
What am I doing wrong here?