When looking for collisions, it may be difficult to find exactly where the collision occurs. The exact point can help improve collisions both visually and calculation wise. The way collisions are currently being done in the neurosis engine is to take every line of every triangle from the main object (model_1) and check if they cross the polygons of the potential colliding object (model2).
So for each initial triangle, three checks are being made - [0][1], [0][2] and [1][2]. These represent two points of the model_1 triangle and for each check - whether the two points intercept a colliding polygon from model_2. Using what was previously learned in tutorial 4, we can calculate the exact collision point.
For every two points from the given triangle of model_1 - see if they are on separate sides and if they are find the collision point. To find the point, calculate the exact position of the collision with the colliding triangle. To do this, use both points and the distance from the collision plane and linearly interpolate the position for each border line of a triangle.
proportion = abs(point_distance[0] / temp_distance);
collision_point.x = point_pos[0].x - ((point_pos[0].x - point_pos[1].x) * proportion); collision_point.y = point_pos[0].y - ((point_pos[0].y - point_pos[1].y) * proportion); collision_point.z = point_pos[0].z - ((point_pos[0].z - point_pos[1].z) * proportion);
Then average out all the collision points and get the exact point. This may take some extra processing power, but the cool thing is you could use a separate collision model to get a quicker representation. Also, a bounding box algorithm could be used to speed up the checks before any other calculations take place. Once the collision point is found to exist, the collision can take place.
|