Homework 5: (100 points)
We discussed how to implement edge lists (for meshes) and primitive lists (for solids) such that vertices are not duplicated. Implement these in C++ in such a way that geometry and topology are separate, and such that we can use this for the bonus, which will render an arbitrary number of lines (for meshes) or polygons (for rendering solids).
1) Class MeshBuffer should have, at the very least:
a.a method to add a “line” or “edge” to the mesh, such that the vertices are not duplicated
b.a method to modify the position of a particular vertex, without disrupting the topology of the mesh (it should be clear that this involves “finding” the vertex in whatever underlying data structure you choose)
c.methods to retrieve the entire mesh in a data format that is consistent with it being passed directly into OpenGL
2)Class TriangleBuffer should have, at the very least:
a.a method to add a “triangle” to the solid, such that the vertices are not duplicated
b.a method to modify the position of a particular vertex, without disrupting the topology of the solid (it should be clear that this involves “finding” the vertex in whatever underlying data structure you choose)
c.a method to calculate the normal to that triangle (and save it)
d.any vertex modifications should trigger recalculation of normals for each triangle in which that vertex plays a part
e.methods to retrieve the entire solid in a data format that is consistent with it being passed directly into OpenGL (vertices and normals)
Use Angel’s vec.h tools as your representation of vertices and normals in 3D homogenous coordinates.
Place all this in a subfolder called “HW5” which should compile on its own.
BONUS: 50 POINTS!!!!
1.
Staring with a copy of this mesh data structure as a jumping off point, use it to draw a shape, called a “buckyball” that is roughly a sphere.
https://en.wikipedia.org/wiki/Truncated_icosahedron
You’ll want to write two more classes, Hexagon and Pentagon, that, when built, will break themselves down into Triangles, and pass these Triangles into your mesh. I’ll provide you with the coordinates and the code that will call your Hexagon and Pentagon constructors for all the shapes necessary to produce the buckyball. Draw your buckyball using the normal Phong lighting model, where the normal for each vertex is the normal of the triangle that contains that vertex. Place all this in a subfolder called “HW5bonus” which should compile and run on its own. It will look a bit like a soccer ball. NOTE that the coordinates may not be within the standard view volume so you may have to do a scaling operation to view the whole thing.
2.
Starting with the first Bonus as a jumping off point, use your mesh to draw the Buckyball using Gouraud Shading. The difference here is you want to add a method to your mesh to calculate the normal on a per-vertex basis as the average of all the normals of the triangles that contain that vertex. It is these modified normals that provides “smoothness” to the object when the colors are calculated in the vertex shader. Place all this in a subfolder called “HW5bonusGouraud” which should compile and run on its own.
版权所有:编程辅导网 2021 All Rights Reserved 联系方式:QQ:99515681 微信:codinghelp 电子信箱:99515681@qq.com
免责声明:本站部分内容从网络整理而来,只供参考!如有版权问题可联系本站删除。