; EntityReceivesDecals Example ; ---------------------------- ; Requires Extended mode. Graphics3D 640,480,0,2 SetBuffer BackBuffer() camera=CreateCamera() PositionEntity camera,0,0,-7 light=CreateLight() RotateEntity light,45,45,0 ; Two crates side by side crate1=CreateCube() PositionEntity crate1,-1.7,0,3 EntityColor crate1,150,110,70 crate2=CreateCube() PositionEntity crate2,1.7,0,3 EntityColor crate2,150,110,70 ; Paint an orange splat texture in memory splat=CreateTexture(64,64,3) SetBuffer TextureBuffer(splat) ClsColor 0,0,0 Cls Color 255,80,20 Oval 6,6,52,52,True SetBuffer BackBuffer() Color 255,255,255 ; One decal projector sweeps across both crates decal=CreateDecal(splat) DecalSize decal,1.2,1.2,0.5 receives=True While Not KeyDown(1) ; Space toggles decal reception on the right crate If KeyHit(57) Then receives=Not receives EntityReceivesDecals crate2,receives EndIf ; Sweep the projector across both crates angle#=angle+1.5 PositionEntity decal,3*Sin(angle),0,2 ; 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,"Arrow keys: move camera Space: toggle right crate Esc: exit" If receives Then Text 0,20,"EntityReceivesDecals crate2,True - both crates take the splat" Else Text 0,20,"EntityReceivesDecals crate2,False - the right crate refuses it" Flip Wend End