Post by GuppyB on Jul 9, 2004 22:06:02 GMT -5
Completing our whirlwind primitive series before we move onto something else is the torus, which actually was tricky, had to search the net for the equation.
Sorry if some of these aren't texture mapped, I may (or may not) get around to doing it. In any event the cylinder should be easy to texture map.
I'm babbling... anyways...
...G
Sorry if some of these aren't texture mapped, I may (or may not) get around to doing it. In any event the cylinder should be easy to texture map.
I'm babbling... anyways...
...G
dim xrot#, yrot#, zrot#
dim torusrad# , toruscentdist# , raddist#
dim i,j
dim cylinder_shade#
dim OldTick, CurrentTick , TimeTick , Frames , FramesSecond#
glEnable (GL_CULL_FACE)
TextMode (TEXT_OVERLAID)
OldTick = TickCount ()
while true
gosub FPSroutine
glClear(GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT)
glLoadIdentity()
glTranslatef(0.0,0.0,-7.0)
glRotatef(xrot#,1.0,0.0,0.0)
glRotatef(yrot#,0.0,1.0,0.0)
glRotatef(zrot#,0.0,0.0,1.0)
toruscentdist# = 2.5 :raddist# = 1.0
gosub drawTorus
DrawText ()
SwapBuffers ()
xrot# = xrot# + 0.1
yrot# = yrot# + 0.2
zrot# = zrot# + 0.05
wend
'********************Torus routine****************************
drawTorus:
glColor3f(1.0,1.0,1.0)
For j = 1 to 18
glbegin (GL_QUAD_STRIP)
for i = 0 to 18
cylinder_shade# = abs (0.09 * (9-j))
glColor3f(cylinder_shade#, cylinder_shade#, cylinder_shade#)
glVertex3f ((toruscentdist# + (raddist# * cosd(j*20))) * cosd(i*20), (toruscentdist# + (raddist# * cosd(j*20))) * sind (i*20), raddist# * sind(j*20))
cylinder_shade# = abs (0.09 * (9-(j-1)))
glColor3f(cylinder_shade#, cylinder_shade#, cylinder_shade#)
glVertex3f ((toruscentdist# + (raddist# * cosd(j*20-20))) * cosd(i*20), (toruscentdist# + (raddist# * cosd(j*20-20))) * sind (i*20), raddist# * sind(j*20-20))
next
glend ()
next
return
'*******************FPS routine****************************
FPSroutine:
CurrentTick = TickCount()
TimeTick = CurrentTick - OldTick
if TimeTick >= 1000 then FramesSecond# = Frames * (TimeTick/1000) : Locate 0,0: Print FramesSecond# + " ": Frames = 0: OldTick = CurrentTick: endif
Frames = Frames + 1
Return