开发者

Determining visible area from globe frustum

I'm working with a mapping application (worldwind) and trying to determine the minimum and maximum latitudes and longitudes that are currently displayed. I have access to the frustum开发者_JS百科, but I'm not sure how to account for the fact that the globe can have its heading and/or pitch changed. Any help on this problem would be appreciated.

thanks,

Jeff


Actually the Frustum isn't the most useful thing in this context. What you need to do is reverse the ModelView-Project transform.

If you can retrieve your projection (frustum) and model-view matrices, then you can invert them. If you project a ray from your camera position along projection space, then you can use those inversions to find that ray in world space. From there, you can intersect that ray with your world to find the exact point where that ray hits the globe.

Do this for the four corners of the screen and then calculate your 2D bounding box based upon those intersection coordinates.


What exactly are you trying to calculate ? Corner points of your window or that of your globe. Remember a circle does not have corners (nor does a sphere). Have you seen the minimap tool in worldwind (WorldMapLayer) . It shows the currently visible extent as an overlay in the minimap, this can give you an idea to work out what exactly is being displayed.

Good to see worldwind questions flowing everywhere. We mustn't be doing a good enough job at the forums.


The corner cases (1) of my previous proposal are making the algorithm difficult for you (I've never had to zoom out from the globe and still don't understand why you still don't just use the hemisphere in that case), so here is another method that can work.

Take your projection frustum as a 3D object and intersect it with the globe (as a 3D object). There are a variety CSG algorithms that can give you union, intersection, and difference. Use intersection. This will result in a 3D mesh of the pieces of the globe that intersect with the frustum. The extents of that mesh are the extents of the bounding box. (Project along the major axis of the frustum.)

This is horribly less efficient than my previous proposal. :-)

(1) Pun completely intended.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜