Video Game Programming
Lab 3 : Rotating Cube

Abstract:
As powerful as it is, DirectX only has the ability to draw one type of primitive -> a triangle. This is not much of a limitation, since any polygonal structure can be represented as a set of triangles. In lab 1, you drew a square using two triangles. In this lab, you will output a cube to screen. A cube has six faces, and therefore can be represented by twelve triangles. Doing this the brute force way, you would need 12 x 3 = 48 vertices just to draw a cube. However, there is a more efficient way to draw structures that share vertices. Fill in the vertex buffer as you normally would -> with 8 vertices for the cube. Now, youll need to make use of the index buffer. Using the index buffer you can assign any set of vertices to a triangle face. So the first face would be vertices 1,2 and 3; the second would be 2,3,and 4, and so on.....

Topics Covered :
  • Vertices and Vertex Buffers
  • Transformations using DirectX
  • World, View and Projection Transforms
  • The Vertex Buffer
  • The index buffer

Assignment:
Your assignment is to write a program that will open up in fullscreen mode. It should quit when the user closes the window. The program should display a cube centered at the origin. The cube should rotate slowly around at least two axes.

Prequisites:
  • Completion of lab 2
  • Knowledge of the C++ language

Readings:
Chapters 1-9 "Real Time Rendering in DirectX"

Grading:
Explanation:
  • Cube appears
  • Cube rotates slowly
  • Vertex buffer appropriately filled
  • Index buffer appropriately filled
  Percentage:
  • 30%
  • 20%
  • 25%
  • 25%

Example:
Lab 3

This lab is being distributed as a zip file. You must unzip all files to the same directory.


Requirements:
This lab requires DirectX 9.0a End-User Runtime

Questions:
Address questions regarding this lab to Prasan Samtani at psamtani@usc.edu

 

The University of Southern California does not screen or control the content on this website and thus does not guarantee the accuracy, integrity, or quality of such content. All content on this website is provided by and is the sole responsibility of the person from which such content originated, and such content does not necessarily reflect the opinions of the University administration or the Board of Trustees