Hi all,
I have been looking into collision handling and a way to have a character move on a ‘random’ uneven terrain while making this appear as natural as possible.
What I want to do:
1)Have a ‘randomly’ created terrain either based on an arbitrary image I will use as a heightfield map or on a polygonal model I will create in some software like Maya (its the one I am currently learning)
2)have a character with some animations for walking, running (perhaps additional ones for walking on terrains with high angle e.t.c)
3)Using collision detection between the character and the terrain i was thinking of placing the character on top of the terrain (for that region) whenever I get a collision with the terrain.
4)Whenever such a colission occurs the characters will not only be moved on top of that part of the terrain but using the normal of that polygon(s) I want to rotate the character accordingly to make the whole thing appear a bit more realistic.
My questions are:
1)Is there a way to know at which part of the polygonal mesh of an object, has a collision occurred? In this case in which polygon of the terrain the character is walking on?
2)If the above is not possible then I can get the 2D coords (lets say x,y for the plane and z for height even though its different in panda) of the character and approximately know when the collision occured. However I somehow need to find the coords of the terrain polygon where this happened so that I can calculate the normal and rotate the character acoordingly. Any thoughts on how to do this?
3)Are my above questions and logic totally stupid? Is there some better and easier way to do all this? I looked into how PandaSteer handles this kind of thing and the characters there are always partially buried in the terrain (part of their feet at least) so the effect looks like walking on level ground while magically climbing. While this may be fine for a far away view, for a 3rd person perspective its not nice.
I have no idea where to turn for this1 Any suggestions/opinions/link/code or any material is totally welcome and appreciated. Once and If I get something functional I will post the code for future reference.
Thanks in advance,
Adam
EDIT:
I just thought that an even better solution would be to have multiple animations for different angles instead of rotating the character. This way it would be even more realistic. However the angle is still need so the above questions still stand…Any help?