PureBasic Forumhttps://www.purebasic.fr/english/ How to Vectorstars (C2P)https://www.purebasic.fr/english/viewtopic.php?f=10&t=39086 Page 1 of 1

 Author: xperience2003 [ Wed Sep 16, 2009 2:53 am ] Post subject: How to Vectorstars (C2P) another fx, 3d vectorstarswe use the chunky to planar engine(on winuae with amisys4 and emulated gfxcard is it ultrafast)Code:#Width  = 320#Height = 256InitChunky(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 starsStructure stars  x.w  y.w  z.wEndStructureNewList stars.stars()For st=0 To 500 Step 2AddElement(stars())stars()\x = PeekW(?startablex+st)stars()\y = PeekW(?startabley+st) stars()\z = PeekW(?startablez+st)Nextdistance.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=2CloseScreen(0)EndDisableDebuggerstartablex:IncludeBinary "dat/2003dstarsx"startabley:IncludeBinary "dat/2003dstarsy"startablez:IncludeBinary "dat/2003dstarsz"sintable:IncludeBinary "dat/sin1000";200word"costable:IncludeBinary "dat/cos1000";200word"EnableDebuggerPB 2.9 source, PB4.0 source and datafields

 Author: aarenlainey [ Thu Apr 08, 2010 4:40 am ] Post subject: Re: How to Vectorstars (C2P) The Vector class provides the capability to implement a growable array of objects Latest Answer : A vector implements dynamic array, which can grow and shrink dynamically.It is similar to Arraylist with a difference that vector can be synchronized. it also contain some legacy methods. ...And you utilise very nicely . All the perimeter of vectors followed correctly and nice logic .

 Author: djes [ Thu Apr 08, 2010 8:41 am ] Post subject: Re: How to Vectorstars (C2P) It would be nice to post an optimised version, because my eyes are hurting when I see that. :'(

 Page 1 of 1 All times are UTC + 1 hour Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Grouphttp://www.phpbb.com/