Jump to content
  • Advertisement
Sign in to follow this  
Khaine

How to determine if one billboard is in front of another?

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

When using a billboard system, what would be the best way to determine whether one billboard is in front of another from a given viewpoint? I have thought about using raytracing, but to do this i dont know how to find the vertices for each triangle for each billboard. Any ideas/help/suggestions would be appreciated? Khaine

Share this post


Link to post
Share on other sites
Advertisement
Well one way of doing this would be to take the average distance that each vertex of the billboards is away from the user. Then compare one average to another.

It really depends on what you mean by '1 in front of the other'.

What about intersecting billboards, do they matter?

If ur not familiar with the maths then

Let A be the user and B be the billboard and D be the distance

D = sqrt( (Ax - Bx)^2 + (Ay - By)^2 + (Az - Bz)^2 )

I think this is right.

Ace

Share this post


Link to post
Share on other sites
I'll see if I can clarify what im trying to do...

Imagine that you've got a viewport and two billboards, A & B.

We'll say that A is closer to the viewport than B.

What I want to be able to figure out is, when looking at B, is A in the way?

I know how to setup a ray between the viewport and B, and i can use D3DXIntersectTri to see if the ray intersects with a triangle, but how would I get the vertices out of A to test with?

Share this post


Link to post
Share on other sites
What you can do to see if one is COMPLETELY behind another is to test whether rays going from the biewpoint to the four corners of one go through the other billboard.

ace

Share this post


Link to post
Share on other sites
Quote:
Original post by ace_lovegrove
What you can do to see if one is COMPLETELY behind another is to test whether rays going from the biewpoint to the four corners of one go through the other billboard.

ace


Except when the one completely encloses the other.

Isn't this just a simple bounding box check problem?

Share this post


Link to post
Share on other sites
Khaine, I think that the simplest way to determine if a billboard occludes another is to take the vertices of both billboards and manually transform them to screen space. (multiply by world, view & projection matrices) Then you only check that if the two 2D-space bounding boxes intersect. Note that the tranformed vertices most probably create a shape of a diamond or another non-square form.

Share this post


Link to post
Share on other sites
What you want to do is generally referred to as "Occlusion culling" - Finding whether one object occludes another or not. This is a very broad subject, but you specifically want billboards, so it's a lot more simple.

1. Project both billboards to screen space
2. If their projected rectangles intersect, then one occludes the other

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!