Blitz3D+ Command Reference

CreateBrush ( [red#][,green#][,blue#] )

Parameters

red# (optional) - red component of the brush colour, 0 to 255; 255 (default)
green# (optional) - green component of the brush colour, 0 to 255; 255 (default)
blue# (optional) - blue component of the brush colour, 0 to 255; 255 (default)

Description

Creates a brush and returns its handle.

A brush is a complete "material" in one handle: colour, alpha, shininess, up to eight textures, blend mode and FX flags. The recipe is always the same - create the brush, set it up with BrushColor, BrushAlpha, BrushShininess, BrushTexture, BrushBlend and BrushFX, then paint it onto geometry.

There are three paint scopes: PaintSurface for one surface, PaintMesh for every surface of a mesh, and PaintEntity for the entity level. Defining a look once and painting it everywhere keeps a family of props consistent and beats repeating EntityColor/EntityTexture lines for each one.

Painting copies the brush's properties at that moment, so you can keep tweaking one brush and painting variations - later changes never touch things already painted. Free it with FreeBrush when you are done; painted geometry keeps its look.

See also: LoadBrush, BrushColor, BrushTexture, PaintEntity, PaintMesh, PaintSurface.

Example

; CreateBrush Example
; -------------------

Graphics3D 640,480,0,2
SetBuffer BackBuffer()

camera=CreateCamera()

light=CreateLight()
RotateEntity light,45,45,0

; A crate to paint. A brush is a 'paint recipe' - colour, alpha, texture
; and so on - which is applied to entities with PaintEntity.
crate=CreateCube()
PositionEntity crate,0,0,5

SeedRnd MilliSecs()

; Create a brush with an initial colour (the r,g,b arguments are optional)
brush=CreateBrush(0,120,255)
PaintEntity crate,brush

While Not KeyDown(1)

    ; Space creates a fresh brush with a random colour and repaints the crate
    If KeyHit(57)
        FreeBrush brush
        brush=CreateBrush(Rand(0,255),Rand(0,255),Rand(0,255))
        PaintEntity crate,brush
    EndIf

    TurnEntity crate,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,"Space: paint with a new random brush   Arrows: camera   Esc: exit"

    Flip

Wend

End

Index