ObjectData::Draw
-
I want to draw the object 2d on the screen (the front, always displayed), but my code will have problems, how can I modify it.
Now it looks like there is a problem with the drawing order? My object should be drawn last.
class Obj : public ObjectData { public: DRAWRESULT Draw(BaseObject* op, DRAWPASS drawpass, BaseDraw* bd, BaseDrawHelp* bh); static NodeData* Alloc() { return NewObjClear(Obj); } }; DRAWRESULT Obj::Draw(BaseObject* op, DRAWPASS drawpass, BaseDraw* bd, BaseDrawHelp* bh) { if (drawpass != DRAWPASS::OBJECT) return DRAWRESULT::SKIP; if (op == nullptr || bd == nullptr || bh == nullptr) return DRAWRESULT::FAILURE; const Vector& screenSpacePos = bd->WS(op->GetMg().off); // set color bd->SetPen(Vector(255,86,137)/255); // draw circle bd->DrawCircle2D(screenSpacePos.x, screenSpacePos.y, 15); // draw handle bd->DrawHandle2D(screenSpacePos, DRAWHANDLE::BIG); if (bd->TestBreak()) return DRAWRESULT::OK; return DRAWRESULT::OK; }
Thank,
AiMiDi -
Hi @AiMiDi,
thank you for reaching out to us. We are not 100% certain what you mean with:
Now it looks like there is a problem with the drawing order?
, but I would assume you want the handle to be drawn in front of the cube-like geometry and not behind it? This is caused by drawing into the draw-pass
DRAWPASS::OBJECT
. Changing the drawing space to a screen projection while in theObject
draw pass will not bring the drawn content in front of everything else, as this just means using another coordinate system and nothing else (as done in your code withconst Vector& screenSpacePos = bd->WS(op->GetMg().off);
).You probably want to draw into the draw-pass
HANDLES
, as this is the draw pass into which one is meant to draw handles. Relevant in this context might also be theDRAWPASS
enum and this olderblog post of ours
[URL-REMOVED].I hope this helps, if anything remains unclear, please do not hesitate to ask.
Cheers,
Ferdinand
[URL-REMOVED] @maxon: This section contained a non-resolving link which has been removed.
-
Thanks for your answer, it solved my problem.
Thank,
AiMiDi