Make a model follow the terrain
Maybe the terrain shouldn't be a mesh... is that the problem? Because I don't know any other way to create an irregular surface
"Improved Collision Detection & Response" at http://www.peroxide.dk/tuts_c.shtml, there is a very simple math for collisions.
Quote:Original post by Feadur
Ok, but the problem is that I don't know how to get the plane where the model is over, since the terrain is also a mesh.
Is there any function in DirectX 9 that gives me the plane from the mesh A to which mesh B is closer?
A terrain is a mesh (everything is a mesh). A mesh is a set of triangles. 1 triangle can make up 1 plane. Make a set of plane using a set of triangls. Yes - you can get it out of a mesh - look at fileformat to see how a triangle is defined in the fileformat and build it accordingly.
Then you can do plane terrain collision.
Ok thank's. Focusing on the problem, I see that's somewhat easier than I thought.
Given a Mesh loaded in DirectX with the Mesh.FromFile() static method, I guess I should be able to convert it to VertexBuffer. Once I have a vertex buffer, iterate throught it's vertices, to get each plane.
But how do I get the vertex buffer? Cos ther's no method or property on the mesh class to extract it.
Given a Mesh loaded in DirectX with the Mesh.FromFile() static method, I guess I should be able to convert it to VertexBuffer. Once I have a vertex buffer, iterate throught it's vertices, to get each plane.
But how do I get the vertex buffer? Cos ther's no method or property on the mesh class to extract it.
You'll need to store the vertices as triangles. Then the non-optimized way to test collision would be to make a verticle line at your character, then do loop through all the triangles and test for line-triangle collision. if there is collision, move the character up or down to the collision point.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement