How to Vectorstars (C2P)
Posted: Wed Sep 16, 2009 2:53 am
another fx, 3d vectorstars
we use the chunky to planar engine
(on winuae with amisys4 and emulated gfxcard is it ultrafast)
PB 2.9 source, PB4.0 source and datafields
we use the chunky to planar engine
(on winuae with amisys4 and emulated gfxcard is it ultrafast)
Code: Select all
#Width = 320
#Height = 256
InitChunky(9,1,1)
InitBitMap(0)
InitPalette(0)
initScreen(0)
*TagList = InitTagList(100)
AllocateLinearBitMap(0,#Width,#Height,8)
AllocateChunkyBuffer(0,#Width,#Height)
AllocateChunkyBuffer(1,#Width,#Height)
ResetTagList(#SA_Type, #CUSTOMSCREEN | #CUSTOMBITMAP )
AddTag(#SA_BitMap, BitMapID())
AddTag(#SA_Draggable, 0)
OpenScreen(0,320,256,8,*TagList)
CreatePalette(0,255)
palrgb(0,0,0,0)
palrgb(1,200,200,200)
DisplayPalette(0,ScreenID())
;setup the stars
Structure stars
x.w
y.w
z.w
EndStructure
NewList stars.stars()
For st=0 To 500 Step 2
AddElement(stars())
stars()\x = PeekW(?startablex+st)
stars()\y = PeekW(?startabley+st)
stars()\z = PeekW(?startablez+st)
Next
distance.l=800
cb.l=1
Repeat
cb.l=1-cb.l
UseChunkyBuffer(cb.l)
ChunkyCls(0)
vx + 1; X rotation speed
vy + 2; 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
ResetList(stars())
While NextElement(stars())
;peek the sinus/cosinus from the tables
;not faster than a array..but arrays does'nt work LOL
cosx=PeekL(?costable+(vx*4))
cosy=PeekL(?costable+(vy*4))
cosz=PeekL(?costable+(vz*4))
sinx=PeekL(?sintable+(vx*4))
siny=PeekL(?sintable+(vy*4))
sinz=PeekL(?sintable+(vz*4))
;"3d-engine" ^^
ty = ((stars()\y * cosx) - (stars()\z * sinx))/1000
tz = ((stars()\y * sinx) + (stars()\z * cosx))/1000
tx = ((stars()\x * cosy) - (tz * siny))/1000
tz = ((stars()\x * siny) + (tz * cosy))/1000
nx = 200 * (tx) / (distance - (tz)) + 160
ny = 128 - (200 * ty) / (distance - (tz))
nodraw=0
;shade or "back plot culling" For objects
;If tz<0:nodraw=1:EndIf
;test plot=inside screenkoordinates
If nx > 319 :nodraw=1:EndIf
If ny > 255 :nodraw=1:EndIf
If nx < 1 :nodraw=1:EndIf
If ny < 1 :nodraw=1:EndIf
If nodraw=0
ChunkyPlot(nx,ny,1)
EndIf
Wend
ChunkyToPlanar(ChunkyBufferID(),BitMapID(),#Height)
mb.w=MouseButtons()
Until mb.w=2
CloseScreen(0)
End
DisableDebugger
startablex:
IncludeBinary "dat/2003dstarsx"
startabley:
IncludeBinary "dat/2003dstarsy"
startablez:
IncludeBinary "dat/2003dstarsz"
sintable:
IncludeBinary "dat/sin1000";200word"
costable:
IncludeBinary "dat/cos1000";200word"
EnableDebugger
PB 2.9 source, PB4.0 source and datafields