Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
A Beautiful accident! Weird, take a look..
#21
Quote:Smile Heh, its 1 PSET, if I clear, it wouln't look half as pretty..

I'm embarking on 3D, so I havn't got to lookup tables, what are they BTW, you on TYPEs or something? :???:



This is a lut for sin/cos...


Code:
Dim tSin(359) as SINGLE, tCos(359) as SINGLE

For i = 0 to 359
   tSin(i) = SIN(i*(Pi/180))
   tCos(i) = COS(i*(Pi/180))
Next

   'rx! = ax * 3.14/180
   'ry! = ay * 3.14/180
   'rz! = az * 3.14/180
   'totally eliminate that code...

    ' Just use it this way...
   cx! = tCos(ax)
   sx! = tSin(ax)
   cy! = tCos(ay)
   sy! = tSin(ay)
   cz! = tCos(az)
   sz! = tSin(az)
Reply
#22
correct me if i'm wrong, but lookuptables for cos and sinus on nowadays machines is a waste of time/space. no need for those as the fpu sin and cos should be faasst enough. somebody correct me
quote="NecrosIhsan"]
[Image: yagl1.png]
[/quote]
Reply
#23
Smile right, okay, I see what you mean, heh, thats simple.. :wink:
Kevin (x.t.r.GRAPHICS)

[Image: 11895-r.png]
Reply
#24
Quote:correct me if i'm wrong, but lookuptables for cos and sinus on nowadays machines is a waste of time/space. no need for those as the fpu sin and cos should be faasst enough. somebody correct me

Yes, for most mortal applications.... BUT.... if you are trying for every last possible bit of speed they can't be beat.


(So that's why we keep all those old programming books :-) )
Reply
#25
As far as I know, the majority of commercial games use lookup tables. Carmack probably used them in Doom 3.
.14159265358979323846264338327950288419716939937510582709445
Glarplesnarkleflibbertygibbertygarbethparkentalelelangathaffendoinkadonkeydingdonkaspamahedron.
Reply
#26
Smile Yeah, makes since, load all the numbers into that table, in it just grabs 'em insted of pausing to generate the number,. I get the point, yep, and I plan to use it to Big Grin ...
Kevin (x.t.r.GRAPHICS)

[Image: 11895-r.png]
Reply
#27
moderday flaoitng calulation are up there with interger calulation i can't see it effect speed all that much.
Reply
#28
It does though. Check it out. I modified his demo to use the lut and it got a boost of about 300,000 "fps"... :lol:


Code:
SCREEN 19, 32, 2' ,-1 I can't run gfxlib in full screen :(

'mangleberry pie    :D
#DEFINE Pi 3.14 '15926535897932

x! = 150
y! = 150
z! = 150

Dim tSin(360) as Single, tCos(360) as Single

For i = 0 to 360
tSin(i) = SIN(i * (Pi/180))
tCos(i) = COS(i * (Pi/180))
Next

centx = 400
centy = 300
LENS = 256 ' centz

ax = 0
ay = 0
az = 0
T! = TIMER
DO
   press$ = INKEY$  
   cx! = tCos(ax)
   sx! = tSin(ax)
   cy! = tCos(ay)
   sy! = tSin(ay)
   cz! = tCos(az)
   sz! = tSin(az)
  

   ny! = (y! * cx!)-(z! * sx!)
   nz! = (z! * cx!)+(y! * sx!)
   y! = ny!
   z! = nz!
   nz! = (z! * cy!)-(x! * sy!)
   nx! = (x! * cy!)+(z! * sy!)
   x! = nx!
   nx! = (x! * cz!)-(y! * sz!)
   ny! = (y! * cz!)+(x! * sz!)
  
   ax += 1
   If ax > 360 then ax -= 360
  
   ay += 1
   If ay > 360 then ay -= 360
  
   az += 1
   If az > 360 then az -= 360
  
   PSET (centx + nx!, centy - ny!), RGB(z!, z!, z! )
   F += 1
LOOP UNTIL press$ = CHR$(27)
PRINT "Average FPS:"; F / (TIMER - T!)
SLEEP
Reply
#29
:o AH!!!!

It ran at 150,000 FPS on mine, 109,000 FPS faster!!!!!!!111 :o (Numbers are rounded)

:wink: Cool!!
Kevin (x.t.r.GRAPHICS)

[Image: 11895-r.png]
Reply
#30
Cool!!!!

Try to play with colors. Like adding thge color you want plus the color on screen limiting the RGB components to 255, and you'd get roughly a swirling hazy effect. :*)
y smiley is 24 bit.
[Image: anya2.jpg]

Genso's Junkyard:
http://rel.betterwebber.com/
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)