CopyCameraSettings camera,source
Parameters
|
camera - destination camera source - camera whose view to copy |
Description
|
Copies one camera's transform and view settings onto another. The copy covers the source's complete world transform, including inherited position and rotation, and its projection, zoom, aspect and fit mode, clipping range, viewport, clear settings, fog settings, shadows and camera effects - handy for a picture-in-picture or a second canvas showing the same view. The destination retains its identity, parent, visibility, enabled state and ownership, and the source is unchanged. Call it again to refresh the view as the source changes. For another canvas, call CameraViewport afterwards to set that canvas's picking and projection dimensions. Requires Extended mode. See also: SetCanvasCamera, CameraViewport, SetWorldEditorViewEntity. |
Example
; CopyCameraSettings Example ; -------------------------- ; Requires Extended mode. Graphics3D 640,480,0,2 SetBuffer BackBuffer() ; The source camera is never drawn; the view camera copies it each frame source=CreateCamera() PositionEntity source,0,0,-5 CameraClsColor source,20,30,50 HideEntity source view=CreateCamera() light=CreateLight() RotateEntity light,45,45,0 cube=CreateCube() EntityColor cube,80,180,240 copying=True While Not KeyDown(1) ; The source camera breathes its zoom and rolls gently on its own CameraZoom source,1.5+Sin(MilliSecs()*0.05)*0.5 RotateEntity source,EntityPitch(source),EntityYaw(source),Sin(MilliSecs()*0.03)*20 ; Arrow keys move the SOURCE camera; the view follows while copying If KeyDown(200) Then MoveEntity source,0,0,0.1 If KeyDown(208) Then MoveEntity source,0,0,-0.1 If KeyDown(203) Then TurnEntity source,0,1,0 If KeyDown(205) Then TurnEntity source,0,-1,0 ; Space freezes or resumes the copy If KeyHit(57) Then copying=Not copying If copying CopyCameraSettings view,source ; Refresh the viewport for this canvas after copying CameraViewport view,0,0,GraphicsWidth(),GraphicsHeight() EndIf TurnEntity cube,0.2,0.4,0 RenderWorld Text 0,0,"Arrow keys: move source camera Space: freeze / resume copy Esc: exit" Text 0,20,"CopyCameraSettings view,source copying: "+copying Flip Wend End
Index