CameraProjMode camera,mode
Parameters
|
camera - camera handle mode - projection mode 0: no projection - the camera is not rendered 1: perspective (default) 2: orthographic |
Description
|
Sets a camera's projection mode. Perspective (mode 1) is the normal 3D view: distant things shrink, parallel lines converge. Orthographic (mode 2) throws perspective away - an object is the same size on screen no matter how far from the camera it sits. That is the look for isometric strategy views, 2D-style games built from 3D models, map screens and level editors. An orthographic camera starts extremely zoomed in, and distance no longer controls how big things appear - CameraZoom is your size control instead. The example drops the zoom to 0.2 the moment it switches to ortho; expect to tune that number for your scene. Mode 0 switches the camera off: RenderWorld simply skips it, at no cost. This is the cheap way to disable a minimap, security-monitor or split-screen camera you are not showing this frame, without freeing and rebuilding it. Note that nothing clears the screen for a camera that is not rendered - old pixels stay - so Cls yourself if you leave mode 0 visible. See also: CreateCamera, CameraZoom, CameraViewport, CameraRange. |
Example
; CameraProjMode Example ; ---------------------- Graphics3D 640,480,0,2 SetBuffer BackBuffer() camera=CreateCamera() PositionEntity camera,0,2,-8 light=CreateLight() RotateEntity light,45,45,0 ; A corridor of columns - perspective makes the far ones shrink, ; orthographic draws every column the same size on screen For i=0 To 5 column=CreateCylinder() ScaleEntity column,0.5,2,0.5 PositionEntity column,-2,1,i*3 column=CreateCylinder() ScaleEntity column,0.5,2,0.5 PositionEntity column,2,1,i*3 Next mode=1 zoom#=1 CameraProjMode camera,mode While Not KeyDown(1) ; 1: perspective 2: orthographic 0: camera off If KeyHit(2) mode=1 CameraProjMode camera,mode zoom=1 CameraZoom camera,zoom EndIf If KeyHit(3) mode=2 CameraProjMode camera,mode ; Ortho views are very zoomed in - scale out with CameraZoom zoom=0.2 CameraZoom camera,zoom EndIf If KeyHit(11) mode=0 CameraProjMode camera,mode EndIf ; + / - adjust the zoom (best seen in orthographic mode) If KeyDown(13) zoom=zoom+0.005 CameraZoom camera,zoom EndIf If KeyDown(12) If zoom>0.05 zoom=zoom-0.005 CameraZoom camera,zoom EndIf EndIf ; 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 ; With the camera off nothing is rendered, so clear by hand If mode=0 Then Cls name$="perspective" If mode=2 Then name$="orthographic" If mode=0 Then name$="off - nothing is rendered" Text 0,0,"1/2: projection 0: camera off +/-: zoom Esc: exit" Text 0,20,"CameraProjMode camera,"+mode+" ("+name$+") zoom "+zoom Flip Wend End
Index