Moving on slanted terrain
I need serious help with this. How would I figure out the angle of rotation between the flat part and the slanted part of the world so that a 3d model could walk and it will adjust to the slanted angle and keep walking in that direction. I want something similar to what they have in mario 64 or in tony hawk''s pro skater. I know how to implement height retrieval by use of collision and rays but i need to also figure out the angle underneath. Does anyone have an algorithm to get this? Thanks for any help.
Programming Rules!!!Skateboarding Rules!!!
if u can extrapolate ur position based on a heightmap, then it shudnt be hard to find out the points on the polygon u're on. Take a triangle for instance (sorry for the screwed up look):
A*
| | | \
B*---*C
Taking the above surface for example, with the user arbitrarily positioned on this. it doesnt matter where the user really is, just make sure u get the right poly.
Now, we need to use the directional vector of the avatar relative to the X-Z plane. meaning, u need (and ideally already know) the direction vector of the avatar. All u need to get now is the vector component (D) that maps to the X-Z plane, ignoring the users pitch (coz i think u're looking for the pitch).
doing a DOT product of the normal and direction vectors N.D will help determine the angle between the vectors. Now, apply a negation of 90 degrees to this obtained angle and u'll know how much u need to orient ur character to be in parallel with the surface!
There might be errors in this, OR it may be a slow way of doing it. more help anyone?
[edited by - crazee on March 22, 2003 11:53:01 AM]
A*
| | | \
B*---*C
Taking the above surface for example, with the user arbitrarily positioned on this. it doesnt matter where the user really is, just make sure u get the right poly.
Now, we need to use the directional vector of the avatar relative to the X-Z plane. meaning, u need (and ideally already know) the direction vector of the avatar. All u need to get now is the vector component (D) that maps to the X-Z plane, ignoring the users pitch (coz i think u're looking for the pitch).
doing a DOT product of the normal and direction vectors N.D will help determine the angle between the vectors. Now, apply a negation of 90 degrees to this obtained angle and u'll know how much u need to orient ur character to be in parallel with the surface!
There might be errors in this, OR it may be a slow way of doing it. more help anyone?
[edited by - crazee on March 22, 2003 11:53:01 AM]
- To learn, we share... Give some to take some -
If you just want Mario(or whoever) to slide down a hill if its too steep, a quick way to do it would be to take the normal of the plane he is standing on, set it''s y(or z, whichever is up) component to 0, and multiply by some constant. That will give you a vector pointing in the direction of "downhill", with a magnitude ranging from 0 on a flat polygon to 1 on a verticle one. Then add it to your velocity. This may not be accurate enough for a physics simulator, but I think it would work for a simple game.
What you want is simply the normal of the triangle the guy is walking on. That's easy --
Now, if you want a rotation (assuming N and up are normalized)...
1. The axis of rotation is
2. The angle of rotation is
[edited by - Jambolo on March 24, 2003 3:05:08 AM]
N = normalize( cross( v0v1, v0v2 ) )
Now, if you want a rotation (assuming N and up are normalized)...
1. The axis of rotation is
cross( N, up )
2. The angle of rotation is
acos( dot( N, up ) )
[edited by - Jambolo on March 24, 2003 3:05:08 AM]
John BoltonLocomotive Games (THQ)Current Project: Destroy All Humans (Wii). IN STORES NOW!
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement