Creating and Positioning a Camera

You’ve actually created a camera several times already by using the Create-Camera() command. Just like with creating shapes, you need to give your camera a name. Typically when coding a camera you should give the camera a generic name like camera or camera1 to make things easier. For example, if we wanted to create and name a camera called camera1, we would enter the following code:

camera1=CreateCamera()

The next step is to position your camera. Cameras can be positioned like most other objects using the PositionEntity command. You simply need to specify where on the screen you would like the camera to be.

For this example, remove the existing code under ;Create Camera in the demo07-01.bb program and replace it with this:

; Create camera
camera1=CreateCamera()
PositionEntity camera1, 1,-3,-1

Now when you run the program, it may seem as though the cylinder has moved, but it hasn’t (see Figure 7.2). What has actually happened is that you’ve moved the location of your camera, and the cylinder is actually in the same spot it always was.

Figure 7.2. The cylinder hasn’t really moved, just the location of the camera.


..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.149.234.188