Heres a cilinder function i made in Blitz 3D, pretty easy to follow I hope
Graphics3D 800,600,32,2
Function Create_Cylinder( radius#, height#, segment )
If segment < 3 Then segment = 3
If segment > 360 Then segment = 360
Local deltaAngle# = 360.0 / Float(segment)
Local i
Local tx1#
Local ty1#
Local ta1#
Local tx2#
Local ty2#
Local ta2#
Local mesh = CreateMesh()
Local surf = CreateSurface(mesh)
Local v1,v2,v3,v4
Local vCt,vCb
Local tv1,tv3
vCb = AddVertex( surf, 0,0,0 )
vCt = AddVertex( surf, 0,height#, 0 )
For i = 0 To segment-1
ta1# = deltaAngle# * Float(i)
tx1# = radius# * Sin( ta1# )
ty1# = radius# * Cos( ta1# )
v1 = AddVertex( surf, tx1#, 0.0, ty1# )
v3 = AddVertex( surf, tx1#, height#, ty1# )
If i = segment - 1
AddTriangle( surf, v1,tv1,v3 )
AddTriangle( surf, tv1,tv3,v3 )
AddTriangle( surf, v1,vCb,tv1 )
AddTriangle( surf, v3,tv3,vCt )
Else
ta2# = deltaAngle# * Float(i + 1)
tx2# = radius# * Sin( ta2# )
ty2# = radius# * Cos( ta2# )
v2 = AddVertex( surf, tx2#, 0.0, ty2# )
v4 = AddVertex( surf, tx2#, height#, ty2# )
AddTriangle( surf, v1,v2,v3 )
AddTriangle( surf, v2,v4,v3 )
AddTriangle( surf, v1,vCb,v2 )
AddTriangle( surf, v3,v4,vCt )
EndIf
If i = 0
tv1 = v1
tv3 = v3
EndIf
Next
UpdateNormals( mesh )
Return mesh
End Function
Global Cylinder = Create_Cylinder( 1, 4, 36 )
ScaleEntity( Cylinder, 10,10,10 )
PositionEntity( CreateCamera(), 0, 0, -70 )
RotateEntity( CreateLight(), 90, 0, 0 )
WireFrame 1
While Not KeyDown(1)
TurnEntity( Cylinder, 0.4, 0.0, 0.1 )
RenderWorld
Flip
Cls
Wend