Jump to content
  • Advertisement
Sign in to follow this  
Kustaz

Dot Product and Reflex Angles

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

Hi there, Im working on a project which requires me to billboard sprites in 3D (simple, easy and pleasing results), based on the direction the sprite is facing with respect to the viewer. However, using the dot product to find the angle between the players view vector and the sprites view vector, it will not recogise reflex angles (where the angle is greater than 180 degrees), which is very important for me to distinguish between the left and right side of the NPC the sprite represents. Is there a work around for this, or a better way of recognising the difference? Any help is much appreciated. Kustaz.

Share this post


Link to post
Share on other sites
Advertisement
This link here shows how to billboard a textured quad based on the view matrix. That might be a better way of doing it, if you have access to the vertices.

Share this post


Link to post
Share on other sites
Create another vector perpendicular to the camera's view vector, 90 degrees to the right. The sign of the dot product of this vector and the sprite's view vector will allow you to differentiate between sprites that are facing right and sprites that are facing left.

I think for best results, it may be better to use the displacement vector from the camera to the sprite instead of the camera's view vector. The camera's view vector is only correct for sprites directly in front of the camera, unless it's using an isometric projection.

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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!