Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Floormapping optimization.
#11
I don't know anything about floormapping. But i can tell you that messing with those loops will hardly do anything. It's algorithm that gives speed and not implementation. If i were you, i'd interpolate betwen the first and the last point every scanline. That way all you have in the loop is just 2 adds.
oship me and i will give you lots of guurrls and beeea
Reply
#12
I don't understand "interpolation" at all. Will you explain it to me?
am an asshole. Get used to it.
Reply
#13
Interpolate is to calculate the values in between two points using some kind of mathematical approach. This is what is done to do smooth zooms, for example:

Imagine that you have an original image with those pixels (X is a pixel):

XXX
XXX
XXX

and you want a zoomed image, you just do...

XoXoX
opopo
XoXoX
opopo
XoXoX

where o can be, for example, a linear interpolation between two adjacent Xs ( (X1+X2)/2 for example ) and p just the same but between two adjacent 'o' or just with two X in diagonal, or maybe four, depending on your algorithm.

That is just the idea behind interpolation, applying that in a floor map... I have no idea... Blitz, can you illuminate us?
SCUMM (the band) on Myspace!
ComputerEmuzone Games Studio
underBASIC, homegrown musicians
[img]http://www.ojodepez-fanzine.net/almacen/yoghourtslover.png[/i
Reply
#14
this is what i would have liked to do, but i couldn't figure out what the POKE command was doing, so I couldn't really mess with it.

*peace*

Meg.
Reply
#15
Well, this is a start...

Code:
'$DYNAMIC
DEFINT A-Z
DIM PIC(63, 63)
DIM buffer(32001) AS INTEGER
DIM Sine(1920) AS SINGLE, Cosine(1920) AS SINGLE
DIM Raylength(99) AS INTEGER

t# = TIMER
CameraHeight = 100
CameraDistance = 128

FOR i# = 0 TO 6.28165 STEP 6.28165 / 1920
     Sine(a) = SIN(i#)
     Cosine(a) = COS(i#)
     a = a + 1
NEXT i#

FOR y = 0 TO 63
FOR x = 0 TO 63
  PIC(x, y) = COS(x / 30) * SIN(y / 30) * 4 + 24
NEXT x
NEXT y

FOR y = 0 TO 99
     Raylength(y) = (CameraHeight / (CameraHeight - y)) * CameraDistance
NEXT y

SCREEN 13
buffer(0) = 2560: buffer(1) = 200
DEF SEG = VARSEG(buffer(0))

lsy& = 32004

DO
  PlayerY = PlayerY + 10

  FOR y = 98 TO 0 STEP -2
     FOR x = 0 TO 159 STEP 2
          xang = 320 + x
          vx = (ABS(Raylength(y) * Cosine(xang))) AND 63
          vy = (PlayerY + Raylength(y) * Sine(xang)) AND 63
          m = 320 * (99 - y)
        
          POKE lsy& + m + x, (PIC(vx, vy))
          POKE lsy& + m + (318 - x), (PIC(vx, vy))
          POKE lsy& - m + x, (PIC(vx, vy))
          POKE lsy& - m + (318 - x), (PIC(vx, vy))
     NEXT x
  NEXT y

  frames& = frames& + 1

  PUT (0, 0), buffer, PSET

LOOP UNTIL INKEY$ <> ""

COLOR 63: PRINT frames& / (TIMER - t#)
SYSTEM
Reply
#16
Alright then, calculate the x and y value of the first and the last value on a scanline, then calculate it's deltas ( how much they change each pixel ). After that you add those deltas to x and y each pixel and you have x and y for each pixel Smile
Start of with floating point, once you've got it to work try with fixed point. If you're going to use long you might as well stick to floating point. But if you can get it to work with just integers then excellent. Try out 9.7 fixed point. That should work fine if starting value and the ending value of a scanline aren't too close to each other.

Code:
dim curx as single, cury as single
dim dudx as single, dudx as single

curx = x1
cury = y1
dudx = (x2-x1) / 320.0
dudy = (y2-y1) / 320.0

for  i = 0 to 319
    ''
    '' Do stuff
    ''


    ''
    '' Update x and y
    ''
    curx = curx + dudx
    cury = cury + dudy
next i
oship me and i will give you lots of guurrls and beeea
Reply
#17
And come on, lsy()? The things you do in the outerloops will hardly affect performance.
oship me and i will give you lots of guurrls and beeea
Reply
#18
replace lsy with its value inside the loop and watch the program not work...
Reply
#19
Well, that's cause QB assumes 32004 is an INTEGER. To make it long, just write 32004&
SCUMM (the band) on Myspace!
ComputerEmuzone Games Studio
underBASIC, homegrown musicians
[img]http://www.ojodepez-fanzine.net/almacen/yoghourtslover.png[/i
Reply
#20
awesome. cool to know. tho i really though i tried that, but knowing me i probably dreamed it or something...

:-D

*peace*

Meg.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)