#### Archived

This topic is now archived and is closed to further replies.

# Using vectors to tell billboard sprite

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

## Recommended Posts

Well, I am making a system much like Xenogears or Doom, in which you can look at a sprite from different angles, and, depending on it, the sprite texture will change. For instance, If you look at the character, and he''s facing the viewer, the sprite that will be selected wil be the front facing sprite. To do this, i have made some vectors: Camara.m_vPosition = position of cam Camara.m_vView = viewing vector of cam Camara.m_vUp = World Up Vector(0,1,0) Character1.m_vPosition = position of character Character1.m_vView = viewing vector of char So, having this vectors(im not using the world up vector), i want to calculate an angle between the cam''s position relative to the sprite, and the character''s view vector.... i have rad a lot, and all seems to point to using the dot product... but.. its not really workin... can any1 help me? Here''s the main formula source.
        TVector3 vDist1 = Normalize(Camara.m_vPosition - Character1.m_vPosition);
TVector3 vDist2 = Normalize(Character1.m_vView);// - Character1.m_vPosition);

vDist1.y = vDist2.y = 0;
float angle = acos(DotProduct(vDist1,vDist2)*M_PI/180)*180/M_PI;


##### Share on other sites
first thing i notice: shouldnt you set y to 0 before you normalize? also acos should only return results between 0-180. and what about that rad/deg back and forth? acos will return rad, you convert that to deg and thats it. why on earth would you want to convert the cos, which has nothing to do with rad or deg?

how is it not working? all i can tell from the code is that you seem to already went through some wild trial and error.

##### Share on other sites
Don''t double post. You already have lots of good replies in the Math & Physics forum. Thank you.

Sander Maréchal

##### Share on other sites

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

This topic is now closed to further replies.

1. 1
Rutin
26
2. 2
3. 3
4. 4
5. 5

• 9
• 11
• 10
• 13
• 20
• ### Forum Statistics

• Total Topics
632948
• Total Posts
3009391
• ### Who's Online (See full list)

There are no registered users currently online

×