I am setting 3 types of transformations i.e. Projection, View & World. Code is below :
Projection
float AspectRatio = (float)Width / Height; // Ratio between Width & Height
// Initialize Perspective View for the Screen
D3DXMatrixPerspectiveFovLH (&Projection, // Projection Matrix
1.0f, // Field of View
AspectRatio, // Aspect Ratio of the Screen
0.0f, // Nearest Clipping Plane
100.0f); // Farthest Clipping Plane
// Setup Projection Matrix for the Screen
Graphics->SetTransform (D3DTS_PROJECTION, &Projection);
View
D3DXMATRIXA16 Camera; // Camera
D3DXVECTOR3 Position (0.0f, 0.0f, -2.0f); // Position of the Camera
D3DXVECTOR3 Direction (0.0f, 0.0f, 0.0f); // Direction of the Camera Looking at
D3DXVECTOR3 UpDirection (0.0f, 1.0f, 0.0f); // Upward Direction for the Camera
// Initialize Camera for the Game
D3DXMatrixLookAtLH (&Camera, // Camera
&Position, // Position of the Camera
&Direction, // Direction of the Camera Looking at
&UpDirection); // Upward Direction of the Camera
// Setup Camera on the Screen
Graphics->SetTransform (D3DTS_VIEW, &Camera);
Rotation is the same as shown before, but here is the code that does the drawing :
static float Angle = 0.0f; // Angle of Rotation
KeysPressed (); // Check for the Keys pressed and process them
D3DXMatrixRotationX (&World, Angle);
// Transform the CoOrdinates according to the World CoOrdinates
Graphics->SetTransform (D3DTS_WORLD, &World);
Graphics->Clear (0, // Number of Areas
NULL, // Areas to clear
D3DCLEAR_TARGET | // Clear the Screen with the Colour defined below
D3DCLEAR_ZBUFFER, // Clear the Depth Buffer with the value given below
D3DCOLOR_XRGB (0, 0, 0), // Colour of the Screen
1.0f, // Dpeth (Z) Buffer
0); // Stencil Buffer
Graphics->BeginScene (); // Begin drawing the Scene
// Bind the Vertex Buffer with the Stream Data
Graphics->SetStreamSource (0, // Data Stream Starting Number
TriangleVB, // Vertex Buffer for the Triangle
0, // Offset
sizeof (sVERTEX)); // Size of the Vertex Structure
// Draw
Graphics->DrawPrimitive (D3DPT_TRIANGLELIST, // Type of Vertex (Triangle with 3 Vertices)
0, // Index Number of Vertex to begin with
1); // Number of Vertex to Draw
Graphics->EndScene (); // Finish drawing the Scene
// Present Back Buffer contents on the Screen
Graphics->Present (NULL, NULL, NULL, NULL);
Angle += 0.05f;
if (Angle >= 360.0f)
{
Angle = 0.0f; // Set Angle back to 0 degrees
}
Please help :confused: !
<span style='color:blue'>I can survive anything ... even NUKES!!!
The Lion King</span>