home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
AMOS PD CD
/
amospdcd.iso
/
sourcecode
/
graphics
/
vectors.amos
/
vectors.amosSourceCode
< prev
Wrap
AMOS Source Code
|
1991-02-14
|
4KB
|
164 lines
Screen Open 0,320,200,2,Lowres : Flash Off : Curs Off : Hide On : Cls 0
Music 1 : Palette 0,$FFC
NUMPOINTS=8 : NUMLINES=12
Gosub STRIPES
Dim X#(14),Y#(14),Z#(14),XX(14),YY(14)
Dim F1(16),F2(16)
'
'set Degree mode and precalculate values for sin and cos of
' rotation angle ( 2 degrees)
'
Degree : CS#=Cos(2)*1.0006 : SN#=Sin(2)*1.0006
'
'
' D = Vanishing point on Z Axis
'
' Try changing D. The Lower the value, the closer the observer is to the
' object.
D=6
' Set for manual screen swapping
Double Buffer : Autoback 0
Restore CDAT
For A=1 To NUMPOINTS
Read X#(A),Y#(A),Z#(A)
Next
'
For A=1 To NUMLINES
Read F1(A),F2(A)
Next
'
'
' Data for ponts in 3D space (X,Y,Z)
' must range from -1 to +1
'
'
CDAT:
Data -1,-1,-1,1,-1,-1,1,1,-1,-1,1,-1
Data -1,-1,1,1,-1,1,1,1,1,-1,1,1
'
'
' Data for connecting lines.
'
' ie pt.1 connected to pt. 2
' pt.2 connected to pt. 3 etc.
Data 1,2,2,3,3,4,4,1,5,6,6,7,7,8,8,5,1,5,2,6,3,7,4,8
'
'ROTATIONS
'=========
'The simple routine below rotates around 2 of 3 axes at once.
'The formulae for rotation are simple. See ROTX,ROTY,ROTZ
'to see how its done.
'
Repeat
ROT:
Add R,1,1 To 100
For A=1 To 14
If R<33
Gosub ROTX
Gosub ROTY
Else If R>=33 and R<=66
Gosub ROTZ :
Gosub ROTY
Else
Gosub ROTX :
Gosub ROTZ
End If
End If
Next A
'
'DISPLAY CUBE
'
DISP:
A=1
While A<(NUMPOINTS+1)
'convert Z factor of a point into x and y coords
XX(A)=((X#(A)*D)/(Z#(A)+D))*50
YY(A)=((Y#(A)*D)/(Z#(A)+D))*50
' translation to middle of screen.
XX(A)=XX(A)+160
YY(A)=YY(A)+100
Inc A
Wend
'
' Clear screen now.
Cls 0
A=1
'
' draw lines
'
While A<(NUMLINES+1)
Draw XX(F1(A)),YY(F1(A)) To XX(F2(A)),YY(F2(A))
Inc A
Wend
'
'
Screen Copy Logic To Physic : Wait Vbl
'
Until Mouse Key
Music Off : End
'
'
' Rotation Subroutines
'
'
ROTZ:
X#(A)=X#(A)*CS#-Y#(A)*SN#
Y#(A)=Y#(A)*CS#+X#(A)*SN#
Return
'
ROTY:
X#(A)=X#(A)*CS#-Z#(A)*SN#
Z#(A)=Z#(A)*CS#+X#(A)*SN#
Return
'
ROTX:
Y#(A)=Y#(A)*CS#-Z#(A)*SN#
Z#(A)=Z#(A)*CS#+Y#(A)*SN#
Return
'
STRIPES:
Set Rainbow 0,1,280,"","",""
Rainbow 0,0,0,280
Colour Back 0
Restore RDATA
For C=0 To 279 : Read CVA : Rain(0,C)=CVA
Next C : View
Return
RDATA:
Data $0,$0,$0,$111,$222,$333,$444,$555
Data $666,$777,$888,$999,$AAA,$BBB,$CCC,$DDD
Data $EEE,$FFF,$FFF,$EEE,$DDD,$CCC,$BBB,$AAA
Data $999,$888,$777,$666,$555,$444,$333,$222
Data $300,$200,$300,$400,$500,$600,$700,$800
Data $900,$A00,$B00,$C00,$D00,$E00,$F00,$F00
Data $E00,$D00,$C00,$B00,$A00,$900,$800,$700
Data $600,$500,$400,$300,$200,$20,$30,$40
Data $50,$60,$70,$80,$90,$A0,$B0,$C0
Data $D0,$E0,$F0,$F0,$E0,$D0,$C0,$B0
Data $A0,$90,$80,$70,$60,$50,$40,$30
Data $30,$0,$1,$2,$3,$4,$5,$6
Data $7,$8,$9,$A,$B,$C,$D,$E
Data $F,$F,$E,$D,$C,$B,$A,$9
Data $8,$7,$6,$5,$4,$3,$2,$1
Data $0,$0,$22,$33,$44,$55,$66,$77
Data $88,$99,$AA,$BB,$CC,$DD,$EE,$FF
Data $FF,$EE,$DD,$CC,$BB,$AA,$99,$88
Data $77,$66,$55,$44,$33,$22,$110,$220
Data $330,$440,$550,$660,$770,$880,$990,$AA0
Data $BB0,$CC0,$DD0,$EE0,$FF0,$FF0,$EE0,$DD0
Data $CC0,$BB0,$AA0,$990,$880,$770,$660,$550
Data $440,$330,$220,$101,$202,$303,$404,$505
Data $606,$707,$808,$909,$A0A,$B0B,$C0C,$D0D
Data $E0E,$F0F,$F0F,$E0E,$D0D,$C0C,$B0B,$A0A
Data $909,$808,$707,$606,$505,$404,$303,$202
Data $111,$222,$333,$444,$555,$666,$777,$888
Data $999,$AAA,$BBB,$CCC,$DDD,$EEE,$FFF,$FFF
Data $EEE,$DDD,$CCC,$BBB,$AAA,$999,$888,$777
Data $666,$555,$444,$333,$222,$300,$200,$300
Data $400,$500,$600,$700,$800,$900,$A00,$B00
Data $C00,$D00,$E00,$F00,$F00,$E00,$D00,$C00
Data $B00,$A00,$900,$800,$700,$600,$500,$400
Data $300,$200,$20,$30,$40,$50,$60,$70
Data $80,$90,$A0,$B0,$C0,$D0,$E0,$F0
Data $F0,$0,$0,$0,$0,$0,$0,$0
Rem