BrushTexture brush,texture[,frame][,index]
Parameters
|
brush - brush handle texture - texture handle frame (optional) - which frame of an animated texture to use; 0 (default) index (optional) - texture layer to assign the texture to, 0 to 7; 0 (default) |
Description
|
Assigns a texture to a brush. The frame parameter picks a frame from a texture loaded with LoadAnimTexture or created with multiple frames - the everyday route to flipbook animation: assign a different frame each update and repaint. The index parameter chooses one of the brush's eight texture layers, 0 to 7. Layers stack for multitexturing: layer 0 sits on the geometry, layer 1 blends onto layer 0 with its TextureBlend mode, and so on - the classic combo being a detail or lightmap layered over a base texture. As with every brush property, the texture reaches geometry when the brush is painted on with PaintSurface, PaintMesh or PaintEntity. To texture an entity directly without a brush, use EntityTexture. See also: EntityTexture, LoadTexture, LoadAnimTexture, TextureBlend, GetBrushTexture, CreateBrush. |
Example
; BrushTexture 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' applied with PaintEntity. crate=CreateCube() PositionEntity crate,0,0,5 tex_logo=LoadTexture("media/b3dlogo.jpg") tex_moss=LoadTexture("media/MossyGround.BMP") ; Give the brush its starting texture (the optional frame,index default to 0) brush=CreateBrush() BrushTexture brush,tex_logo PaintEntity crate,brush tex_name$="tex_logo" While Not KeyDown(1) ; Keys 1/2 choose the brush texture, then repaint the crate If KeyHit(2) BrushTexture brush,tex_logo PaintEntity crate,brush tex_name="tex_logo" EndIf If KeyHit(3) BrushTexture brush,tex_moss PaintEntity crate,brush tex_name="tex_moss" 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,"1: logo texture 2: moss texture Arrows: camera Esc: exit" Text 0,20,"BrushTexture brush,"+tex_name Flip Wend End
Index