PaintSurface surface,brush
Parameters
|
surface - surface handle brush - brush handle |
Description
|
Paints a single surface with a brush. The brush's properties - colour, alpha, shininess, texture, blend and FX flags - are written onto that one surface, instantly changing that section of the mesh. This is the finest-grained of the three paint scopes, and the only way to give different parts of one mesh different materials: PaintSurface for one surface, PaintMesh for every surface of a mesh, PaintEntity for the entity level. Get surface handles from CreateSurface when building meshes, or from GetSurface and FindSurface on loaded models. Painting copies the brush's current properties - changing the brush afterwards does not update surfaces already painted with it. Repaint if you want the new look. See also: PaintEntity, PaintMesh, GetSurface, FindSurface, CreateBrush, GetSurfaceBrush. |
Example
; PaintSurface Example ; -------------------- ; PaintSurface applies a brush to ONE surface of a mesh, leaving its ; other surfaces alone. (PaintMesh paints every surface; PaintEntity ; is the entity-level version.) Space repaints only the LEFT panel. Graphics3D 640,480 SetBuffer BackBuffer() camera=CreateCamera() PositionEntity camera,0,0,-5 ; One mesh with two quad surfaces, side by side mesh=CreateMesh() left_surf=CreateSurface(mesh) v0=AddVertex(left_surf,-2.1,1,0) v1=AddVertex(left_surf,-0.1,1,0) v2=AddVertex(left_surf,-0.1,-1,0) v3=AddVertex(left_surf,-2.1,-1,0) AddTriangle left_surf,v0,v1,v2 AddTriangle left_surf,v0,v2,v3 right_surf=CreateSurface(mesh) v0=AddVertex(right_surf,0.1,1,0) v1=AddVertex(right_surf,2.1,1,0) v2=AddVertex(right_surf,2.1,-1,0) v3=AddVertex(right_surf,0.1,-1,0) AddTriangle right_surf,v0,v1,v2 AddTriangle right_surf,v0,v2,v3 ; Fullbright so the brush colours show without lighting setup EntityFX mesh,1 ; Three brushes to cycle through red_brush=CreateBrush() BrushColor red_brush,255,80,80 green_brush=CreateBrush() BrushColor green_brush,80,255,80 logo_brush=CreateBrush() BrushTexture logo_brush,LoadTexture("media/b3dlogo.jpg") ; Paint both surfaces to start - the documented command PaintSurface left_surf,red_brush PaintSurface right_surf,green_brush idx=0 brush_name$="red" While Not KeyDown(1) ; Space repaints ONLY the left surface - the right one never changes If KeyHit(57) Then idx=(idx+1) Mod 3 If idx=0 Then PaintSurface left_surf,red_brush : brush_name="red" If idx=1 Then PaintSurface left_surf,logo_brush : brush_name="logo texture" If idx=2 Then PaintSurface left_surf,green_brush : brush_name="green" EndIf ; 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: repaint the left surface Arrow keys: move camera Esc: exit" Text 0,20,"PaintSurface left_surf with the "+brush_name+" brush" Flip Wend End
Index