CameraFogMode camera,mode
Parameters
|
camera - camera handle mode - fog mode 0: no fog (default) 1: linear fog |
Description
|
Sets the camera fog mode - the master switch for fogging. Fog gradually fades out graphics the further they are from the camera. It hides 'pop-up' - the moment 3D objects suddenly appear on the horizon at the camera's far range - and sets atmosphere on the cheap: mist, murky water, gloomy dungeons. CameraFogMode is the switch the other fog commands depend on: with mode 0 (the default), CameraFogColor and CameraFogRange have no visible effect. Turn fog on with mode 1, then tune the colour (default black) and range (default 1-1000). Each camera has its own fog mode, colour and range, so different views can have different fog effects on screen at once. Individual entities can opt out of fog with the disable-fog EntityFX flag - useful for skyboxes, which should never fog out. See also: CameraFogColor, CameraFogRange, CameraRange, EntityFX. |
Example
; CameraFogMode Example ; --------------------- Graphics3D 640,480,0,2 SetBuffer BackBuffer() camera=CreateCamera() PositionEntity camera,0,2,0 ; Grey clear colour matches the fog colour so fogged pillars blend into the sky CameraClsColor camera,128,128,128 light=CreateLight() RotateEntity light,45,45,0 ; Textured ground plane gives a sense of distance plane=CreatePlane() ground_tex=LoadTexture("media/MossyGround.BMP") ScaleTexture ground_tex,4,4 EntityTexture plane,ground_tex ; An avenue of pillars marching into the distance shows the fog thickening For z=10 To 150 Step 10 pillar=CreateCylinder() ScaleEntity pillar,0.5,3,0.5 PositionEntity pillar,-4,3,z pillar=CreateCylinder() ScaleEntity pillar,0.5,3,0.5 PositionEntity pillar,4,3,z Next ; Fog colour and range only take effect while fog mode is switched on CameraFogColor camera,128,128,128 CameraFogRange camera,5,60 fog_mode=0 While Not KeyDown(1) ; Space toggles fog mode between 0 (no fog) and 1 (linear fog) If KeyHit(57) Then fog_mode=1-fog_mode ; Apply the fog mode to the camera CameraFogMode camera,fog_mode ; 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 fog Esc: exit" Text 0,20,"CameraFogMode camera,"+fog_mode+" (0=no fog, 1=linear fog)" Flip Wend End
Index