home *** CD-ROM | disk | FTP | other *** search
AMOS Source Code | 1993-06-16 | 2.8 KB | 147 lines |
- ' ---------------------------------
- '
- ' AMOSPro Compiler Example
- '
- ' 3D dotted Ball 1
- '
- ' By Jean-Baptiste BOLCATO
- '
- ' (c) 1993 Europress Software Ltd.
- '
- ' ---------------------------------
- '
- ' ------------------------------------------------------
- ' Remark: A real time calculated 3D dotted Ball.
- '
- ' Average Acceleration: 400 %
- '
- ' Test configuration: A1200, 6Mb
- ' Original AMOS Compiler: 300 %
- ' ------------------------------------------------------
-
-
- ' ---- Variables Init ----
-
- Set Buffer 30
- ' Lens paramenter
- DIST0=300 : ZOM=250
-
- ' Radius of ball
- R=100
-
- ' Time for loops
- TIME=1000
-
- ' Options screen
- Screen Open 0,320,32,2,Hires
- Palette 0,$FFF
-
- ' Number of x,y steps
- Input "Grid Radius subdivision (8 to 48)?:";NS1
- If NS1<8
- NS1=8
- Else
- If NS1>48
- NS1=48
- End If
- End If
- Input "Grid Height subdivision (8 to 48)?:";NS2
- If NS2<8
- NS2=8
- Else
- If NS2>48
- NS2=48
- End If
- End If
-
- ' Init coords
- On Error Goto _EXIT
- Degree
- NP=NS1*NS2
- Dim X3D(NP),Y3D(NP),Z3D(NP)
- SJ#=2*R : SJ#=SJ#/(NS2-1)
- SI#=360 : SI#=SI#/NS1
- K=0
- For J#=-R To R Step SJ#
- For I#=1 To 360-SI Step SI#
- Inc K
- X3D(K)=Sqr(R*R-(J#*J#))*Cos(I#)
- Y3D(K)=Sqr(R*R-(J#*J#))*Sin(I#)
- Z3D(K)=J#
- Next I#
- Next J#
- _EXIT:
- NP=K-1
-
- ' ---- Screen Init ----
-
- Screen Open 0,320,200,2,Lowres
- Palette 0,$FFF
- Curs Off : Hide
- Cls 0 : Ink 1
- Double Buffer : Autoback 0
-
- ' ---- Main Loop ----
-
- Timer=0
- Repeat
-
- Cls 0
-
- ' Increment rotation angles
- Add TETA,1,0 To 359
- Add PHI,2,0 To 359
-
- ' Precalculation 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
-
- ' Modify zoom
- DIST=DIST0+SPHI
-
- ' Draw ball backbground
- R3D=(R*ZOM)/DIST
- Ink 1 : Circle 160,100,R3D-1 : Paint 160,100 : Ink 0
-
- For I=1 To NP
-
- ' Calculation of rotated 3D coords for each displayable
- ' point of the ball (Z<=0)
- ' ( /256 to bring back COS and SIN beetween 0->1)
- ' Rotation (X-Z with PHI) & rotation (X-Y with TETA)
- Z=Z3D(I)*CPHI-Y3D(I)*SPHI
- If Z<=0
- Z=Z/256
- Y=(Z3D(I)*SPHI+Y3D(I)*CPHI)/256
- X=(X3D(I)*CTETA-Y*STETA)/256
- Y=(X3D(I)*STETA+Y*CTETA)/256
-
- ' Calculation of screen coords of A,B,C,D and draw lines
- X=(X*ZOM)/(DIST+Z) : Add X,160
- Y=(Y*ZOM)/(DIST+Z) : Add Y,100
- Plot X,Y
- End If
- Next I
-
- Screen Swap
- Wait Vbl
- Inc N
-
- Until Timer>=TIME
- T#=Timer
-
- ' --- Final Report ---
-
- Autoback 1 : Cls 0 : Paper 0 : Pen 1
- Print " Needs";T#/50;" seconds for";N;" loops."
- V#=T#/N
- Print " ( =";V#;" VBLs )"
- Print
- Print " Press mouse key to end"
- Repeat
- Multi Wait
- Until Mouse Key or(Inkey$<>"")
- End