Hello,
Quote:1. How can I test for collision detection just for triangles of a mesh?
You'd need to use any of those functions:
Code:
Bool Sweep(Vec &point,Vec &move,Mshr &mshr,Matrix *mesh_matrix=NULL,Flt *hit_frac=NULL,Vec *hit_pos=NULL,Int *hit_face=NULL );
Bool Sweep(Vec &point,Vec &move,MeshBase &mshb,Matrix *mesh_matrix=NULL,Flt *hit_frac=NULL,Vec *hit_pos=NULL,Int *hit_face=NULL ,Bool test_quads_as_2_tris=true);
Bool Sweep(Vec &point,Vec &move,Mesh &mesh,Matrix *mesh_matrix=NULL,Flt *hit_frac=NULL,Vec *hit_pos=NULL,Int *hit_face=NULL,Int *hit_mshb=NULL ,Bool test_quads_as_2_tris=true); // 'hit_mshb'=index of hit MeshBase
Bool Sweep(Vec &point,Vec &move,MeshGroup &mshg,Matrix *mesh_matrix=NULL,Flt *hit_frac=NULL,Vec *hit_pos=NULL,Int *hit_face=NULL,Int *hit_mshb=NULL,Int *hit_mesh=NULL,Bool test_quads_as_2_tris=true); // 'hit_mshb'=index of hit MeshBase, 'hit_mesh'=index of hit Mesh
you can grab the index of mesh part, face index,
compare it to the face triangle vertex positions,
calculate barycentric coordinates of 'hit_pos' on the triangle using helper function:
Code:
// return blending factors 'blend' that (blend.x*tri.p[0] + blend.y*tri.p[1] + blend.z*tri.p[2] == p), these are also known as "barycentric coordinates"
Vec TriBlend(Vec2 &p,Tri2 &tri);
VecD TriBlend(VecD2 &p,TriD2 &tri);
Vec TriBlend(Vec &p,Tri &tri);
VecD TriBlend(VecD &p,TriD &tri);
according to barycentric coordinates you can calculate UV texture position (use triangle uv vertexes combined with obtained barycentric coordinates)
having UV on the texture you can lock it, update and unlock
(per pixel updating requires textures to be non compressed- not DXT)
generally this is slow process.