English
Source / code snippets

Torus / Donut / ring in OpenGL

 

Sven
Bader
from one this uralten Examples of opengl.org have I something to Profan Translated and it additional yet Texturkoordinaten missed - there were it with so one complex Objekt sure several Approaches.

Download

in the Contrast to the internen OpenGL Objects, ought to the Torus in each drop before me StartList/Endlist stored and DrawList abgerufen go.

Similar How with the bullet (Sphere) can The Segmente in two Dimensionen dial, additional can the inside- and Außenradius indicated go.



to that better understanding, a korrekte Textur must vaguely so aufgebaut his



here only The function self:
Proc Torus

    Parameters majorRadius!, minorRadius!, numMajor%, numMinor%
    Declare  majorStep!, minorStep!
    Declare a0!,a1!,x0!,y0!,x1!,y1!,b!,c!,r!,z!,loop2&
    majorStep! = 2.0*Pi() / numMajor%
    minorStep! = 2.0*Pi() / numMinor%

    WhileLoop 0, numMajor% - 1

        a0! = &loop  * majorStep!
        a1! = a0! + majorStep!
        x0! =  cos(a0!)
        y0! =  sin(a0!)
        x1! =  cos(a1!)
        y1! =  sin(a1!)
        loop2& = &loop
        oGL("glBegin", ~GL_TRIANGLE_STRIP)

        WhileLoop 0, numMinor%

            b! = &loop * minorStep!
            c! = cos(b!)
            r! = minorRadius! * c! + majorRadius!
            z! = minorRadius! *  sin(b!)
            oGL("glNormal3f", x0!*c!, y0!*c!, z!/minorRadius!)
            oGL("glTexCoord2f", loop2& / numMajor%, &loop /  numMinor%)
            oGL("glVertex3f", x0!*r!, y0!*r!, z!)
            oGL("glNormal3f", x1!*c!, y1!*c!, z!/minorRadius!)
            oGL("glTexCoord2f",  (loop2& + 1) /  numMajor%,  &loop / numMinor%)
            oGL("glVertex3f", x1!*r!, y1!*r!, z!)

        EndWhile

        oGL("glEnd")

    EndWhile

Endproc


58 kB
Bezeichnung:Donut
Hochgeladen:08/12/21
Downloadcounter58
Download
4 kB
Bezeichnung:Komplettes Listing
Hochgeladen:08/12/21
Downloadcounter74
Download
136 kB
Bezeichnung:Donut
Hochgeladen:08/12/21
Downloadcounter63
Download
 
08/12/21  
 



Zum Quelltext


Topictitle, max. 100 characters.
 

Systemprofile:

no Systemprofil laid out. [anlegen]

XProfan:

 Posting  Font  Smilies  ▼ 

Please register circa a Posting To verfassen.
 

Topic-Options

1.561 Views

Untitledvor 0 min.
Sven Bader12/22/22
Ernst05/29/22
p.specht11/18/21
RudiB.11/18/21
More...

Themeninformationen

this Topic has 1 subscriber:

Sven Bader (1x)


Admins  |  AGB  |  Applications  |  Authors  |  Chat  |  Privacy Policy  |  Download  |  Entrance  |  Help  |  Merchantportal  |  Imprint  |  Mart  |  Interfaces  |  SDK  |  Services  |  Games  |  Search  |  Support

One proposition all XProfan, The there's!


My XProfan
Private Messages
Own Storage Forum
Topics-Remember-List
Own Posts
Own Topics
Clipboard
Log off
 Deutsch English Français Español Italia
Translations

Privacy Policy


we use Cookies only as Session-Cookies because of the technical necessity and with us there no Cookies of Drittanbietern.

If you here on our Website click or navigate, stimmst You ours registration of Information in our Cookies on XProfan.Net To.

further Information To our Cookies and moreover, How You The control above keep, find You in ours nachfolgenden Datenschutzerklärung.


all rightDatenschutzerklärung
i want none Cookie