Creates an empty triangle mesh.
A TriMeshGeom has the following slots:
Slot | Type | Access | Description |
---|---|---|---|
cog_slot | vec3 | r | The local center of gravity |
inertiatensor_slot | mat3 | r | The local inertia tensor |
verts_slot | vec3 array | rw | The mesh vertices |
faces_slot | int[3] array | rw | The mesh faces |
Center of gravity with respect to the local coordinate system of the triangle mesh.
Inertia tensor with respect to the local coordinate system of the triangle mesh.
This attribute contains the sequence of mesh vertices.
This attribute contains the sequence of mesh faces. Each face contains three vertex indices.
Intersect a ray with the mesh. The ray starts at origin and travels along direction which must both be of type vec3. origin and direction must be given with respect to the local coordinate system L of the geometry. If earlyexit is True the method returns after the first hit, otherwise all triangles are tested and the result contains the nearest hit. The return value is a tuple (hit, t, faceindex, u, v) where hit is a boolean that indicates if the mesh was hit or not. t is the ray parameter, i.e. the point of intersection is at origin + t**direction*. faceindex is the index of the face that was hit and u v are the parameter coordinates of the intersection point.
This method tests the ray with all triangles, so it is not efficient if you have a lot of rays to test. It is meant for only a few rays where the preprocessing cost wouldn’t be amortized.
The ray-triangle intersection code (non-culling case) is based on:
Tomas Möller and Ben TrumboreFast, minimum storage ray-triangle intersectionJournal of graphics tools, 2(1):21-28, 1997 —