| parent (optional) - parent entity of camera |
|
Creates a camera entity and returns its handle. Without at least one camera you won't be able to see anything in your 3D world - RenderWorld draws the scene from each camera's point of view. With more than one camera you can achieve effects such as split-screen modes and rear-view mirrors (see CameraViewport). A camera is a normal entity, so all the entity commands work on it: position it with PositionEntity, fly it around with MoveEntity and TurnEntity, or parent it to a vehicle so it rides along. A new camera starts at 0,0,0 facing positive z, with a viewport covering the whole screen, a range of 1 to 1000 and a 90 degree field of view (zoom 1). RenderWorld draws cameras to the backbuffer. In Extended mode a camera can also be shown on a GUI canvas with RenderWorldToCanvas or SetCanvasCamera. The optional parent parameter allows you to specify a parent entity for the camera, so that when the parent moves the camera moves with it. The relationship is one way: applying movement commands to the camera will not affect the parent. Specifying a parent will still result in the camera being created at position 0,0,0 rather than at the parent entity's position. See also: CameraZoom, CameraRange, CameraViewport, CameraClsColor, RenderWorld. |
; CreateCamera Example
; --------------------
Graphics3D 640,480,0,2
SetBuffer BackBuffer()
; Create the camera - the scene is rendered from its point of view
camera=CreateCamera()
PositionEntity camera,0,1,-5
light=CreateLight()
RotateEntity light,45,45,0
; A spinning cone to look at
cone=CreateCone(16)
PositionEntity cone,0,1,0
EntityColor cone,255,100,0
While Not KeyDown(1)
TurnEntity cone,0,1,0
; A camera is a normal entity, so entity commands move and turn it
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 Esc: exit"
Text 0,20,"The view is rendered through the camera returned by CreateCamera()"
Flip
Wend
End