We have 12 triangles with 8 vertices. Then again, we want those sharp corners, s
ID: 3634444 • Letter: W
Question
We have 12 triangles with 8 vertices. Then again, we want those sharp corners, so we have to duplicate corner vertices so that there is one for every face it is used in. At every corner, 3 faces meet, therefore we have 24 vertices making up 12 triangles (with re-use on some of them).In this case, GetVertices() would return a list like this:
(index)(xyz)
[0]: (0,0,0) {a vertex at 0,0,0}
[1]: (0,0,0) {duplicate--necessary}
[2]: (0,0,0) {second duplicate--none other needed for this point}
[3]: (1,0,0)
[4]: (1,0,0)
[5]: (1,0,0)
[6]: (0,1,0)
[7]: (0,1,0)
[8]: (0,1,0)
[9]: (0,0,1)
[10]: (0,0,1)
[11]: (0,0,1)
[12]: (1,1,0)
[13]: (1,1,0)
[14]: (1,1,0)
... that a little more than HALF of the vertices... everything except the three top vertices (3 * 3 = 9, 9 + 15 = 24).
and another method is, GetFaces() would return a list of faces containing the indexes (referencing the points in above), describing each triangle. Note that this is using ONE indexing. We'll have two faces for each side of the cube, for a total of 12 faces (or triangles). The only time a vertex will be shared (ie, referenced twice in the list of faces) is when it is on the same side of the cube. An example here is useful:
triangle: list of indices of vertices:
[0]: (1, 4, 11) {this draws a triangle from (0,0,0) to (1,0,0) and up to (0,0,1)}
[1]: (3, 11, ??) {this COMPLETES THIS SIDE OF THE BUILDING by drawing another triangle, SHARING the two vertices it can, and using a third, as yet unnamed vertex, to complete the side}
...
Now, for the bottom of the building, it would NOT use index 0 to describe the triangle, even though 1 is the same as 0, because otherwise, they would get averaged together in the normal. Instead, we could use indexes (2, 5, 13) to describe the triangle. (remember here that (2, 5, 13) is element of [1], [4], [12]).
here is the start of that class:
using System;
public class House
{
class House(int height,int width,int length)
{
........
}
//this method will return list of vertices
public Vertex[] getVertices()
{
......
}
return list
}
//This method will return list of faces
public Vertex[] getFace()
{
.....
}
return faces
}
Explanation / Answer
http://msdn.microsoft.com/en-us/library/ms747437.aspx http://msdn.microsoft.com/en-us/magazine/cc163449.aspx
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.