|
Post by wallypog on Aug 29, 2015 16:40:18 GMT -5
hi all: here is thecode: 'from OpenGL torus with texture mapping and normals 'stripped down to bare minimum to run
dim r# = 0.07 'torus ring radius dim c# = 0.15 'torus tube radius dim rSeg = 64 '16 'number of segments dim cSeg = 64 '8 'number of segments dim texture texture = LoadMipMapTexture ("Textures\redGreen.bmp") dim i, j, k dim s#, t#, u#, v#, x#, y#, z#, i# dim PI# = m_pi dim TAU# = 2 * PI# function drawTorus(r#, c#, rSeg, cSeg, texture) glEnable(GL_TEXTURE_2D) ' Show chessbrd 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 glTranslatef(0,0,-1.5) DrawTorus(r#, c#, rSeg, cSeg, texture) swapbuffers() end
next step is to animate it. regards John
|
|
|
Post by PeterMaria on Aug 30, 2015 6:09:55 GMT -5
Hello,
where's the texture ?
|
|
|
Post by wallypog on Aug 30, 2015 10:08:18 GMT -5
oops! coming up. John redGreen.bmp
|
|
|
Post by wallypog on Aug 30, 2015 13:52:50 GMT -5
|
|
|
Post by PeterMaria on Aug 30, 2015 15:10:14 GMT -5
Thanks!
|
|
|
Post by matthew on Aug 31, 2015 14:38:49 GMT -5
At last, we can finally see what you've been working on. :-)
|
|