About
Many classic plugin classes can implement a "Draw" function that allows to draw something in the editor viewport. These "Draw" functions differ from class to class.
Draw
A "Draw" function can be found in the following classic base classes:
- Note
- To avoid drawing order problems the drawing operations of multiple objects or tags can be replaced by the use of the "Draw" function in a SceneHookData plugin.
Usage
A "Draw" function is typically called multiple times during the drawing process for different draw passes and for each open viewport window. The given BaseDraw object represents a viewport window and is used to draw in that window.
This is an example implementation of ObjectData::Draw():
{
if (drawpass != DRAWPASS_OBJECT)
return SUPER::Draw(
op, drawpass, bd, bh);
return SUPER::Draw(
op, drawpass, bd, bh);
}
Definition: c4d_basedraw.h:40
const Matrix & GetMg()
Definition: c4d_basedraw.h:85
Definition: c4d_basedraw.h:755
void DrawLine(const Vector &p1, const Vector &p2, Int32 flags)
Definition: c4d_basedraw.h:1219
void SetDrawParam(Int32 id, const GeData &data)
Definition: c4d_basedraw.h:1507
GeData GetDrawParam(Int32 id) const
Definition: c4d_basedraw.h:1515
void SetMatrix_Matrix(BaseObject *op, const Matrix &mg)
Definition: c4d_basedraw.h:1111
void SetPen(const Vector &col, Int32 flags=0)
Definition: c4d_basedraw.h:991
Definition: c4d_baseobject.h:248
Definition: c4d_gedata.h:83
maxon::Vec3< maxon::Float64, 1 > Vector
Definition: ge_math.h:141
#define DRAW_PARAMETER_LINEWIDTH
Float Line width in pixels. (OpenGL only.)
Definition: c4d_basedraw.h:1520
DRAWPASS
Definition: ge_prepass.h:3509
DRAWRESULT
Definition: ge_prepass.h:4364
#define NOCLIP_D
Clip against the view border.
Definition: c4d_basedraw.h:1140
PyObject * op
Definition: object.h:520
Typical tasks in a "Draw" function are:
- Check the current draw pass to avoid unnecessary operations.
- Check if the assigned layer of the object, tag or material disables viewport drawing.
- Set the reference coordinate system for the following drawing operations.
- Set the drawing parameters for the following drawing operations.
- Perform drawing operations.
- Reset the drawing parameters.
How to use a BaseDraw object is described in BaseView / BaseDraw Manual.
Examples
For objects that can be assigned to layers it might be necessary to check if the assigned layer forbids viewport drawing. See Layer Manual.
Definition: c4d_basedocument.h:497
BaseDocument * GetDocument()
Definition: c4d_basedraw.h:73
@ SKIP
There was nothing to draw in this pass.
const char * doc
Definition: pyerrors.h:226
Definition: c4d_basedocument.h:318
Bool view
Visible in editor view.
Definition: c4d_basedocument.h:352
If the drawing operations should only be applied to the currently selected viewport window it is needed to check if the given BaseDraw represents the selected viewport.
const Bool isActiveBD = bd && (bd == activeBD);
if (!isActiveBD)
maxon::Bool Bool
Definition: ge_sys_math.h:51
It is also possible to enable or disable several viewport filters that define what should be visible in the viewport.
Further Reading