Game Development Reference
In-Depth Information
4. Calling
cinematic.play()
at this point should display Jaime sliding along
the path.
Once we're happy with it, we can go on and do the camera work as follows:
1. The
Cinematic
instance will create a
CameraNode
for us if we call
cine-
matic.bindCamera("cam1", cam)
, so let's do that for our first camera.
The string is the reference that
Cinematic
will know the camera by.
2. It will be a camera that pans so we create a
MotionPath
instance and a
Mo-
tionEvent
instance for it. Again, we can get the waypoints of the camera path
from the scene. Since the
Node
we added in
SceneComposer
by default snaps
to the ground, we need to add between 1.5f and 2.0f to the y axis to get it to a
suitable height.
3. The camera should look at a fixed point as it pans, so we set
directionType
of camera's
MotionEvent
to
LookAt
and then also set the direction it should
look at with
cam1Event.setLookAt
where the first
Vector3f
is the loca-
tion to look at and the second is
Vector3f
, which is up in the world:
cam1Event = new MotionEvent(camNode, camPath1,
5f);
cam1Event.setDirectionType(MotionEvent.Direction.LookAt);
cam1Event.setLookAt(Vector3f.UNIT_X.mult(100),
Vector3f.UNIT_Y);
4. With that done, we can test the first camera pan. We do that by calling the follow-
ing code:
cinematic.activateCamera(0, "cam1");
5. The next camera will get its own
MotionPath
and
MotionEvent
instances
and can similarly get its own
CameraNode
. It's perfectly fine to use the same
physical camera for both of the CameraNodes.
Now, we can start doing something about the lack of animation in the scene.
1. The first thing Jaime does in the scene is walk towards the beach. We can create a
new
AnimationEvent
instance that uses the
Walk
animation: