Game Development Reference
In-Depth Information
Lights are great, but they are better when you interact with the camera and a light. Previ-
ously you created an ambient light that was used to light the scene. You already have al-
lowed the player to move the camera around. This time you will attach a spotlight to the
camera node to light up your hero.
The camera object is used to present scenes to the user from their point of view. You can
use the camera object to set and adjust the field of view, near and distant visibility limits,
and the focal length of the camera. Figure 12-3 shows you the main parameters of the
field of view. These variables are as follows:
xFOV : This is the angle at which the x-axis will be seen.
yFOV : This is the angle at which the y-axis will be seen.
zNear : This parameter is the minimal distance between the camera and the
surface. Any object that is closer to the camera is not shown.
zFar : This parameter is the maximum distance between the camera and the
surface. Any object that is beyond this distance does not appear.
Figure 12-3 . Camera field of view diagram
Now it is time to create the camera node that you will use to view the game. In the
GameViewController , you will add the class-level variable that will be used to fol-
low the spaceman around the scene: var cameraNode: SCNNode! .
The next piece of the code puzzle is to find the createMainScene() method. In this
method, you will add a call to setupCameras(mainScene) . You need to add this
method call anywhere after the mainScene variable is initialized. You should have an
Search WWH ::




Custom Search