CameraAspect camera[,aspect#]
Parameters
|
camera - camera handle aspect# (optional) - fixed width-to-height frustum ratio; 0 (default) derives the ratio automatically from the viewport |
Description
|
Overrides the aspect ratio used by a camera's projection. Normally a camera derives its aspect ratio from its viewport, so the picture is never stretched whatever window or screen size the game runs at - the default value of 0 keeps that automatic behaviour, and most games never need this command. Passing a positive value fixes the frustum's width-to-height ratio regardless of the viewport shape. Use 1 for equal horizontal and vertical frustum extents - which reproduces renderers that deliberately stretch a square projection into a rectangular viewport - or a specific ratio when you want a stylised stretched look, or to match footage rendered for a different shape of screen. A zero or negative aspect other than exactly 0 is rejected with a runtime error. Whether the fixed ratio is fitted horizontally or vertically is chosen with CameraAspectMode. See also: CameraAspectMode, CameraZoom, CameraViewport. |
Example
; CameraAspect Example ; -------------------- Graphics3D 800,450,0,2 SetBuffer BackBuffer() camera=CreateCamera() CameraClsColor camera,0,0,64 light=CreateLight() RotateEntity light,30,-30,0 AmbientLight 64,64,64 ; A tumbling cube shows how the frustum shape changes cube=CreateCube() PositionEntity cube,0,0,6 EntityColor cube,255,180,40 fixed=0 While Not KeyDown(1) ; Space toggles between automatic aspect and a fixed square aspect If KeyHit(57) Then fixed=1-fixed If fixed Then ; Force a square (1:1) frustum - the cube stretches in this window CameraAspect camera,1 Else ; The default of 0 restores automatic aspect correction CameraAspect camera EndIf TurnEntity cube,0.2,0.4,0.1 RenderWorld Text 0,0,"Space: toggle automatic / square aspect Esc: exit" If fixed Then Text 0,20,"CameraAspect camera,1 (fixed square frustum)" Else Text 0,20,"CameraAspect camera (automatic aspect)" EndIf Flip Wend End
Index