|
Since polygons have boundaries and are do not go on forever, we will need to allow a structure for calculating various things we want to do to our polygons. Without boundaries collisions would occur anywhere as long as the point passed through the plane and for things such as decals, we need the boundaries to calculate edges. Another reason for using boundaries with polygons is to provide pre-calculated values which will help with rendering and object interaction.
Now we can create a new triangles for the boundaries by using the base triangle and the normal to setup three other triangles:
newPoint1 = baseTrianglePoint1; newPoint2 = baseTrianglePoint2; newPoint3 = baseTrianglePoint1 + normal; | ![]() |
This will allow a new triangle in which we can calculate a normal for. After doing this for all three edges we end up with four normals - one for the base triangle and three more for the sides. As can be seen in the picture, the green triangle is the original, the blue triangle is the newly formed triangle and the red line is new normal. With all four normals we can then calculate if a collision occurs within the boundaries:
1 - Does collision occur with main triangle?
2 - If so, calculate the collision point.
3 - Does the collision point occur within the boundaries?
4 - If so, calculate collision.
Another area where our way of boundaries could come in is when calculating things like decals when deciding whether certain features may occur within the polygon itself. An example of boundaries with decals could be an explosion over a corner wall - by using the boundaries of the wall the explosion could be wrapped around by placing it both walls that make up the corner and cutting off at the boundaries of each.