c4d.BaseDraw

This class represents a CINEMA 4D window and cannot be instantiated.

Inheritance

Members

BaseDraw.GetParameterData(id)

Get a new parameter object.

Parameters: id (int) – A parameter ID. See the dbasedraw.h description file.
Return type: any
Returns: The parameter data for id. The type depends on the id.
BaseDraw.GetFrameScreen()

Used in the Extended GL mode. This mode is not documented. See c4d_gl.h for definitions.

Return type: dict{cl: int, ct: int, cr: int, cb: int, }
Returns: A dict or None.

Indicates if the camera link is enabled.

Return type: bool
Returns: True if a scene camera is used, and False if the editor camera is used.
BaseDraw.SetSceneCamera([op=None][, animate=False])

Sets a new scene camera. If op os None, the editor camera is used.

Parameters:
  • op (BaseObject) – The new camera.
  • animate (bool) – Private.
BaseDraw.GetSceneCamera(doc)

Returns the current scene camera from the passed document, or None if no scene camera is used.

Parameters: doc (BaseDocument) – The document to get the scene camera from.
Return type: BaseObject
Returns: The scene camera.
BaseDraw.GetEditorCamera(doc)

Returns the editor camera.

Parameters: doc (BaseDocument) – The document to get the editor camera from.
Return type: BaseObject
Returns: The editor camera.
BaseDraw.GetDisplayFilter()

Returns the current display filter. This is a bit field derived from the BASEDRAW_DISPLAYFILTER_* description flags in dbasedraw.res. To set the display filter you have to use the description flags with BaseList2D.__setitem__().

Return type: int
Returns: A bit field with the following flags:
DISPLAYFILTER_0 No flags.
DISPLAYFILTER_NULL Null objects.
DISPLAYFILTER_POLYGON Polygon objects.
DISPLAYFILTER_SPLINE Spline objects.
DISPLAYFILTER_GENERATOR Generator.
DISPLAYFILTER_HYPERNURBS Hyper NURBS.
DISPLAYFILTER_UNUSED1 Bones.
DISPLAYFILTER_DEFORMER Deformers.
DISPLAYFILTER_CAMERA Cameras.
DISPLAYFILTER_LIGHT Lights.
DISPLAYFILTER_SCENE Scene objects.
DISPLAYFILTER_PARTICLE Particle objects.
DISPLAYFILTER_OTHER Other objects.
DISPLAYFILTER_NULLBONES Null bones.
DISPLAYFILTER_GRID Grid.
DISPLAYFILTER_HORIZON Horizon.
DISPLAYFILTER_WORLDAXIS World axis.
DISPLAYFILTER_BOUNDS Bounds.
DISPLAYFILTER_HUD HUD.
DISPLAYFILTER_SDS SDS.
DISPLAYFILTER_HIGHLIGHTING Highlighting.
DISPLAYFILTER_MULTIAXIS Multi axis.
DISPLAYFILTER_OBJECTHANDLES Object handles.
DISPLAYFILTER_HANDLEBANDS Handle bands.
DISPLAYFILTER_SDSCAGE SDS cage.
DISPLAYFILTER_NGONLINES N-gon lines.
DISPLAYFILTER_JOINT Joint objects.
BaseDraw.GetEditState()

Get the edit state. This is a bit field derived from the BASEDRAW_DISPLAYFILTER_* description flags in dbasedraw.res. To set the display filter you have to use the description flags with BaseList2D.__setitem__().

Return type: int
Returns: A bit field with the following flags:
DISPLAYEDITSTATE_0 No flags.
DISPLAYEDITSTATE_SDS SDS edit state.
DISPLAYEDITSTATE_DEFORM Deformed edit state.
BaseDraw.IsViewOpen(doc)

Checks if the current tool can use the curent SDS/Deformed editing state.

Parameters: doc (BaseDocument) – The current document.
Return type: bool
Returns: True if the view is open, otherwise False.
BaseDraw.InitializeView(doc, cam, editorsv)

Used after rendering into a framebuffer with different resolution than the editor view.

Parameters:
  • doc (BaseDocument) – The view’s document.
  • cam (BaseObject) – The view’s camera.
  • editorsv (bool) – Set this True to retain the view’s ratio.
BaseDraw.InitClipbox(left, top, right, bottom, flags)

Used to render into a framebuffer with different resolution than the editor view.

Parameters:
  • left (int) – Left coordinate of the framebuffer.
  • top (int) – Top coordinate of the framebuffer.
  • right (int) – Right coordinate of the framebuffer.
  • bottom (int) – Bottom coordinate of the framebuffer.
  • flags (int) –

    Flags:

    INIT_CLIPBOX_ADJUSTGLSIZE Adjust the size of the frame buffer.
BaseDraw.InitView(camera, op_m, sv, pix_x, pix_y, fitview)

Used to render into a framebuffer with different resolution than the editor view.

Parameters:
  • camera (BaseContainer) – The camera’s container.
  • op_m (Matrix) – The camera’s matrix.
  • sv (float) – The frame’s ratio.
  • pix_x (float) – The frame’s X size.
  • pix_y (float) – The frame’s Y size.
  • fitview (bool) – Set this to True to fit the view.
BaseDraw.AddToPostPass(op, bh)

Adds the object op to DRAWPASS_XRAY. For example:

def Draw(self, op, drawpass, bd, bh):
    if drawpass==c4d.DRAWPASS_OBJECT:
        bd.AddToPostPass(op, bh)
        ok=True
    elif drawpass==c4d.DRAWPASS_XRAY:
        ok=True

    if ok==False: return c4d.DRAWRESULT_OK
Parameters:
  • op (BaseObject) – The object to add to the X-ray pass.
  • bh (BaseDrawHelp) – The current base draw helper.
BaseDraw.GetObjectColor(bh, op)

Returns the wireframe color in editor for the specified object. Some types of objects have certain colors. For polygon objects the main color is taken into account.

Parameters:
Return type:

Vector

Returns:

The object color.

BaseDraw.CheckColor(col)

Makes sure that a color has at least 15% difference to the background color.

Parameters: col (Vector) – The original vector.
Return type: Vector
Returns: The new color, adjusted if needed.
BaseDraw.SetTransparency(trans)

Sets the transparency value for following polygons. The range is 0 to 255, where 255 is 100% transparent. Use negative values for true transparencies and positive values for ‘dotted’ transparencies.

Parameters: trans (int) – The transparency.
BaseDraw.GetTransparency()

Returns the current transparency value for polygons. The range is 0 to 255, where 255 is 100% transparent. Negative values are true transparencies and positive values are ‘dotted’ transparencies.

Return type: int
Returns: The transparency.
BaseDraw.PointInRange(p, x, y)

Returns True if the screen point (x,y) is within a hit range of the world point p, i.e. if the screen point is close to the world points projection on the screen.

Parameters:
  • p (Vector) – A point in world space.
  • x (int) – Screen x coordinate.
  • y (int) – Screen y coordinate.
Return type:

bool

Returns:

True if the point is within range, otherwise True.

BaseDraw.SetPen(col[, flags=0])

Sets the pen color for following drawing operations.

Parameters:
  • col (Vector) – The new color.
  • flags (int) –

    New in version R13.016.

    SET_PEN_USE_PROFILE_COLOR Set this flag if the color is already in the color space of the BaseDraw. Otherwise the color will be converted.
BaseDraw.SetPointSize(pointsize)

New in version R13.016.

Sets the drawn point size.

Parameters: pointsize (float) – The new point size.
BaseDraw.SimpleShade(p, n)

A quick shading algorithm that only takes the angle to the camera and a default light into account. You pass a point and a normal in world space and get back the intensity. Can be combined with Polygon() to draw simple shaded polygons.

Parameters:
  • p (Vector) – A point in world space.
  • n (Vector) – A normal in world space.
Return type:

float

Returns:

The intensity of the light. Between 0 and 1.

BaseDraw.ConvertColor(c)

New in version R13.016.

Converts colors from document color profile to viewport color profile.

Parameters: c (Vector) – The color to convert (document).
Return type: Vector
Returns: The converted color (viewport).
BaseDraw.ConvertColorReverse(c)

New in version R13.016.

Converts colors from viewport color profile to document color profile.

Parameters: c (Vector) – The color to convert (viewport).
Return type: Vector
Returns: The converted color (document).
BaseDraw.LineZOffset(offset)

Sets the current Z buffer offset. Use this to for example draw lines over shaded polygons in front of the screen. A higher offset value means a higher draw priority in the Z buffer. For example:

  • shaded polygon (level 0)
  • unselected edges (level 2)
  • selected edges (level 4)

Note

This function only affects the new draw functions below it, i.e. DrawHandle(), DrawTexture(), DrawCircle(), DrawBox(), and DrawSphere().

Parameters: offset (int) – The new Z buffer offset.
BaseDraw.SetDepth(enable)

New in version R13.016.

Enables/disables writing to the depth buffer.

Parameters: enable (bool) – True to enable depth buffer writing, otherwise False.
BaseDraw.SetMatrix_Projection()

For internal use only.

BaseDraw.SetMatrix_Screen([offset==-1])

Sets the transformation matrix to screen coordinates, i.e. from (0, 0) to (width, height).

Note

This function only affects the new draw functions below it, i.e. DrawHandle(), DrawTexture(), DrawCircle(), DrawBox(), and DrawSphere().

Parameters: offset (int) –

Sets the current Z buffer offset. Use this to for example draw lines over shaded polygons in front of the screen. A higher zoffset value means a higher draw priority in the Z buffer. For example:

  • shaded polygon (level 0)
  • unselected edges (level 2)
  • selected edges (level 4)
BaseDraw.SetMatrix_Camera()

Sets the transformation matrix to the camera system.

Note

This function only affects the new draw functions below it, i.e. DrawHandle(), DrawTexture(), DrawCircle(), DrawBox(), and DrawSphere().

BaseDraw.SetMatrix_Matrix(op, mg[, zoffset])

Sets the transformation matrix to the given matrix mg. The matrix should transform coordinates passed to the draw functions into world coordinates.

Parameters:
  • op (BaseObject) – A scene object. If passed this is used to compare if the same object is still used.
  • mg (Matrix) – The new transformation matrix.
  • zoffset (int) –

    Sets the current Z buffer offset. Use this to for example draw lines over shaded polygons in front of the screen. A higher zoffset value means a higher draw priority in the Z buffer. For example:

    • shaded polygon (level 0)
    • unselected edges (level 2)
    • selected edges (level 4)
BaseDraw.DrawPoint2D(p)

Draws a one-pixel point in the current pen color at p. The coordinates must be in screen space.

Parameters: p (Vector) – A point.
BaseDraw.DrawLine2D(p1, p2)

Draws a line in the current pen color between p1 and p2. The coordinates must be in screen space.

Parameters:
  • p1 (Vector) – The start point.
  • p2 (Vector) – The end point.
BaseDraw.DrawHandle2D(p[, type=DRAWHANDLE_SMALL])

Draws a standard handle (orange dot) at p. The coordinates must be in screen space.

Parameters:
  • p (Vector) – A point.
  • type (int) –

    The handle type. Possible values are:

    DRAWHANDLE_MINI Mini handle.
    DRAWHANDLE_SMALL Small handle.
    DRAWHANDLE_MIDDLE Middle handle.
    DRAWHANDLE_BIG Handle used by object generators and deformers.
    DRAWHANDLE_CUSTOM Custom handle.
BaseDraw.DrawCircle2D(mx, my, rad)

Draws a circle in the current pen color with a radius of rad and the center at (mx, my). The coordinates must be in screen space.

Parameters:
  • mx (int) – Center x coordinate.
  • my (int) – Center y coordinate.
  • rad (float) – The radius.
BaseDraw.DrawLine(p1, p2, flags)

Draws a line in the current pen color between p1 and p2. The coordinates must be in world space.

Parameters:
  • p1 (Vector) – The start point.
  • p2 (Vector) – The end point.
  • flags (int) –

    New in version R13.016.

    Flags:

    NOCLIP_D Clip against the view border.
    NOCLIP_Z Z clipping.
BaseDraw.DrawHandle(vp, type, flags)

Draws a standard handle (orange dot) at vp. The coordinates must be in world space.

Parameters:
  • vp (Vector) – A point.
  • type (int) –

    The handle type. Valid types are:

    DRAWHANDLE_MINI Mini handle.
    DRAWHANDLE_SMALL Small handle.
    DRAWHANDLE_MIDDLE Middle handle.
    DRAWHANDLE_BIG Handle used by object generators and deformers.
    DRAWHANDLE_CUSTOM Custom handle.
  • flags (int) – Private, set to 0.
BaseDraw.DrawPoints(vp[, vc][, colcnt=0][, vn])

Draws an array of shaded points with individual colors. The shading is determined by SetLightList().

Note

The coordinates must be in the space defined by SetMatrix_Screen(), SetMatrix_Camera() or SetMatrix_Matrix().

Parameters:
  • vp (any) – An iteratable object with Vector as elements for the point coordinates.
  • vc (any) – An iteratable object with floats as elements for the point color.
  • colcnt (int) – The number of color elements, for example 3 for RGB.
  • vn (any) – An iteratable object with Vector as elements for the normals of the shaded points.
BaseDraw.DrawTexture(bmp, padr4, cadr, vnadr, uvadr, pntcnt, alphamode, flags)

Draws a colored and shaded texture polygon using the points in padr4, the colors in cadr, the normals in vnadr and the UV coordinates in uvadr. Only triangles and quadrangles are accepted. The colors are interpolated between the points and mutiplied with the texture color. The shading is determined by SetLightList().

Note

The coordinates must be in the space defined by SetMatrix_Screen(), SetMatrix_Camera() or SetMatrix_Matrix().

Parameters:
  • bmp (BaseBitmap) – The texture to draw.
  • padr4 (any) – An iteratable object with Vector as elements for the point coordinates.
  • cadr (any) – An iteratable object with Vector as elements for the colors.
  • vnadr (any) – An iteratable object with Vector as elements for the point normals.
  • uvadr (any) – An iteratable object with Vector as elements for UV coordinates.
  • pntcnt (int) – The number of points. Must be either 3 or 4.
  • alphamode (int) –
    DRAW_ALPHA_NONE No alpha.
    DRAW_ALPHA_INVERTED Inverted alpha.
    DRAW_ALPHA_NORMAL Normal alpha.
    DRAW_ALPHA_FROM_IMAGE Alpha from image.
  • flags (int) –
    DRAW_TEXTUREFLAGS_0 No flags.
    DRAW_TEXTUREFLAGS_COLOR_IMAGE_TO_LINEAR Convert from embedded profile to linear.
    DRAW_TEXTUREFLAGS_COLOR_SRGV_TO_LINEAR Convert from SRGB to linear.
    DRAW_TEXTUREFLAGS_IMAGE_TO_SRGB Convert from embedded profile to SRGB.
    DRAW_TEXTUREFLAGS_COLOR_LINEAR_TO_SRGB Convert from linear to SRGB.
    DRAW_TEXTUREFLAGS_COLOR_CORRECTION_MASK Color correction mask.
    DRAW_TEXTUREFLAGS_USE_PROFILE_COLOR Use color profile from the image.
    DRAW_TEXTUREFLAGS_ALLOW_FLOATINGPOINT Allow float point textures (if supported).
    DRAW_TEXTUREFLAGS_INTERPOLATION_NEAREST Nearest interpolation.
    DRAW_TEXTUREFLAGS_INTERPOLATION_LINEAR Linear interpolation.
    DRAW_TEXTUREFLAGS_INTERPOLATION_LINEAR_MIPMAP Mipmap interpolation.
    DRAW_TEXTUREFLAGS_INTERPOLATION_MASK Mask interpolation.
BaseDraw.DrawBox(m, size, col, wire)

Draws a box. The eight points of the box are defined as:

p = (None)*8
p[0] = Vector(-size, -size, -size);
p[1] = Vector( size, -size, -size);
p[2] = Vector( size, -size,  size);
p[3] = Vector(-size, -size,  size);
p[4] = Vector(-size,  size, -size);
p[5] = Vector( size,  size, -size);
p[6] = Vector( size,  size,  size);
p[7] = Vector(-size,  size,  size);

To get arbitrary cubic forms, set size to 0.5 and multiply the vectors in the matrix by the length.

Note

The coordinates must be in the space defined by SetMatrix_Screen(), SetMatrix_Camera() or SetMatrix_Matrix().

Parameters:
  • m (Matrix) – A matrix describing the box.
  • size (float) – The size of the box.
  • col (Vector) – The color of the box.
  • wire (bool) – If this is True a wireframe is drawn.
BaseDraw.DrawCircle(m)

Draws an ellipse in the current pen color. The ellipse is specified by the matrix m, where m.v1 and m.v2 are the axis vectors and m.off is the center position. (m.v3 isn’t used.) The coordinates must be in world space.

Note

The coordinates must be in the space defined by SetMatrix_Screen(), SetMatrix_Camera() or SetMatrix_Matrix().

Parameters: m (Matrix) – A matrix describing the circle.
BaseDraw.DrawPolygon(p, f)

Draws a manually shaded triangle or quadrangle. The corner points are given as a list of Vectors in p, and the corner colors as a corresponding list of Vectors in f. Example:

p = ( c4d.Vector(0,0,0), c4d.Vector(100,0,0), c4d.Vector(50,100,0) )
f = ( c4d.Vector(1,0,0), c4d.Vector(0,0,1), c4d.Vector(0,1,0) )
bd.DrawPolygon(p, f)

Note

The coordinates must be in the space defined by SetMatrix_Screen(), SetMatrix_Camera() or SetMatrix_Matrix().

Parameters:
  • p (list of Vector) – A list of points.
  • f (list of type Vector) – A list of points.
BaseDraw.DrawSphere(off, size, col, flags)

Draws a sphere at position off with size specified by the size vector in each direction and color specified by col.

Note

The coordinates must be in the space defined by SetMatrix_Screen(), SetMatrix_Camera() or SetMatrix_Matrix().

Parameters:
  • off (Vector) – Position coordinate.
  • size (Vector) – Sphere size.
  • col (Vector) – The color.
  • flags (int) –
    NOCLIP_D Clip against the view border.
    NOCLIP_Z Z clipping.
BaseDraw.DrawArrayEnd()

Each DrawPolygon() puts the polygon into an internal array and draws the polygons when the array is full or an OpenGL state changes (e.g. the matrix). With this method you can force this operation.

BaseDraw.DrawPolygonObject(bh, op, flags)

Draws a polygon object into the view.

Parameters:
  • bh (BaseDrawHelp) – Needs to be passed along.
  • op (BaseObject) – The object.
  • flags (int) –

    Flags:

    DRAWOBJECT_0 No flags.
    DRAWOBJECT_FORCELINES Force wireframe display, independent of view settings.
    DRAWOBJECT_NOBACKCULL Force no backface culling, independent of view settings.
    DRAWOBJECT_LOCALMATRIX Object drawn will be drawn relative to the currently processed object (used when called from the draw function in an object).
    DRAWOBJECT_EDITMODE Object is drawn in edit-mode style.
    DRAWOBJECT_FORCEBASE The draw call is only executed for the base class, and thus not for the instanciated object, if passed to BaseDraw.DrawObject() and the object type is an instance of either Opoint or Opolygon. This way, you can do a draw call without running into a recursion if you’re in your from points/polygons derived object.
    DRAWOBJECT_FORCEPOINTS Private.
    DRAWOBJECT_NO_EOGL Private.
    DRAWOBJECT_USE_OBJECT_COLOR Private.
    DRAWOBJECT_USE_CUSTOM_COLOR Private.
    DRAWOBJECT_XRAY_ON Private.
    DRAWOBJECT_XRAY_OFF Private.
    DRAWOBJECT_PRIVATE_ANY Private.
BaseDraw.DrawObject(bh, op, flags, drawpass, parent)

Draws a polygon object into the view.

Parameters:
  • bh (BaseDrawHelp) – Needs to be passed along.
  • op (BaseObject) – The object.
  • flags (int) –

    Flags:

    DRAWOBJECT_0 No flags.
    DRAWOBJECT_FORCELINES Force wireframe display, independent of view settings.
    DRAWOBJECT_NOBACKCULL Force no backface culling, independent of view settings.
    DRAWOBJECT_LOCALMATRIX Object drawn will be drawn relative to the currently processed object (used when called from the draw function in an object).
    DRAWOBJECT_EDITMODE Object is drawn in edit-mode style.
    DRAWOBJECT_FORCEBASE The draw call is only executed for the base class, and thus not for the instanciated object, if passed to BaseDraw.DrawObject() and the object type is an instance of either Opoint or Opolygon. This way, you can do a draw call without running into a recursion if you’re in your from points/polygons derived object.
    DRAWOBJECT_FORCEPOINTS Private.
    DRAWOBJECT_NO_EOGL Private.
    DRAWOBJECT_USE_OBJECT_COLOR Private.
    DRAWOBJECT_USE_CUSTOM_COLOR Private.
    DRAWOBJECT_XRAY_ON Private.
    DRAWOBJECT_XRAY_OFF Private.
    DRAWOBJECT_PRIVATE_ANY Private.
  • drawpass (int) –

    Drawpass:

    DRAWPASS_OBJECT Object pass
    DRAWPASS_BOX Box pass
    DRAWPASS_HANDLES Handle pass
    DRAWPASS_HIGHLIGHTS Highlights pass
    DRAWPASS_XRAY X-ray pass
  • parent (BaseObject) – The parent object, can be None.
BaseDraw.DrawScene(flags)

Draw a scene into the framebuffer.

Parameters: flags (int) – Private.
Return type: bool
Returns: Success of drawing the scene.
BaseDraw.GetReductionMode()

Private.

Return type: bool
Returns: True on success, otherwise False.
BaseDraw.SetLightList(mode)

Sets the lighting used by the draw functions.

Note

The coordinates must be in the space defined by SetMatrix_Screen(), SetMatrix_Camera() or SetMatrix_Matrix().

Parameters: mode
BDRAW_SETLIGHTLIST_NOLIGHTS No lights.
BDRAW_SETLIGHTLIST_SCENELIGHTS Scene lights.
BDRAW_SETLIGHTLIST_QUICKSHADING Quick shading.
Return type: bool
Returns: True on success, otherwise False.
BaseDraw.InitUndo(doc)

Called before a change is made to the view to add the old setting to the undo buffer for the view. (This undo buffer is separate from the normal undo buffer.)

BaseDraw.DoUndo(doc)

Performs an undo operation in the view. This is the same as the user selecting Undo View from within CINEMA 4D.

BaseDraw.SetDrawParam(id, data)

Sets draw parameters.

Note

The coordinates must be in the space defined by SetMatrix_Screen(), SetMatrix_Camera() or SetMatrix_Matrix().

Parameters:
  • id (int) – Parameter ID.
  • data (any) – Depends on the parameter ID.
BaseDraw.GetDrawParam(id)

Gets draw parameters.

Parameters: id (int) – Parameter ID.
Return type: any
Returns: Depends on the parameter ID.
BaseDraw.TestBreak(id)

Checks for thread breaks in the draw.

Return type: bool
Returns: True if a stopping condition has occurred, otherwise False.
BaseDraw.GetEditorWindow(id)

Get the editor window of the BaseDraw.

Return type: EditorWindow
Returns: The editor window of the base draw.
BaseDraw.SetTexture(bm, tile, alphamode, flags)

Set a texture used by the vertex buffer.

Parameters:
  • bm (BaseBitmap) – The texture’s bitmap.
  • tile (bool) – Enable tiling.
  • alphamode (int) –

    Alpha channel mode:

    DRAW_ALPHA_NONE No alpha.
    DRAW_ALPHA_INVERTED Inverted alpha.
    DRAW_ALPHA_NORMAL Normal alpha.
  • flags (int) – Private, set to 0.

Table Of Contents