CameraSceneSort
CameraSceneSort CameraIndex, Flag
 
Parameters:

    CameraIndex = The Index Identifier of the Camera that you wish to create.
    Flag = The state of camera sort (1= on, 0 = off)
Returns: NONE
 

      CameraSceneSort allows the user to enable/disable a camera from pre-sorting the items in the scene buffer prior to rendering. This can useful, when you need to render the same scene more than once and don't want PlayBASIC to waste any time re-sorting the scene items again.




FACTS:


      * None





Mini Tutorial:


      This example creates a star field effect. To the view two cameras.


  
; Get Screen Width & Height
  sw=GetScreenWidth()
  sh=GetScreenHeight()
  
  Type tStar
     X#,y#,Z,speed#,colour
  EndType
  
  max=1000
  
; Create an array to hold a list of stars
  Dim Stars(Max) As tstar
  
  
; Init the stars
  For lp=0 To Max
     Stars(lp).x=Rnd(sw)
     Stars(lp).y=Rnd(sh)
     Speed#=RndRange#(1,5)
     z=(5-Speed#)*10
     Stars(lp).Z=z
     Stars(lp).Colour=RGBFade(RGB(255,255,255),(100-z))
     Stars(lp).Speed=Speed#
  Next
  
  
  
; Create a new camera, this camera will attach it self to
; the default PB screen
  TopCamera=NewCamera()
  
; resize the camera viewport to be the top half of the screen
  CameraViewPort TopCamera,0,0,Sw,Sh/2
  
  
; Create a new camera, this camera will attach it self to
; the default PB screen
  BottomCamera=NewCamera()
  
; resize the camera viewport size to be the bottom half of the screen
  CameraViewPort BottomCamera,0,sh/2,Sw,Sh
  
; move the bottom camera down.
  PositionCamera BottomCamera,0,sh/w
  
  
; Set the Bottom Camera CLS colour to dark RED
  CameraClsColour BottomCamera, RGB(75,0,0)
  
; Disable the sorting when drawing the bottom camera.
  CameraSceneSort BottomCamera, off
  
  
; Start of the Program Main loop
  Do
     CaptureToScene
     ClsScene
     
   ; Update and capture the stars to the scene buffer
     For lp=0 To max
        x#=Stars(lp).x-Stars(lp).Speed
        CaptureDepth Stars(lp).z
        DotC x#,Stars(lp).y,Stars(lp).Colour
        If x#<0 Then X#=X#+GetScreenWidth()
        Stars(lp).x=x#
     Next
     
   ; Draw The Top half of the screen
     DrawCamera TopCamera
     
   ; Draw The Bottom Camera
     DrawCamera BottomCamera
     
   ; refresh the screen to the user
     Sync
     
   ; Loop back to the DO statement
  Loop
  
  





  
  no Text output
  

 
Related Info: CameraBasics | CaptureToScene | DeleteCamera | DrawAllCameras | DrawCamera | GetCameraStatus | GetFreeCamera | NewCamera :
 


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