Rotating a Camera

Just like other objects, you can rotate a camera to change the angle of your view. By using the RotateEntity command, you can specify the axis on which you want the rotation to occur. To test this out, we’re going to place a camera on top of our shape and rotate it so that it is facing downward. Replace the code under ;Create camera with the following:

; Create camera
camera1 = CreateCamera()
PositionEntity camera1,0,5,5
RotateEntity camera1,90,0,0

After you run the program, you’ll notice that you now have a view of the cylinder, as if you were on the ceiling looking down (see Figure 7.3).

Figure 7.3. A view of the cylinder from the top.


Let’s take a closer look at the code to see how we created this.

PositionEntity camera1, 0,5,5 moved the camera along the y and z axes so that the camera was directly over the cylinder (remember the cylinder is at position 0,0,5). If you ran the program at this point, you wouldn’t see anything because the camera is pointing straight ahead instead of downward at the cylinder. To correct this, we rotate the camera by entering this code:

RotateEntity camera1,90,0,0

The 90,0,0 rotated the camera 90 degrees along the x axis.

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

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