c4d.BaseDraw
¶
This class represents a Cinema 4D window and cannot be instantiated.
c4d.
BaseDraw
¶
BaseDraw.GetFrameScreen()
BaseDraw.HasCameraLink()
BaseDraw.SetSceneCamera()
BaseDraw.GetSceneCamera()
BaseDraw.GetEditorCamera()
BaseDraw.GetDisplayFilter()
BaseDraw.GetEditState()
BaseDraw.IsViewOpen()
BaseDraw.LineZOffset()
BaseDraw.SetDepth()
BaseDraw.SetMatrix_Projection()
BaseDraw.SetMatrix_Screen()
BaseDraw.SetMatrix_Camera()
BaseDraw.SetMatrix_Matrix()
BaseDraw.SetClipPlaneOffset()
BaseDraw.DrawPoint2D()
BaseDraw.DrawLine2D()
BaseDraw.DrawHandle2D()
BaseDraw.DrawCircle2D()
BaseDraw.DrawHandle()
BaseDraw.DrawLine()
BaseDraw.DrawPoints()
BaseDraw.DrawTexture()
BaseDraw.DrawBox()
BaseDraw.DrawCircle()
BaseDraw.DrawArc()
BaseDraw.DrawPolygon()
BaseDraw.DrawSphere()
BaseDraw.DrawArrayEnd()
BaseDraw.DrawPolygonObject()
BaseDraw.DrawObject()
BaseDraw.DrawScene()
BaseDraw.GetReductionMode()
BaseDraw.GetDrawPass()
c4d.BaseView
BaseDraw.
__init__
(
)
¶
New in version R17.053.
Initialize a new base draw.
Note
Useful for situations when there is no base draw available. It is used for instance in Mograph’s Camera shader.
Return type: | c4d.BaseDraw |
---|---|
Returns: | A new base draw. |
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 . |
BaseDraw.
HasCameraLink
(
)
¶
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: |
|
---|
BaseDraw.
GetSceneCamera
(
doc
)
¶
Returns the current scene camera from the passed document, or None if no scene camera is used.
Parameters: | doc ( c4d.documents.BaseDocument ) – The document to get the scene camera from. |
---|---|
Return type: | c4d.BaseObject |
Returns: | The scene camera. |
BaseDraw.
GetEditorCamera
(
)
¶
Returns the editor camera.
Return type: | c4d.BaseObject |
---|---|
Returns: | The editor camera. Guaranteed to never be None . |
BaseDraw.
GetDisplayFilter
(
)
¶
Returns the current display filter. This is a bit field derived from the
DISPLAYFILTER
values. To set the display filter use the description flags with
GeListNode.__setitem__()
or
C4DAtom.SetParameter()
.
For instance the following script switches the Filter “Subdivision Surface”:
bd = doc.GetActiveBaseDraw() displayFilter = bd.GetDisplayFilter() if displayFilter & c4d.DISPLAYFILTER_HYPERNURBS: bd[c4d.BASEDRAW_DISPLAYFILTER_HYPERNURBS] = False print "Switched Off Subdivision Surface Display Filter" else: bd[c4d.BASEDRAW_DISPLAYFILTER_HYPERNURBS] = True print "Switched On Subdivision Surface Display Filter" bd.Message(c4d.MSG_CHANGE) c4d.EventAdd()
Note the difference between the filters “Subdivision Surface” and “SDS Mesh”.
Return type: | int | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Returns: |
A bit field with the following flags:
|
BaseDraw.
GetEditState
(
)
¶
Get the edit state. This is a bit field derived from the the edit state description flags in
dbasedraw.h
. To set the display filter use the description flags with
GeListNode.__setitem__()
or
C4DAtom.SetParameter()
.
Return type: | int | ||||||||
---|---|---|---|---|---|---|---|---|---|
Returns: |
A bit field with the following flags:
|
BaseDraw.
IsViewOpen
(
doc
)
¶
Checks if the current tool can use the curent SDS/Deformed editing state.
Parameters: | doc ( c4d.documents.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: |
|
---|
BaseDraw.
InitClipbox
(
left
,
top
,
right
,
bottom
,
flags
)
¶
Used to render into a framebuffer with different resolution than the editor view.
Parameters: |
|
---|
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: |
|
---|
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
The object in this example is drawn both in regular and X-ray passes.
Note
This example is only relevant to
ObjectData
plugins.
Parameters: |
|
---|---|
Return type: |
bool |
Returns: |
True if succesful, otherwise False . |
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: | |
Returns: |
The object color. |
BaseDraw.
CheckColor
(
col
)
¶
Makes sure that a color has at least 15% difference to the background color.
Parameters: | col ( c4d.Vector ) – The original vector. |
---|---|
Return type: | c4d.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: |
|
---|---|
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: |
|
---|
BaseDraw.
SetPointSize
(
pointsize
)
¶
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: |
|
---|---|
Return type: |
float |
Returns: |
The intensity of the light. Between 0 and 1. |
BaseDraw.
ConvertColor
(
c
)
¶
Converts colors from document color profile to viewport color profile.
Parameters: | c ( c4d.Vector ) – The color to convert (document). |
---|---|
Return type: | c4d.Vector |
Returns: | The converted color (viewport). |
BaseDraw.
ConvertColorReverse
(
c
)
¶
Converts colors from viewport color profile to document color profile.
Parameters: | c ( c4d.Vector ) – The color to convert (viewport). |
---|---|
Return type: | c4d.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()
, andDrawSphere()
.
Parameters: | offset ( int ) – The new Z buffer offset. |
---|
BaseDraw.
SetDepth
(
enable
)
¶
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()
, andDrawSphere()
.
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:
|
---|
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()
, andDrawSphere()
.
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: |
|
---|
BaseDraw.
SetClipPlaneOffset
(
o
)
¶
New in version R14.014.
Offsets the OpenGL clipping planes by this offset.
Parameters: | o ( float ) – The offset. |
---|
BaseDraw.
DrawPoint2D
(
p
)
¶
Draws a one-pixel point in the current pen color at p. The coordinates must be in screen space.
Parameters: | p ( c4d.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: |
|
---|
BaseDraw.
DrawHandle2D
(
p
[
,
type=DRAWHANDLE_SMALL
]
)
¶
Draws a standard handle (orange dot) at p . The coordinates must be in screen space.
Parameters: |
|
---|
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: |
|
---|
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: |
|
---|
BaseDraw.
DrawHandle
(
vp
,
type
,
flags
)
¶
Draws a standard handle (orange dot) at vp . The coordinates must be in world space.
Parameters: |
|
---|
BaseDraw.
DrawPoints
(
vp[, vc][, colcnt=0][, vn]
)
¶
Draws an array of points with individual colors.
Note
The coordinates must be in the space defined by
SetMatrix_Screen()
,
SetMatrix_Camera()
or
SetMatrix_Matrix()
.
Parameters: |
|
---|
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 a triangle or a quadrangle is 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: |
|
---|
BaseDraw.
DrawBox
(
m
,
size
,
col
,
wire
)
¶
Draws a box. The eight points of the box are defined as:
p = [c4d.Vector() for x in xrange(8)] p[0] = c4d.Vector(-size, -size, -size) p[1] = c4d.Vector( size, -size, -size) p[2] = c4d.Vector( size, -size, size) p[3] = c4d.Vector(-size, -size, size) p[4] = c4d.Vector(-size, size, -size) p[5] = c4d.Vector( size, size, -size) p[6] = c4d.Vector( size, size, size) p[7] = c4d.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: |
|
---|
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 is not 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 ( c4d.Matrix ) – A matrix describing the circle. |
---|
BaseDraw.
DrawArc
(
pos
,
radius
,
angle_start
,
angle_end
[
,
subdiv=32
,
flags=0
]
)
¶
New in version R14.014.
Draws an arc (section of a circle) in the current pen color at pos . The coordinates must be in screen space.
Parameters: |
|
---|
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: |
---|
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: |
|
---|
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: |
|
---|
BaseDraw.
DrawObject
(
bh
,
op
,
flags
,
drawpass
,
parent
)
¶
Draws a polygon object into the view.
Parameters: |
|
---|
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.
GetDrawPass
(
)
¶
New in version R14.041.
Gets the current drawpass.
Return type: | int | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Returns: |
One of the following flags:
|
BaseDraw.
GetHighlightPassColor
(
bh
,
lineObject
)
¶
New in version R19.
Returns the color in which the object has to be drawn in the highlight pass.
Note
This function should only be called in the highlight pass.
Parameters: |
|
---|---|
Return type: | |
Returns: |
The highlight color, or None if drawing the object can be skipped. |
BaseDraw.
GetHighlightFramebuffer
(
[
vMin=c4d.Vector(-1)
,
vMax=c4d.Vector(1)
]
)
¶
New in version R19.
Returns the framebuffer in which the highlights are drawn and sets the bounding box of the highlight area ( vMin and vMax ). Both vectors must be in clip space [-1, 1] on all axes. They should be passed when the bounding box is known for the current object to speed up the calculation of the highlights and outlines.Note
This function should only be called in the highlight pass.
Parameters: |
|
---|---|
Return type: |
PyCObject |
Returns: |
The highlight framebuffer if successful, otherwise None . |
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
–
|
||||||
---|---|---|---|---|---|---|---|
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: |
|
---|
BaseDraw.
GetDrawParam
(
id
)
¶
Gets draw parameters.
Parameters: | id ( int ) – Parameter ID. |
---|---|
Return type: | any |
Returns: | Depends on the parameter ID. |
BaseDraw.
TestBreak
(
)
¶
Checks for thread breaks in the draw.
Return type: | bool |
---|---|
Returns: | True if a stopping condition has occurred, otherwise False . |
BaseDraw.
GetEditorWindow
(
)
¶
Get the editor window of the BaseDraw.
Return type: | c4d.gui.EditorWindow |
---|---|
Returns: | The editor window of the base draw. |
BaseDraw.
SetTexture
(
bm
,
tile
,
alphamode
,
flags
)
¶
Set a texture used by the vertex buffer.
Parameters: |
|
---|
BaseDraw.
GetGridStep
(
)
¶
New in version R14.014.
Gets the grid spacing and the transparency value of the minor grid that fade when the user zoom in or out with dynamic grid.
Return type: | tuple(float, float) |
---|---|
Returns: | The workplane grid spacing and the transparency value of the minor grid. |
BaseDraw.
GetViewMatrix
(
n
)
¶
New in version R14.014.
Gets the view matrix.
Parameters: |
n
(
int
) –
View matrix to get:
|
||||||||
---|---|---|---|---|---|---|---|---|---|
Return type: | tuple(16*float) (4x4 Matrix) | ||||||||
Returns: | The view matrix. |
BaseDraw.
DrawHUDText
(
x
,
y
,
txt
)
¶
New in version R18.020.
Draws 2D text into the viewport in the style of the HUD.
Parameters: |
|
---|
BaseDraw.
DrawMultipleHUDText
(
texts
)
¶
New in version R18.020.
Draws many 2D text into the viewport at once.
Parameters: |
texts
(list of dict{‘_txt’: str, ‘_position’:
c4d.Vector
}) – The list of text entries and their screen space positions to draw to the HUD.
|
---|
BaseDraw.
IsMarkedAsGPURenderer
(
)
¶
New in version R19.024.
Checks if the view is marked as GPU Renderer.
Return type: | bool |
---|---|
Returns: | True if the view is marked to run the GPU Renderer, otherwise False . |
BaseDraw.
IsGPURenderer
(
)
¶
New in version R19.024.
Checks if the view is running the GPU Renderer.
Return type: | bool |
---|---|
Returns: | True if the view is running the GPU renderer, otherwise False . |