? Curved surface - overlay a surface on a sphere ?

Given a 3D earth and a vehicle flying overhead I want to draw the ground coverage zone that the vehicle is currently over. I want to represent this by a filled, colored circle.

I sort of want this kind of view:

The above image is not exactly the solution…the colored regions are really 3D cones and not projected on the surface. In my case, I have the latitude/longitude coordinates of the circle on the surface so I can draw the circle representing the boundary but I want to also fill in the circle with some transparent color so it sorts of looks like the image above…does anyone have suggestions?

Effectively I sort of want to do what glutSolidSphere() does but only for a small section of surface, instead of an entire sphere. The worst case solution would be to figure out a triangulator for a curved surface section and draw the triangles each myself but if anyone has a better solution or suggestion, I’ll take it. Thanks.

I am not sure to understand your problem here… is it that you don’t know how to generate yellow or red surfaces and fill them in with a translucent color?

no…I know how to do it, but I need the surfaces to be curved.

Basically imagine taking an ball and you draw a circle on the ball and fill it in with some color. So you’ve basically put a thin film of ink on the surface of the ball…I want to do the same with some polygon (right now just a colored circle for which I have the coordinates of the boundary of the circle. The ball is curved and so if I just drew a normal filled in circle, the filled in part would be inside the ball…ie you wouldn’t see it, so you have to curve it up to be slightly above the surface of the ball.

Does that make sense?

What’s wrong with the cones? They look good to me.

A quick and dirty cheat is to make one poly from the circle vertices you already have. The poly will cut through the earth’s surface, UNLESS you turn off depth buffering before drawing the filled circle. The problem with this approach is that it won’t look right when the circles are on the horizon.

Otherwise you’re going to have to tessellate your original circle (as you mention). It’s not that hard. I’ve done similar things in about 50 lines of code.

no…I know how to do it, but I need the surfaces to be curved.

Ok, so that was what I was asking for. :slight_smile: My question must been badly formulated.

The 1st idea I have is considering a point x on the earth, I assume that x is in the field of view of a satellite if:

|x - satellite_position| <= Rmax

Where Rmax, is the satellite range.

You can express points on the earth in spherical coordinates with the earth center as origin and with a vertical axis toward the satellite. With physicians conventions (theta is colatitude), you have to know the theta_max value from which the point x is out of range:

You can compute theta_max transforming point x spherical coordinates to cartesian coordinates. Then calculate the difference between x and the satellite position and compare with Rmax.
This is easy since you have just one unknown variable: theta_max.

Then you can generate red surface points taking theta values in the range [0 theta_max] and Phi values in the range [0 2Pi] with a custom step for theta and Phi values, depending of how many slices and rings you want.

This is one solution for the “simple” case of a circular projection…I understand it. It requires that I basically do the triangulation (for example, Delaunay Triangulation) of the region (ie slices/rings) and use primitive calls to fill in polygons or triangles as I go…great for a circle case.

In the case of an irregular shapes it gets harder…for example, say I had the boundaries of the countries and I wanted to fill in the boundary of the united states with the color white then this would be a much tougher solution because I would have to use triangulation to figure out the triangles in the region and then I would have to figure out the radius at the triangle vertices so that they would be properly raised above the sphere boundary.

Sigh…I think I’m making this harder than is done in real life…I figure the example I just gave (coloring in a country boundary) has been done by others, I can’t be the only one trying this.

Thanks for all of the help.

If I understand you, you want that the ground coverage area shape fits countries borders?? You are asking to much here and is that useful indeed? Anyway you should explain clearly from the beginning what you want to do, that was not, the idea you exposed in your first post and we would not suggest you solutions that doesn’t answer your real problem!

well it sort of was…I was just trying to be as simplistic as possible. I figured it would be easier to understand if I used a circle for the object and I was hoping the attached image explained better than I could in words.

My ultimate goal is to be able to map a 2D polygon onto a 3D surface. I want to be able to do multiple things with this…first is I want to show the circular ground coverage of a vehicle flying overhead - hence the circle. I would also want to be able to draw a ground station coverage zone that represents what a ground station on the surface can see - given that there are buildings/mountains etc that could obstruct its view - in which case the ground coverage zone would be an irregular circle with cutouts in it and that’s not too much different that the irregular shapes of countries.

In all of these cases I have the coordinates (latitude/longitude) of the boundary - be it the circle boundary or the boundary of some irregular shape. I can draw the boundary that connects these coordinates and I would see the shape but I want to be able to now use a fill inside the region of the boundary. Say a solid or transparent fill - whatever, it doesn’t matter as long as I can fill it.

So the question is how do I fill in this region while making sure that the area is curved so that it touches the surface of the planet and doesn’t cut into it…basically, I need to figure out how to curve the area inside the boundary that I have and then use triangulation to calculate the triangles that make up that curve. This solution seems kind of hard and if I have to do this a lot because the vehicle moves or something changed, it seems like this would be very expensive to do repetitive triangulation and drawing of the surface.

This is supremely easy to do in Java2D - for obvious reasons, but when you go into 3D you have to be able to curve the surface up so that it looks like it is on top of the ground.

Thanks for taking the time to decipher my messages. :slight_smile:

Clearly one option is to draw on the texture that I wrap around the earth, but I have moving vehicles and that would require me changing the texture each time the vehicle moves and that seems very costly do keep doing.

It seems very complicated to realize this effect building the shape geometry… Maybe it is not applicable in your case but, I suggest you to use an an algorithm similar to shadow mapping combined with a shader that renders every objects on earth and earth itself in the coverage area.
The idea is, basing on the shadow map, to see what earth/object rendered fragment are visible or not from the satellite. If you are familiar with shadow mapping, you should see what I mean. This way, if you detect that some part of the earth or objects on this one is inside coverage area, you can blend its texture with the area color inside a fragment shader.

I’m not familiar with shadow mapping, but I think that is a possible direction…thanks for the idea.

As I mentioned before the case of a circular region on the earth’s surface can be done with about 50 lines of codes. You have to generate vertices, tris, and quads internal to the circle you start with. Put all vertices exactly on the earth’s surface. This will result in polys which cut through the earth’s surface, which is taken care off by turning off the Z-buffer, drawing the polys, then turning it on again to draw orbits, satellites, etc. Generate your circular region with its center where the X axis intersects the earth’s surface. Then use glRotate’s to position the region at the correct lat and lon. You’ll find it to be easier than it sounds. This is how I generated the circular boundaries and filled in regions in the included figure (the 2 northern-most circles are filled in with light, white, transparent, polys).


Nice MaxH, that’s is exactly what I need to do then…thanks for the info. I never thought about Z-buffer stuff…I’m pretty sure that’s because I don’t know that much OpenGL. I’ll see what I can come up with. Very interesting solution.

This will definitely solve one of my needs, after that I just might need a little more code to make irregular regions work the same way.

btw, for the simple case of a filled in circle, I should just be able to use a gluDisk(), right? I really don’t need to create the tris/quads/etc since gluDisk() will do it for me.

I’m going to try this now. thanks.

One question…how do I prevent the object from being seen when I rotate the earth away from the view…say I have a disk over the united states, but I rotate the earth and the US is behind and I’m looking at China…as it stands,I can still see the disk in the scene and through the earth. Do I need to enable back face culling?

It should work to some extent. Not sure if it will look right when a circular region is on the horizon. But it’s worth a try.

Yes. Back face culling. Is gluDisk working well enough for your purposes?

Sort of…I probably need to figure out the order of drawing or maybe I’m seeing that horizon issue you just mentioned.

See the following 3 pics…the solution is crude right now:

This first image is a direct view of the “disk” using gluDisk()

This second image is when I rotate my view and are almost seeing the disk edge on…I don’t see the earth tip well (the part “above” the disk) well…it seems a bit transparent but that could be some issue with a blending flag…not sure yet.

This third image is the earth rotated almost 180 degrees…so the disk is on the other side but it is being seen. Again, I might need to mess with my culling/blending flags more, etc. I

Where are the screenshots?
You mean that with back face culling enabled, the disc is visible when looking in front of and behind it? You must have been messed up something while setting face culling…
Try to simplify your code, to focus only on the rendering of this disc, you will probably find the solution.

dletozeun, You don’t see the images in my post? hmm…I see them, weird.

Here were the direct links:

I think I probably did mess up the face culling…I need to dig in a bit more because I have other 3D shapes for which I wrote special classes and I’m reusing the disk class for my current test. I’m afraid I may have set some blending option that is causing the issue.

Thanks for all of the help…this is a real cool solution.

MaxH, I sent you a PM because I was curious about how you did the text, etc…if you get a chance I would appreciate any info. Thanks again.