Jump to content
  • Advertisement
Sign in to follow this  
Tang of the Mountain

Finding the forward vector

This topic is 4583 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Sure, Sounds easy enough. And maybe it is, but i cant figure it out. Perhaps my math skills are on the weak side. I have an objects position i have the normal of the plain below him(which is not necessarily his normal) I have the objects Yaw based on the worlds Y axis naturally. Thats it. I know it can be done, and ideally with as little trig as possible as I think trig is ugly. But if it cant be avoided, oh well. I would appreciate an help. Please no code, thats not what im here for. But a plan of attack and maybe some psuedocode would be great. I dont care if i find the forward or the right facing vector, but i need one of them. Regards

Share this post


Link to post
Share on other sites
Advertisement
Is the character always aligned with the world up axis? Also, can you clarify what you mean by forward vector? Do you mean the vector that moves the character in the direction he's facing, but also up or down depending on the orientation of the terrain beneath him?

Share this post


Link to post
Share on other sites
his normal, is not always the world Y, he can be rotated any direction

I just want one of the other two vectors, not his normal, either his look at vector, or the vector protruding out his right side. If i had one of these, i could figure out his orientation completely, but i am not sure how to go from point and yaw to a directional vector.

Share this post


Link to post
Share on other sites
You can't do it. There isn't enough information. Consider the two cases of a guy located at the origin facing north and looking upwards at a 45 degree angle, and another guy located at the origin facing north and looking downwards at a 45 degree angle. These guys have the same position, yaw, and "plane below them", but have different forward vectors.

Share this post


Link to post
Share on other sites
You should know your righ vector first before you could get your forward vector. Just do a cross and viola. But as they said, you can't calculate your forward vector unless given more info.

Share this post


Link to post
Share on other sites
what other information would i need? i need to get this guy to follow terrain. I can find the yaw, pitch, and roll of the plane. I have the guys position and yaw. His velocity(which doesnt help as it can be forward and backward). I know I should store his normal from the beginning, but I dont.
So should i go back and store it when I know what his position and orientation is(init), or can i some how figure it out without storing it. If i store it i have to store that same info on hundreds of other objects which i dont need to do/wont use it.
Edit:
dont have other vec for the guy, but im storing the previous pitch yaw and roll as well.

Share this post


Link to post
Share on other sites
On a planar terrain, you could just subtract the objects last postition to your new position to get the forward vector. As for following the terrain, there are different approaches for that.

Share this post


Link to post
Share on other sites
Quote:
Original post by Tang of the Mountain
I have the guys position and yaw.

Err.... so when he looks up or down, what data changes?

Share this post


Link to post
Share on other sites
Quote:
Original post by Tang of the Mountain
I can find the yaw, pitch, and roll of the plane...
Ack :-| Forget about Euler angles - they aren't the right tool for this job. You're on the right track with the rest of your post though, with tracking the character's orientation from frame to frame. You mentioned being concerned about storing that data for hundreds of objects. Unless your available memory is very limited, that really shouldn't be a problem; and if you're really concerned about it, you can always store the orientation as a quaternion instead (or otherwise compress the data).

One consideration is that 'following the terrain' can mean a couple of different things. A humanoid character might always be aligned with the world up axis, and just have the vertical component of his position determined by the terrain. On the other hand, a vehicle might also orient itself to be aligned with the terrain normal. It sounds like it's the latter that you want.

The standard way to do this is to track the orientation from frame to frame, and each frame apply a rotation to align the object's local coordinate system with the normal of the current triangle. Also, you'll want to interpolate to the new orientation; otherwise the object will 'snap' when going over triangle boundaries.

Share this post


Link to post
Share on other sites
so i created a forward facing vector and init it to 1 0 0 cause x is forward facing

on every pass through update
convert yaw to a rotation matrix
mult by forward vec
stick that in forawrd vec

this, seems right, but at the same time, it isnt accounting for the other euler angles

I was going to do this
yaw = phi
X = F
Y = U
Z = R

F' = cos(phi) F + sin(phi) U
U' = cos(phi) U - sin(phi) F
R' = R

but are they the same thing? Am i missing something? will this break the second i gain some pitch or roll? or am I WAAY off base?

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!