Using a face normal as a direction vector

I want to keep track of triangle that I use a reference pointer to a location on weapon model, I would also like to use that triangles facing direction as the travel direction of bullets when fire is called is there an easy built in way to do it…apart from setting up a ray reflection, or is this my best option.


The triangles should have information about the normals already, so just convert it to the coordinate space you want and you should be sorted. Unless i’m missing something

could u elaborate a bit, or point me to docs tried a search but couldn’t pinpoint what I was looking for

which part, getting the normal or converting it?

[java]Triangle triangle = // however you got the triangle, perhaps a ray with results.getClosestCollision().getTriangle(null);
Vector3f normal = triangle.getNormal(); // this will be in object/model space (i think)
spatial.getWorldRotation ().mult (normal); //using the spatial the triangle belongs to, you can get the triangle normal direction in another coordinate system (global in this case)[/java]

1 Like

shit!..math.triangle… ah …some how it never occurred to me to look there -.-