GetEntityBrush ( entity )
Parameters
| entity - entity handle |
Description
|
Returns a copy of an entity's brush - its colour, texture and other material settings. An entity's brush is where EntityColor, EntityAlpha, EntityShininess, EntityTexture, EntityBlend and EntityFX store their results. GetEntityBrush hands you the whole lot as one brush, which makes it an easy way to copy a look from one entity to another: grab the brush from the master, PaintEntity it onto the copycat, and the copycat matches - whatever mix of colour and texture the master had. The entity must be a model-type entity - a mesh, sprite, terrain or BSP. Cameras, lights and pivots have no brush. What you get back is a COPY, not a live link. Changing the copy with BrushColor and friends does nothing to the entity until you paint it back on with PaintEntity or PaintMesh. And because every call creates a new brush, free it with FreeBrush once you are done or they quietly pile up. One thing it will not show you: for meshes, individual surfaces can carry their own brushes (from PaintSurface or a loaded model's materials). GetEntityBrush returns only the entity's own master brush - use GetSurfaceBrush to inspect per-surface materials. See also: GetSurfaceBrush, GetBrushTexture, PaintEntity, CreateBrush, FreeBrush. |
Example
; GetEntityBrush Example ; ---------------------- Graphics3D 640,480,0,2 SetBuffer BackBuffer() camera=CreateCamera() PositionEntity camera,0,1,-6 light=CreateLight() RotateEntity light,45,45,0 ; The master cube - tint it with the number keys master=CreateCube() PositionEntity master,-1.5,1,0 EntityColor master,255,80,80 ; The copycat cube - Space copies the master's look onto it copycat=CreateCube() PositionEntity copycat,1.5,1,0 While Not KeyDown(1) ; 1/2/3 tint the master cube If KeyHit(2) Then EntityColor master,255,80,80 If KeyHit(3) Then EntityColor master,80,255,80 If KeyHit(4) Then EntityColor master,80,80,255 ; Space: grab the master's brush and paint the copycat with it If KeyHit(57) brush=GetEntityBrush(master) PaintEntity copycat,brush ; GetEntityBrush returns a copy - free it once used FreeBrush brush EndIf TurnEntity master,0,1,0 TurnEntity copycat,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 left cube Space: copy its brush to the right Esc: exit" Text 0,20,"brush=GetEntityBrush(master) then PaintEntity copycat,brush" Flip Wend End
Index