THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 20/12/2010 at 00:40, xxxxxxxx wrote:
User Information:
Cinema 4D Version: R12
Platform: Windows ;
Language(s) : C++ ;
---------
Hi all,
I have a full working SceneHookPlugin witch Draw some additional information about an object to the viewport. All works great except for the performance of the viewport, witch goes down to 20%.
To show the informations I use that function (GeClipmap, BaseBitmap...) :
https://plugincafe.maxon.net/topic/4169/3712_draw-text-to-viewport-like-measureconst&PID=15161#15161
Also the recalculation slows the fps-rate. Is there a Event like: "PolygonObject Changed?"
How can I boost the performance?
Here is is the code-snippet:
static Bool DrawText(String text, LONG xpos, LONG ypos, BaseDraw *bd)
{
AutoAlloc<GeClipMap> cm;
cm->Destroy();
if(!cm) return FALSE;
if(cm->Init(0,0,1)!=IMAGERESULT_OK) return FALSE;
cm->BeginDraw();
LONG width = cm->TextWidth(text);
LONG height = cm->TextHeight();
cm->EndDraw();
cm->Destroy();
if(cm->Init(width, height, 1)!=IMAGERESULT_OK) return FALSE;
cm->BeginDraw();
cm->SetColor(255, 255, 255, 0);
cm->TextAt(0,0,text);
cm->EndDraw();
bd->SetMatrix_Screen();
bd->SetLightList(BDRAW_SETLIGHTLIST_NOLIGHTS);
Vector *padr = bNew Vector[4];
//...
uvadr[3] = Vector(0,1,0);
BaseBitmap *cmbmp = NULL;
cmbmp = cm->GetBitmap();
if(!cmbmp) return FALSE;
BaseBitmap *bmp = NULL;
bmp = cmbmp->GetClone();
if(!bmp) return FALSE;
// inverted alpha mode
bd->DrawTexture(bmp, padr, cadr, vnadr, uvadr, 4, DRAW_ALPHA_INVERTED, DRAW_TEXTUREFLAGS_0);
return TRUE;
}
Bool XXProgram::Draw(BaseSceneHook *node, BaseDocument *doc, BaseDraw *bd, BaseDrawHelp *bh, BaseThread *bt, SCENEHOOKDRAW flags)
{
if(!SCENEHOOKDRAW_DRAW_PASS) return FALSE;
if(!doc) return FALSE;
AutoAlloc <AtomArray> arr;
doc->GetActivePolygonObjects(*arr, TRUE);
//...calculations
DrawText(result, 5, 15, bd);
return TRUE;
}