EntityShadows entity[,cast][,receive][,recursive]
Parameters
|
entity - entity handle cast (optional) - True lets the entity cast shadows; True (default) receive (optional) - True lets the entity receive shadows; True (default) recursive (optional) - True also applies the values to the entity's current children; False (default) |
Description
|
Controls whether an entity casts and receives automatic shadows. Shadows appear only when the whole chain is enabled: Shadows turns the system on, a shadow-enabled light is selected (LightShadows), the camera keeps CameraShadows on, and casters and receivers keep EntityShadows on. This command is the per-entity opt-out (or opt-in). Cast and receive are independent. Turn casting off on swarms of small debris or particles-on-meshes to save shadow-render cost, or on an object whose shadow looks wrong. Turn receiving off for stylised or glowing objects that should not be darkened. Without an explicit call, sensible type defaults apply: meshes and terrain cast and receive, while planes and sprites receive but do not cast. An explicit EntityShadows call always wins over the type default - it is also how you make a plane or sprite cast. The recursive flag applies the values to the descendants the entity has right now; children attached later keep their own defaults, so re-apply after building a hierarchy if you need the whole tree covered. Requires Extended mode. See also: Shadows, CameraShadows, LightShadows, ShadowColor. |
Example
; EntityShadows Example ; --------------------- ; Requires Extended mode. Graphics3D 640,480,0,2 SetBuffer BackBuffer() camera=CreateCamera() PositionEntity camera,0,5,-9 RotateEntity camera,25,0,0 ; A directional sun; the shadow system selects it automatically sun=CreateLight(1) AmbientLight 70,75,85 ; Ground plane that receives the shadows ground=CreateCube() ScaleEntity ground,10,0.1,10 PositionEntity ground,0,-0.1,4 EntityColor ground,170,190,170 ; A tall pillar whose shadow sweeps over the crate pillar=CreateCylinder() ScaleEntity pillar,0.7,2.5,0.7 PositionEntity pillar,0,2.5,6 EntityColor pillar,120,160,220 ; The hero crate whose cast/receive policy we override crate=CreateCube() PositionEntity crate,0,1,3 EntityColor crate,210,150,80 ; Turn on the automatic shadow system Shadows 1 cast=1 receive=1 angle#=0 While Not KeyDown(1) ; C toggles casting, R toggles receiving, independently If KeyHit(46) Then cast=1-cast If KeyHit(19) Then receive=1-receive ; Override the crate's automatic shadow policy EntityShadows crate,cast,receive ; Swing the sun so the pillar's shadow crosses the crate angle=angle+0.3 RotateEntity sun,55,angle,0 TurnEntity crate,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,"C: toggle cast R: toggle receive Arrow keys: move camera Esc: exit" Text 0,20,"EntityShadows crate,"+cast+","+receive Flip Wend End
Index