eine möglichkeit "vectorstars" zu basteln (unoptimiert)
1-bitplane screen, rotiert 3 achsen, sin/cos vorberechnet, ausführbar mit aktueller amiblitzversion
1-bitplane screen, rotiert 3 achsen, sin/cos vorberechnet, ausführbar mit aktueller amiblitzversion
Code:
Statement xCls{a.l}
MOVE.l d0,a0 : ADD.l #40*256,a0
MOVEQ #0,d0 : MOVEQ #0,d1 : MOVEQ #0,d2 : MOVEQ #0,d3 : MOVEQ #0,d4
MOVEQ #0,d5 : MOVEQ #0,d6 : MOVE.l d0,a1 : MOVE.l d0,a2 : MOVE.l d0,a3
MOVE #255,d7
loop1:MOVEM.l d0-d6/a1-a3,-(a0):DBRA d7,loop1
AsmExit
End Statement
BitMap 0,320,256,1
BitMap 1,320,256,1
AGAPalRGB 0,0,32,22,33
AGAPalRGB 0,1,200,200,200
NEWTYPE.ball
x.q
y
z
nx
ny
End NEWTYPE
Dim List balls.ball(50)
While AddLast(balls())
balls()\x=Rnd(40)-20
balls()\y=Rnd(40)-20
balls()\z=Rnd(40)-20
Wend
distance.w = 20
Dim Costable(360)
Dim Sintable(360)
For i=0 To 359
Costable(i)=Int( Cos(i*0.017453) *1024 )
Sintable(i)=Int( Sin(i*0.017453) *1024 )
Next
BLITZ
InitCopList 0,44,256,$10001,8,2,0
Mouse On
CreateDisplay 0
DisplayBitMap 0,0:DisplayPalette 0,0
Use BitMap db
While Joyb(0)=0
VWait
DisplayBitMap 0,db
db=1-db
Use BitMap db
xCls{Peek.l (Addr BitMap(db)+8)}
vx + 2; X rotation speed
vy + 1; Y rotation speed
vz + 1; Z rotation speed
If vx>359:vx=1:EndIf
If vy>359:vy=1:EndIf
If vz>359:vz=1:EndIf
distance=10+MouseY
cosx=Costable(vx)
cosy=Costable(vy)
cosz=Costable(vz)
sinx=Sintable(vx)
siny=Sintable(vy)
sinz=Sintable(vz)
ResetList balls()
While NextItem(balls())
;simply move stars
balls()\x+1
If balls()\x>20 Then balls()\x=-20
;"3d-engine" ^^
ty = ((balls()\y * cosx) - (balls()\z * sinx))/1024
tz = ((balls()\y * sinx) + (balls()\z * cosx))/1024
tx = ((balls()\x * cosy) - (tz * siny))/1024
tz = ((balls()\x * siny) + (tz * cosy))/1024
balls()\nx = ( 200 * tx) / (distance - tz ) + 160
balls()\ny = ( 200 * ty) / (distance - tz) + 127
nodraw=0
If balls()\nx > 319 : nodraw=1 : EndIf
If balls()\ny > 255 : nodraw=1 : EndIf
If balls()\nx < 1 : nodraw=1 : EndIf
If balls()\ny < 1 : nodraw=1 : EndIf
If nodraw=0
Plot balls()\nx,balls()\ny,1
EndIf
Wend
Wend
End