Blitz3D+ Command Reference

PaintEntity entity,brush

Parameters

entity - entity handle
brush - brush handle

Description

Paints an entity with a brush.

The brush's properties - colour, alpha, shininess, texture, blend and FX flags - are applied to the entity in one go. Defining one brush and painting with it over and over is tidier and less error-prone than repeating EntityColor, EntityTexture, EntityAlpha and friends for every object, and it keeps a whole family of props visually consistent.

PaintEntity is the whole-entity member of a family of three scopes: PaintSurface paints one surface, PaintMesh paints every surface of a mesh, and PaintEntity paints at the entity level, over the top of whatever the surfaces carry.

Painting copies the brush's current properties - changing the brush afterwards does not update anything already painted with it. Repaint if you want the new look.

See also: PaintMesh, PaintSurface, CreateBrush, LoadBrush, GetEntityBrush.

Example

; PaintEntity Example
; -------------------

; PaintEntity applies a brush at the ENTITY level - it works on any
; entity, including loaded models. (PaintMesh paints every surface of
; a mesh; PaintSurface paints just one surface.) Here we tint a
; textured oil drum: the brush colour combines with its texture.

Graphics3D 640,480
SetBuffer BackBuffer()

camera=CreateCamera()
PositionEntity camera,0,0,-4

light=CreateLight()
RotateEntity light,30,40,0

; Load a textured model and fit it into a 2-unit box
drum=LoadMesh("media/oil-drum/oildrum.3ds")
FitMesh drum,-1,-1,-1,2,2,2,1

; Three tint brushes
red_brush=CreateBrush()
BrushColor red_brush,255,90,90
blue_brush=CreateBrush()
BrushColor blue_brush,90,140,255
white_brush=CreateBrush()
BrushColor white_brush,255,255,255

tint$="none yet"

While Not KeyDown(1)

    ; 1/2/3 repaint the whole entity - the documented command
    If KeyHit(2) Then PaintEntity drum,red_brush : tint="1: red"
    If KeyHit(3) Then PaintEntity drum,blue_brush : tint="2: blue"
    If KeyHit(4) Then PaintEntity drum,white_brush : tint="3: white"

    TurnEntity drum,0,1,0

    ; Arrow keys move the camera
    If KeyDown(200) Then MoveEntity camera,0,0,0.1
    If KeyDown(208) Then MoveEntity camera,0,0,-0.1
    If KeyDown(203) Then TurnEntity camera,0,1,0
    If KeyDown(205) Then TurnEntity camera,0,-1,0

    RenderWorld

    Text 0,0,"1 / 2 / 3 : tint the drum   Arrow keys: move camera   Esc: exit"
    Text 0,20,"PaintEntity drum with brush "+tint

    Flip

Wend

End

Index