Jump to content
  • Advertisement
Sign in to follow this  
Relfos

Help with Eye Movement

This topic is 3800 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

In my game I'm trying to animate the character eyes, similar to what happens in Zelda:Wind Waker. Basically, I assign a "Target" point, and the character should move their eyes in that point direction, unless the point is not visible (behind their head, for example). My technique consists of rendering first opaque white eyes, and the calculate the texture coords displacement to render the iris/pupils. The calculations I'm currently doing are those, where Source is a point somewhere between the character eyes, Direction is a normal Function GetEyeToTarget(Target, Source, Direction:LVector):LVector; Begin // Calculate direction between source and target Result:=VectorSubtract(Target, Source); Result:=VectorNormalize(Result); // Check if target is not visible If VectorDot(Result, Direction)<0 Then Begin Result.X:=0; Result.Y:=0; End Else Begin // Scale the texture coords offset Result:=VectorScale(Result, 0.075); End; End; However, this function doesnt work as it should, half of the time. Sometimes the character looks where it should, sometimes look in the opposite direction it should, like in this image. The blue arrow is the eye "Direction" vector, and the red one is the calculated normal between "Source" and "Target", properly rescaled. I think the problem is that I only use the X and Y coords of the displacement vector, since I add it to the texture Coords UV vector. So, I'm discard the Z value of the direction, and I'm not too good at math, how can I fix this?

Share this post


Link to post
Share on other sites
Advertisement
I dont know if I understand your method correctly, but I think you need to rotate target vector to your pupil space, where x,y are same as u,v and z is a direction character is facing. Thus if you happen to not to use scale, rotate direction vector with inverse of your character rotation.

Share this post


Link to post
Share on other sites
Ok, I changed it.
Now I calculate the direction vector from the eye Position, and the target Position, and normalize it.
Then I rotate it by the inverse transform of the object.

It works better now, but the X result is reversed for some input positions, almost half of time actually...

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!