Sign in to follow this  
CBell

Drawing Circles

Recommended Posts

I'm making a model of the solar system, and for the rings around Saturn I was going to draw a torus and make it long and thin, but those options aren't available in the glutsolidtorus function. Then I thought to just draw a circle around it and place a ring texture I have on that. But there isn't a circle function, so what is the best way to draw one? Or, what would be the best way to put the rings around Saturn?

Share this post


Link to post
Share on other sites
Quote:
Original post by CBell
I'm making a model of the solar system, and for the rings around Saturn I was going to draw a torus and make it long and thin, but those options aren't available in the glutsolidtorus function.

Then I thought to just draw a circle around it and place a ring texture I have on that. But there isn't a circle function, so what is the best way to draw one? Or, what would be the best way to put the rings around Saturn?
A flat ring with a texture rendered to both sides should work fine, I would think. You're right that GLUT does not include a function to render this particular shape, but it's easy enough to generate the mesh data yourself.

Basically, you'll want to generate vertices for two circles of different radii (one for the inner edge of the ring, and one for the outer edge), and then connect them with triangles. If there's any part of this that you're not sure how to do, post back.

Share this post


Link to post
Share on other sites
Yeah, I came across this problem recently. I used Google.

Read the following after searching on Google, please. (If you haven't already.)

Find anything? Yeah, it doesn't look like there's any built-in support. But, I'm lucky: where you'll have to do math, I built a PolarVector class a long time ago so all I have to do is set the radius, set theta, it'll give me a RectVector that I'll offset by where the middle of the circle should be. Then I'll just increment theta and do it again!

...On the other hand, that seems a little harder than http://steinsoft.net/index.php?site=Programming/Code%20Snippets/OpenGL/no5
This is what I suggest, simply because it's simplest. Although, if you want what claims to be efficient...
http://forum.gamedeception.net/showthread.php?t=7810
I don't really know how much more efficient it is. In fact, it LOOKS less so.

I suggest going with the simplicity of the first link, but like the second, having the step not (always) be one. I'd make that an argument, prioritizing not circles that look nice, but letting the programmer decide how nice they should look at any one time.

Although, like the above said, you can always use a texture. It'll probably look nicer and run faster, but the above techniques are good if you're not good with MS Paint (I know I'm not).

EDIT
If you look around on the first site I linked, he shows how to do eclipses as well.

Share this post


Link to post
Share on other sites
Just thought I'd let you guys know that I found out that there is a gluDisk() function that I could use that did exactly what I wanted. But leaning how to draw a circle was good.

Thanks for the help.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this