Make a model follow the terrain
First of all, sorry about my english (it's not my language actually).
I'm pretty shure this question has been answered before, but since I cannot find it, I'll make it again.
I have two meshes, one for the terrain, and one for the character (in fact, it is the "tiny.x" model that ships with the DirectX SDK).
There's no problem if i make the character move along the terrain, as long as it is a plane, but, how can it detects when the terrain mesh is not a plane and so, move the model along the Y axis?
I cannot use bounding sphere and standard collision test, because de character mesh bounding sphere is always inside the terrain mesh bounding sphere.
I'm workin with c# and DirectX 9
Thanks in advance ;)
Are you trying to orient your model to the plane angle when its slanted or like a slope ? If so you need to do ray/sphere plane collision and get the angle using the dot product and axis or rotation using cross product.
Hope this helps.
Hope this helps.
Actually that's what I'm trying to do. But I have no clue on how to do it. Do you have any example -web link, or wathever- of ray/sphere plane collision?
Thanks
I'll try to search thought gamedev anyway.
Thanks
I'll try to search thought gamedev anyway.
Thanks Ocelot. That's what I'm trying to do, but since I don't understand C++, I can't extract any idea from it :(
And even if I can run the compiled example, the code doesn't compile on Visual Studio 2005.
And even if I can run the compiled example, the code doesn't compile on Visual Studio 2005.
Have a look here for sphere plane collision.
http://www.edenwaith.com/products/pige/tutorials/collision.php
http://www.edenwaith.com/products/pige/tutorials/collision.php
Thanks Crack123, it's a good starting point, but as it says in that tutorial, I have to compare the distance between the sphere and the plane with the bounding sphere radius, where
distance = plane.normal · sphere.position
The problem is how to calculate the plane normal, because I know how to calculate the normal given a plane, but my terrain IS NOT a single plane. Instead, is a polygonal mesh with lots of vertices and planes, and I need to know which plane is te bounding sphere over. Also, it can be colliding with multiple planes at the same time. For example, a building in the middle of the terrain would make 2 collisions. the one with the floor, and the other with the building's wall.
distance = plane.normal · sphere.position
The problem is how to calculate the plane normal, because I know how to calculate the normal given a plane, but my terrain IS NOT a single plane. Instead, is a polygonal mesh with lots of vertices and planes, and I need to know which plane is te bounding sphere over. Also, it can be colliding with multiple planes at the same time. For example, a building in the middle of the terrain would make 2 collisions. the one with the floor, and the other with the building's wall.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement