Jump to content
  • Advertisement
Sign in to follow this  
zacaj

OpenGL Billboard and multi-perspective sprite algorithm

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

I'm working on a DOOM-esque game in opengl for 7dfps and I need to make the billboarded pickups and enemies.  Is there somewhere which documents the 'correct' way to rotate the quads and to choose which sprite of the enemy to show?  If not, can someone tell me if there's anything wrong with the algorithms I've come up with?

 

For billboards:

I have made the billboard perpendicular to the player's view angle.  I also tried making it perpendicular to a line pointing at the player's position, but it looked worse.  

 

For enemies:

radiansToSide=PI*2/8  (8 is the number of sprites I have for enemy)

angle=atan2(enemy.y-player.y,enemy.x-player.x)

angle+=radiansToside/2   

angle/=PI*2

angle*=8

angle=floor(angle)

//angle is now an int 0-7

Share this post


Link to post
Share on other sites
Advertisement

Close but you are not taking into account the direction the enemy is facing.  You will need to transform the players position into the enemy's local coordinate system and then apply your algorithm.

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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!