Visibility question

Started by
2 comments, last by SyncOrSwim 18 years, 8 months ago
Hi i have a model of the earth and an object above the earth, say 30km above a point on the ground of the earth. The earth is an ellipsoid and the object a mesh of about 100 polys. When i rotate the earth the object moves as well, staying anchored above the same point on the surface of the earth. How can i tell when this object goes behind the earth? Many Thanx Tom
Advertisement
I assume you mean 'behind the earth' in relation to a specific viewpoint? One way to test for this would be to intersect a line segment from the viewpoint to the object center with the earth; if it intersects, the object is not visible. This will have some error, depending on the relative size of the object.

For more accuracy, you could require that the segment not only intersect the Earth, but also penetrate by some distance, such as the approximate radius of the object. This will also have some error, but will give false positives rather than false negatives, which is generally better.

If your Earth is a sphere, these tests are pretty easy. If you really need it to be an ellipsoid for some reason, the tests are a little more complex.
ahh cool, i had just came to that conclusion myself last night. But now i am wondering how do i do that? Are there are good sites to look at? it might sound trivial to everyone else, but im not sure how to achieve this.

In a similar vein, you could use occlusion queries on the graphics hardware to determine the relative visibility of one object behind another.

The accuracy would depend on your implementation; specifically the type of bounding volumes (if any) you used.

I've not tried this approach myself, but i'm just going on what I understand about occlusion queries. (mostly from a good article in the first "GPU Gems" series of books covering their use - in this instance for lens flare effects).

I would guess that a ray intersection test might be easier to code, but if anything at least its another option.

Cheers,
Ben

This topic is closed to new replies.

Advertisement