This week's assignment was really difficult. Even though, I had everything figured out in my head, I had no idea where to start from. Structuring the code was hardest part. I wasted most of my time studying up DirectX syntax and functions and looking up oversimplfied tutorials.
Enough of ranting, let's move to the code.
Here's is my code
Download
Changes:
- Changed the mesh file format to include Color and Indices.
The new format looks like this:
NoOfTriangles = n
NoOfVertices = n
NoOfIndices = n
Vertices
x , y , z | r , g , b, a
x , y , z | r , g , b, a
x , y , z | r , g , b, a
x , y , z | r , g , b, a
Indices
i1 , i2 , i3
i1 , i2 , i3
- Added an index buffer and changed the draw call to drawIndexedPrimitive.
- Added a cMesh class, which contains the cube's position and modelToWorld matrix, which transforms the model from Model space to World space. It also contains basic functions for moving around and rotating the mesh about the Y axis. (for now)
- Added a cCamera class which holds the camera position and worldToView matrix, which transforms the model from World space to View space.
- I am creating the viewToProjected matrix (which transforms the model from View to Projected space , 3d to 2d representation of the model) in the cRenderer class for now.
- Added a LoadTransforms() function to the cRenderer class which loads all these matrices into the Vertex shader.
- Added a GetInput() function to the cRenderer class which gets the user input and moves the camera or cube accordingly.
- Made the Update and waitForShutdownThis non const, for now. This was really frustrating. I was constantly getting 'Conversion loose qualifiers' errors.
Instructions:
- Move the cube using W,A,S,D.
- Move the camera using the arrow keys.
Screenshot of my funky cube
PIX Screenshots of Mesh Pre and Post Vertex Shader



No comments:
Post a Comment