CameraGrabWorldAt
CameraGrabWorldAt CameraIndex, WorldIndex, XBasePos, YBasePos, ZBasePos
 
Parameters:

    CameraIndex = The camera index you wish to use screen the world data with
    WorldIndex = The world buffer index that you wish to grab from
    XBasePos = X base position to shift element too
    YBasePos = Y base position to shift element too
    ZBasePos = Z base position to shift element too
Returns: NONE
 

      CameraGrabWorldAt transfers the previously captured gfx elements from a world buffer to the scene buffer. CameraGrabWorldAt can not only grab the elements that are in front of the selected chosen camera, but it can also relocate them. This allows you to grab section or sections from a previously created world buffer and then basically paste them ever you wish into the scene buffer.

      This could used to grab either entire scenes or segments to construct more complex or a bigger game worlds, more efficiently. You could even capture your GUI components to world buffers.. etc etc. Your only limited by your imagination.

      It's important to understand that when CameraGrabWorldAt grabs from the world buffer, it uses the selected cameras position and size as the location of where it's going to be grabbing from within that world buffer. This can be confusing if you if your using just a single camera. It's generally better to use a second camera purely for grabbing from worlds. This saves you having to constantly reposition a camera.




FACTS:


      * CameraGrabWorldAt grabs frome from the selected cameras position/size within the selected world.




Mini Tutorial:


      Part 1 of this example creates a world buffer, then fills this world buffer full of static dots (stars). Part 2, then creates second world buffer with a box shaded boxes in it.

      During the main loop, it grabs a camera full of this data from the world buffer and places it in the scenebuffer. Then calls the camera to render it. This allows us to mix data from different worlds, through different cameras, and maintain the scenes depth.


  
  
; =========================
; Part 1 - Create World Buffer 1
; =========================
  
  
; Create World
  CreateWorld 1
  
; Tell PB to Capture ALL following GFX commands
; to this world
  CaptureToWorld 1
  
; Plot 1000 Stars into this world buffer
  Stars=1000
  sW=GetScreenWidth()
  sH=GetScreenHeight()
  
  For lp =0 To Stars
     X=Rnd(sw)
     y=Rnd(sh)
     c=RndRGB()
     DotC x,y,c
     DotC x+sw,y,c
  Next
  
  
; =========================
; Part 2 - Create World Buffer 2
; =========================
  
; Create World Buffer #2
  CreateWorld 2
  
; Tell Pb to capture the following gfx commands to this
; world buffer
  CaptureToWorld 2
  
; Capture at a Z depth of 50
  CaptureDepth 50
  
; Loop through and draw some boxes in a mesh pattern
  For ylp =0 To 100 Step 20
     For xlp =0 To 100 Step 20
        BoxC xlp,ylp,xlp+10,ylp+10,1,RGBFade(RGB(100,0,10),50+xlp+ylp)
     Next
  Next
  
  
  
; Create camera
  CreateCamera 5
  
; Create camera 10
; this camera is just used for grabbing from World buffer 2
  CreateCamera 10
  
  
; Start of DO/LOOP
  Do
     
   ; Enable Capturing to Scene Buffer
     CaptureToScene
     
   ; Clear the scene buffer
     ClsScene
     
   ; Grab from world buffer #1 through camera 5
     CameraGrabWorld 5,1
     
   ; Get the viewers camera position
     cx=GetCameraX(5)
     cy=GetCameraY(5)
     
   ; Grab the world buffer Data And paste it To scene
   ; buffer at the viewers mouses position
     CameraGrabWorldAt 10,2,cx+MouseX(),cy+MouseY(),0
     
   ; Draw Camera #5
     DrawCamera 5
     
   ; Move the camera
     x#=x#+1
     PositionCameraX 5,X#
     If x#=>GetScreenWidth() Then x#=x#-GetScreenWidth()
     
   ; Display the screen
     Sync
     
   ; Loop back to the DO
  Loop
  
  




This example would output.

  
  no Text Output
  

 
Related Info: CameraGrabWorld :
 


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