It is currently Mon Dec 10, 2018 4:16 am

All times are UTC + 1 hour




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: How to Vectorstars (C2P)
PostPosted: Wed Sep 16, 2009 2:53 am 
Offline
Enthusiast
Enthusiast

Joined: Tue Oct 05, 2004 9:05 pm
Posts: 103
Location: germany
another fx, 3d vectorstars
we use the chunky to planar engine
(on winuae with amisys4 and emulated gfxcard is it ultrafast)

Code:
#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

_________________
Kultstudio


Top
 Profile  
Reply with quote  
 Post subject: Re: How to Vectorstars (C2P)
PostPosted: Thu Apr 08, 2010 4:40 am 
Offline
New User
New User

Joined: Tue Apr 06, 2010 4:01 am
Posts: 3
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 .

_________________
r4 revolution


Top
 Profile  
Reply with quote  
 Post subject: Re: How to Vectorstars (C2P)
PostPosted: Thu Apr 08, 2010 8:41 am 
Offline
Addict
Addict
User avatar

Joined: Sat Feb 19, 2005 2:46 pm
Posts: 1749
Location: Pas-de-Calais, France
It would be nice to post an optimised version, because my eyes are hurting when I see that. :'(


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  

 


Powered by phpBB © 2008 phpBB Group
subSilver+ theme by Canver Software, sponsor Sanal Modifiye