home *** CD-ROM | disk | FTP | other *** search
AMOS Source Code | 1993-06-16 | 2.7 KB | 153 lines |
- ' ---------------------------------
- '
- ' AMOSPro Compiler Example
- '
- ' Linear 3D-cuboid
- '
- ' By Jean-Baptiste BOLCATO
- '
- ' (c) 1993 Europress Software Ltd.
- '
- ' ---------------------------------
- '
- ' -----------------------------------------------
- ' Remark: A nice little 3D-line cube!
- ' It's a simple effect and is calculated in real time.
- '
- ' Average Acceleration: 260 %
- '
- ' Test configuration: A1200, 6Mb
- '
- ' Original AMOS Compiler: 200 %
- ' -----------------------------------------------
-
-
- ' ---- Variables Init ----
-
- ' Ntsc test
- YMID=128-28*(Ntsc=True)
-
- ' Lens paramenter
- DIST=500 : ZOM=350
-
- ' Number of loops
- NL=100
-
- ' Init coords
- Restore _DATA_POINTS
- Read NP
- Dim XP(NP),YP(NP),ZP(NP)
- Dim XP2(NP),YP2(NP),ZP2(NP)
- For I=1 To NP
- Read XP(I),YP(I),ZP(I)
- Next I
-
- Restore _DATA_ARETES
- Read NA
- Dim P(NA,2)
- For I=1 To NA
- For J=1 To 2
- Read P(I,J)
- Next J
- Next I
-
- ' ---- Screen Init ----
-
- Screen Open 0,320,YMID*2,2,Lowres
- Palette 0,$FFF,$BBB,$444
- Curs Off : Hide : Cls 0
-
- Double Buffer
- Autoback 0
- Degree
-
- ' ---- Main Loop ----
-
- Timer=0
- For N=1 To NL
-
- Cls 0
-
- ' Increment rotation angles
- Add TETA,1,0 To 359
- Add PHI,2,0 To 359
-
- ' Orecalculation of COSs and SINs
- ' ( *256 to stay in integer mode (faster!))
- CPHI=Cos(PHI)*256
- SPHI=Sin(PHI)*256
- CTETA=Cos(TETA)*256
- STETA=Sin(TETA)*256
-
- ' Calculation of rotated 3D coords of all points
- ' ( /256 to bring back COS and SIN between 0->1)
- ' Rotation (X-Z with PHI) & rotation (X-Y with TETA)
- For I=1 To NP
- ZP2(I)=(ZP(I)*CPHI-YP(I)*SPHI)/256
- YP2(I)=(ZP(I)*SPHI+YP(I)*CPHI)/256
- XP2(I)=(XP(I)*CTETA-YP2(I)*STETA)/256
- YP2(I)=(XP(I)*STETA+YP2(I)*CTETA)/256
- Next I
-
- ' Calculation of A,B,C,D screen coords and draw lines
- For I=1 To NA
- P1=P(I,1)
- P2=P(I,2)
- X2=160+(XP2(P2)*ZOM)/(DIST+ZP2(P2))
- Y2=YMID+(YP2(P2)*ZOM)/(DIST+ZP2(P2))
- If P1=0
- Draw To X2,Y2
- Else
- X1=160+(XP2(P1)*ZOM)/(DIST+ZP2(P1))
- Y1=YMID+(YP2(P1)*ZOM)/(DIST+ZP2(P1))
- Draw X1,Y1 To X2,Y2
- End If
- Next I
- Screen Swap
- Wait Vbl
-
- Next N
- T#=Timer
-
- ' --- Final Report ---
-
- Autoback 1 : Cls 0 : Paper 0 : Pen 1
- Print " Needs";T#/50;" seconds for";NL;" loops."
- V#=T#/NL
- Print " ( =";V#;" VBLs )"
- Print
- Print " Press mouse key to end"
- Repeat
- Multi Wait
- Until Mouse Key or(Inkey$<>"")
- End
-
- ' ---- Cube Data ----
-
- _DATA_POINTS:
- Data 8
-
- Data -100,-100,-100
- Data 100,-100,-100
- Data 100,100,-100
- Data -100,100,-100
-
- Data -100,-100,100
- Data 100,-100,100
- Data 100,100,100
- Data -100,100,100
-
- _DATA_ARETES:
- Data 12
- Data 1,2
- Data ,3
- Data ,4
- Data ,1
- Data ,5
- Data ,6
- Data ,7
- Data ,8
- Data ,5
- Data 7,3
- Data 6,2
- Data 4,8