Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Show me the steps to solve this assignment. Objective The objective of this assignment is to help you understand how matrices work in conjunction with
Show me the steps to solve this assignment.
Objective
The objective of this assignment is to help you understand how matrices work in conjunction with D mesh data. Before we only worked in a dimensional space, but now were moving on into D space. In order to see objects as they would be in the real world, we need to involve different matrices that serve different purposes.
First lets talk about the three matrices and what their purpose are. A world matrix is used for objects to dictate where they are in Cartesian space. This matrix can include rotation, scale, and translation information. Each object in your scene will have their own world matrix. Second matrix we will discuss here will be the view matrix. This matrix acts like a camera in your scene. This view matrix has a position and a direction of where to look. Lastly, we have a projection matrix. This matrix helps us see objects as if they were distant from us by shrinking or growing the items in our scene. In essence this matrix is what gives us the feel of real D by adding perspective to our scene. Keep in mind that all of these matrices will be a x matrix.
First we should start by creating the vertex information for our grid and our cube. We need to draw lines so take a few minutes to think about how many total vertices we will need for our objects. The grid will be x Meaning we will have horizontal lines and vertical lines. I shouldnt have to go into a lot of detail about the cube, but if you are still confused on the total amount of lines needed to draw a cube then I suggest drawing this out.
Keep in mind we would like for the grid to be placed around the origin For the cube, make sure to create it around the origin as well but we will be translating this upwards by half of its height.
The grid will have a total width of and a total depth of Hint: If we are placing this directly in the middle of our screen, where would the left and right side of our grid be located
The cube will have a total width of and height of and lastly a depth of
Once we have our geometry, the next step would be to create the world matrices for each. The world matrix for our grid can be the identity. No translation, rotation, or scaling for this matrix needed. We simply want the grid to be drawn at the origin.
The world matrix for our cube will be translated upwards by half of its total height. We will also ask of you to rotate the cube over time on its yaxis.
Integrating the view matrix is next. Create a x rotation matrix rotated degrees on the X axis. Then translate this matrix backwards along the local Zaxis unit.
Once our camera matrix has been fully built in World Space, we will need to inverse this matrix temporarily in order for it to be a proper view matrix. Reverse motion
Once we have our view matrix involved the next matrix we need to create will be our projection matrix. For our projection matrix our Near Plane is at our Far Plane is at the Vertical Field Of View is degrees and the Aspect Ratio is based on your windows dimension.
With all of our matrices created its time to create a vertex shader that will implement all three of these. We need to multiply our vertex by each matrix in this specific order. VertexW VertexL times World. VertexV VertexW times View. VertexP VertexV times Projection.
Once all three matrices have been multiplied in the last step is to do the perspective divide in order to see depth in our scene.
All in Cpp
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started