View Full Version : How can we draw a partial torus using opengl

Fastian

02-20-2001, 11:27 PM

Hi,

can anyone tell me how to draw a partial torus like partial disc using OpenGL. aux and glut support full torus only. is there any other way? should i use nurbs, etc?? i don't know...

Fastian

02-21-2001, 02:11 AM

aint no one out there that can help me out ..????

Michael Steinberg

02-21-2001, 02:57 AM

You can just use another user clipping plane together with the aux functions

Fastian

02-21-2001, 03:01 AM

actually i'm rather new to clipping.. what is a user clipping plane to aux..?

Michael Steinberg

02-21-2001, 03:15 AM

Use glClipPlane( GLenum pname, const GLdouble *equation )

pname contains the symbolic clipping plane name. 0 <= pname < GL_MAX_CLIP_PLANES

equation holds the four components a,b,c and d for the plane equation.

a*x+b*y+c*z+d = 0

The coefficients are defined in world space and the result takes the current modelview matrix in account.

So visible points are all:

(a b c d)*M^-1 * (x y z w) >= 0

Where the vector (x y z w) is column based.

So place your plane there, with that orientation, where you want the torus to be culled.

Fastian

02-21-2001, 07:16 PM

Thanx man, youve been a lot of help. I appreciate that.

clip planes? huh? what on earth for? <looks perplexed>

draw a diagram of what you want to achieve and you'll see how to do it without messing about with clip planes. (clip planes will work, incidentially, but... it's serious overkill)

anyway, the diagram. you'll have a serious of connected circles. gads, i can't draw it with ascii art. but, just, er, visualise it. a torus is a circle swept about a point, righty?

so you draw a series of quad strips around the circumfrence of each crosssection. that's a pretty poxy descrition, i know. gads.

you haev two loops... one sweeping along the arc and another sweeping in the circle cross-section. each iteration you plot two points: the point in the circle on one partition, and the point in the circle of the NEXT partition. as you sweep through the circle loop, you'll get a quad strip ring... you just need to do this for all the partitions you have in your arc. Simple! nice! =)

cheers

John

Michael Steinberg

02-22-2001, 03:31 AM

The topic starter wanted to use the standard aux torus', so I gave a possibility for it. I for myself would also prefer to create my own torus function.

Just learn the mathematics behind a torus, and you can build a function that generates a torus of any degree.

It's worth knowing how a torus is built, because it may help your future 3D endeavours. A torus is a really simple structure, so it shouldn't be hard to understand how it can be built with OpenGL.

Powered by vBulletin® Version 4.2.5 Copyright © 2018 vBulletin Solutions Inc. All rights reserved.