|
Post by wallypog on Nov 25, 2015 12:05:38 GMT -5
Hi All: Here is my rotating torus:
dim r# = 0.07 'torus ring radius dim c# = 0.15 'torus tube radius dim rSeg = 64 'number of segments dim cSeg = 64 'number of segments dim texture texture = LoadTexture ("Textures\redGreen.bmp") dim i, j, k dim s#, t#, u#, v#, x#, y#, z#, i# dim PI# = m_pi dim TAU# = 2 * PI# dim angle#
function drawTorus(r#, c#, rSeg, cSeg, texture) glEnable(GL_TEXTURE_2D) glBindTexture(GL_TEXTURE_2D, texture) glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL) for i = 0 to rSeg glBegin(GL_TRIANGLE_STRIP) for j = 0 to cSeg for k = 0 TO 1 s# = (i + k) % rSeg + 0.5 t# = j % (cSeg + 1) x# = (c# + r# * cos(s# * TAU# / rSeg)) * cos(t# * TAU# / cSeg) y# = (c# + r# * cos(s# * TAU# / rSeg)) * sin(t# * TAU# / cSeg) z# = r# * sin(s# * TAU# / rSeg) i# = i * 1.0 'convert to float for real division u# = (i# + k) /rSeg v# = t# /cSeg glTexCoord2d(u#, v#) glVertex3d(2 * x#, 2 * y#, 2 * z#) next next glEnd() next return 0 end function 'main while true glClear(GL_DEPTH_BUFFER_BIT or GL_COLOR_BUFFER_BIT) drawTorus(r#, c#, rSeg, cSeg, texture) glLoadIdentity () glTranslatef(0, 0, -2) glRotatef(angle#, 1, 1, 1) SwapBuffers () sleep(1) angle# = angle# + 5 wend Regards, John Fortier
|
|
|
Post by matthew on Nov 25, 2015 14:03:48 GMT -5
Hi John, could you upload the "redGreen.bmp" texture you've used?
|
|
|
Post by wallypog on Nov 26, 2015 12:25:20 GMT -5
The texture is the same one included with a previous demo "textured torus.gb". For some reason I don't seem able to include an attachment. Dyslexia? I'll try again. redGreen.bmp (183.64 KB)
|
|
|
Post by matthew on Nov 26, 2015 14:02:06 GMT -5
Sorry, I'd got your 'Textured Torus' routine already saved on my computer but I'd placed your new program in a different location which is why the texture wasn't being loaded. :-P
|
|