Set the "DrawCircle" orientation to face camera
-
Hello,
How to set the orientation of "DrawCircle" to face the camera like in Orientation Property of Null Object.
info = c4d.HandleInfo() # Defines the position and the size of the circle circleSettings = bh.GetMg() circleSettings.off = info.position circleSettings.v1 *= 20 circleSettings.v2 *= 20 circleSettings.v3 *= 20 # Draw the Circle bd.DrawCircle(circleSettings)
Thank you.
-
Hello,
as always, please mark your post as a question.
Can you share a little more information about what you are actually doing? What is the context of the code you provided?
If you want to draw a circle in screen space, the easiest thing would be to just draw a 2D circle using DrawCircle2D().
# This example draws a 2D line, circle and point. bd.SetMatrix_Screen() center = c4d.Vector(100.0, 100.0, 0) tangentPoint = c4d.Vector(150.0, 100.0, 0) # draw line and circle bd.SetPen(c4d.Vector(0.8)) bd.DrawLine2D(center, tangentPoint) bd.DrawCircle2D(center.x, center.y, tangentPoint.x - center.x) # draw point bd.SetPen(c4d.Vector(1.0)) bd.DrawPoint2D(center) bd.SetMatrix_Matrix(None, c4d.Matrix())
best wishes,
Sebastian -
@s_bach
Hello,
I want use it on the ObjectData.Draw() function.Here is the full code:
def Draw(self, op, drawpass, bd, bh): if drawpass != c4d.DRAWPASS_HANDLES: return c4d.DRAWRESULT_SKIP bd.SetMatrix_Matrix(op, bh.GetMg()) hitid = op.GetHighlightHandle(bd) for i in xrange(self.GetHandleCount(op)): color = c4d.GetViewColor(c4d.VIEWCOLOR_SELECTION_PREVIEW) if i == hitid else c4d.GetViewColor(c4d.VIEWCOLOR_ACTIVEPOINT) bd.SetPen(color) info = c4d.HandleInfo() self.GetHandle(op, i, info) bd.DrawHandle(info.position, c4d.DRAWHANDLE_BIG, 0) bd.SetMatrix_Matrix(op, bh.GetMg()) circleSettings = bh.GetMg() circleSettings.off = info.position circleSettings.v1 *= 20 circleSettings.v2 *= 20 circleSettings.v3 *= 20 bd.DrawCircle(circleSettings) return c4d.DRAWRESULT_OK
Thank you.
-
hello,
using this to draw a circle at op position. You can use your handle position instead.
The main point is retrieving the view matrix with bd.GetMg() to have you Y and X vectors lined with the view.if drawpass == c4d.DRAWPASS_OBJECT: rad = 20.0 bd.SetMatrix_Matrix(op, c4d.Matrix()); m = bd.GetMg(); m.off = bh.GetMg().off; m.v3 = c4d.Vector(0.0); m.v1 *= rad; m.v2 *= rad; bd.DrawCircle(m); return c4d.DRAWRESULT_OK
Cheers,
Manuel -
@m_magalhaes
Thank you. I made some changes but its work!Cheers,
Mustapha