Jump to content
  • Advertisement
Sign in to follow this  
glSmurf

OpenGL rendering an ellipsoid

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

just wondering if someone could pass me the code to render an ellipsoid with opengl... I just need it for debugging and I realy don't want to put more time into it then necessary. tnx

Share this post


Link to post
Share on other sites
Advertisement

GLUquadricObj* obj = gluNewQuadric();
glScale3f(radiusX, radiusY, radiusZ);
gluSphere(obj, 1.0, 10, 10);
gluDeleteQuadric(obj);


Untested, but it's really simple so it should work.

Share this post


Link to post
Share on other sites
Doesn't OpenGL have some built-in support for rendering spheres? Perhaps you could render a unit sphere, but call glScale() first with the ellipse extents as arguments.

You could also tessellate your own, but that can be a little involved.

Share this post


Link to post
Share on other sites
I'm close to implement ellipsoid rendering for collision detection debugging. I use DirectX so I don't know with OpenGl. Personally I would scale a unit sphere by the ellipsoid radius

Share this post


Link to post
Share on other sites
I've already tried scaling a unit sphere... works fine untill the ellipsoid is rotated.

tnx anyways =/

Share this post


Link to post
Share on other sites
For one thing, you should be able to rotate the unit sphere after you scale it, giving you the ellipsoid you need in any orientation.

Also, I wrote some code a while ago that projects a 3D ellipsoid into a major and minor axis that lie on the projection plane. Then I render a rectangular billboard using the two axes with a spherical glow map texture stretched onto it. Aside from being flat and unshaded, it looks exactly like the ellipsoid it's supposed to represent from any angle. It might be of some use to you. If you're interested, send me a PM or an email.

Share this post


Link to post
Share on other sites
Quote:
I've already tried scaling a unit sphere... works fine untill the ellipsoid is rotated.
As s_p_ said, just rotate the sphere after scaling it:

glTranslate(position.x, position.y, position.z);
glRotate(angle, axis.x, axis.y, axis.z);
glScale3f(radius.x, radius.y, radius.z);
DrawUnitSphere();

With this you should be able to position and orient the ellipsoid in whatever way you want.

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!