PS2 Linux Programming
Viewing and Manipulating a Model in 3D
Introduction
This tutorial illustrates
some of the basic model and camera manipulation techniques that are required in
order to make a 3D Computer Game. Once again, it is stressed that the coding is
inefficient but is written in a manner to help the reader understand the
techniques being used – it is up to the reader to use the concepts being
presented to develop more efficient code. It will also be noted when running
the program that the frame rate has dropped to about 75 FPS. This is due to a
number of factors including the coding method being used and the number of
vertices (about 2000) being rendered. In order to harness the true power of the
PS2 much of the vertex transformation processing must be moved onto the vector
units and this will be investigated in the next series of tutorials.
One additional class has
been added at this stage; an axes class (CAxes) which can be used to draw an x,
y, z axes triplet in any coordinate system. The x, y and z axes are coloured
red, green and blue respectively. This is useful when attempting to understand
and visualise the techniques being illustrated.
Operation of the
Program.
On running the program a
humanoid figure is presented in the middle of the screen along with two axes
systems. The axes system in the middle of the screen is the world coordinate
axes and the axes system at the bottom of the model is the local axes system
for the model. The model and camera are controlled by the controller connected
to port 1 in the following manner.
·
The d-pads and
shoulder pads on the left of the controller control the axes of movement, left
and right are x-axis movement, up and down are y-axes movement and L1 and L2
are z axes movement.
·
The keys on the right
hand side of the controller control the movement characteristics of the model
and the camera. Pressing one of the keys on the right of the controller sets
the movement functionality as described below.
Cross: Move the model along the world axes;
Circle: Rotate the model around it’s own local axes
system;
Square: Move the camera along it’s local axes;
Triangle: Move the model in the direction it is pointing
along it’s local axes system;
L1: Rotate the camera round it’s local axes.
To reset the camera and the
model to their default starting positions press down either of the analogue
stick buttons.
Experiment with the
movement of the camera and the model.
In this tutorial a 3D
model has been loaded and rendered on screen. The position of the model and
camera can be manipulated using the controller pad. The movement illustrates
some of the basic controls that are required when creating a 3D computer Game.
Dr Henry S Fortuna
University of Abertay
Dundee