Page 1 of 3

Polygons to the world's end

Posted: Thu Jan 17, 2013 5:36 pm
by Michael Vogel
I want to draw an overview map of the world showing some points of interest etc. My first approach was to make a grid model which was already some work for me, but it works now (see below).
but now I have some problems to get a better picture of the world: I'd like to remove all hidden points and colorize the visible earth's landmass by using polygons...
...and these things are tricky!

Here's the starting code, my little rotating world (use 'x' and 'y' for that):

Code: Select all

Procedure Init()

	; My little World – (c) 2013 by Michael Vogel

	#Size=2*2*2*2*2*2*2*2*2
	#Dots=(2*2+3*3*11)*3*3
	#InvisibleFlag=5*5*5*5*5
	#Shapes=7*7

	Global RotX=0
	Global RotY=0
	Global Invisible

	Structure DotType
		x.i
		y.i
	EndStructure
	Structure ShapeType
		len.i
		start.i
	EndStructure

	Global Dim Dots.DotType(#Dots)
	Global Dim Dots3D.DotType(#Dots)
	Global Dim Shapes.ShapeType(#Shapes)

	count=0
	For i=0 To #Shapes
		Shapes(i)\start=count
		Read.a Shapes(i)\len

		For j=1 To Shapes(i)\len
			Read.a Dots(count)\x
			Read.a Dots(count)\y
			Dots(count)\x*#Size>>8
			Dots(count)\y*#Size>>8
			count+1
		Next j
	Next i

	DataSection
		Data.a $DC,$FD,$24,$FF,$25,$FE,$27,$FC,$28,$FA,$29,$F8,$2A,$F6,$2B,$F4
		Data.a $2C,$F4,$30,$F2,$33,$EF,$36,$F2,$2C,$F5,$28,$F2,$2A,$F0,$29,$EE
		Data.a $2C,$EA,$2B,$E6,$2C,$E1,$31,$E2,$33,$E4,$34,$E4,$38,$E2,$3F,$DE
		Data.a $42,$DB,$48,$DB,$4E,$DA,$4D,$D9,$4A,$D8,$47,$D6,$47,$D6,$4B,$D5
		Data.a $4E,$D7,$54,$D6,$57,$D5,$5B,$D4,$5E,$D1,$60,$D0,$61,$CD,$62,$CD
		Data.a $69,$CE,$70,$CB,$73,$C9,$6E,$C7,$73,$CA,$7E,$C7,$75,$C5,$69,$C3
		Data.a $66,$C0,$60,$BF,$61,$B9,$6A,$B9,$71,$B5,$6E,$B4,$67,$B4,$61,$B2
		Data.a $62,$B0,$5E,$AD,$5C,$A8,$5A,$A3,$55,$A2,$58,$A5,$5B,$A8,$5C,$AA
		Data.a $5F,$A9,$65,$A5,$6A,$A0,$6D,$9E,$6A,$9D,$65,$9C,$60,$9A,$5A,$98
		Data.a $58,$97,$54,$99,$50,$9A,$4C,$96,$4C,$94,$4B,$93,$48,$95,$46,$99
		Data.a $45,$9C,$42,$9B,$3D,$99,$3E,$98,$3F,$99,$40,$98,$3F,$96,$3E,$94
		Data.a $41,$94,$46,$91,$47,$90,$49,$8F,$48,$8C,$43,$8A,$3F,$8A,$42,$8C
		Data.a $45,$8C,$49,$8B,$46,$87,$41,$84,$42,$81,$46,$7E,$4C,$7A,$4A,$7A
		Data.a $44,$7F,$42,$7E,$3C,$7E,$3B,$81,$39,$83,$36,$84,$34,$86,$33,$86
		Data.a $2F,$88,$30,$87,$32,$89,$33,$8C,$32,$8F,$31,$8F,$2E,$91,$2D,$92
		Data.a $2B,$95,$2B,$92,$2A,$90,$2A,$8F,$27,$92,$23,$90,$22,$8F,$24,$8D
		Data.a $26,$8C,$28,$8D,$2A,$8D,$2C,$8C,$2D,$89,$31,$88,$2D,$87,$2B,$85
		Data.a $2D,$84,$2B,$84,$2A,$85,$29,$84,$28,$84,$27,$85,$26,$87,$25,$89
		Data.a $23,$89,$21,$8B,$20,$8C,$1F,$8D,$1D,$8E,$1D,$90,$1C,$92,$1B,$93
		Data.a $1C,$94,$1C,$97,$1D,$9B,$1F,$9D,$22,$98,$21,$99,$24,$9A,$24,$9C
		Data.a $23,$9F,$22,$A1,$1F,$A2,$20,$A6,$1E,$A7,$1F,$AB,$1E,$AE,$1D,$B0
		Data.a $1D,$B0,$1A,$B4,$19,$B4,$1D,$B3,$21,$B4,$21,$B6,$1E,$B7,$20,$B5
		Data.a $1D,$B5,$19,$B7,$1B,$B7,$19,$BB,$1B,$BC,$1A,$B9,$18,$BB,$17,$BD
		Data.a $16,$BF,$15,$C1,$14,$C2,$14,$C3,$14,$C4,$14,$C8,$13,$C9,$12,$CB
		Data.a $12,$CC,$13,$CD,$13,$CF,$13,$D1,$14,$D1,$15,$CF,$16,$CC,$18,$CE
		Data.a $17,$CF,$17,$D1,$17,$D4,$18,$D8,$18,$DA,$17,$DC,$18,$DC,$1A,$DE
		Data.a $1B,$E1,$1A,$E3,$1A,$E6,$19,$E8,$19,$E7,$1A,$EB,$1A,$EC,$1B,$F1
		Data.a $1B,$F4,$1D,$F7,$1D,$F9,$1D,$FF,$1D,$D5,$0A,$27,$0A,$29,$0B,$2B
		Data.a $0D,$2A,$0D,$2C,$0F,$2C,$10,$2E,$0E,$31,$0C,$32,$0D,$31,$0F,$30
		Data.a $11,$2F,$12,$2D,$13,$2B,$15,$28,$14,$2A,$14,$2C,$16,$2A,$17,$29
		Data.a $18,$2A,$1A,$2B,$1D,$2B,$1E,$2B,$1F,$2D,$20,$2D,$21,$2D,$21,$2E
		Data.a $22,$2F,$22,$31,$23,$31,$23,$32,$24,$34,$25,$36,$25,$37,$27,$38
		Data.a $28,$39,$29,$3A,$29,$3C,$27,$3C,$28,$3E,$28,$44,$29,$4A,$2A,$4D
		Data.a $2B,$4F,$2D,$53,$2F,$57,$2F,$5A,$31,$5E,$31,$5C,$30,$58,$2E,$53
		Data.a $30,$55,$31,$59,$33,$5C,$35,$61,$36,$65,$39,$68,$3C,$6A,$41,$6D
		Data.a $43,$72,$46,$75,$49,$77,$48,$7D,$47,$84,$46,$88,$49,$90,$4C,$97
		Data.a $4E,$A1,$4D,$A9,$4D,$B2,$4C,$B9,$4C,$BC,$4C,$C0,$4C,$C2,$4A,$C3
		Data.a $4B,$C4,$4B,$C7,$4C,$C9,$4D,$CB,$4E,$CB,$4F,$C7,$51,$C3,$52,$BD
		Data.a $52,$BA,$56,$B7,$57,$B1,$5B,$AF,$5D,$A7,$60,$A1,$63,$9F,$64,$96
		Data.a $66,$8E,$63,$84,$60,$82,$5D,$83,$5B,$81,$5A,$79,$56,$76,$54,$72
		Data.a $53,$71,$4F,$70,$4D,$73,$4D,$6F,$49,$74,$46,$73,$44,$6A,$41,$68
		Data.a $42,$62,$3E,$66,$3B,$62,$3A,$5D,$3B,$5A,$3B,$58,$3C,$57,$3D,$56
		Data.a $40,$56,$41,$55,$45,$56,$46,$5C,$46,$54,$48,$50,$4A,$4E,$4A,$4C
		Data.a $4A,$4A,$4A,$48,$4A,$4A,$4A,$48,$4B,$46,$4E,$45,$4E,$44,$4F,$42
		Data.a $50,$40,$53,$40,$52,$41,$54,$3F,$52,$3D,$50,$3A,$4F,$3B,$54,$38
		Data.a $58,$36,$57,$34,$56,$33,$56,$32,$54,$30,$54,$2E,$53,$2C,$52,$2A
		Data.a $50,$2D,$4E,$2C,$4E,$2B,$4C,$29,$4B,$28,$49,$27,$49,$2A,$48,$2C
		Data.a $4A,$30,$48,$34,$48,$37,$46,$36,$45,$31,$41,$30,$3E,$2E,$3D,$2B
		Data.a $3E,$28,$3F,$26,$3F,$25,$41,$25,$40,$22,$42,$21,$45,$22,$45,$1F
		Data.a $44,$1D,$43,$1E,$41,$1F,$3F,$1D,$3E,$1C,$3D,$1A,$3B,$1B,$3C,$1D
		Data.a $3D,$1E,$3C,$20,$3A,$1F,$37,$1F,$34,$1E,$34,$1F,$33,$20,$32,$20
		Data.a $30,$20,$2E,$1E,$2B,$1D,$28,$1D,$27,$1D,$25,$1C,$23,$1D,$22,$1D
		Data.a $20,$1E,$1D,$1D,$1A,$1C,$16,$1C,$13,$1B,$11,$1B,$0F,$1B,$0E,$1C
		Data.a $0C,$1D,$09,$1F,$0C,$21,$0E,$21,$0E,$22,$0C,$21,$09,$22,$0B,$24
		Data.a $0D,$24,$0C,$26,$42,$6D,$1E,$6F,$1D,$70,$1C,$6C,$1C,$6F,$1C,$70
		Data.a $1A,$6E,$19,$6F,$17,$70,$16,$71,$15,$71,$14,$71,$13,$72,$12,$71
		Data.a $11,$72,$0F,$71,$0E,$71,$0D,$76,$0C,$73,$0C,$6F,$0D,$70,$0B,$6A
		Data.a $0C,$6D,$0B,$6F,$0A,$6A,$0A,$68,$0A,$6A,$09,$65,$09,$65,$0A,$60
		Data.a $0A,$62,$0A,$61,$0B,$5E,$0B,$5C,$0C,$58,$0B,$57,$0C,$54,$0C,$51
		Data.a $0E,$52,$0E,$50,$0F,$4C,$11,$4F,$12,$4F,$13,$53,$14,$57,$15,$59
		Data.a $17,$59,$1A,$5C,$1C,$5C,$1D,$5C,$1F,$5A,$21,$5B,$24,$5C,$26,$5D
		Data.a $28,$5E,$29,$5F,$29,$60,$2B,$62,$29,$62,$27,$63,$25,$63,$23,$65
		Data.a $22,$66,$22,$68,$21,$69,$1F,$6A,$1F,$31,$46,$0E,$47,$0D,$4A,$0D
		Data.a $48,$0C,$47,$0D,$45,$0E,$45,$0D,$43,$0D,$44,$0D,$43,$0D,$41,$0D
		Data.a $40,$0D,$40,$0C,$43,$0B,$45,$0B,$46,$0B,$48,$0A,$4B,$0A,$50,$0A
		Data.a $52,$0A,$54,$0B,$50,$0C,$4F,$0C,$52,$0C,$4E,$0E,$4C,$0F,$49,$0F
		Data.a $4B,$0F,$49,$10,$4A,$10,$49,$11,$46,$12,$47,$14,$44,$14,$41,$13
		Data.a $42,$12,$41,$12,$43,$12,$45,$11,$43,$12,$44,$11,$44,$10,$42,$11
		Data.a $42,$10,$45,$10,$44,$0F,$43,$0E,$46,$0F,$46,$0E,$25,$8E,$52,$8A
		Data.a $52,$88,$4E,$85,$4B,$81,$4C,$7C,$4D,$79,$56,$74,$60,$74,$69,$75
		Data.a $6F,$76,$73,$79,$77,$80,$78,$84,$79,$87,$7B,$86,$81,$89,$8A,$89
		Data.a $93,$89,$9B,$8A,$A2,$8C,$AA,$8D,$B1,$91,$B1,$96,$AA,$99,$A3,$9A
		Data.a $9B,$9D,$95,$9C,$8E,$9C,$86,$A0,$7D,$A4,$73,$A1,$71,$9E,$6C,$9B
		Data.a $65,$99,$5C,$97,$54,$93,$53,$1A,$E5,$96,$E1,$96,$E1,$92,$DF,$91
		Data.a $DE,$91,$DC,$96,$DA,$94,$D8,$97,$D7,$9A,$D2,$9E,$D1,$A2,$D1,$A6
		Data.a $D2,$B0,$D6,$B0,$DD,$AD,$E0,$B1,$E2,$B0,$E3,$B2,$E7,$B6,$E9,$B7
		Data.a $EB,$B2,$ED,$AB,$EC,$A3,$EA,$9E,$E8,$99,$E6,$91,$17,$51,$26,$52
		Data.a $25,$50,$23,$52,$23,$54,$22,$51,$1F,$51,$1D,$4F,$1C,$4C,$1A,$4A
		Data.a $19,$47,$19,$44,$18,$44,$1B,$43,$18,$40,$1A,$43,$1C,$48,$1D,$4B
		Data.a $1E,$4B,$22,$49,$25,$4C,$25,$4E,$27,$51,$27,$0D,$90,$0E,$91,$0E
		Data.a $92,$0E,$93,$0E,$92,$0F,$91,$0F,$90,$0F,$8F,$0F,$90,$0F,$8E,$0F
		Data.a $8D,$0E,$8E,$0E,$8F,$0E,$10,$42,$0F,$43,$0F,$41,$10,$40,$10,$3E
		Data.a $11,$3E,$10,$3F,$0F,$3E,$0F,$3C,$0F,$3C,$0E,$3D,$0E,$3C,$0E,$3D
		Data.a $0D,$3F,$0D,$41,$0E,$42,$0E,$0F,$8D,$0F,$8E,$0F,$8E,$10,$8D,$12
		Data.a $8C,$13,$8A,$12,$8B,$12,$8B,$11,$8C,$10,$8A,$10,$89,$10,$88,$0F
		Data.a $89,$0F,$8A,$0F,$8C,$10,$10,$38,$1D,$37,$1D,$36,$1E,$33,$1E,$2F
		Data.a $1E,$2E,$1C,$2E,$1A,$2C,$1A,$2F,$18,$30,$18,$31,$19,$32,$18,$33
		Data.a $19,$34,$18,$36,$1A,$38,$1C,$0C,$7E,$38,$81,$37,$80,$34,$7E,$30
		Data.a $7D,$2E,$7C,$2D,$7C,$2F,$7C,$31,$7D,$30,$7D,$32,$7E,$34,$7D,$37
		Data.a $0A,$33,$14,$32,$13,$33,$14,$34,$15,$31,$16,$31,$15,$2F,$15,$2E
		Data.a $14,$2D,$14,$2E,$14,$0A,$AC,$13,$AF,$13,$B0,$14,$AB,$15,$A9,$16
		Data.a $A9,$17,$A7,$18,$A7,$17,$A8,$15,$AA,$14,$09,$E6,$85,$E2,$82,$DF
		Data.a $81,$DF,$84,$E0,$86,$E3,$8A,$E5,$8D,$E8,$8B,$EB,$8E,$09,$CF,$7D
		Data.a $D1,$7A,$D3,$77,$D4,$78,$D4,$7A,$D4,$7F,$D2,$85,$D0,$85,$CE,$81
		Data.a $07,$A2,$0E,$A3,$0E,$A4,$0E,$A4,$0D,$A3,$0D,$A2,$0D,$A2,$0E,$08
		Data.a $70,$24,$70,$23,$6F,$23,$70,$22,$71,$23,$73,$22,$75,$22,$75,$24
		Data.a $07,$2A,$21,$28,$22,$29,$23,$2A,$23,$2B,$23,$2C,$22,$2B,$22,$07
		Data.a $39,$14,$37,$14,$37,$15,$39,$15,$3A,$15,$3B,$14,$39,$13,$08,$41
		Data.a $15,$44,$15,$45,$14,$47,$15,$44,$16,$41,$16,$3F,$16,$3D,$14,$07
		Data.a $46,$3F,$44,$3E,$42,$40,$42,$45,$43,$40,$44,$42,$46,$40,$07,$FA
		Data.a $BA,$FC,$BB,$FB,$BD,$FA,$C0,$F8,$C2,$F7,$C1,$F8,$BF,$07,$2B,$19
		Data.a $2D,$17,$2A,$16,$27,$16,$27,$18,$27,$1A,$2A,$1A,$06,$31,$27,$2F
		Data.a $27,$2E,$27,$2E,$29,$2C,$29,$30,$29,$06,$FB,$B2,$FC,$B4,$FE,$B6
		Data.a $FE,$B8,$FC,$B9,$FC,$B4,$06,$39,$18,$38,$19,$3A,$1A,$3B,$19,$3B
		Data.a $17,$38,$17,$06,$A5,$4C,$A6,$47,$A5,$43,$A7,$40,$A2,$3F,$A3,$46
		Data.a $06,$90,$11,$91,$11,$91,$12,$90,$12,$8F,$12,$8F,$11,$06,$C8,$7D
		Data.a $C9,$7F,$CB,$85,$C9,$85,$C6,$7C,$C5,$79,$06,$7A,$32,$79,$34,$79
		Data.a $36,$7A,$37,$7C,$34,$7B,$31,$05,$A8,$18,$A9,$1B,$A7,$1C,$A6,$1B
		Data.a $A5,$19,$06,$E5,$48,$E3,$4F,$E0,$50,$DE,$4F,$E2,$4C,$E4,$45,$05
		Data.a $56,$3B,$59,$3D,$5A,$3C,$59,$3A,$58,$37,$05,$39,$10,$38,$11,$36
		Data.a $10,$35,$10,$37,$0F,$05,$4E,$E3,$4B,$E5,$4C,$E8,$46,$E8,$3B,$E7
		Data.a $05,$D7,$7F,$D6,$7F,$D7,$83,$D6,$85,$D5,$80,$04,$3B,$13,$3D,$13
		Data.a $3F,$13,$3F,$14,$05,$A4,$96,$A1,$A3,$9F,$9B,$A1,$96,$A3,$92,$04
		Data.a $05,$21,$04,$22,$03,$20,$01,$1F,$04,$3F,$17,$3E,$19,$3C,$19,$3C
		Data.a $17,$04,$44,$23,$47,$25,$44,$25,$42,$26,$04,$A0,$0D,$A0,$0E,$A1
		Data.a $0D,$A2,$0D,$04,$50,$CC,$50,$CE,$4E,$CD,$4E,$CC,$04,$3A,$33,$3C
		Data.a $38,$3A,$36,$3A,$33,$04,$E0,$DD,$D8,$DF,$D1,$DE,$CB,$DD,$04,$BB
		Data.a $DF,$B5,$E3,$AB,$E0,$A6,$DE,$03,$47,$61,$44,$60,$49,$61,$04,$D0
		Data.a $8C,$CC,$8A,$CD,$89,$D1,$8B,$04,$D7,$69,$D8,$6D,$D6,$6D,$D6,$66

	EndDataSection

EndProcedure
Procedure Dot3D(x.f,y.f,x_.f,y_.f,color)

	Protected x2.f,y2.f

	#Radiant=#PI/180

	x*#Radiant
	y*#Radiant
	x_*#Radiant
	y_*#Radiant
	x2=Sin(x-x_)*Cos(y)
	y2=Sin(y)*Cos(y_)-Cos(x-x_)*Cos(y)*Sin(y_)

	If x2>=-1 And x2<=1
		If y2>=-1 And y2<=1
			Plot(x2*#Size/2+#Size/2,y2*#Size/2+#Size/2,color)
		EndIf
	EndIf

EndProcedure
Procedure View(a,b)

	Protected i
	Protected x.f,y.f
	Protected x_.f,y_.f

	#Radiant=#PI/180

	x_=a*#Radiant
	y_=b*#Radiant

	For i=0 To #Dots
		x=(Dots(i)\x/#Size*360-180)*#Radiant
		y=(Dots(i)\y/#Size*180-90)*#Radiant
		;If (Invisible=1) And (Mod(x-x_,2*#PI)< -#PI Or  Mod(x-x_,2*#PI) > #PI)
		;	Dots3D(i)\x=#InvisibleFlag
		;Else
			Dots3D(i)\x=(Sin(x-x_)*Cos(y))*#Size/2+#Size/2
			Dots3D(i)\y=(Sin(y)*Cos(y_)-Cos(x-x_)*Cos(y)*Sin(y_))*#Size/2+#Size/2
		;EndIf
	Next i

EndProcedure
Procedure World()

	Protected i,j

	StartDrawing(CanvasOutput(0))
	Circle(#Size/2,#Size/2,#Size/2,$F8F8F0)
	DrawingMode(#PB_2DDrawing_Transparent)

	; ~~ Grid ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

	i=-180
	While i<180
		i+15
		j=-90
		While j<90
			j+2
			Dot3D(i,j,RotX,RotY,#Gray)
		Wend
	Wend

	i=-90
	While i<90
		i+15
		j=-180
		While j<180
			j+2
			Dot3D(j,i,RotX,RotY,#Gray)
		Wend
	Wend

	; ~~ Shapes ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

	View(RotX,RotY)

	For i=0 To #Shapes
		start=Shapes(i)\start
		stop=start+Shapes(i)\len-1

		;If Dots3D(start)\x<>#InvisibleFlag And Dots3D(stop)\x<>#InvisibleFlag
			LineXY(Dots3D(stop)\x,Dots3D(stop)\y,Dots3D(start)\x,Dots3D(start)\y,#Blue)
		;EndIf

		For j=start To stop-1
			;If Dots3D(j)\x<>#InvisibleFlag And Dots3D(j+1)\x<>#InvisibleFlag
				LineXY(Dots3D(j)\x,Dots3D(j)\y,Dots3D(j+1)\x,Dots3D(j+1)\y,#Blue)
			;EndIf
		Next j

	Next i

	StopDrawing()

EndProcedure
Procedure Main()

	Init()

	OpenWindow(0,0,0,#Size+1,#Size+1,"My little World by Michael Vogel",#PB_Window_ScreenCentered)
	CanvasGadget(0,0,0,#Size+1,#Size+1)

	RotY=-30
	RotX=30

	World()

	Repeat
		Select WaitWindowEvent()
		Case #PB_Event_CloseWindow
			End
		Case #WM_CHAR
			Select EventwParam()
			Case #ESC
				End
			Case 'x'
				RotX+2
				World()
			Case 'X'
				RotX-2
				World()
			Case 'y'
				RotY+2
				World()
			Case 'Y'
				RotY-2
				World()
			Case ' '
				Invisible!1
				World()
			EndSelect
		EndSelect

	Until EndOfWorld

EndProcedure

Main()

Re: Polygons to the world's end

Posted: Thu Jan 17, 2013 6:42 pm
by IdeasVacuum
Now that is a clever bit of code! I like it as-is :mrgreen: How about mapping a colour image onto the sphere?

Re: Polygons to the world's end

Posted: Thu Jan 17, 2013 6:56 pm
by Demivec
Michael Vogel wrote: I'd like to remove all hidden points and colorize the visible earth's landmass by using polygons...
Your progress so far looks impressive. I am in the process of implementing a polygon filler using only PureBasic code and will present it when finished. Some questions that are relate to this are whether winding is important (for holes for instance) and whether floating point is used. What are some important elements that you would need?

I also know there are ways of doing this with GDI+. There are a few implementations of those as well as one or two other PureBasic solutions already in the forums.

Re: Polygons to the world's end

Posted: Thu Jan 17, 2013 8:14 pm
by davido
Amazing :!:

With so few lines of code.

Re: Polygons to the world's end

Posted: Fri Jan 18, 2013 1:39 am
by BasicallyPure
This is almost exactly what I have been thinking about doing for some time.
I don't have any code yet to demonstrate but I have worked out some math that I think I can use for the project.

My idea will first convert map latitude and longitude coordinates to 3D XYZ coordinates then project 3D to 2D for display.
The origin (X=0,Y=0,Z=0) will be the center of the sphere.
With this method the invisible points will be any point that has a negative Z coordinate.

Here are the formulas I hope to use:

Code: Select all

; Latitude range -90 to +90
; Longitude range = -180 to +180

; convert Latitude and Longitude to XYZ
 X3d = Cos(Latitude) * Sin(Longitude)
 Y3d = Sin(Latitude)
 Z3d = Cos(Longitude) * Cos(Latitude)

; 3d to 2d projection as follows:
 X2d = X3d / Z3d
 Y2d = Y3d / Z3d
If I get this to work I will post an example.

B.P.

Re: Polygons to the world's end

Posted: Fri Jan 18, 2013 10:41 am
by Little John
Hi Michael,

very impressive work! Image
Michael Vogel wrote:but now I have some problems to get a better picture of the world: I'd like to remove all hidden points and colorize the visible earth's landmass by using polygons...
Maybe you can use Subdivision surface?

Regards, Little John

Re: Polygons to the world's end

Posted: Fri Jan 18, 2013 10:42 am
by Fred
Yes, that's good !

Re: Polygons to the world's end

Posted: Fri Jan 18, 2013 12:19 pm
by flaith
:shock: Excellent Michael
How did you create the datasection ?

Re: Polygons to the world's end

Posted: Fri Jan 18, 2013 9:13 pm
by idle
I haven't got time to look at your code
but if you're drawing a parametric sphere then you can simply texture map it
from a 2d map

the other alternative is to use a flood fill but you would need to remove hidden lines first
and have the edges of the sphere drawn
you always know if your inside a polygon or outside a polygon by using a counter
odd is outside, even is inside

Re: Polygons to the world's end

Posted: Fri Jan 18, 2013 9:16 pm
by Michael Vogel
Thanks for all your comments, just some additionally remarks:

• I took the database from here, wrote a shape editor to connect all broken lines (hard work) and just removed tons of points for this small demo.

• I don't want to use 3D functions, because (a small number of) PC's have problems with these functions

• a nice polygon function for all output modes would be fine, just as simple and fast as possible (before I will know exactly, what I could need, I have to some work: to find out, if a shape on the globe it totally or partially (!) visible and to calculate all points to form a polygon then...)

• will check the wikipedia text and other things also, thanks. A quick try to limit the grid by using the formula cos(x)*sin(y) to show only it's visible part did not work for me, I have to think about that also...

Code: Select all

	If Cos(x-x_)*Sin(y-y_)>=0
		Plot(x2*#Size/2+#Size/2,y2*#Size/2+#Size/2,color)
	EndIf

Re: Polygons to the world's end

Posted: Sat Jan 19, 2013 2:15 pm
by Crusiatus Black
That's some nice code Michael! Impressive, I loved the condition for the end of the loop as well haha! 'Until EndOfWorld'.

Nice!

Re: Polygons to the world's end

Posted: Sat Jan 19, 2013 5:43 pm
by Michael Vogel
Here's more or less the same code than before, but I am a little bit closer now in deciding which points should be visible or not – but there are still some issues to solve before doing polygons.

You can remove the invisible points by pressing 'space', but when you do so, you'll see, that the zero meridian (and some other lines near the north pole) won't be seen until you rotate the globe by using 'x'. By using 'y' and Shift+'y' the number of erroneous points increase/decrease as well. The worst situation is seen when y=-90, the whole grid stays invisible then.

Code: Select all

Procedure Init()

	; My little World Version 1.1
	; (c) 2013 by Michael Vogel

	#Size=2*2*2*2*2*2*2*2*2
	#Dots=(2*2+3*3*11)*3*3
	#InvisibleFlag=5*5*5*5*5
	#Shapes=7*7

	Global RotX=0
	Global RotY=0
	Global Invisible

	Structure DotType
		x.i
		y.i
	EndStructure
	Structure ShapeType
		len.i
		start.i
	EndStructure

	Global Dim Dots.DotType(#Dots)
	Global Dim Dots3D.DotType(#Dots)
	Global Dim Shapes.ShapeType(#Shapes)

	count=0
	For i=0 To #Shapes
		Shapes(i)\start=count
		Read.a Shapes(i)\len

		For j=1 To Shapes(i)\len
			Read.a Dots(count)\x
			Read.a Dots(count)\y
			Dots(count)\x*#Size>>8
			Dots(count)\y*#Size>>8
			count+1
		Next j
	Next i

	DataSection
		Data.a $DC,$FD,$24,$FF,$25,$FE,$27,$FC,$28,$FA,$29,$F8,$2A,$F6,$2B,$F4
		Data.a $2C,$F4,$30,$F2,$33,$EF,$36,$F2,$2C,$F5,$28,$F2,$2A,$F0,$29,$EE
		Data.a $2C,$EA,$2B,$E6,$2C,$E1,$31,$E2,$33,$E4,$34,$E4,$38,$E2,$3F,$DE
		Data.a $42,$DB,$48,$DB,$4E,$DA,$4D,$D9,$4A,$D8,$47,$D6,$47,$D6,$4B,$D5
		Data.a $4E,$D7,$54,$D6,$57,$D5,$5B,$D4,$5E,$D1,$60,$D0,$61,$CD,$62,$CD
		Data.a $69,$CE,$70,$CB,$73,$C9,$6E,$C7,$73,$CA,$7E,$C7,$75,$C5,$69,$C3
		Data.a $66,$C0,$60,$BF,$61,$B9,$6A,$B9,$71,$B5,$6E,$B4,$67,$B4,$61,$B2
		Data.a $62,$B0,$5E,$AD,$5C,$A8,$5A,$A3,$55,$A2,$58,$A5,$5B,$A8,$5C,$AA
		Data.a $5F,$A9,$65,$A5,$6A,$A0,$6D,$9E,$6A,$9D,$65,$9C,$60,$9A,$5A,$98
		Data.a $58,$97,$54,$99,$50,$9A,$4C,$96,$4C,$94,$4B,$93,$48,$95,$46,$99
		Data.a $45,$9C,$42,$9B,$3D,$99,$3E,$98,$3F,$99,$40,$98,$3F,$96,$3E,$94
		Data.a $41,$94,$46,$91,$47,$90,$49,$8F,$48,$8C,$43,$8A,$3F,$8A,$42,$8C
		Data.a $45,$8C,$49,$8B,$46,$87,$41,$84,$42,$81,$46,$7E,$4C,$7A,$4A,$7A
		Data.a $44,$7F,$42,$7E,$3C,$7E,$3B,$81,$39,$83,$36,$84,$34,$86,$33,$86
		Data.a $2F,$88,$30,$87,$32,$89,$33,$8C,$32,$8F,$31,$8F,$2E,$91,$2D,$92
		Data.a $2B,$95,$2B,$92,$2A,$90,$2A,$8F,$27,$92,$23,$90,$22,$8F,$24,$8D
		Data.a $26,$8C,$28,$8D,$2A,$8D,$2C,$8C,$2D,$89,$31,$88,$2D,$87,$2B,$85
		Data.a $2D,$84,$2B,$84,$2A,$85,$29,$84,$28,$84,$27,$85,$26,$87,$25,$89
		Data.a $23,$89,$21,$8B,$20,$8C,$1F,$8D,$1D,$8E,$1D,$90,$1C,$92,$1B,$93
		Data.a $1C,$94,$1C,$97,$1D,$9B,$1F,$9D,$22,$98,$21,$99,$24,$9A,$24,$9C
		Data.a $23,$9F,$22,$A1,$1F,$A2,$20,$A6,$1E,$A7,$1F,$AB,$1E,$AE,$1D,$B0
		Data.a $1D,$B0,$1A,$B4,$19,$B4,$1D,$B3,$21,$B4,$21,$B6,$1E,$B7,$20,$B5
		Data.a $1D,$B5,$19,$B7,$1B,$B7,$19,$BB,$1B,$BC,$1A,$B9,$18,$BB,$17,$BD
		Data.a $16,$BF,$15,$C1,$14,$C2,$14,$C3,$14,$C4,$14,$C8,$13,$C9,$12,$CB
		Data.a $12,$CC,$13,$CD,$13,$CF,$13,$D1,$14,$D1,$15,$CF,$16,$CC,$18,$CE
		Data.a $17,$CF,$17,$D1,$17,$D4,$18,$D8,$18,$DA,$17,$DC,$18,$DC,$1A,$DE
		Data.a $1B,$E1,$1A,$E3,$1A,$E6,$19,$E8,$19,$E7,$1A,$EB,$1A,$EC,$1B,$F1
		Data.a $1B,$F4,$1D,$F7,$1D,$F9,$1D,$FF,$1D,$D5,$0A,$27,$0A,$29,$0B,$2B
		Data.a $0D,$2A,$0D,$2C,$0F,$2C,$10,$2E,$0E,$31,$0C,$32,$0D,$31,$0F,$30
		Data.a $11,$2F,$12,$2D,$13,$2B,$15,$28,$14,$2A,$14,$2C,$16,$2A,$17,$29
		Data.a $18,$2A,$1A,$2B,$1D,$2B,$1E,$2B,$1F,$2D,$20,$2D,$21,$2D,$21,$2E
		Data.a $22,$2F,$22,$31,$23,$31,$23,$32,$24,$34,$25,$36,$25,$37,$27,$38
		Data.a $28,$39,$29,$3A,$29,$3C,$27,$3C,$28,$3E,$28,$44,$29,$4A,$2A,$4D
		Data.a $2B,$4F,$2D,$53,$2F,$57,$2F,$5A,$31,$5E,$31,$5C,$30,$58,$2E,$53
		Data.a $30,$55,$31,$59,$33,$5C,$35,$61,$36,$65,$39,$68,$3C,$6A,$41,$6D
		Data.a $43,$72,$46,$75,$49,$77,$48,$7D,$47,$84,$46,$88,$49,$90,$4C,$97
		Data.a $4E,$A1,$4D,$A9,$4D,$B2,$4C,$B9,$4C,$BC,$4C,$C0,$4C,$C2,$4A,$C3
		Data.a $4B,$C4,$4B,$C7,$4C,$C9,$4D,$CB,$4E,$CB,$4F,$C7,$51,$C3,$52,$BD
		Data.a $52,$BA,$56,$B7,$57,$B1,$5B,$AF,$5D,$A7,$60,$A1,$63,$9F,$64,$96
		Data.a $66,$8E,$63,$84,$60,$82,$5D,$83,$5B,$81,$5A,$79,$56,$76,$54,$72
		Data.a $53,$71,$4F,$70,$4D,$73,$4D,$6F,$49,$74,$46,$73,$44,$6A,$41,$68
		Data.a $42,$62,$3E,$66,$3B,$62,$3A,$5D,$3B,$5A,$3B,$58,$3C,$57,$3D,$56
		Data.a $40,$56,$41,$55,$45,$56,$46,$5C,$46,$54,$48,$50,$4A,$4E,$4A,$4C
		Data.a $4A,$4A,$4A,$48,$4A,$4A,$4A,$48,$4B,$46,$4E,$45,$4E,$44,$4F,$42
		Data.a $50,$40,$53,$40,$52,$41,$54,$3F,$52,$3D,$50,$3A,$4F,$3B,$54,$38
		Data.a $58,$36,$57,$34,$56,$33,$56,$32,$54,$30,$54,$2E,$53,$2C,$52,$2A
		Data.a $50,$2D,$4E,$2C,$4E,$2B,$4C,$29,$4B,$28,$49,$27,$49,$2A,$48,$2C
		Data.a $4A,$30,$48,$34,$48,$37,$46,$36,$45,$31,$41,$30,$3E,$2E,$3D,$2B
		Data.a $3E,$28,$3F,$26,$3F,$25,$41,$25,$40,$22,$42,$21,$45,$22,$45,$1F
		Data.a $44,$1D,$43,$1E,$41,$1F,$3F,$1D,$3E,$1C,$3D,$1A,$3B,$1B,$3C,$1D
		Data.a $3D,$1E,$3C,$20,$3A,$1F,$37,$1F,$34,$1E,$34,$1F,$33,$20,$32,$20
		Data.a $30,$20,$2E,$1E,$2B,$1D,$28,$1D,$27,$1D,$25,$1C,$23,$1D,$22,$1D
		Data.a $20,$1E,$1D,$1D,$1A,$1C,$16,$1C,$13,$1B,$11,$1B,$0F,$1B,$0E,$1C
		Data.a $0C,$1D,$09,$1F,$0C,$21,$0E,$21,$0E,$22,$0C,$21,$09,$22,$0B,$24
		Data.a $0D,$24,$0C,$26,$42,$6D,$1E,$6F,$1D,$70,$1C,$6C,$1C,$6F,$1C,$70
		Data.a $1A,$6E,$19,$6F,$17,$70,$16,$71,$15,$71,$14,$71,$13,$72,$12,$71
		Data.a $11,$72,$0F,$71,$0E,$71,$0D,$76,$0C,$73,$0C,$6F,$0D,$70,$0B,$6A
		Data.a $0C,$6D,$0B,$6F,$0A,$6A,$0A,$68,$0A,$6A,$09,$65,$09,$65,$0A,$60
		Data.a $0A,$62,$0A,$61,$0B,$5E,$0B,$5C,$0C,$58,$0B,$57,$0C,$54,$0C,$51
		Data.a $0E,$52,$0E,$50,$0F,$4C,$11,$4F,$12,$4F,$13,$53,$14,$57,$15,$59
		Data.a $17,$59,$1A,$5C,$1C,$5C,$1D,$5C,$1F,$5A,$21,$5B,$24,$5C,$26,$5D
		Data.a $28,$5E,$29,$5F,$29,$60,$2B,$62,$29,$62,$27,$63,$25,$63,$23,$65
		Data.a $22,$66,$22,$68,$21,$69,$1F,$6A,$1F,$31,$46,$0E,$47,$0D,$4A,$0D
		Data.a $48,$0C,$47,$0D,$45,$0E,$45,$0D,$43,$0D,$44,$0D,$43,$0D,$41,$0D
		Data.a $40,$0D,$40,$0C,$43,$0B,$45,$0B,$46,$0B,$48,$0A,$4B,$0A,$50,$0A
		Data.a $52,$0A,$54,$0B,$50,$0C,$4F,$0C,$52,$0C,$4E,$0E,$4C,$0F,$49,$0F
		Data.a $4B,$0F,$49,$10,$4A,$10,$49,$11,$46,$12,$47,$14,$44,$14,$41,$13
		Data.a $42,$12,$41,$12,$43,$12,$45,$11,$43,$12,$44,$11,$44,$10,$42,$11
		Data.a $42,$10,$45,$10,$44,$0F,$43,$0E,$46,$0F,$46,$0E,$25,$8E,$52,$8A
		Data.a $52,$88,$4E,$85,$4B,$81,$4C,$7C,$4D,$79,$56,$74,$60,$74,$69,$75
		Data.a $6F,$76,$73,$79,$77,$80,$78,$84,$79,$87,$7B,$86,$81,$89,$8A,$89
		Data.a $93,$89,$9B,$8A,$A2,$8C,$AA,$8D,$B1,$91,$B1,$96,$AA,$99,$A3,$9A
		Data.a $9B,$9D,$95,$9C,$8E,$9C,$86,$A0,$7D,$A4,$73,$A1,$71,$9E,$6C,$9B
		Data.a $65,$99,$5C,$97,$54,$93,$53,$1A,$E5,$96,$E1,$96,$E1,$92,$DF,$91
		Data.a $DE,$91,$DC,$96,$DA,$94,$D8,$97,$D7,$9A,$D2,$9E,$D1,$A2,$D1,$A6
		Data.a $D2,$B0,$D6,$B0,$DD,$AD,$E0,$B1,$E2,$B0,$E3,$B2,$E7,$B6,$E9,$B7
		Data.a $EB,$B2,$ED,$AB,$EC,$A3,$EA,$9E,$E8,$99,$E6,$91,$17,$51,$26,$52
		Data.a $25,$50,$23,$52,$23,$54,$22,$51,$1F,$51,$1D,$4F,$1C,$4C,$1A,$4A
		Data.a $19,$47,$19,$44,$18,$44,$1B,$43,$18,$40,$1A,$43,$1C,$48,$1D,$4B
		Data.a $1E,$4B,$22,$49,$25,$4C,$25,$4E,$27,$51,$27,$0D,$90,$0E,$91,$0E
		Data.a $92,$0E,$93,$0E,$92,$0F,$91,$0F,$90,$0F,$8F,$0F,$90,$0F,$8E,$0F
		Data.a $8D,$0E,$8E,$0E,$8F,$0E,$10,$42,$0F,$43,$0F,$41,$10,$40,$10,$3E
		Data.a $11,$3E,$10,$3F,$0F,$3E,$0F,$3C,$0F,$3C,$0E,$3D,$0E,$3C,$0E,$3D
		Data.a $0D,$3F,$0D,$41,$0E,$42,$0E,$0F,$8D,$0F,$8E,$0F,$8E,$10,$8D,$12
		Data.a $8C,$13,$8A,$12,$8B,$12,$8B,$11,$8C,$10,$8A,$10,$89,$10,$88,$0F
		Data.a $89,$0F,$8A,$0F,$8C,$10,$10,$38,$1D,$37,$1D,$36,$1E,$33,$1E,$2F
		Data.a $1E,$2E,$1C,$2E,$1A,$2C,$1A,$2F,$18,$30,$18,$31,$19,$32,$18,$33
		Data.a $19,$34,$18,$36,$1A,$38,$1C,$0C,$7E,$38,$81,$37,$80,$34,$7E,$30
		Data.a $7D,$2E,$7C,$2D,$7C,$2F,$7C,$31,$7D,$30,$7D,$32,$7E,$34,$7D,$37
		Data.a $0A,$33,$14,$32,$13,$33,$14,$34,$15,$31,$16,$31,$15,$2F,$15,$2E
		Data.a $14,$2D,$14,$2E,$14,$0A,$AC,$13,$AF,$13,$B0,$14,$AB,$15,$A9,$16
		Data.a $A9,$17,$A7,$18,$A7,$17,$A8,$15,$AA,$14,$09,$E6,$85,$E2,$82,$DF
		Data.a $81,$DF,$84,$E0,$86,$E3,$8A,$E5,$8D,$E8,$8B,$EB,$8E,$09,$CF,$7D
		Data.a $D1,$7A,$D3,$77,$D4,$78,$D4,$7A,$D4,$7F,$D2,$85,$D0,$85,$CE,$81
		Data.a $07,$A2,$0E,$A3,$0E,$A4,$0E,$A4,$0D,$A3,$0D,$A2,$0D,$A2,$0E,$08
		Data.a $70,$24,$70,$23,$6F,$23,$70,$22,$71,$23,$73,$22,$75,$22,$75,$24
		Data.a $07,$2A,$21,$28,$22,$29,$23,$2A,$23,$2B,$23,$2C,$22,$2B,$22,$07
		Data.a $39,$14,$37,$14,$37,$15,$39,$15,$3A,$15,$3B,$14,$39,$13,$08,$41
		Data.a $15,$44,$15,$45,$14,$47,$15,$44,$16,$41,$16,$3F,$16,$3D,$14,$07
		Data.a $46,$3F,$44,$3E,$42,$40,$42,$45,$43,$40,$44,$42,$46,$40,$07,$FA
		Data.a $BA,$FC,$BB,$FB,$BD,$FA,$C0,$F8,$C2,$F7,$C1,$F8,$BF,$07,$2B,$19
		Data.a $2D,$17,$2A,$16,$27,$16,$27,$18,$27,$1A,$2A,$1A,$06,$31,$27,$2F
		Data.a $27,$2E,$27,$2E,$29,$2C,$29,$30,$29,$06,$FB,$B2,$FC,$B4,$FE,$B6
		Data.a $FE,$B8,$FC,$B9,$FC,$B4,$06,$39,$18,$38,$19,$3A,$1A,$3B,$19,$3B
		Data.a $17,$38,$17,$06,$A5,$4C,$A6,$47,$A5,$43,$A7,$40,$A2,$3F,$A3,$46
		Data.a $06,$90,$11,$91,$11,$91,$12,$90,$12,$8F,$12,$8F,$11,$06,$C8,$7D
		Data.a $C9,$7F,$CB,$85,$C9,$85,$C6,$7C,$C5,$79,$06,$7A,$32,$79,$34,$79
		Data.a $36,$7A,$37,$7C,$34,$7B,$31,$05,$A8,$18,$A9,$1B,$A7,$1C,$A6,$1B
		Data.a $A5,$19,$06,$E5,$48,$E3,$4F,$E0,$50,$DE,$4F,$E2,$4C,$E4,$45,$05
		Data.a $56,$3B,$59,$3D,$5A,$3C,$59,$3A,$58,$37,$05,$39,$10,$38,$11,$36
		Data.a $10,$35,$10,$37,$0F,$05,$4E,$E3,$4B,$E5,$4C,$E8,$46,$E8,$3B,$E7
		Data.a $05,$D7,$7F,$D6,$7F,$D7,$83,$D6,$85,$D5,$80,$04,$3B,$13,$3D,$13
		Data.a $3F,$13,$3F,$14,$05,$A4,$96,$A1,$A3,$9F,$9B,$A1,$96,$A3,$92,$04
		Data.a $05,$21,$04,$22,$03,$20,$01,$1F,$04,$3F,$17,$3E,$19,$3C,$19,$3C
		Data.a $17,$04,$44,$23,$47,$25,$44,$25,$42,$26,$04,$A0,$0D,$A0,$0E,$A1
		Data.a $0D,$A2,$0D,$04,$50,$CC,$50,$CE,$4E,$CD,$4E,$CC,$04,$3A,$33,$3C
		Data.a $38,$3A,$36,$3A,$33,$04,$E0,$DD,$D8,$DF,$D1,$DE,$CB,$DD,$04,$BB
		Data.a $DF,$B5,$E3,$AB,$E0,$A6,$DE,$03,$47,$61,$44,$60,$49,$61,$04,$D0
		Data.a $8C,$CC,$8A,$CD,$89,$D1,$8B,$04,$D7,$69,$D8,$6D,$D6,$6D,$D6,$66

	EndDataSection

EndProcedure
Procedure Dot3D(x.f,y.f,x_.f,y_.f,color)

	Protected x2.f,y2.f
	
	#Radiant=#PI/180

	x*#Radiant
	y*#Radiant
	x_*#Radiant
	y_*#Radiant
	x2=Sin(x-x_)*Cos(y)
	y2=Sin(y)*Cos(y_)-Cos(x-x_)*Cos(y)*Sin(y_)
	
	If x2>=-1 And x2<=1
		If y2>=-1 And y2<=1
			If Invisible And Cos(x-x_)*Cos(RotY*#Radiant)+Sin(y)*Sin(RotY*#Radiant)<0
				color=#White
			EndIf
			Plot(x2*#Size/2+#Size/2,y2*#Size/2+#Size/2,color)
		EndIf
	EndIf

EndProcedure
Procedure View(a,b)

	Protected i
	Protected x.f,y.f
	Protected x_.f,y_.f

	#Radiant=#PI/180

	x_=a*#Radiant
	y_=b*#Radiant

	For i=0 To #Dots
		x=(Dots(i)\x/#Size*360-180)*#Radiant
		y=(Dots(i)\y/#Size*180-90)*#Radiant
		If (Invisible=1) And Cos(x-x_)*Cos(RotY*#Radiant)+Sin(y)*Sin(RotY*#Radiant)<0
			Dots3D(i)\x=#InvisibleFlag
		Else
			Dots3D(i)\x=(Sin(x-x_)*Cos(y))*#Size/2+#Size/2
			Dots3D(i)\y=(Sin(y)*Cos(y_)-Cos(x-x_)*Cos(y)*Sin(y_))*#Size/2+#Size/2
		EndIf
	Next i

EndProcedure
Procedure World()

	Protected i,j

	StartDrawing(CanvasOutput(0))
	Circle(#Size/2,#Size/2,#Size/2,$F8F8F0)
	DrawingFont(FontID(0))
	DrawText(0,0,Str(rotx)+"/"+Str(roty)+"  ",#Black,#White)
	DrawingMode(#PB_2DDrawing_Transparent)

	; ~~ Grid ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


	i=-180
	While i<180
		i+30
		j=-91
		While j<90
			j+1
			Dot3D(i,j,RotX,RotY,#Gray)
		Wend
	Wend

	i=-90
	While i<90
		i+15
		j=-181
		While j<180
			j+1
			Dot3D(j,i,RotX,RotY,#Gray)
		Wend
	Wend

	; ~~ Shapes ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

	View(RotX,RotY)

	For i=0 To #Shapes
		start=Shapes(i)\start
		stop=start+Shapes(i)\len-1

		If Dots3D(start)\x<>#InvisibleFlag And Dots3D(stop)\x<>#InvisibleFlag
			LineXY(Dots3D(stop)\x,Dots3D(stop)\y,Dots3D(start)\x,Dots3D(start)\y,#Blue)
		EndIf

		For j=start To stop-1
			If Dots3D(j)\x<>#InvisibleFlag And Dots3D(j+1)\x<>#InvisibleFlag
				LineXY(Dots3D(j)\x,Dots3D(j)\y,Dots3D(j+1)\x,Dots3D(j+1)\y,#Blue)
			EndIf
		Next j

	Next i

	StopDrawing()

EndProcedure
Procedure Main()

	Init()

	LoadFont(0,"Arial",8)
	OpenWindow(0,0,0,#Size+1,#Size+1,"My little World by Michael Vogel",#PB_Window_ScreenCentered)
	CanvasGadget(0,0,0,#Size+1,#Size+1)

	RotY=-40
	RotX=0

	World()

	Repeat
		Select WaitWindowEvent()
		Case #PB_Event_CloseWindow
			End
		Case #WM_CHAR
			Select EventwParam()
			Case #ESC
				End
			Case 'x'
				RotX+5
				World()
			Case 'X'
				RotX-5
				World()
			Case 'y'
				RotY+5
				World()
			Case 'Y'
				RotY-5
				World()
			Case ' '
				Invisible!1
				World()

			EndSelect
		EndSelect

	Until EndOfWorld

EndProcedure

Main()

Re: Polygons to the world's end

Posted: Sat Jan 19, 2013 6:50 pm
by rsts
Very impressive! :shock:

Re: Polygons to the world's end

Posted: Sat Jan 19, 2013 7:48 pm
by BasicallyPure
Michael,
Is the data you have for your shapes in any way mapped to latitude and longitude?
If so maybe I could make use of the data in my code.
edit: disregard the question, I figured it out. :wink:

Here is what I have so far.
It shows that using the negative Z coordinate can do an effective hide.
My latitude rotation isn't working correctly but the longitude looks pretty good.
I may have to use a completely different method for rotation to get it right.

B.P.

Code: Select all

; Globe.pb
; drawing a 3D sphere with 2D graphics
; graphing latitude & longitude on sphere.
;
; by BasicallyPure, 1.19.2013
;
; Windows, Linux
;
EnableExplicit

#WinWidth = 800
#winHeight = 600

Declare Verify(result, text.s)
Declare Grid()

Global.d latitude, longitude, Yos, Xos, LatInc, LngInc, X3d, Y3d, Z3d, X2d, Y2d
Global.d La, Lo
Global midX = #WinWidth / 2 - 100, midY = #winHeight / 2
Global distance.d = 10 ; viewing distance
Global R1 = 1, R2, Hide = 1, scale = 2500

Define event, flags = #PB_Window_SystemMenu | #PB_Window_ScreenCentered | #PB_Window_MinimizeGadget

Verify(OpenWindow(0,0,0,#WinWidth,#winHeight,"Globe",flags),"OpenWindow")
Verify(CanvasGadget(0,0,0,#WinWidth - 200,#winHeight),"CanvasGadget")
CheckBoxGadget(1,#WinWidth - 190,050,150,25,"rotate Longitude")
CheckBoxGadget(2,#WinWidth - 190,100,150,25,"rotate Latitude")
CheckBoxGadget(3,#WinWidth - 190,150,100,25,"hide")
flags = #PB_TrackBar_Vertical | #PB_TrackBar_Ticks
TrackBarGadget(4,#WinWidth - 190,200,030,200,10,30,flags)
TextGadget(5,#WinWidth - 190, 405,125,25,"Distance")
SetGadgetState(1,#True)
SetGadgetState(3,#True)

Macro Plot_Lat_Lon_point_on_sphere
   ; latitude and longitude are in radians
   
   ; add offsets for rotation
   ; this may not be the correct way to do rotation
   Lo = longitude + Xos
   La = latitude + Yos
   
   ; latitude must have range limited (-90 to +90)
   If La > Radian(90) : La - #PI
   ElseIf La < Radian(-90) : La + #PI
   EndIf
   
   Z3d = Cos(La) * Cos(Lo) ; first calculate Z3d coordinate
   
   ;only plot if located on the front hemisphere
   If Z3d >= 0 Or Hide = 0
      X3d = Cos(La) * Sin(Lo)
      y3d = Sin(La)
      
      ; 3D to 2D projection
      X2d = X3d / (distance - Z3d) * scale
      Y2d = Y3d / (distance - Z3d) * scale
      
      Plot(X2d + midX, Y2d + MidY, $FFFFFF)
   EndIf
EndMacro

Define.f n, stp
Grid()

Repeat
   n = 0 : stp = 0.25
   Repeat
      Repeat
         event = WindowEvent()
         Select event
            Case #PB_Event_CloseWindow : End
            Case #PB_Event_Gadget
               Select EventGadget()
                  Case 1 : R1   = GetGadgetState(1)
                  Case 2 : R2   = GetGadgetState(2)
                  Case 3 : Hide = GetGadgetState(3) : Grid()
                  Case 4 : distance = GetGadgetState(4) : Grid()
               EndSelect
         EndSelect
      Until event = #False
      
      If R1 : Xos = Radian(n) : EndIf
      If R2 : Yos = Radian(n) : EndIf
      
      If R1 Or R2 : Grid() : n + Stp : EndIf
      Delay(25)
   Until n > 180
ForEver

Procedure Grid() ; draw grid
   StartDrawing(CanvasOutput(0))
      Box(0,0,#WinWidth,#winHeight,0)
      Circle(midX,midY,scale/distance,$8F271C)
      longitude = Radian(-180)
      LatInc = Radian(15)
      LngInc = Radian(2)
      
      Repeat
         latitude = Radian(-90)
         Repeat
            Plot_Lat_Lon_point_on_sphere
            latitude + LatInc
         Until latitude > Radian(89)
         longitude + LngInc
      Until longitude > Radian(179)
      
      latitude = Radian(-90)
      LatInc = Radian(2)
      LngInc = Radian(15)
      
      Repeat
         longitude = Radian(-180)
         Repeat
            Plot_Lat_Lon_point_on_sphere
            longitude + LngInc
         Until longitude > Radian(179)
         latitude + LatInc
      Until latitude > Radian(89)
   StopDrawing()
EndProcedure

Procedure Verify(result, text.s)
   ;display message and terminate on error
   If result = 0
      MessageRequester("Error!", text + " failed to initalize")
      End
   EndIf
   ProcedureReturn result
EndProcedure

Re: Polygons to the world's end

Posted: Sun Jan 20, 2013 12:24 am
by idle
I don't have any time at the moment, sorry hacked up the code was in a rush
the z parameter culls back faces
flood fill doesn't work as expected may need eight connecting

Code: Select all

EnableExplicit 

#Shapes=7*7
 
 Structure DotType
    x.i
    y.i
 EndStructure
   
 Structure ShapeType
    len.i
    start.i
    List dot.DotType()
 EndStructure

 Global Dim Shapes.ShapeType(#Shapes)

#PI2 =6.283185
Procedure fill(x,y,w,h,col)
   If x < 0 Or x > w Or y < 0 Or y > h 
      ProcedureReturn 
   EndIf    
   If col <> Point(x,y)
        Plot(x,y,col)
        Fill(x+1,y,w,h,col)
        Fill(x,y+1,w,h,col)
        Fill(x-1,y,w,h,col)
        Fill(x,y-1,w,h,col)
     Else 
        ProcedureReturn
     EndIf      
 EndProcedure 
  
 Procedure drawplanet(w,h,cx,cy,radius.f,rx.f=1,ry.f=1) 
   Protected x.f,y.f,z.f,ux.f,vy.f,imageout,lx,ly,lz,dx,dy,a,b,fx.f,fy.f,ct 
   Protected sumx.f,sumy.f
   imageout = CreateImage(#PB_Any,w,h)
    StartDrawing(ImageOutput(imageout)) 
    
    Circle(cx,cy,radius,RGB(0,255,0))
    Circle(cx,cy,radius-1.0,RGB(0,0,0))
    
    For a =0 To #Shapes 
      ForEach shapes(a)\dot() 
         ux = shapes(a)\dot()\x * #PI2 / (2*radius) 
         vy = shapes(a)\dot()\y * #Pi2 / (2 * radius)
                 
         x.f = cx +  radius *  Cos(ux) * Sin(vy)
         y.f = cy +  radius *  Sin(ux) * Sin(vy) 
         z.f =  radius * Cos(vy) 
               
         If z > 0 
            If lx 
              LineXY(x,y,lx,ly,RGB(0,255,0)) 
            EndIf   
            sumx + x
            sumy + y 
            ct+1
            If Not fx 
             fx=x
             fy=y
          EndIf 
            
         EndIf  
       
          ly = y
          lx = x    
          lz = z
      Next
      If lz > 0 
       LineXY(lx,ly,fx,fy,RGB(0,255,0)) 
      EndIf  
      fx = sumx / ct 
      fy = sumy / ct 
     ; fill(fx,fy,w,h,RGB(0,255,0))
      
      sumx=0
      sumy=0
      ct=0
      fx=0
      fy=0
      lx=0
      ly=0
  Next    
  
  StopDrawing()
    ProcedureReturn imageout 
 EndProcedure 
 
 Define i,j,count
 
   For i=0 To #Shapes
      Shapes(i)\start=count
      Read.a Shapes(i)\len

      For j=1 To Shapes(i)\len
         AddElement(Shapes(i)\dot())
         Read.a Shapes(i)\dot()\x
         Read.a shapes(i)\dot()\y
       Next j
   Next i
  
   
   Define img 
 OpenWindow(0,0,0,800,600,"test") 
 img = drawplanet(800,600,400,300,150) 
 ImageGadget(0,0,0,800,600,ImageID(img)) 
  
 Repeat 
   Until WaitWindowEvent() = #PB_Event_CloseWindow  
 
   
    DataSection
      Data.a $DC,$FD,$24,$FF,$25,$FE,$27,$FC,$28,$FA,$29,$F8,$2A,$F6,$2B,$F4
      Data.a $2C,$F4,$30,$F2,$33,$EF,$36,$F2,$2C,$F5,$28,$F2,$2A,$F0,$29,$EE
      Data.a $2C,$EA,$2B,$E6,$2C,$E1,$31,$E2,$33,$E4,$34,$E4,$38,$E2,$3F,$DE
      Data.a $42,$DB,$48,$DB,$4E,$DA,$4D,$D9,$4A,$D8,$47,$D6,$47,$D6,$4B,$D5
      Data.a $4E,$D7,$54,$D6,$57,$D5,$5B,$D4,$5E,$D1,$60,$D0,$61,$CD,$62,$CD
      Data.a $69,$CE,$70,$CB,$73,$C9,$6E,$C7,$73,$CA,$7E,$C7,$75,$C5,$69,$C3
      Data.a $66,$C0,$60,$BF,$61,$B9,$6A,$B9,$71,$B5,$6E,$B4,$67,$B4,$61,$B2
      Data.a $62,$B0,$5E,$AD,$5C,$A8,$5A,$A3,$55,$A2,$58,$A5,$5B,$A8,$5C,$AA
      Data.a $5F,$A9,$65,$A5,$6A,$A0,$6D,$9E,$6A,$9D,$65,$9C,$60,$9A,$5A,$98
      Data.a $58,$97,$54,$99,$50,$9A,$4C,$96,$4C,$94,$4B,$93,$48,$95,$46,$99
      Data.a $45,$9C,$42,$9B,$3D,$99,$3E,$98,$3F,$99,$40,$98,$3F,$96,$3E,$94
      Data.a $41,$94,$46,$91,$47,$90,$49,$8F,$48,$8C,$43,$8A,$3F,$8A,$42,$8C
      Data.a $45,$8C,$49,$8B,$46,$87,$41,$84,$42,$81,$46,$7E,$4C,$7A,$4A,$7A
      Data.a $44,$7F,$42,$7E,$3C,$7E,$3B,$81,$39,$83,$36,$84,$34,$86,$33,$86
      Data.a $2F,$88,$30,$87,$32,$89,$33,$8C,$32,$8F,$31,$8F,$2E,$91,$2D,$92
      Data.a $2B,$95,$2B,$92,$2A,$90,$2A,$8F,$27,$92,$23,$90,$22,$8F,$24,$8D
      Data.a $26,$8C,$28,$8D,$2A,$8D,$2C,$8C,$2D,$89,$31,$88,$2D,$87,$2B,$85
      Data.a $2D,$84,$2B,$84,$2A,$85,$29,$84,$28,$84,$27,$85,$26,$87,$25,$89
      Data.a $23,$89,$21,$8B,$20,$8C,$1F,$8D,$1D,$8E,$1D,$90,$1C,$92,$1B,$93
      Data.a $1C,$94,$1C,$97,$1D,$9B,$1F,$9D,$22,$98,$21,$99,$24,$9A,$24,$9C
      Data.a $23,$9F,$22,$A1,$1F,$A2,$20,$A6,$1E,$A7,$1F,$AB,$1E,$AE,$1D,$B0
      Data.a $1D,$B0,$1A,$B4,$19,$B4,$1D,$B3,$21,$B4,$21,$B6,$1E,$B7,$20,$B5
      Data.a $1D,$B5,$19,$B7,$1B,$B7,$19,$BB,$1B,$BC,$1A,$B9,$18,$BB,$17,$BD
      Data.a $16,$BF,$15,$C1,$14,$C2,$14,$C3,$14,$C4,$14,$C8,$13,$C9,$12,$CB
      Data.a $12,$CC,$13,$CD,$13,$CF,$13,$D1,$14,$D1,$15,$CF,$16,$CC,$18,$CE
      Data.a $17,$CF,$17,$D1,$17,$D4,$18,$D8,$18,$DA,$17,$DC,$18,$DC,$1A,$DE
      Data.a $1B,$E1,$1A,$E3,$1A,$E6,$19,$E8,$19,$E7,$1A,$EB,$1A,$EC,$1B,$F1
      Data.a $1B,$F4,$1D,$F7,$1D,$F9,$1D,$FF,$1D,$D5,$0A,$27,$0A,$29,$0B,$2B
      Data.a $0D,$2A,$0D,$2C,$0F,$2C,$10,$2E,$0E,$31,$0C,$32,$0D,$31,$0F,$30
      Data.a $11,$2F,$12,$2D,$13,$2B,$15,$28,$14,$2A,$14,$2C,$16,$2A,$17,$29
      Data.a $18,$2A,$1A,$2B,$1D,$2B,$1E,$2B,$1F,$2D,$20,$2D,$21,$2D,$21,$2E
      Data.a $22,$2F,$22,$31,$23,$31,$23,$32,$24,$34,$25,$36,$25,$37,$27,$38
      Data.a $28,$39,$29,$3A,$29,$3C,$27,$3C,$28,$3E,$28,$44,$29,$4A,$2A,$4D
      Data.a $2B,$4F,$2D,$53,$2F,$57,$2F,$5A,$31,$5E,$31,$5C,$30,$58,$2E,$53
      Data.a $30,$55,$31,$59,$33,$5C,$35,$61,$36,$65,$39,$68,$3C,$6A,$41,$6D
      Data.a $43,$72,$46,$75,$49,$77,$48,$7D,$47,$84,$46,$88,$49,$90,$4C,$97
      Data.a $4E,$A1,$4D,$A9,$4D,$B2,$4C,$B9,$4C,$BC,$4C,$C0,$4C,$C2,$4A,$C3
      Data.a $4B,$C4,$4B,$C7,$4C,$C9,$4D,$CB,$4E,$CB,$4F,$C7,$51,$C3,$52,$BD
      Data.a $52,$BA,$56,$B7,$57,$B1,$5B,$AF,$5D,$A7,$60,$A1,$63,$9F,$64,$96
      Data.a $66,$8E,$63,$84,$60,$82,$5D,$83,$5B,$81,$5A,$79,$56,$76,$54,$72
      Data.a $53,$71,$4F,$70,$4D,$73,$4D,$6F,$49,$74,$46,$73,$44,$6A,$41,$68
      Data.a $42,$62,$3E,$66,$3B,$62,$3A,$5D,$3B,$5A,$3B,$58,$3C,$57,$3D,$56
      Data.a $40,$56,$41,$55,$45,$56,$46,$5C,$46,$54,$48,$50,$4A,$4E,$4A,$4C
      Data.a $4A,$4A,$4A,$48,$4A,$4A,$4A,$48,$4B,$46,$4E,$45,$4E,$44,$4F,$42
      Data.a $50,$40,$53,$40,$52,$41,$54,$3F,$52,$3D,$50,$3A,$4F,$3B,$54,$38
      Data.a $58,$36,$57,$34,$56,$33,$56,$32,$54,$30,$54,$2E,$53,$2C,$52,$2A
      Data.a $50,$2D,$4E,$2C,$4E,$2B,$4C,$29,$4B,$28,$49,$27,$49,$2A,$48,$2C
      Data.a $4A,$30,$48,$34,$48,$37,$46,$36,$45,$31,$41,$30,$3E,$2E,$3D,$2B
      Data.a $3E,$28,$3F,$26,$3F,$25,$41,$25,$40,$22,$42,$21,$45,$22,$45,$1F
      Data.a $44,$1D,$43,$1E,$41,$1F,$3F,$1D,$3E,$1C,$3D,$1A,$3B,$1B,$3C,$1D
      Data.a $3D,$1E,$3C,$20,$3A,$1F,$37,$1F,$34,$1E,$34,$1F,$33,$20,$32,$20
      Data.a $30,$20,$2E,$1E,$2B,$1D,$28,$1D,$27,$1D,$25,$1C,$23,$1D,$22,$1D
      Data.a $20,$1E,$1D,$1D,$1A,$1C,$16,$1C,$13,$1B,$11,$1B,$0F,$1B,$0E,$1C
      Data.a $0C,$1D,$09,$1F,$0C,$21,$0E,$21,$0E,$22,$0C,$21,$09,$22,$0B,$24
      Data.a $0D,$24,$0C,$26,$42,$6D,$1E,$6F,$1D,$70,$1C,$6C,$1C,$6F,$1C,$70
      Data.a $1A,$6E,$19,$6F,$17,$70,$16,$71,$15,$71,$14,$71,$13,$72,$12,$71
      Data.a $11,$72,$0F,$71,$0E,$71,$0D,$76,$0C,$73,$0C,$6F,$0D,$70,$0B,$6A
      Data.a $0C,$6D,$0B,$6F,$0A,$6A,$0A,$68,$0A,$6A,$09,$65,$09,$65,$0A,$60
      Data.a $0A,$62,$0A,$61,$0B,$5E,$0B,$5C,$0C,$58,$0B,$57,$0C,$54,$0C,$51
      Data.a $0E,$52,$0E,$50,$0F,$4C,$11,$4F,$12,$4F,$13,$53,$14,$57,$15,$59
      Data.a $17,$59,$1A,$5C,$1C,$5C,$1D,$5C,$1F,$5A,$21,$5B,$24,$5C,$26,$5D
      Data.a $28,$5E,$29,$5F,$29,$60,$2B,$62,$29,$62,$27,$63,$25,$63,$23,$65
      Data.a $22,$66,$22,$68,$21,$69,$1F,$6A,$1F,$31,$46,$0E,$47,$0D,$4A,$0D
      Data.a $48,$0C,$47,$0D,$45,$0E,$45,$0D,$43,$0D,$44,$0D,$43,$0D,$41,$0D
      Data.a $40,$0D,$40,$0C,$43,$0B,$45,$0B,$46,$0B,$48,$0A,$4B,$0A,$50,$0A
      Data.a $52,$0A,$54,$0B,$50,$0C,$4F,$0C,$52,$0C,$4E,$0E,$4C,$0F,$49,$0F
      Data.a $4B,$0F,$49,$10,$4A,$10,$49,$11,$46,$12,$47,$14,$44,$14,$41,$13
      Data.a $42,$12,$41,$12,$43,$12,$45,$11,$43,$12,$44,$11,$44,$10,$42,$11
      Data.a $42,$10,$45,$10,$44,$0F,$43,$0E,$46,$0F,$46,$0E,$25,$8E,$52,$8A
      Data.a $52,$88,$4E,$85,$4B,$81,$4C,$7C,$4D,$79,$56,$74,$60,$74,$69,$75
      Data.a $6F,$76,$73,$79,$77,$80,$78,$84,$79,$87,$7B,$86,$81,$89,$8A,$89
      Data.a $93,$89,$9B,$8A,$A2,$8C,$AA,$8D,$B1,$91,$B1,$96,$AA,$99,$A3,$9A
      Data.a $9B,$9D,$95,$9C,$8E,$9C,$86,$A0,$7D,$A4,$73,$A1,$71,$9E,$6C,$9B
      Data.a $65,$99,$5C,$97,$54,$93,$53,$1A,$E5,$96,$E1,$96,$E1,$92,$DF,$91
      Data.a $DE,$91,$DC,$96,$DA,$94,$D8,$97,$D7,$9A,$D2,$9E,$D1,$A2,$D1,$A6
      Data.a $D2,$B0,$D6,$B0,$DD,$AD,$E0,$B1,$E2,$B0,$E3,$B2,$E7,$B6,$E9,$B7
      Data.a $EB,$B2,$ED,$AB,$EC,$A3,$EA,$9E,$E8,$99,$E6,$91,$17,$51,$26,$52
      Data.a $25,$50,$23,$52,$23,$54,$22,$51,$1F,$51,$1D,$4F,$1C,$4C,$1A,$4A
      Data.a $19,$47,$19,$44,$18,$44,$1B,$43,$18,$40,$1A,$43,$1C,$48,$1D,$4B
      Data.a $1E,$4B,$22,$49,$25,$4C,$25,$4E,$27,$51,$27,$0D,$90,$0E,$91,$0E
      Data.a $92,$0E,$93,$0E,$92,$0F,$91,$0F,$90,$0F,$8F,$0F,$90,$0F,$8E,$0F
      Data.a $8D,$0E,$8E,$0E,$8F,$0E,$10,$42,$0F,$43,$0F,$41,$10,$40,$10,$3E
      Data.a $11,$3E,$10,$3F,$0F,$3E,$0F,$3C,$0F,$3C,$0E,$3D,$0E,$3C,$0E,$3D
      Data.a $0D,$3F,$0D,$41,$0E,$42,$0E,$0F,$8D,$0F,$8E,$0F,$8E,$10,$8D,$12
      Data.a $8C,$13,$8A,$12,$8B,$12,$8B,$11,$8C,$10,$8A,$10,$89,$10,$88,$0F
      Data.a $89,$0F,$8A,$0F,$8C,$10,$10,$38,$1D,$37,$1D,$36,$1E,$33,$1E,$2F
      Data.a $1E,$2E,$1C,$2E,$1A,$2C,$1A,$2F,$18,$30,$18,$31,$19,$32,$18,$33
      Data.a $19,$34,$18,$36,$1A,$38,$1C,$0C,$7E,$38,$81,$37,$80,$34,$7E,$30
      Data.a $7D,$2E,$7C,$2D,$7C,$2F,$7C,$31,$7D,$30,$7D,$32,$7E,$34,$7D,$37
      Data.a $0A,$33,$14,$32,$13,$33,$14,$34,$15,$31,$16,$31,$15,$2F,$15,$2E
      Data.a $14,$2D,$14,$2E,$14,$0A,$AC,$13,$AF,$13,$B0,$14,$AB,$15,$A9,$16
      Data.a $A9,$17,$A7,$18,$A7,$17,$A8,$15,$AA,$14,$09,$E6,$85,$E2,$82,$DF
      Data.a $81,$DF,$84,$E0,$86,$E3,$8A,$E5,$8D,$E8,$8B,$EB,$8E,$09,$CF,$7D
      Data.a $D1,$7A,$D3,$77,$D4,$78,$D4,$7A,$D4,$7F,$D2,$85,$D0,$85,$CE,$81
      Data.a $07,$A2,$0E,$A3,$0E,$A4,$0E,$A4,$0D,$A3,$0D,$A2,$0D,$A2,$0E,$08
      Data.a $70,$24,$70,$23,$6F,$23,$70,$22,$71,$23,$73,$22,$75,$22,$75,$24
      Data.a $07,$2A,$21,$28,$22,$29,$23,$2A,$23,$2B,$23,$2C,$22,$2B,$22,$07
      Data.a $39,$14,$37,$14,$37,$15,$39,$15,$3A,$15,$3B,$14,$39,$13,$08,$41
      Data.a $15,$44,$15,$45,$14,$47,$15,$44,$16,$41,$16,$3F,$16,$3D,$14,$07
      Data.a $46,$3F,$44,$3E,$42,$40,$42,$45,$43,$40,$44,$42,$46,$40,$07,$FA
      Data.a $BA,$FC,$BB,$FB,$BD,$FA,$C0,$F8,$C2,$F7,$C1,$F8,$BF,$07,$2B,$19
      Data.a $2D,$17,$2A,$16,$27,$16,$27,$18,$27,$1A,$2A,$1A,$06,$31,$27,$2F
      Data.a $27,$2E,$27,$2E,$29,$2C,$29,$30,$29,$06,$FB,$B2,$FC,$B4,$FE,$B6
      Data.a $FE,$B8,$FC,$B9,$FC,$B4,$06,$39,$18,$38,$19,$3A,$1A,$3B,$19,$3B
      Data.a $17,$38,$17,$06,$A5,$4C,$A6,$47,$A5,$43,$A7,$40,$A2,$3F,$A3,$46
      Data.a $06,$90,$11,$91,$11,$91,$12,$90,$12,$8F,$12,$8F,$11,$06,$C8,$7D
      Data.a $C9,$7F,$CB,$85,$C9,$85,$C6,$7C,$C5,$79,$06,$7A,$32,$79,$34,$79
      Data.a $36,$7A,$37,$7C,$34,$7B,$31,$05,$A8,$18,$A9,$1B,$A7,$1C,$A6,$1B
      Data.a $A5,$19,$06,$E5,$48,$E3,$4F,$E0,$50,$DE,$4F,$E2,$4C,$E4,$45,$05
      Data.a $56,$3B,$59,$3D,$5A,$3C,$59,$3A,$58,$37,$05,$39,$10,$38,$11,$36
      Data.a $10,$35,$10,$37,$0F,$05,$4E,$E3,$4B,$E5,$4C,$E8,$46,$E8,$3B,$E7
      Data.a $05,$D7,$7F,$D6,$7F,$D7,$83,$D6,$85,$D5,$80,$04,$3B,$13,$3D,$13
      Data.a $3F,$13,$3F,$14,$05,$A4,$96,$A1,$A3,$9F,$9B,$A1,$96,$A3,$92,$04
      Data.a $05,$21,$04,$22,$03,$20,$01,$1F,$04,$3F,$17,$3E,$19,$3C,$19,$3C
      Data.a $17,$04,$44,$23,$47,$25,$44,$25,$42,$26,$04,$A0,$0D,$A0,$0E,$A1
      Data.a $0D,$A2,$0D,$04,$50,$CC,$50,$CE,$4E,$CD,$4E,$CC,$04,$3A,$33,$3C
      Data.a $38,$3A,$36,$3A,$33,$04,$E0,$DD,$D8,$DF,$D1,$DE,$CB,$DD,$04,$BB
      Data.a $DF,$B5,$E3,$AB,$E0,$A6,$DE,$03,$47,$61,$44,$60,$49,$61,$04,$D0
      Data.a $8C,$CC,$8A,$CD,$89,$D1,$8B,$04,$D7,$69,$D8,$6D,$D6,$6D,$D6,$66

   EndDataSection