Game Development Reference
In-Depth Information
void getViewMatrix(D3DXMATRIX* V);
void setCameraType(CameraType cameraType);
void getPosition(D3DXVECTOR3* pos);
void setPosition(D3DXVECTOR3* pos);
void getRight(D3DXVECTOR3* right);
void getUp(D3DXVECTOR3* up);
void getLook(D3DXVECTOR3* look);
private:
CameraType _cameraType;
D3DXVECTOR3 _right;
D3DXVECTOR3 _up;
D3DXVECTOR3 _look;
D3DXVECTOR3 _pos;
};
One thing shown in this class definition that we haven't discussed is
the CameraType enumerated type. Presently, our camera supports
two types of camera models, a LANDOBJECT model and an AIRCRAFT
model. The AIRCRAFT model allows us to move freely through space
and gives us six degrees of freedom. However, in some games, such as
a first-person shooter, people can't fly; therefore we must restrict
movement on certain axes. Specifying LANDOBJECT for the camera
type has these restrictions carried out, as you can see in the following
section.
12.2 Implementation Details
12.2.1 Computing the View Matrix
We now show how the view matrix transformation can be computed
given the camera vectors. Let p =( p x , p y , p z ), r =( r x , r y , r z ), u =( u x , u y ,
u z ), and d =( d x , d y , d z ) be the position, right, up, and look vectors,
respectively.
Recall that in Chapter 2 we said that the view space transformation
transforms the geometry in the world so that the camera is centered at
the origin and axis aligned with the major coordinate axes (see Figure
12.2).
Search WWH ::




Custom Search