csTriangleMeshTools Class Reference
[Geometry utilities]
A set of tools to work with iTriangleMesh instances.
More...
#include <csgeom/trimeshtools.h>
Static Public Member Functions | |
static bool | BoxInClosedMesh (const csBox3 &box, csVector3 *vertices, csTriangleMinMax *tris, int tri_count, csPlane3 *planes) |
Test if a box is in a closed mesh. | |
static csTriangleMeshEdge * | CalculateEdges (iTriangleMesh *, size_t &num_edges) |
Create a table of edges for this mesh. | |
static void | CalculateNormals (iTriangleMesh *mesh, csVector3 *normals) |
This function will calculate normals for all triangles in the mesh. | |
static void | CalculateOutline (csTriangleMeshEdge *edges, size_t num_edges, csPlane3 *planes, size_t num_vertices, const csVector3 &pos, size_t *outline_edges, size_t &num_outline_edges, bool *outline_verts, float &valid_radius) |
Given a table of edges (as calculated with CalculateEdges()), a table of planes (as calculated with CalculatePlanes()), and a position in space. | |
static void | CalculatePlanes (iTriangleMesh *mesh, csPlane3 *planes) |
This function will calculate planes for all triangles in the mesh. | |
static csArray < csArray< int > > * | CalculateVertexConnections (iTriangleMesh *mesh) |
Create a table of vertex connections for this mesh. | |
static size_t | CheckActiveEdges (csTriangleMeshEdge *edges, size_t num_edges, csPlane3 *planes) |
This function will check all edges and mark them as active if the two triangles are not co-planar. | |
static void | CloseMesh (iTriangleMesh *trimesh, csArray< csTriangle > &newtris) |
Close a triangle mesh. | |
static bool | IsMeshClosed (iTriangleMesh *trimesh) |
Test whether a triangle mesh is closed. | |
static bool | IsMeshConvex (iTriangleMesh *trimesh) |
Test whether a triangle mesh is convex. | |
static bool | LineInClosedMesh (const csVector3 &p1, const csVector3 &p2, csVector3 *vertices, csTriangleMinMax *tris, int tri_count, csPlane3 *planes) |
Test if a line is in a closed mesh. | |
static bool | PointInClosedMesh (const csVector3 &point, csVector3 *vertices, csTriangleMinMax *tris, int tri_count, csPlane3 *planes) |
Test if a point is in a closed mesh. | |
static void | SortTrianglesX (iTriangleMesh *trimesh, csTriangleMinMax *&tris, size_t &tri_count, csPlane3 *&planes) |
Take a polygon mesh and sort triangles on maximum x coordinate. |
Detailed Description
A set of tools to work with iTriangleMesh instances.Definition at line 70 of file trimeshtools.h.
Member Function Documentation
static bool csTriangleMeshTools::BoxInClosedMesh | ( | const csBox3 & | box, | |
csVector3 * | vertices, | |||
csTriangleMinMax * | tris, | |||
int | tri_count, | |||
csPlane3 * | planes | |||
) | [static] |
Test if a box is in a closed mesh.
The mesh is defined by an array of triangles which should be sorted on x using the SortTrianglesX() function. This function does not check if the mesh is really closed. This function also needs an array of planes. You can calculate that with CalculatePlanes(). This function does not check if the eight corner points are actually in the object. If they are not then you will actually reverse the check and this function will return true if the box is completely outside the object. Basically this function tests if the box intersects some polygon in the object and it will return false if it does.
static csTriangleMeshEdge* csTriangleMeshTools::CalculateEdges | ( | iTriangleMesh * | , | |
size_t & | num_edges | |||
) | [static] |
Create a table of edges for this mesh.
The resulting table may later be deleted with 'delete[]'. Note that every edge will only connect two triangles. If more triangles connect to an edge then the edge will be duplicated. The 'active' flag of the returned edges is not calculated by this routine. Use 'CheckActiveEdges()' for that.
static void csTriangleMeshTools::CalculateNormals | ( | iTriangleMesh * | mesh, | |
csVector3 * | normals | |||
) | [static] |
This function will calculate normals for all triangles in the mesh.
The given array of 'normals' should be big enough to have normals for the number of triangles as defined in the mesh itself.
static void csTriangleMeshTools::CalculateOutline | ( | csTriangleMeshEdge * | edges, | |
size_t | num_edges, | |||
csPlane3 * | planes, | |||
size_t | num_vertices, | |||
const csVector3 & | pos, | |||
size_t * | outline_edges, | |||
size_t & | num_outline_edges, | |||
bool * | outline_verts, | |||
float & | valid_radius | |||
) | [static] |
Given a table of edges (as calculated with CalculateEdges()), a table of planes (as calculated with CalculatePlanes()), and a position in space.
This function will calculate an outline that is valid from that position. This outline will be given as an array of bool indicating which vertex indices that are used (so these have to be transformed from 3D to 2D) and also an array of double vertex indices (every set of two vertex indices forms one edge) that form the outline. This function will also return a radius. As long as the position doesn't move outside this radius the outline will be valid. The two input tables should have enough space for the returned number of edges and vertex indices. The safest way is to allocate double the amount of vertices as there are active edges in the input edge table and enough vertices as the polygon mesh supports.
Note: this function requires that the given edges are marked as active or not (use CheckActiveEdges()).
Note: num_outline_edges will be the amount of edges (which means that there will be twice as much vertices in the 'outline_edges' table.
static void csTriangleMeshTools::CalculatePlanes | ( | iTriangleMesh * | mesh, | |
csPlane3 * | planes | |||
) | [static] |
This function will calculate planes for all triangles in the mesh.
The given array of 'planes' should be big enough to have planes for the number of triangles as defined in the mesh itself.
static csArray<csArray<int> >* csTriangleMeshTools::CalculateVertexConnections | ( | iTriangleMesh * | mesh | ) | [static] |
Create a table of vertex connections for this mesh.
The resulting data structure must be freed by user after using it.
static size_t csTriangleMeshTools::CheckActiveEdges | ( | csTriangleMeshEdge * | edges, | |
size_t | num_edges, | |||
csPlane3 * | planes | |||
) | [static] |
This function will check all edges and mark them as active if the two triangles are not co-planar.
This function will return the number of active edges.
static void csTriangleMeshTools::CloseMesh | ( | iTriangleMesh * | trimesh, | |
csArray< csTriangle > & | newtris | |||
) | [static] |
Close a triangle mesh.
The current implementation is rather naive; it just returns all faces, but flipped.
static bool csTriangleMeshTools::IsMeshClosed | ( | iTriangleMesh * | trimesh | ) | [static] |
Test whether a triangle mesh is closed.
- Remarks:
- This function works best if vertices are shared.
static bool csTriangleMeshTools::IsMeshConvex | ( | iTriangleMesh * | trimesh | ) | [static] |
Test whether a triangle mesh is convex.
Note! This is NOT a fast function. Use with care.
- Remarks:
- This function works best if vertices are shared.
static bool csTriangleMeshTools::LineInClosedMesh | ( | const csVector3 & | p1, | |
const csVector3 & | p2, | |||
csVector3 * | vertices, | |||
csTriangleMinMax * | tris, | |||
int | tri_count, | |||
csPlane3 * | planes | |||
) | [static] |
Test if a line is in a closed mesh.
The mesh is defined by an array of triangles which should be sorted on x using the SortTrianglesX() function. This function does not check if the mesh is really closed. This function also needs an array of planes. You can calculate that with CalculatePlanes(). This function does not check if the two points are actually in the object. If they are not then you will actually reverse the check and this function will return true if the line is completely outside the object. Basically this function tests if the line intersects some polygon in the object and it will return false if it does.
static bool csTriangleMeshTools::PointInClosedMesh | ( | const csVector3 & | point, | |
csVector3 * | vertices, | |||
csTriangleMinMax * | tris, | |||
int | tri_count, | |||
csPlane3 * | planes | |||
) | [static] |
Test if a point is in a closed mesh.
The mesh is defined by an array of triangles which should be sorted on x using the SortTrianglesX() function. This function does not check if the mesh is really closed. This function also needs an array of planes. You can calculate that with CalculatePlanes().
static void csTriangleMeshTools::SortTrianglesX | ( | iTriangleMesh * | trimesh, | |
csTriangleMinMax *& | tris, | |||
size_t & | tri_count, | |||
csPlane3 *& | planes | |||
) | [static] |
Take a polygon mesh and sort triangles on maximum x coordinate.
That means that the first triangle in the returned array will have a minimum x coordinates that is lower then further triangles. This is useful for the SortedIn() routine below. This routine will also calculate planes. When done delete the returned arrays.
The documentation for this class was generated from the following file:
- csgeom/trimeshtools.h
Generated for Crystal Space 1.2.1 by doxygen 1.5.3