; 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