Jump to content

  • Log In with Google      Sign In   
  • Create Account


#Actualhaegarr

Posted 21 December 2012 - 12:51 PM

A variation of the standard way to compute a look-at matrix works here as well: If m denotes the movement direction (e.g. projected onto the x-z plane) and n the terrain normal at the current position, then
r := m cross n
denotes the side vector perpendicular to both m and n. Then
f := n cross r
denotes the forward vector that can be used as look-along vector as requested. It usually need to be normalized, though.

If, on the other hand, the normal isn't available because you're working with a height map, then this topic may help you. (Please notice that my first posts therein haven't considered triangulation correctly, but down from post #15 inclusive things are done well). After computing the height at the current position and the height a bit in direction of the movement vector, then the normalized difference vector is the result.

BTW: To be pedantic: A bi-normal is a construct that can be computed at locations on a line. In case of a surface the correct term is bi-tangent.

#1haegarr

Posted 21 December 2012 - 12:50 PM

A variation of the standard way to compute a look-at matrix works here as well: If m denotes the movement direction (e.g. projected onto the x-z plane) and n the terrain normal at the current position, then 

r := m cross n

denotes the side vector perpendicular to both m and n. Then 

f := n cross r

denotes the forward vector that can be used as look-along vector as requested. It usually need to be normalized, though.

 

If, on the other hand, the normal isn't available because you're working with a height map, then this topic may help you. (Please notice that my first posts therein haven't considered triangulation correctly, but down from post #15 inclusive things are done well). After computing the height at the current position and the height a bit in direction of the movement vector, then the normalized difference vector is the result.

 

BTW: To be pedantic: A bi-normal is a construct that can be computed at locations on a line. In case of a surface the correct term is bi-tangent.


PARTNERS