help with cylinder text

BlitzMax Forums/BlitzMax Beginners Area/help with cylinder text

I am trying to create text that spins around in a 3d cylinder pattern. I can seem to figure out the math that is involved. I would appreciate if anybody is interested in helping me figure out the math. or a better way of doing it.

The code follows:
   Strict
' functionject; threeD ROTATING CUBE                   Date; Unknown Date           
'  Author; Joshua Dickerson                          
'  Origin; FidoNet QUIK_BAS Echo 
'  modified for bmax by Jesse Perez           
'===========================================================================
Framework BRL.GLMax2D
AppTitle = "cube"
Graphics 640,480,16
Local array:Tnode[]=texttable("Hello World!")
Local threeDobject:TthreeDobject = New TthreeDobject.create()
threeDobject.nodelist=ListFromArray(array)
While Not KeyDown(KEY_ESCAPE)
  	Cls
	threeDobject.AngleAxisz = (threeDobject.AngleAxisz + 1) Mod 360
  	threeDobject.AngleAxisx = 180'(threeDobject.AngleAxisx +1) Mod 360
	threeDobject.AngleAxisy =0 '(threeDobject.AngleAxisy +1) Mod 360
	threeDobject.draw()
	Flip()
Wend
End 

Type Tnode
	Field threeDx#
	Field threeDy#
	Field threeDz#
	Field color
	Global twoDx#
	Global twoDy#
End Type
	Function setfont:Int(name$=Null,size=8)
		If Name
			If size<8 size = 8
			If size>40 size = 40
			Local font:timagefont =LoadImageFont( name,size)
			If font SetImageFont(font);Return 1 
		EndIf
		Return 0
	EndFunction

	Function texttable:tnode[](text$)
		Local Twidth#=TextWidth(text)
		Local Theight#=TextHeight(text)
		Local tlength=Len(text)
		Local array:tnode[twidth*Theight]
		Local image:timage=CreateImage(Twidth,theight,1,DYNAMICIMAGE)
		Local map:tpixmap
		Local radius#=50.0
		Local circumference# = Pi*radius
		Local fg# = twidth/circumference
		Local sgh# = theight/circumference
		Local ang# = circumference/360.0
		Local sg# = fg/ang
		Cls
		Local c = 0
		DrawText text,0,0
		GrabImage image,0,0
		map = LockImage(image)
		Cls
		For Local y = 0 To PixmapHeight(map)-1
			For Local x=0 To PixmapWidth(map)-1
				Local color = $ff&ReadPixel(map,x,y)
				If  color
					array[c]=New tnode
					Local xd# =(x-twidth/2)*sg
					Local yd# =(y-theight/2)*sg
					array[c].threeDx = (Cos(xd) * Cos((xd)) * radius) 
					array[c].threeDy = (Cos(yd) * Sin((yd)) * radius) 
					array[c].threeDz = -Sin(xd) * radius 
					array[c].color=color
					c=c+1
				EndIf
			Next
		Next
		array=array[..c-1]
		Return array
	EndFunction

Type TthreeDobject
 
	Global D#,Z#
	Global AngleAxisz#, AngleAxisx#, AngleAxisy#, mZ#
	Global sinAngleAxisz#,cosAngleAxisz#, cosAngleAxisx#, sinAngleAxisx#, sinAngleAxisy#, cosAngleAxisy#
	Global nodeList:Tlist

	Function create:TthreeDobject(IsInHardDrive=0,filename:tstream=Null)
		Local nodes
		SetOrigin 320, 240
		SetColor 255,0,0
		Local threeDobject:TthreeDobject = New TthreeDobject
		threeDobject.D# = 400        'View point And rotation values
		threeDobject.mZ# = -100	    'shift from z axis away from viewpoint
		threeDobject.AngleAxisz# = 0 'spin along y axis; angle of z
		threeDobject.AngleAxisx# = 0 'spin along z axiz; angle of x
		threeDobject.AngleAxisy# = 0 'spin along x axis; angle of y
		Return threeDobject
	End Function

	Function Calc3d(point:tnode)
		
		Local Xa# = cosAngleAxisz * point.threeDx - sinAngleAxisz * point.threeDz 
		Local Ya# = cosAngleAxisx * point.threeDy - sinAngleAxisx * Xa
		Local Za# = sinAngleAxisz * point.threeDx + cosAngleAxisz * point.threeDz
		Z = cosAngleAxisy * Za - sinAngleAxisy * Ya + mZ
		point.twoDx = (cosAngleAxisx * Xa + sinAngleAxisx * point.threeDy ) * D / Z; 
		point.twoDy = (sinAngleAxisy * Za + cosAngleAxisy * Ya) * D / Z;

	End Function

	Method Draw()

		sinAngleAxisz = Sin(AngleAxisz)
		cosAngleAxisz = Cos(AngleAxisz)
		sinAngleAxisx = Sin(AngleAxisx)
		cosAngleAxisx = Cos(AngleAxisx)
		sinAngleAxisy = Sin(AngleAxisy)
		cosAngleAxisy = Cos(AngleAxisy)
		For Local node:tnode  = EachIn nodeList
			Calc3d(node)
			If Z < 0 Then Plot node.twoDx,node.twoDy',node.twoDx2,node.twoDy2 'get start and end points before drawing.
		Next
	End Method

End Type


Looks very impressive, where is the issue?

My guess: It isn't his code... :D

I was trying to make the text go around a cylinder format.
the problem is its costing me time to figure out the math. the origina example displays it in a sine which is not what I want. I figured out that I need a sine for the z axis and a cosine for the x axis and to calculate the distance factor for Z.
I have been looking around for possible solutions. there is code and tutiorials out there for three D and I am starting to get the hang of it.
I modified the above example and now it looks more like what I want:
 Strict
' functionject; threeD ROTATING CUBE                   Date; Unknown Date           
'  Author; Joshua Dickerson                          
'  Origin; FidoNet QUIK_BAS Echo 
'  modified for bmax by Jesse Perez           
'===========================================================================
Framework BRL.GLMax2D
AppTitle = "cube"
Graphics 640,480,16
Local array:Tnode[]=texttable("Hello World!")
Local threeDobject:TthreeDobject = New TthreeDobject.create()
threeDobject.nodelist=ListFromArray(array)
While Not KeyDown(KEY_ESCAPE)
  	Cls
	threeDobject.AngleAxisz = (threeDobject.AngleAxisz  -1) Mod 360
  	threeDobject.AngleAxisx = 0'(threeDobject.AngleAxisx +1) Mod 360
	threeDobject.AngleAxisy =0 '(threeDobject.AngleAxisy +1) Mod 360
	threeDobject.draw()
	Flip()
Wend
End 

Type Tnode
	Field threeDx#
	Field threeDy#
	Field threeDz#
	Field color
	Global twoDx#
	Global twoDy#
End Type
	Function setfont:Int(name$=Null,size=8)
		If Name
			If size<8 size = 8
			If size>40 size = 40
			Local font:timagefont =LoadImageFont( name,size)
			If font SetImageFont(font);Return 1 
		EndIf
		Return 0
	EndFunction

	Function texttable:tnode[](text$)
		Local Twidth#=TextWidth(text)
		Local Theight#=TextHeight(text)
		Local tlength=Len(text)
		Local array:tnode[twidth*Theight]
		Local image:timage=CreateImage(Twidth,theight,1,DYNAMICIMAGE)
		Local map:TPixmap
		Local radius#=50.0
		Cls
		Local c = 0
		DrawText text,0,0
		GrabImage image,0,0
		map = LockImage(image)
		Cls
		For Local y = 0 To PixmapHeight(map)-1
			For Local x=0 To PixmapWidth(map)-1
				Local color = $fff&ReadPixel(map,x,y)
				If  color
					Local sg# = x
					array[c]=New tnode
					Local xd# =((x) -(twidth/2))
					Local yd# =(y)
					array[c].threeDx = (Cos(xd) + Cos((xd)) * radius) 
					array[c].threeDy = -(Cos(yd) + Sin((yd)) * radius) 
					array[c].threeDz = xd*.8  
					array[c].color=color
					c=c+1
				EndIf
			Next
		Next
		array=array[..c-1]
		Return array
	EndFunction
              
Type TthreeDobject
 
	Global D#,Z#,tz#
	Global AngleAxisz#, AngleAxisx#, AngleAxisy#, mZ#
	Global sinAngleAxisz#,cosAngleAxisz#, cosAngleAxisx#, sinAngleAxisx#, sinAngleAxisy#, cosAngleAxisy#
	Global nodeList:TList

	Function create:TthreeDobject(IsInHardDrive=0,filename:TStream=Null)
		Local nodes
		SetOrigin 320, 240
		SetColor 255,0,0
		Local threeDobject:TthreeDobject = New TthreeDobject
		threeDobject.D# = 400        'View point And rotation values
		threeDobject.mZ# = -200	    'shift from z axis away from viewpoint
		threeDobject.AngleAxisz# = 0 'spin along y axis; angle of z
		threeDobject.AngleAxisx# = 0 'spin along z axiz; angle of x
		threeDobject.AngleAxisy# = 0 'spin along x axis; angle of y
		Return threeDobject
	End Function

	Function Calc3d(point:tnode)
		
		Local Xa# = cosAngleAxisz * point.threeDx - sinAngleAxisz * point.threeDz 
		Local Ya# = cosAngleAxisx * point.threeDy - sinAngleAxisx * Xa
		Local Za# = sinAngleAxisz * point.threeDx + cosAngleAxisz * point.threeDz
		Z = cosAngleAxisy * Za - sinAngleAxisy * Ya + mZ
		tz=za
		point.twoDx = (cosAngleAxisx * Xa + sinAngleAxisx * point.threeDy ) * D / Z; 
		point.twoDy = (sinAngleAxisy * Za + cosAngleAxisy * Ya) * D / Z;

	End Function

	Method Draw()

		sinAngleAxisz = Sin(AngleAxisz)
		cosAngleAxisz = Cos(AngleAxisz)
		sinAngleAxisx = Sin(AngleAxisx)
		cosAngleAxisx = Cos(AngleAxisx)
		sinAngleAxisy = Sin(AngleAxisy)
		cosAngleAxisy = Cos(AngleAxisy)
		
		For Local node:tnode  = EachIn nodeList
			Calc3d(node)
			If tz > 0 Plot  node.twoDx,node.twoDy',2,2
		Next
	End Method

End Type

What I want now is to put any text length and be flexible enough to display it correcttly. right now if I add more text it's displayed aukwardly.
here is a tutorial that has helped me some what if any body is interested:
http://rel.betterwebber.com/mytutes/3dtutes/chapter1/chapter1.htm
http://rel.betterwebber.com/mytutes/3dtutes/chapter2/chapter2.htm
http://rel.betterwebber.com/mytutes/3dtutes/chapter3/chapter3.htm
http://rel.betterwebber.com/mytutes/3dtutes/chapter4/chapter4.htm