I need a function written to clip a triangle mesh.
Given a geometric plane represented by a width and height and 3 dimensional position, and an opengl polygon object represented by an array of 3 dimensional vertexs and a drawing order of indices, calculate a new opengl polygon.
Its basically an implementation of the Intersection of a Triangle and a Plane: [login to view URL]
The plane is represented by a position in 3 dimensions, and a width and height
The polygon is represented like this:
Vector3 positions[] = {
Vector3Make(-halfSide, -halfSide, halfSide),
Vector3Make( halfSide, -halfSide, halfSide),
Vector3Make(-halfSide, -halfSide, -halfSide),
Vector3Make( halfSide, -halfSide, -halfSide),
Vector3Make(-halfSide, halfSide, halfSide),
Vector3Make( halfSide, halfSide, halfSide),
Vector3Make(-halfSide, halfSide, -halfSide),
Vector3Make( halfSide, halfSide, -halfSide)
};
int indices[] = {
// bottom
0, 2, 1,
1, 2, 3,
// back
2, 6, 3,
3, 6, 7,
// left
0, 4, 2,
2, 4, 6,
// right
1, 3, 5,
3, 7, 5,
// front
0, 1, 4,
1, 5, 4,
// top
4, 5, 6,
5, 7, 6
};