Local p = self:getVertex(v1):lerp(self:getVertex(v2), 0.5) create an entry in the edge map at this point Local ei = math.min(v1, v2) * vc + math.max(v1, v2) For the sake of simplicity, let’s define the center of the poly as the average of the vertex positions in the poly. To figure out how to triangulate a poly around its centroid, we first need to define the centroid. There are a couple of different ways you could define the “center” of the poly. This triangulation is useful on both triangles and polygons with > 3 indicies. Of course, beauty is subjective, so it’s good to have options for different types of triangulations, so that you can use whatever suits your particular algorithm best. Notice how the fan triangulation above creates small angles next to the index that was used as the base of the fan and notice how in contrast, centroid triangulation does a slightly better job of creating similarly-sized angles. By more attractive, I mean that if we proceed to apply a warp to this mesh, or extrude all of the faces of the tris we created, they’ll look more predictable and even. Mesh.polys = Įnd Fan triangulation of a 5-index polygonĬentroid-based triangulation is a slightly more attractive way to break up high-order polys into triangles. The header image used centroid triangulation on a cube made of 4-index polys before extruding it. visit every index between the second and second-to-last indicies It creates a new poly to store those connections and adds that poly to the end of the poly list. To create the new triangles that create the fan shape, the algorithm connects the first index in the mesh to every index between the second and second-to-last positions in the poly. The original poly is on the left, and the new ones are on the right. The illustration below the pseudocode shows an example of this algorithm breaking up a 5-index poly into three 3-index polys. This algorithm is useless on triangles, but is u seful on any polys with > 3 indicies. Storing the mesh with as little data as possible allows us to save memory space, and anything that processes the mesh (like the renderer!) spends less time traversing it. It breaks down high-order polys (polygons with >3 indicies) into tris without adding any new verticies. The fan-shaped triangulation is great as a last step before handing a mesh to a renderer. (again… these are NOT the scientific names for these algorithms… LOL) There are 3 algorithms that we are going to learn today: Fan, Centroid, and Triforce. But DO use it to get better acquainted with procedural geometry, make cool shapes, and have fun! So, disclaimer, maybe don’t try to base your Stanford 3D graphics paper on this blog post. BUT, I’m not one of those people, and I don’t think that the majority of people making games or dipping their toes into procedural geometry are! This post is focused on the visually pleasing application of these algorithms for procedural 3D geometry, and it is not focused on using all the correct scientific terminology. Tessellation and triangulation can mean complicated, fancy things to people who are mathematicians and computer scientists studying complicated, fancy things like computational geometry. This is where tessellation and triangulation come in handy! The algorithms I’m going to be showing in this tutorial break up the polys that make up a mesh without changing the shape of the mesh. We may need to break up polygons with lots of verticies into triangles, a necessary step before handing it to the renderer or prepare a mesh for a warp like stellation or extrusion to ensure that it’ll have lots of small details. Sometimes, we want to add detail to a mesh without changing its shape. DISCLAIMER #1: Code presented here is pseudocode that does NOT necessarily reflect production Limit Theory code.ĭISCLAIMER #2: This tutorial assumes you have at least basic knowledge of 3D geometry and related math.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |