Blitz3D+ Command Reference

EntityReceivesDecals entity[,enabled][,recursive]

Parameters

entity - entity to change

enabled (optional) - True lets decals stamp this entity, False makes it ignore them; True (default)

recursive (optional) - True applies the setting to every descendant too; False (default)

Description

Turns decal reception on or off for an entity, and optionally its descendants.

Every new entity receives decals. That is right for walls and floors, but wrong for plenty of things: you do not want your player character picking up a wall's paint splat while walking past it, a skybox catching stray bullet holes, or water carrying scorch marks. One call with False and the entity is invisible to every decal projector, while everything around it still gets stamped.

The flag is per entity. Pass recursive True to sweep a whole model hierarchy in one go - the usual move for a character made of many child meshes, or a complete loaded scene.

The setting only controls receiving. It has no effect on the decal entities themselves, and you can flip it at any time - reception applies per frame at render time.

Requires Extended mode.

See also: CreateDecal, DecalSize, AlignDecal, RenderDecals.

Example

; 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

Index