Damage to terrain with .X file

I was looking for an example of a terrain clash that is in C ++, but I did not find anything. I found one example that uses the .RAW file in toymaker.info, so don't mention this. How do you discover that the collision of an object can intersect with each triangle. I know it will be slow. How do you detect a collision between the terrain and the .X file?

+3
source share
2 answers

Here is one way:

Draw a line from the origin through the center of the ball you want to check. Now make the intersection of the rays a triangle using the line or ray that you just created. Now you know if the ray passed through the triangle or not. If he passed through a triangle, then we get the point at which he crossed the triangle and performs a simple remote check with the center of the sphere. If the distance is greater than the radius of the sphere, a collision has not occurred. If it is smaller, then the sphere intersects the triangle.

It is also worth checking on which side of the triangle the center of the sphere is turned on. This is a simple point product between the face of a triangle and the center of a sphere. a value of 0 indicates that the center of the sphere lies in the triangle, and a positive result indicates it on one side and negative on the other.

. , , , , , , . . 4 , . , 1 5 . 0,8 . , , , , .

+2
+1

All Articles