DecalSize decal[,width#][,height#][,depth#]
Parameters
|
decal - decal entity created with CreateDecal width# (optional) - size of the stamp across the decal's local X axis; must be positive; 1 (default) height# (optional) - size of the stamp across the decal's local Y axis; must be positive; 1 (default) depth# (optional) - how far the projection reaches behind the decal's plane; must be positive; .25 (default) |
Description
|
Sets a decal's stamp size and how deep its projection reaches. Width and height are simply how big the mark is on the surface, in world units. Depth is the interesting one: it is the thickness of the projection volume, measured behind the decal's plane along its local -Z axis. Any receiving surface inside that reach gets stamped - which is what lets one decal wrap over a bumpy rock face, a stair edge or a curved pipe instead of only touching a perfectly flat wall. Tune depth to the situation. Too shallow, and parts of an uneven surface poke out of the volume and show holes in the stamp. Too deep, and the projection reaches through thin geometry and paints the far side too - a splat on a fence appearing on the wall behind it. The 0.25 default suits marks on reasonably flat scenery. All three dimensions must be positive and finite, and the entity must be a decal, or the program stops with a runtime error. Scale changes take effect immediately - shrinking a decal over time is a cheap way to fade out old marks. Requires Extended mode. See also: CreateDecal, AlignDecal, EntityReceivesDecals. |
Example
; DecalSize Example ; ----------------- ; Requires Extended mode. Graphics3D 640,480,0,2 SetBuffer BackBuffer() camera=CreateCamera() PositionEntity camera,0,0,-6 light=CreateLight() RotateEntity light,45,45,0 ; A wall with a thin pillar sticking out in front of it wall=CreateCube() ScaleEntity wall,4,2.5,0.2 PositionEntity wall,0,0,3 EntityColor wall,110,120,135 pillar=CreateCube() ScaleEntity pillar,0.3,2.5,0.3 PositionEntity pillar,0,0,2.4 EntityColor pillar,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 that slides back and forth across the wall decal=CreateDecal(splat) size#=1 depth#=0.25 While Not KeyDown(1) ; [ and ] change the size, D cycles the projection depth If KeyHit(26) And size>0.25 Then size=size-0.25 If KeyHit(27) And size<3 Then size=size+0.25 If KeyHit(32) Then depth=depth*2 If depth>2 Then depth=0.25 EndIf ; DecalSize sets width, height and how far the decal projects DecalSize decal,size,size,depth ; Slide the projector across the wall - a big depth also reaches the pillar angle#=angle+1.5 PositionEntity decal,3*Sin(angle),0,2.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 [ / ] : size D: depth Esc: exit" Text 0,20,"DecalSize decal,"+size+","+size+","+depth Text 0,40,"Depth "+depth+" decides whether the splat reaches the wall behind the pillar" Flip Wend End
Index