Computer Science Canada

[Tutorial] [Blitz] Making Cameras

Author:  shorthair [ Tue Feb 17, 2004 9:06 pm ]
Post subject:  [Tutorial] [Blitz] Making Cameras

Cameras allow you to see what's going on in the 3D world. Without at least one camera, nothing that may be happening in the world will be rendered to the screen.

Cameras also control a number of other effects, including rendering range, zoom and fog.

Creating Cameras
To create a camera, simply use the CreateCamera command:


code:
   
 ;create a new camera!
    camera=CreateCamera()
 


Camera Viewport
A camera needs to know where on screen its view of the world is to be rendered. This area of the screen is known as the camera viewport. By default, a new camera's viewport is set to the entire screen.

To change the camera viewport use the CameraViewport command:


code:
   
 ;Draw to top left corner of the screen
    CameraViewport camera,0,0,GraphicsWidth()/2,GraphicsHeight()/2



Camera Range
Camera range determines how far into the distance a camera can 'see'. You specify 2 values for camera range - a near value and a far value. All rendering is clipped to this range.

Its a good idea to try and keep the near value as high as possible, while keeping the far value as low as possible. This helps to minimize z-buffer problems like 'jaggies'. By default, the near value for a new camera is 1, and the far value is 1000.

To change the camera range, use the CameraRange command:


code:
   
 ;Sets the near range to 5 and the far range to 5000
    CameraRange camera,5,5000



Camera Zoom
Changing a cameras zoom allows you to 'zoom-in' or 'zoom-out' of the action in the world. The default zoom value for a new camera is 1. Zoom values greater than 1 will cause a 'zoom-in' effect, while zoom values less than 1 will cause a 'zoom-out'. Zoom values should never be set at 0 or less!

The CameraZoom command controls camera zoom:


code:

  ;Zoom-in a bit!
    CameraZoom camera,1.5




Fog Effects
Blitz3D allows you to setup fog effects independently for each camera. This can be useful for limiting what a certain camera can see. For example, a racing game might use a camera for its rearview mirror. However, you might want to limit what is visible in the rearview mirror in order to keep the game running fast.

To setup a simple fog effect for a camera, you might use something like this:

code:
   
     ;Sets the color of fog for this camera
    CameraFogColor camera,0,128,255

    ;Sets the near/far range of fog for this camera
    CameraFogRange camera,1,1000

    ;Sets the fog mode for this camera.
    CameraFogMode camera,1

 


Often, the fog range and camera range will be the same. However, by increasing the near value of fog, you can control how 'thick' fog appears to be. Smaller fog near values will result in a thicker fog effect, since the fog will start nearer to the camera.

Unfortunately, fog is not well supported on all graphics cards. While all cards can perform some kind of fog effect, the quality varies a lot. For this reason, its a good idea to make fog optional in your Blitz3D games.

Author:  jonos [ Fri Feb 20, 2004 7:54 am ]
Post subject: 

nice tutorial, but you should add that you have to set:

Graphics3d w, h

or else it won't work.

woould anyone be able to tell me why this isn't working (maybe jusdt because the pattern is not 3d...

code:

Graphics3D 400, 400

count% = 60
camera=CreateCamera()

For k = 50 To 350 Step 10
        Plot 50, k
        Plot 350, k
        Plot k, 50
        Plot k, 350
Next

For count1 = 50 To 350 Step 10
        For count2 = 50 To 350 Step 10
                Plot count1, count2
        Next
Next

For count3 = 55 To 345 Step 10
        For count4 = 50 To 350 Step 2.5
                Plot count3, count4
        Next
Next

For count5 = 55 To 345 Step 10
        For count6 = 50 To 350 Step 2.5
                Plot count6, count5
        Next
Next

CameraViewport camera, 50, 350, 50, 350

For count6 = 2 To 10
        CameraZoom camera, count6
        Delay(25)
Next

Delay(3000)


thanks

jonos edit:
ive been thinking about this and i think i need 3d models, which i will make when i am finished buying the 3rd 3dmax iso, oops.

Author:  shorthair [ Fri Feb 20, 2004 3:24 pm ]
Post subject: 

Starting in 3ds max , is quite intimidating , the help file is your friend , all the exra options make you feel like your just in the ocean of buttons ,


: