CameraPriority
CameraPriority CameraIndex, Priority
 
Parameters:

    CameraIndex = The Index of the Camera
    Priority = The Draw priority of this camera
Returns: NONE
 

      CameraPriority set the drawing priority of this camera. This only effects when all of the cameras are drawn together using the DrawALLCameras command.

      Cameras set to lower priority value are drawn BEFORE those with a higher priority value. This allows you to render a camera to an image, then have this image/sprite rendered in another camera




FACTS:


      * CameraPriority only take affect when cameras are drawn using DrawALLCameras

      * By default CameraPrioriy is set to 0.

      * Cameras set to a lower priority value are drawn BEFORE those with a higher priority value.




Mini Tutorial:


      This example is broken into three parts. Part 1 creates a camera, Part 2 creates a second camera that will render to image #1. Part 3 is the main program.

      At first glance, the operation of this program is easily missed. In nut shell the code is using the camera priorities to draw two scenes in particular order. In this situation it's important that we render them in order since the result of the first camera render, are being used in the second camera render.



  
; ===========================
; Part 1
; ===========================
  
; Create Camera 1.  Which will attach itself to
; the current surface, which will be the screen
; by default
  CreateCamera 1
  
; Activate the camera Auto CLS to screen the cameras
;  viewport before it starts drawing
  CameraCls 1,on
  
; Set the Cameras Auto CLS colour to Bright green colour
  CameraClsColour 1,RGB(100,155,0)
  
; Set this camera to the Higher priority, so it's DRAWN LAST
  CameraPriority 1,50
  
  
  
; ===========================
; Part 2
; ===========================
  
; Create an image 100x by 100 pixels
  MyIMage=NewImage(100,100)
  
; Tell PB to make this the current surface
  RenderToImage MyIMage
  
; Create Camera 2.  This camera will attach itself to
; the current surface, which will be the image #1
  CreateCamera 2
  
; Activate the camera Auto CLS to screen the cameras viewport
; before it starts drawing
  CameraCls 2,on
  
; Set the Cameras Auto CLS colour to Bright green colour
  CameraClsColour 2,RGB(055,205,200)
  
  
; Position Camera 2 at 1000x,0y
  PositionCamera 2,1000,0
  
  
; Set this camera to the lowest priority, so it's DRAWN FIRST.
; So during draw all cameras operation.  PB will draw this camera
; to it's attached surface (MyImage) first.
  CameraPriority 2,0
  
  
  
  
  
  
  
; ===========================
; Part 3
; ===========================
  
; limit the program to 30 frames per second or less
  SetFPS 30
  
  RenderToScreen
  
; Start a Do /loop
  Do
     
   ; Tell PB to caputre all GFX commands to the Scene buffer
     CaptureToScene
     
   ; Clear the scene buffer
     ClsScene
     
   ; DRaw some random Dots, where camera 2 is positioned
     x=GetCameraX(2)
     y=GetCameraY(2)
     For lp =0 To 100
        CircleC x+Rnd(100),y+Rnd(100),Rnd(10),Rnd(1),RndRGB()
     Next
     
   ; Draw Image 1 (which the camera 2 is attached to) into
   ; camera 1's space
     For ylp=0 To 1000 Step 200
        For xlp=0 To 1000 Step 200
           DrawImage MyIMage,Xlp,Ylp,0
        Next
     Next
     
     
     x#=CosRadius(angle#,100)
     y#=SinRadius(angle#,100)
     PositionCamera 1,x#,y#
     angle#=WrapAngle(angle#,1)
     
   ; Draw all of the cameras in order.
   ; scene buffer
     DrawAllCameras
     
   ; Display messages
     RenderToScreen
     SetCursor 0,0
     
     Print "Camera Priorities"
     For ThisCamera=1 To 10
        If GetCameraStatus(thisCamera)
           s$="Camera #"+Str$(ThisCamera)+"Draw Priority"
           s$=s$+Str$(GetCameraPriority(ThisCamera))
           Print s$
        EndIf
     Next
     
     
   ; Show the user the screen.
     Sync
     
   ; Loop back to the DO statement
  Loop
  



This example would output.

  
  no Text output
  


 
Related Info: CreateCamera | DrawAllCameras | DrawCamera | GetCameraPriority :
 


(c) Copyright 2002 - 2024 - Kevin Picone - PlayBASIC.com