Advertisement

Rendering Torus with line strip adjacency (not triangle)

Started by October 05, 2023 06:12 AM
2 comments, last by cebugdev2 1 year, 2 months ago

Can anyone help me render a torus in OpenGL like this?
The torus will have inner and outer radius, and unlike most of the examples online it will only have a few rings horizontal and vertical,
when viewed horizontally, there will be 4 rings, one inner, outer, top and bottom and all are connected with 4 rings vertically as well.

and it should not be triangulated or shaded but thur use of Line strip and/or GL_LINE_STRIP_ADJACENCY
Most of the samples I found online are triangulated and I cant seem to find the write approach of doing it.

Here is a more clear drawing from wikipedia, In summary I just want to draw the colored lines excluding the solid shapes, the ones in orange, blue, green and red.
Basically I just want to draw the orange, blue, green and red circles only.

My problem is how do I get the positions of these circles correctly that they are inside the parameters of the torus? (given the inner and outer radius, and center position)

Its easy to get the blue circles as it is just the inner and outer radius, but for the orange (top and buttom), the green and the red circles, Im having trouble figuring out the right formula.

cebugdev2 said:
Its easy to get the blue circles as it is just the inner and outer radius, but for the orange (top and buttom), the green and the red circles, Im having trouble figuring out the right formula.

But that's all obvious.

Red circle centers: center +/- local x axis * (inner + outer radius)/2
Green circle centers: same with local y axis
radii of those is (outer - inner) / 2

Yellow circle centers: center +/- local z axis * red/green radius
radius = (inner + outer radius)/2

Advertisement

perfect thanks @joej you are always helpful

This topic is closed to new replies.

Advertisement