Triangulator | An implementation of ear clipping triangulation in C
kandi X-RAY | Triangulator Summary
kandi X-RAY | Triangulator Summary
Triangulator is an implementation of Dave Eberly's ear clipping algorithm as described here: The project allows you to simply input a list of vertices and get back the required vertices (in order) and indices needed to construct a VertexBuffer and IndexBuffer for rendering the particular shape. The library is able to cut holes inside of polygons without error (the only caveat to this is that the library assumes that the hole to be cut lies completely within the shape so erroneous data given as a hole will result in invalid output data). Note: Triangulator is set up to write a good amount of verbose output in Debug mode. This will affect performance. For optimal performance, make sure you are building the library in Release mode or modify the source to remove the logging functionality.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of Triangulator
Triangulator Key Features
Triangulator Examples and Code Snippets
Community Discussions
Trending Discussions on Triangulator
QUESTION
So I need to generate a polygon using the Unity Mesh component that has n number of vertices. I am using a custom Triangulate() function that is able to find the indices for the mesh.triangles.
The problem is that based on the vertices I feed that function, the polygon generates on the wrong side and sometimes is not visible to the camera (unless I flip the camera to the other side).
Now I know this has to do with Unity's clockwise winding order, but how can I make sure the polygon is always generated on the correct side, no matter the vertices I feed it? Or could there be a way to know on which side the mesh generated so I can adjust the camera accordingly?
...ANSWER
Answered 2020-Feb-24 at 02:55This is the normal vector n of a triangle:
The visibility of the triangle is based on its normal. The math that calculates the light that hits the triangle, is reflected and goes to your eyes (Unity camera) uses the normal of the triangle for that. Basically, if that vector n points towards your eyes it means you can see [part of] the light that hits that surface.
To know if you can see the triangle, you need to know if the normal points to you. Without going further with the math, the normal is given by calculating the cross product of the vectors defined by the vertices of the triangle.
For example, a triangle A-B-C can be defined by the vectors AB and BC (not related with the figure above). Or you can invert the "direction" of this triangle and define it AC and CB. The normal of AB/BC has one direction and the normal of AC/CB has the opposite direction, because of ... math - if you google this stuff you can learn why, there are tons of tutorials.
So I wrote all this to tell something you already know: the order of the vertices defines the visibility. But that's because it defines the direction of the normal. Now take a look at this code:
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install Triangulator
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page