On 03/07/2015 at 07:38, xxxxxxxx wrote:
yes I mean the dimensions of pDest bitmap, that's why I don't know what is gone wrong.
here is the whole message code:
Bool SevenPhotonsMaterial::Message(GeListNode* node, Int32 type, void* data)
{
if (type == MSG_UPDATE)
updatecount++;
switch (type)
{
case MATPREVIEW_GET_OBJECT_INFO:
{
MatPreviewObjectInfo* info = (MatPreviewObjectInfo* )data;
info->bHandlePreview = true; // own preview handling
info->bNeedsOwnScene = true; // we need our own entry in the preview scene cache
info->bNoStandardScene = false; // we modify the standard scene
info->lFlags = 0;
break;
}
case MATPREVIEW_MODIFY_CACHE_SCENE:
// modify the preview scene here. We have a pointer to a scene inside the preview scene cache.
// our scene contains the object
{
MatPreviewModifyCacheScene* scene = (MatPreviewModifyCacheScene* )data;
// get the striped plane from the preview
BaseObject* plane = scene->pDoc->SearchObject("Polygon");
if (plane)
{
plane->SetRelScale(Vector(0.1)); // scale it a bit
//update the singleton scene renderer here, also with pushbutton
//GePrint("change called");
}
break;
}
case MATPREVIEW_PREPARE_SCENE:
// let the preview handle the rest...
//return true;
break;
case MATPREVIEW_GENERATE_IMAGE:
{
MatPreviewGenerateImage* image = (MatPreviewGenerateImage* )data;
if (image->pDoc)
{
Int32 w = image->pDest->GetBw();
Int32 h = image->pDest->GetBh();
RenderData* rdata = image->pDoc->GetActiveRenderData();
BaseContainer bcRender = rdata->GetData();
bcRender.SetFloat(RDATA_XRES, w);
bcRender.SetFloat(RDATA_YRES, h);
bcRender.SetInt32(RDATA_ANTIALIASING, ANTI_GEOMETRY);
image->pDest->Clear(0, 0, 0);
GePrint("m_update_preview = " + String::IntToString(m_update_preview));
if(image->bLowQuality)
{
bcRender.SetBool(RDATA_RENDERENGINE, RDATA_RENDERENGINE_PREVIEWSOFTWARE);
image->lResult = RenderDocument(image->pDoc, bcRender, nullptr, nullptr, image->pDest,
RENDERFLAGS_EXTERNAL | RENDERFLAGS_PREVIEWRENDER, image->pThread);
}
else if(m_update_preview == TRUE)
{
((SevenPhotonsMaterial* )node)->m_update_preview = FALSE;
BaseVideoPost* myRenderer = BaseVideoPost::Alloc(ID_SEVENPHOTONS);
rdata->InsertVideoPost(myRenderer);
bcRender.SetInt32(RDATA_RENDERENGINE, ID_SEVENPHOTONS);
image->lResult = RenderDocument(image->pDoc, bcRender, nullptr, nullptr, image->pDest,
RENDERFLAGS_EXTERNAL, image->pThread);
}
}
break;
}
case MATPREVIEW_GET_PREVIEW_ID:
{
*((Int32* )data) = SEVENPHOTONS_MAT_PREVIEW;
break;
}
case MSG_MATERIALDRAGANDDROP:
{
BaseMaterial* mat = static_cast<BaseMaterial*>(node);
MaterialDragAndDrop* mdd = static_cast<MaterialDragAndDrop*>(data);
mdd->result = mdd->op->MakeTag(Ttexture);
mdd->result->SetParameter(TEXTURETAG_MATERIAL, mat, DESCFLAGS_SET_0);
mdd->result->SetParameter(TEXTURETAG_PROJECTION, TEXTURETAG_PROJECTION_UVW, DESCFLAGS_SET_0);
break;
}
case MSG_DESCRIPTION_COMMAND:
{
DescriptionCommand* dc = (DescriptionCommand* )data;
if (dc->id[0].id == SEVENPHOTONS_MAT_PREVIEW_UPDATE)
{
m_update_preview = TRUE;
break;
}
else if (dc->id[0].id == SEVENPHOTONS_MAT_PREVIEW_UPDATE_STOP)
{
m_update_preview = FALSE;
break;
}
}
}
return MaterialData::Message(node, type, data);
}
and the GUI is created using resources
CONTAINER Msevenphotons
{
NAME Msevenphotons;
GROUP
{
MATPREVIEW SEVENPHOTONS_MAT_PREVIEW { OPEN; MIN_WIDTH 288; MIN_HEIGHT 288; NO_SIZE_POPUP; NO_SCENESETTINGS;}
}
INCLUDE Mbase;
}
and in Init()
GeData previewData(CUSTOMDATATYPE_MATPREVIEW, DEFAULTVALUE);
MaterialPreviewData* preview = (MaterialPreviewData* )previewData.GetCustomDataType(CUSTOMDATATYPE_MATPREVIEW);
if (!preview)
return false;
data->SetData(SEVENPHOTONS_MAT_PREVIEW, previewData);
and GetDParameter()
if(id[0].id == SEVENPHOTONS_MAT_PREVIEW)
{
return GetDParameterPreview(data, (GeData* )&t_data, flags, SEVENPHOTONS_MAT_PREVIEW, updatecount, (BaseMaterial* )node);
}
SetDParameter()
if(id[0].id == SEVENPHOTONS_MAT_PREVIEW)
{
return SetDParameterPreview(data, &t_data, flags, SEVENPHOTONS_MAT_PREVIEW);
}