On 27/09/2015 at 01:05, xxxxxxxx wrote:
User Information:
Cinema 4D Version: 13-16
Platform:
Language(s) : C++ ;
---------
Hi,
Is it possible to show only some custom scenes in the material preview? It is easy to just add custom scenes, but i want to get rid of all the others. Using MATPREVIEW_GET_POPUP_OPTIONS gives me a submenu which i also do not want. Here is a little illustration:
and my code, straight from the SDK Examples:
Bool RegisterAtmosphereMaterialData(void)
{
// decide by name if the plugin shall be registered - just for user convenience
String name=GeLoadString(IDS_ATMOSPHERE); if (!name.Content()) return TRUE;
name = GeGetDefaultFilename(DEFAULTFILENAME_SHADER_VOLUME)+name; // place in default Shader section
String previewName = GeLoadString(IDS_ATMOSPHERE_MATPREVIEW);
AddUserPreviewScene(GeGetPluginPath() + String("res") + String("scene") + String("Atmosphere Preview.c4d"), ID_ATMOSPHERE2, &previewName;);
previewName = GeLoadString(IDS_ATMOSPHERE_MATPREVIEW2);
AddUserPreviewScene(GeGetPluginPath() + String("res") + String("scene") + String("Atmosphere Low.c4d"), ID_ATMOSPHERE2, &previewName;);
previewName = GeLoadString(IDS_ATMOSPHERE_MATPREVIEW3);
AddUserPreviewScene(GeGetPluginPath() + String("res") + String("scene") + String("Atmosphere Ground.c4d"), ID_ATMOSPHERE2, &previewName;);
return RegisterMaterialPlugin(ID_ATMOSPHERE2,name,0,AtmosphereMaterialData::Alloc,"Mplanetatmosphere2",0);
}
Bool AtmosphereMaterialData::Message(GeListNode *node, LONG type, void *data)
{
if (type == MSG_UPDATE)
updatecount++;
switch(type)
{
case MSG_DESCRIPTION_VALIDATE:
{
UpdateGuiValues((BaseMaterial* )node);
return TRUE;
}
break;
case MATPREVIEW_GET_PREVIEW_ID:
{
*((LONG* )data) = MAT_PREVIEW;
return TRUE;
}
break;
case MATPREVIEW_GET_OBJECT_INFO:
{
MatPreviewObjectInfo* info = (MatPreviewObjectInfo* )data;
info->bHandlePreview = TRUE; // own preview handling
info->bNeedsOwnScene = TRUE;
info->bNoStandardScene = FALSE;
info->lFlags = MATPREVIEW_FLAG_HIDE_SCENES; //MATPREVIEW_FLAG_HIDE_SCENE_SETTINGS;
return TRUE;
}
break;
case MATPREVIEW_MODIFY_CACHE_SCENE:
{
return TRUE;
}
break;
case MATPREVIEW_PREPARE_SCENE:
{
auto* preparescene = static_cast<MatPreviewPrepareScene*>(data);
AutoAlloc<AliasTrans> trans;
if (!trans)
return FALSE;
if (!trans->Init(GetActiveDocument()))
return FALSE;
BaseMaterial* matclone = (BaseMaterial* )(Get()->GetClone(COPYFLAGS_0, trans));
preparescene->pDoc->InsertMaterial(matclone);
trans->Translate(TRUE);
if (preparescene->pLink) preparescene->pLink->SetLink(matclone); // necessary
BaseObject* obj = preparescene->pDoc->SearchObject("Object");
if (obj)
{
TextureTag* textag = (TextureTag* )obj->GetTag(Ttexture);
if (textag)
textag->SetMaterial(matclone);
}
const Real radius_in_preview_scene = 100.;
SetParameter(matclone, RADIUS_UNITS, GeData(radius_in_preview_scene));
SetParameter(matclone, ORIGIN_AT_SURFACE, GeData(FALSE));
preparescene->bScenePrepared = TRUE; // inform the preview that the scene is prepared now
return TRUE;
}
break;
case MATPREVIEW_GET_POPUP_OPTIONS:
{
BaseContainer* bc = (BaseContainer* )data;
bc->SetString(MATPREVIEW_POPUP_NAME, GeLoadString(IDS_ATMOSPHERE));
bc->SetString(1, GeLoadString(IDS_ATMOSPHERE_MATPREVIEW));
bc->SetString(2, GeLoadString(IDS_ATMOSPHERE_MATPREVIEW2));
bc->SetString(3, GeLoadString(IDS_ATMOSPHERE_MATPREVIEW3));
return TRUE;
}
break;
case MATPREVIEW_GENERATE_IMAGE:
{
MatPreviewGenerateImage* image = (MatPreviewGenerateImage* )data;
if (image->pDoc)
{
if (!image->bEditorPreview)
{
// we don't calculate a preview map for the editor
LONG w = image->pDest->GetBw();
LONG h = image->pDest->GetBh();
BaseContainer bcRender = image->pDoc->GetActiveRenderData()->GetData();
bcRender.SetReal(RDATA_XRES, w);
bcRender.SetReal(RDATA_YRES, h);
bcRender.SetLong(RDATA_ANTIALIASING, ANTI_GEOMETRY);
if (image->bLowQuality)
bcRender.SetBool(RDATA_RENDERENGINE, RDATA_RENDERENGINE_PREVIEWSOFTWARE);
image->pDest->Clear(0, 0, 0);
image->lResult = RenderDocument(image->pDoc, bcRender, NULL, NULL, image->pDest,
RENDERFLAGS_EXTERNAL | RENDERFLAGS_PREVIEWRENDER, image->pThread);
}
}
return TRUE;
}
break;
}
return MaterialData::Message(node, type, data);
}