View previous topic - View next topic |
Author |
Message |
XMark Guitar playin' black mage
Joined: 30 May 2002 Posts: 870 Location: New Westminster, BC, Canada
|
Posted: Sat Dec 06, 2003 2:15 am Post subject: |
[quote] |
|
Yeah, what I was gonna do is release it as a tutorial on rpgdx.net. So anyone can do whatever they want with it :) _________________ Mark Hall
Abstract Productions
I PLAYS THE MUSIC THAT MAKES THE PEOPLES FALL DOWN!
|
|
Back to top |
|
|
XMark Guitar playin' black mage
Joined: 30 May 2002 Posts: 870 Location: New Westminster, BC, Canada
|
|
Back to top |
|
|
Mandrake elementry school minded asshole
Joined: 28 May 2002 Posts: 1341 Location: GNARR!
|
Posted: Wed Dec 10, 2003 5:10 am Post subject: |
[quote] |
|
Ported.
Code: |
class mode7effect:
"This is a port of Xmark's Fake Floormapping"
def __init__(self):
self.ltable=zeros((240))
y = 0.0
changey=0.0
for x in range(240):
changey = 1.5 - float(x / 240.0)
y = y + changey
if (y > 239):
y = 239
self.ltable[x] = y
def draw(self, bmp, scrn):
for x in range(240):
xpos= x / 4
ypos=self.ltable[x]
swidth= 320 - (x / 2)
sheight=1
destx=0
desty=x
destwidth=320
destheight=1
gfx=pygame.transform.scale(bmp, (swidth, sheight))
scrn.blit(gfx, (destx, desty), (xpos, ypos, swidth, sheight))
|
_________________ "Well, last time I flicked on a lighter, I'm pretty sure I didn't create a black hole."-
Xmark
http://pauljessup.com
|
|
Back to top |
|
|
Terry Spectral Form
Joined: 16 Jun 2002 Posts: 798 Location: Dublin, Ireland
|
Posted: Wed Aug 03, 2005 1:08 pm Post subject: |
[quote] |
|
Bump.
I went looking for a floormapping tutorial on google earlier, but surprisingly, nothing turns up... Then I remembered this thread. (I was kinda hoping somebody had posted a link to the proper algorithm). I need to do it properly, with rotations. I've managed to get the effect working with vertical raycasting scans of the screen, but I've heard there is a much faster way to do it with horizontal scans...
Does anyone out there know the method off hand? Or could they point me to a tutorial on the subject?
[edit] quickly now, I'd like to print it off before I finish work :) _________________ http://www.distractionware.com
|
|
Back to top |
|
|
DeveloperX 202192397
Joined: 04 May 2003 Posts: 1626 Location: Decatur, IL, USA
|
Posted: Fri Aug 05, 2005 3:05 am Post subject: |
[quote] |
|
Chaotic Harmony wrote: | Bump.
I went looking for a floormapping tutorial on google earlier, but surprisingly, nothing turns up... Then I remembered this thread. (I was kinda hoping somebody had posted a link to the proper algorithm). I need to do it properly, with rotations. I've managed to get the effect working with vertical raycasting scans of the screen, but I've heard there is a much faster way to do it with horizontal scans...
Does anyone out there know the method off hand? Or could they point me to a tutorial on the subject?
[edit] quickly now, I'd like to print it off before I finish work :) |
I assume I didn't answer quick enough, but here:
Code: |
DEFINT A-Z
'FLRMAP - simple floormapper with diagram and explanation.
'by Toshi Horie March 2001
'based on Floormapper Ecliptorial and
'Qasir's constant-z optimization explanation.
SCREEN 13
CONST sc = 128 'fixed point scaling factor
'generate texture
DIM tex(63, 63)
FOR v = 0 TO 63
FOR u = 0 TO 63
tex(u, v) = u XOR v
NEXT
NEXT
'For coordinate system with the origin at the + sign,
'and up is +, and right is +, units in pixels.
h = -18
CONST d = 300
CONST ytop = 0, ybot = 99
'For coordinate system with the origin at B,
'and up direction is +, and right is positive.
'
'eye at y = h * = screen pixel to be plotted with texel o.
'screen at z = d o = floormap texel hit by ray from eye.
'floor at y = 0 v = non-tiled v texel coordinate of floormap.
'
' eye screen
' : | \ #
' : | \ #
' : | \ #
' : | \#
' : +---d----*
' h | # \
' : | # \
' : | y # \
' : | # \
' : | # \
' : B========#===========o================floor
' <---------- v ------->
'
' From this diagram, we can derive the equation for v
' using similar triangles. u can be derived likewise.
' u = x* h/(h-y)
' v = d* h/(h-y)
' In the lut!() array, we calculate the values for h/(h-y)
' for all y values inside the screen. The result is that
' only two (none if you use three tables) multiplications are
' needed per scanline.
DIM lut!(ytop TO ybot)
FOR y = ytop TO ybot
lut!(y) = CSNG(h) / (h - y)
NEXT
DEF SEG = &HA7D0 'start at x=0,y=100
'move forward in the z direction
FOR vofs = 0 TO 1000
p% = 0
FOR y = ytop TO ybot
v! = vofs + d * lut!(y): vv = v! AND 63
u! = -160 * lut!(y): du! = lut!(y)
FOR x = 0 TO 319
'PSET (x, y + 100), tex(u! AND 63, vv)
POKE p%, tex(u! AND 63, vv)
u! = u! + du!
p% = p% + 1
NEXT x
NEXT y
'WAIT &H3DA, 8
IF INKEY$ <> "" THEN END
NEXT vofs
END
|
Code: |
DEFINT A-Z
'FLRMAP2 - simple floormapper with diagram and explanation.
'by Toshi Horie March 2001
'based on Floormapper Ecliptorial and
'Qasir's constant-z optimization explanation.
SCREEN 13
CONST sc = 78 'fixed point scaling factor
CONST sc2 = 500 'fixed point scaling factor
CONST omax = 64 * sc2
'generate texture
DIM tex(63, 63)
FOR v = 0 TO 63
FOR u = 0 TO 63
tex(u, v) = u XOR v
NEXT
NEXT
'For coordinate system with the origin at the + sign,
'and up is +, and right is +, units in pixels.
h = -18
CONST d = 300
CONST ytop = 0, ybot = 99
'For coordinate system with the origin at B,
'and up direction is +, and right is positive.
'
'eye at y = h * = screen pixel to be plotted with texel o.
'screen at z = d o = floormap texel hit by ray from eye.
'floor at y = 0 v = non-tiled v texel coordinate of floormap.
'
' eye screen
' : | \ #
' : | \ #
' : | \ #
' : | \#
' : +---d----*
' h | # \
' : | # \
' : | y # \
' : | # \
' : | # \
' : B========#===========o================floor
' <---------- v ------->
'
' From this diagram, we can derive the equation for v
' using similar triangles. u can be derived likewise.
' u = x* h/(h-y)
' v = d* h/(h-y)
' In the lut!() array, we calculate the values for h/(h-y)
' for all y values inside the screen. The result is that
' only two (none if you use three tables) multiplications are
' needed per scanline.
DIM lut(ytop TO ybot)
FOR y = ytop TO ybot
lut(y) = CINT(sc2 * CSNG(h) / (h - y))
NEXT
DIM ulut(ytop TO ybot)
FOR y = ytop TO ybot
u! = -160& * CSNG(h) / (h - y)
IF u! < 0 THEN
DO
u! = u! + 64
LOOP UNTIL u! >= 0
ELSE
DO
u! = u! - 64
LOOP UNTIL u! < 64
END IF
ulut(y) = CINT(u! * sc2)
NEXT
DIM vlut(ytop TO ybot)
FOR y = ytop TO ybot
vlut(y) = CINT(sc * d * CSNG(h) / (h - y))
NEXT
'$DYNAMIC
DIM divs(0 TO 32000)
FOR y = 0 TO 32000
divs(y) = (y \ sc) AND 63
NEXT
DIM uu(0 TO omax)
FOR y = 0 TO omax
uu(y) = (y \ sc2) AND 63
NEXT y
DIM olut(0 TO 100)
FOR vofs = 0 TO 100
olut(vofs) = (vofs * sc)
NEXT vofs
DEF SEG = &HA7D0 'start at x=0,y=100
'move forward in the z direction
t1! = TIMER
FOR q = 1 TO 50
FOR vofs = 1 TO 64
p% = 0
FOR y = ytop TO ybot
vv = divs(olut(vofs) + vlut(y))
du = lut(y): u = ulut(y)
FOR x = 0 TO 319
IF u > omax THEN u = u - omax
POKE p%, tex(uu(u), vv)
u = u + du
p% = p% + 1
NEXT x
NEXT y
NEXT vofs
IF LEN(INKEY$) THEN EXIT FOR
NEXT q
t1! = TIMER - t1!
SCREEN 0: WIDTH 80
PRINT "FLRMAP2 - fixed point floormapper by Toshi"
PRINT vofs * q / (t1!); "fps"
END
|
Source located at this very useful resource site:
http://www.tekscode.com/~toshi/
Goodluck! _________________ Principal Software Architect
Rambling Indie Games, LLC
See my professional portfolio
|
|
Back to top |
|
|
Terry Spectral Form
Joined: 16 Jun 2002 Posts: 798 Location: Dublin, Ireland
|
|
Back to top |
|
|
DeveloperX 202192397
Joined: 04 May 2003 Posts: 1626 Location: Decatur, IL, USA
|
Posted: Fri Aug 05, 2005 7:01 pm Post subject: |
[quote] |
|
Chaotic Harmony wrote: | Thank you. That was actually the exact tutorial I was looking for! |
Your most welcome. Glad I could help.
btw, I tried the code on an old computer I had in the closet, that had QB on it, and its rather cool to watch on a 33Mhz 386 :D _________________ Principal Software Architect
Rambling Indie Games, LLC
See my professional portfolio
|
|
Back to top |
|
|
|
Page 2 of 2 |
All times are GMT Goto page Previous 1, 2
|
|
|
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 You cannot vote in polls in this forum
|
|