|
mesh - mesh handle brush - brush handle |
|
Paints every surface of a mesh with a brush. The brush's properties - colour, alpha, shininess, texture, blend and FX flags - are written onto each of the mesh's surfaces, instantly changing its appearance. Define the brush once and you can restyle mesh after mesh with a single call instead of a pile of EntityColor and EntityTexture lines. PaintMesh is the middle member of a family of three scopes: PaintSurface paints one surface, PaintMesh paints all of a mesh's surfaces, and PaintEntity paints at the entity level. Use PaintSurface when different sections of the mesh should look different. Painting copies the brush's current properties - changing the brush afterwards does not update meshes already painted with it. Repaint if you want the new look. See also: PaintEntity, PaintSurface, CreateBrush, LoadBrush. |
; PaintMesh Example
; -----------------
; A brush bundles material properties: colour, texture, shininess...
; PaintMesh applies a brush to EVERY surface of a mesh.
; (PaintSurface paints just one surface; PaintEntity is the
; entity-level version that works on any entity.)
Graphics3D 640,480
SetBuffer BackBuffer()
camera=CreateCamera()
PositionEntity camera,0,1,-4
light=CreateLight()
RotateEntity light,30,40,0
crate=CreateCube()
; Three different brushes to paint with
blue_brush=CreateBrush()
BrushColor blue_brush,60,120,255
BrushShininess blue_brush,1
logo_brush=CreateBrush()
BrushTexture logo_brush,LoadTexture("media/b3dlogo.jpg")
moss_brush=CreateBrush()
BrushTexture moss_brush,LoadTexture("media/MossyGround.BMP")
BrushColor moss_brush,180,255,180
; Start with the blue brush - the documented command
PaintMesh crate,blue_brush
brush_name$="1: shiny blue"
While Not KeyDown(1)
; 1/2/3 repaint every surface of the mesh with a new brush
If KeyHit(2) Then PaintMesh crate,blue_brush : brush_name="1: shiny blue"
If KeyHit(3) Then PaintMesh crate,logo_brush : brush_name="2: logo texture"
If KeyHit(4) Then PaintMesh crate,moss_brush : brush_name="3: tinted moss"
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,"1 / 2 / 3 : paint with a different brush Arrow keys: move camera Esc: exit"
Text 0,20,"PaintMesh crate with brush "+brush_name
Flip
Wend
End