; AlignDecal Example ; ------------------ ; Requires Extended mode. Graphics3D 640,480,0,2 SetBuffer BackBuffer() SeedRnd MilliSecs() camera=CreateCamera() PositionEntity camera,0,0,-8 light=CreateLight() RotateEntity light,45,45,0 ; Three walls at different angles - pickable so we can read surface normals For n=-1 To 1 wall=CreateCube() ScaleEntity wall,1.8,2,0.2 PositionEntity wall,n*3.4,0,3 TurnEntity wall,0,n*40,0 EntityColor wall,110,120,135 EntityPickMode wall,2 Next ; 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 While Not KeyDown(1) ; Space fires a paintball through the screen centre If KeyHit(57) Then If CameraPick(camera,320,240) Then decal=CreateDecal(splat) ; AlignDecal sits the splat flush on the surface, aimed along the picked normal AlignDecal decal,PickedX(),PickedY(),PickedZ(),PickedNX(),PickedNY(),PickedNZ(),Rnd(360) hits=hits+1 EndIf EndIf ; Arrow keys aim the camera at the different walls 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: aim camera Space: fire at the crosshair Esc: exit" Text 0,20,"AlignDecal matches each angled wall's surface normal, with a random roll" Text 316,232,"+" Flip Wend End