# "Angled" billboards and finding the correct frame

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

## Recommended Posts

Hello Graphics Programming and Theory, I figure you guys should be able to figure this out. For my project DOOM.Net I have multiple billboards throughout the level. Each THING(players, monsters, etc..) has an angle and a position(X and Y, DOOM levels are actually 2D), so I guess you could represent each thing as a 2D vector. Now when the monster moves/rotates or the camera moves/rotates I need to figure out what frame(out of a sprite sheet) to draw. Here's some idea of how the sprite sheet looks and what values each angle has: East is 0 degrees, north is 90, west is 180 and south is 270 This is the default shot. Both the camera and zombie guy there are facing north(90 degrees). In this shot I'm not actually trying to calculate the correct angle, I just render whatever frame the monsters angle equals( in this case 90 / 45 = 2 = North ). I've tried a number of techniques. I tried taking the angle of the line between them, the difference between the zombie's angle and the player, both, but nothing seems it work right. Mabye my formulas are off or mabye I'm just going about it the wrong way. Please help. The sooner this is fixed, the sooner I can add in the other cool monsters [smile].

##### Share on other sites
To get the angle/direction that the player would be viewing the monster in, you'd use the formula:

90 - (Ma - Pa)

Ma is the Monster's Angle, Pa is the angle from the Player to the Monster.

Ma-Pa is the difference between the two, and 90 just acts as an offset, since you're starting at East rather than North.

Keep up the great work with DooM.NET; I'm still avidly/devoutly following your journal. [smile]

##### Share on other sites
Thanks that works pretty well. However shouldn't the camera rotation have something to do with it as well? In DOOM if you stand in one spot ( and the monsters are "asleep" ) and rotate the camera, the billboards change.

##### Share on other sites

90 - (Ma - (Pa + Fa) / 2 )

Essentially just using the mean of the player's facing direction (Fa) and the angle from the player to the monster (Pa). This will allow the player's facing to influence what portion of the animation/billboard s/he sees.

##### Share on other sites
Alright thanks. It doesn't work perfectly like the originals, but it's getting there. I've already started adding the other monsters [smile].

##### Share on other sites
I don't have any better advice to give than what's already been said, but just a random question: whereabouts in Mississauga are you? I live in Port Credit. :)

##### Share on other sites
Quote:
 Original post by ScetAlright thanks. It doesn't work perfectly like the originals, but it's getting there.

Try tweaking it a little; I don't think I'm THAT far off from the original's style. [smile] Try increasing the influence of the playing's facing, over the player->monster direction. The current averaging gives 50%/50% to both values. Perhaps something along the lines of:

A = Pa * 0.25
B = Fa * 0.75

90 - (Ma - (A + B))

##### Share on other sites
Quote:
 Original post by Julian SpillaneI don't have any better advice to give than what's already been said, but just a random question: whereabouts in Mississauga are you? I live in Port Credit. :)

I dislike giving out personal information, so I'll just say I live west of you.

Quote:
 Original post by HopeDaggerA = Pa * 0.25B = Fa * 0.7590 - (Ma - (A + B))

That works almost spot on, expect in to make make it so that doesn't flip out when the camera angle changes from 0 to 359. Shouldn't be too hard to fix. Thanks.

##### Share on other sites
Quote:
 Original post by ScetThat works almost spot on, expect in to make make it so that doesn't flip out when the camera angle changes from 0 to 359. Shouldn't be too hard to fix. Thanks.

Awesome. If anyone asks down the line, I can say that I helped on the DooM.NET project after it makes its first million. [grin]

1. 1
Rutin
19
2. 2
3. 3
JoeJ
15
4. 4
5. 5

• 21
• 19
• 11
• 13
• 17
• ### Forum Statistics

• Total Topics
631697
• Total Posts
3001763
×