'=========================================================================== ' Subject: 3D DOT ROTATING CUBE Date: 01-20-99 (08:16) ' Author: The ABC Programmer Code: BEC ' Origin: voxel@edmc.net Packet: BASEC.ABC '=========================================================================== ' 3D Dot Rotating Cube for BASEC v0.15 [DOS] by William Yu ' Requires GRAPHICS.LIB from BEC-MM.ZIP 'Variable list for 3DROT.BAS DIM NOP% AS INTEGER DIM RADC AS SINGLE DIM I% AS INTEGER DIM S% AS INTEGER DIM XP! AS SINGLE DIM YP! AS SINGLE DIM ZP! AS SINGLE DIM SV AS SINGLE DIM ANXY AS SINGLE DIM CV AS SINGLE DIM TX% AS INTEGER DIM TY% AS INTEGER DIM ANXZ AS SINGLE DIM TZ% AS INTEGER DIM ANYZ AS SINGLE DIM CX0% AS INTEGER DIM CY0% AS INTEGER DIM CZ0% AS INTEGER DIM CX1% AS INTEGER DIM CY1% AS INTEGER DIM CZ1% AS INTEGER DIM CX2% AS INTEGER DIM CY2% AS INTEGER DIM CZ2% AS INTEGER DIM CX3% AS INTEGER DIM CY3% AS INTEGER DIM CZ3% AS INTEGER DIM SK AS SINGLE DIM X% AS INTEGER DIM Y% AS INTEGER DIM BANAN AS SINGLE '=========================================================================== ' Subject: 3D MATRIX ROTATIONS Date: 03-22-96 (07:45) ' Author: Peder Brynolf Code: QB, QBasic, PDS ' Origin: pbrynolf@dataphone.se Packet: GRAPHICS.ABC '=========================================================================== 'This one shows how to do some 3d matris rotations. CLS PRINT "Typ 125 okompilerad f”r 1vbl" PRINT "Typ 220 kompilerad f”r 1vbl" PRINT : PRINT "P† en 66a ass†!" PRINT INPUT "Antal punkter:"; NOP% SCREEN 13 RANDOMIZE TIMER REM NOP% = 150 DIM OX%(NOP%) AS INTEGER DIM OY%(NOP%) AS INTEGER 'DIM PFX(NOP%) AS INTEGER, PTX(NOP%) AS INTEGER 'DIM PFY(NOP%) AS INTEGER 'DIM PTY(NOP%) AS INTEGER 'DIM PFZ(NOP%) AS INTEGER 'DIM PTZ(NOP%) AS INTEGER DIM XP(NOP%) AS SINGLE DIM YP(NOP%) AS SINGLE DIM ZP(NOP%) AS SINGLE DIM SX%(NOP%) AS INTEGER DIM SY%(NOP%) AS INTEGER DIM SZ%(NOP%) AS INTEGER DIM KX(3) AS INTEGER DIM KY(3) AS INTEGER DIM KZ(3) AS INTEGER DIM CX%(3) AS INTEGER DIM CY%(3) AS INTEGER DIM CZ%(3) AS INTEGER RADC = 0.01745328 ' BASEC does not support Palette... yet. 'FOR I% = 0 TO 63 ' PALETTE I%, I% + I% * 256 + I% * 65536 'NEXT I% FOR I% = 0 TO 3 READ KX(I%), KY(I%), KZ(I%) NEXT I% FOR I% = 0 TO NOP% S% = RND * 6 IF S% = 0 THEN XP(I%) = RND: YP(I%) = RND: ZP(I%) = 0 IF S% = 1 THEN XP(I%) = RND: YP(I%) = RND: ZP(I%) = 1 IF S% = 2 THEN XP(I%) = RND: YP(I%) = 0: ZP(I%) = RND IF S% = 3 THEN XP(I%) = RND: YP(I%) = 1: ZP(I%) = RND IF S% = 4 THEN XP(I%) = 0: YP(I%) = RND: ZP(I%) = RND IF S% = 5 THEN XP(I%) = 1: YP(I%) = RND: ZP(I%) = RND NEXT I% DO FOR I% = 0 TO 3 CX%(I%) = KX(I%) + XP! CY%(I%) = KY(I%) + YP! CZ%(I%) = KZ(I%) + ZP! NEXT I% REM *** ROTATE X/Y *** SV = SIN(RADC * ANXY) CV = COS(RADC * ANXY) FOR I% = 0 TO 3 TX% = SV * CX%(I%) + CV * CY%(I%) TY% = -SV * CY%(I%) + CV * CX%(I%) CX%(I%) = TX% CY%(I%) = TY% NEXT I% REM *** ROTATE X/Z *** SV = SIN(RADC * ANXZ) CV = COS(RADC * ANXZ) FOR I% = 0 TO 3 TX% = SV * CX%(I%) + CV * CZ%(I%) TZ% = -SV * CZ%(I%) + CV * CX%(I%) CX%(I%) = TX% CZ%(I%) = TZ% NEXT I% REM *** ROTATE Y/Z *** SV = SIN(RADC * ANYZ) CV = COS(RADC * ANYZ) FOR I% = 0 TO 3 TY% = SV * CY%(I%) + CV * CZ%(I%) TZ% = -SV * CZ%(I%) + CV * CY%(I%) CY%(I%) = TY% CZ%(I%) = TZ% NEXT I% FOR I% = 1 TO 3 CX%(I%) = CX%(I%) - CX%(0) CY%(I%) = CY%(I%) - CY%(0) CZ%(I%) = CZ%(I%) - CZ%(0) NEXT I% CX0% = CX%(0) CY0% = CY%(0) CZ0% = CZ%(0) CX1% = CX%(1) CY1% = CY%(1) CZ1% = CZ%(1) CX2% = CX%(2) CY2% = CY%(2) CZ2% = CZ%(2) CX3% = CX%(3) CY3% = CY%(3) CZ3% = CZ%(3) FOR I% = 0 TO NOP% XP! = XP(I%) YP! = YP(I%) ZP! = ZP(I%) SX%(I%) = CX0% + CX1% * XP! + CX2% * YP! + CX3% * ZP! SY%(I%) = CY0% + CY1% * XP! + CY2% * YP! + CY3% * ZP! SZ%(I%) = CZ0% + CZ1% * XP! + CZ2% * YP! + CZ3% * ZP! IF SY%(I%) > 80 THEN SY%(I%) = 80 NEXT I% FOR I% = 0 TO NOP% SK = 300 / (300 + SZ%(I%)) SX%(I%) = SX%(I%) * SK SY%(I%) = SY%(I%) * SK NEXT I% FOR I% = 0 TO NOP% X% = SX%(I%) + 160 Y% = SY%(I%) + 100 PSET (OX%(I%), OY%(I%)), 0 OX%(I%) = X% OY%(I%) = Y% PSET (X%, Y%), 32 - SZ%(I%) / 8 NEXT I% REM WK: IF INKEY$ = "" THEN GOTO WK ANXY = ANXY - .25 ANXZ = ANXZ - .5 ANYZ = ANYZ - 1 XP! = SIN(RADC * BANAN * 1.7315) * 40 YP! = SIN(RADC * BANAN * 2.3125) * 40 ZP! = SIN(RADC * BANAN * 3.2357) * 200 BANAN = BANAN + .5 REM *** Wait vbl *** 'WVBL: A% = INP(&H3DA) ' A% = A% MOD 16 ' A% = A% / 16 ' IF A% <> 1 THEN GOTO WVBL LOOP UNTIL INKEY$ <> "" DATA 50,50,50, -50,50,50 ,50,-50,50, 50,50,-50 QUIT: END