Hi @C4DS,
thank you for reaching out to us. This is probably not possible in the way you are trying to implement it, assuming that I do understand your approach correctly. Note the special note in the description of BaseDarw::SetMatrix_Screen
This method only affects the new 3D drawing methods below it, i.e. DrawLine(), LineStrip(), DrawHandle(), DrawPoly(), DrawTexture(), DrawCircle(), DrawBox(), DrawPolygon() and DrawSphere().
What is also a bit unclear to me is on which plane you do draw your texture, I assume on the camera plane, i.e., at z=0.0
? I am not sure if you are aware of it, but screen space does not mean 2D, you can still offset things along the depth/z-axis.
Long story short, I did recreate your setup in Python and do not really see a way out. I also looked at the code of DrawPolygonObject
and it looks like that is should respect the z-depth of a drawing operation when you pass DRAWOBJECT::Z_OFFSET
as flag
, but it does not work for me. I will reach out to the devs to ask them if this combination of screen space (the texture) and world space (the polygon object) drawing operation while supporting a drawing order is supported. I will report back when I have an answer. But I would not hold my breath that this is possible.
Cheers,
Ferdinand
My test script as a Python scripting tag, in case I somehow misunderstood you.
import c4d
LINEZOFFSET = 0
def GetViewBitmapData(viewFrame, color=c4d.Vector(.25, .5, 1), alpha=.5,
zdepth=0.):
"""Returns the data for a texture drawing operation of filling the
viewport with an uniformly colored bitmap.
"""
# Create the canvas for a 1x1 bitmap.
color *= 255
alpha *= 255
canvas = c4d.bitmaps.GeClipMap()
canvas.Init(w=1, h=1)
canvas.BeginDraw()
canvas.SetColor(int(color.x),
int(color.y),
int(color.z),
int(alpha))
canvas.SetPixel(0, 0)
canvas.EndDraw()
# The polygon data.
padr4 = [c4d.Vector(viewFrame["cl"], viewFrame["ct"], zdepth),
c4d.Vector(viewFrame["cl"], viewFrame["cb"], zdepth),
c4d.Vector(viewFrame["cr"], viewFrame["cb"], zdepth),
c4d.Vector(viewFrame["cr"], viewFrame["ct"], zdepth)]
cadr = [c4d.Vector(1)] * 4
vnadr = [c4d.Vector(0, 0, 1)] * 4
uvadr = [c4d.Vector(0, 0, 0),
c4d.Vector(0, 1, 0),
c4d.Vector(1, 1, 0),
c4d.Vector(1, 0, 0)]
# Return the DrawTexture signature.
return {"bmp": canvas.GetBitmap().GetClone(),
"padr4": padr4,
"cadr": cadr,
"vnadr": vnadr,
"uvadr": uvadr,
"pntcnt": 4,
"alphamode": c4d.DRAW_ALPHA_FROM_IMAGE,
"flags": c4d.DRAW_TEXTUREFLAGS_USE_PROFILE_COLOR}
def draw(bd):
"""
"""
# The hosting object and the frame of the viewport.
node = op.GetObject()
viewFrame = bd.GetSafeFrame()
# Draw the bitmap.
bd.SetMatrix_Screen(LINEZOFFSET)
#bd.DrawTexture(**GetViewBitmapData(viewFrame))
# Draw the polygon object.
bh = c4d.plugins.BaseDrawHelp(bd, doc)
# bd.SetMatrix_Screen(LINEZOFFSET + 1)
bd.LineZOffset(5)
bd.DrawPolygonObject(bh, node, c4d.DRAWOBJECT_Z_OFFSET)
def main():
pass