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: Thu Nov 13, 2003 11:47 pm Post subject: Fake floormapping! |
[quote] |
|
If you want to do floormapping but don't want to spend hours figuring out all the trigonometry and stuff involved, here's a simple way to fake it using a bunch of stretch_blits of increasing stretchiness!
Quote: |
res = 2; // Set resolution to whatever value looks good without being too slow
for (x = 0; x < 240; x += res) {
stretch_blit(buffer, screen, x / 4, x, 320 - x / 2, res, 0, x * 2, 640, res * 2);
}
// This example stretches from a 320x240 buffer into a 640*480 screen
|
It's going in ARC Legacy Gold, unless I can figure out real floormapping. Where did that tutorial go?
EDIT:
BTW, first person to say "but floormapping is a simple thing" gets slapped. _________________ 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
|
Posted: Fri Nov 14, 2003 12:08 am Post subject: |
[quote] |
|
Here's an example screenshot
A couple problems though: it goes pretty slow when I set it to a resolution of 1, and it doesn't seem to be a flat 3-d effect. It's like walking on the inside of a cylinder because it stretches at a constant rate rather than increasing as you get closer to the "camera". Also, the way I have it right now it only does the effect at blitting time so the main character gets floormapped along with the world, and so would any menus or anything. The last two problems should be simple enough to fix but I don't know how to make it faster. _________________ Mark Hall
Abstract Productions
I PLAYS THE MUSIC THAT MAKES THE PEOPLES FALL DOWN!
|
|
Back to top |
|
|
js71 Wandering DJ
Joined: 22 Nov 2002 Posts: 815
|
Posted: Fri Nov 14, 2003 1:53 am Post subject: |
[quote] |
|
But floormapping is a simple thing.
=D
Wait. I don't know shit about programming. Who am I to say that when I can't even make a tile engine?
>.>
|
|
Back to top |
|
|
Ninkazu Demon Hunter
Joined: 08 Aug 2002 Posts: 945 Location: Location:
|
Posted: Fri Nov 14, 2003 2:09 am Post subject: |
[quote] |
|
Whatever happened to x-tech? I NEED THAT TUTORIAL NOW THAT I'VE LEARNED TRIG! AHHHHHHHHHHHHHHHHHHH!
|
|
Back to top |
|
|
Rainer Deyke Demon Hunter
Joined: 05 Jun 2002 Posts: 672
|
Posted: Fri Nov 14, 2003 2:44 am Post subject: |
[quote] |
|
Floor mapping is simple even without trig.
Abridged code from Lightslayer: Code: |
for (i = 0; i < RENDER_HEIGHT / 2; i++) {
dist = 160 / (RENDER_HEIGHT / 2 - double(i));
// 'dist' is the distance of the current horizontal line from the player along the (sdx, sdy) ray
// the leftmost point on that line is 'dist' to the left, the rightmost point is 'dist' to the right
// so the leftmost point is (player_x + (sdx - pdx) * dist, player_y + (sdy - pdy) * dist) and the
// rightmost point is (player_x + (sdx + pdx) * dist, player_y + (sdy + pdy) * dist)
draw_horizontal_texture_line_64(i, true, player_x + (sdx + pdx) * dist, player_y + (sdy + pdy) * dist, player_x + (sdx - pdx) * dist, player_y + (sdy - pdy) * dist);
} |
That's for first person perspective; use sdx=0 and sdy=-1 to point the camera northward. Not sure why you'd want to use floormapping in the first place; it's a rather ugly effect IMO.
|
|
Back to top |
|
|
LeoDraco Demon Hunter
Joined: 24 Jun 2003 Posts: 584 Location: Riverside, South Cali
|
Posted: Fri Nov 14, 2003 3:07 am Post subject: |
[quote] |
|
Rainer Deyke wrote: | Not sure why you'd want to use floormapping in the first place; it's a rather ugly effect IMO. |
It makes your penis larger. _________________ "...LeoDraco is a pompus git..." -- Mandrake
|
|
Back to top |
|
|
Ninkazu Demon Hunter
Joined: 08 Aug 2002 Posts: 945 Location: Location:
|
Posted: Fri Nov 14, 2003 3:50 am Post subject: |
[quote] |
|
LeoDraco wrote: | Rainer Deyke wrote: | Not sure why you'd want to use floormapping in the first place; it's a rather ugly effect IMO. |
It makes your penis larger. |
Nuh uh! You're kidding, right? Shit, I gotta TRY this!
[/sarcasm]
|
|
Back to top |
|
|
Rainer Deyke Demon Hunter
Joined: 05 Jun 2002 Posts: 672
|
Posted: Fri Nov 14, 2003 4:51 am Post subject: |
[quote] |
|
Forgot to explain pdx and pdy in the code above. They are defined as:
Code: |
pdx = sdy;
pdy = -sdx;
|
|
|
Back to top |
|
|
Xegnma Monkey-Butler
Joined: 03 Apr 2003 Posts: 53 Location: Trapped in Middle Earth
|
Posted: Fri Nov 14, 2003 4:57 pm Post subject: |
[quote] |
|
LeoDraco wrote: | Rainer Deyke wrote: | Not sure why you'd want to use floormapping in the first place; it's a rather ugly effect IMO. |
It makes your penis larger. |
BWAA HA HAH HAHA....My God that is just too hilarious...
|
|
Back to top |
|
|
valderman Mage
Joined: 29 Aug 2002 Posts: 334 Location: Gothenburg, Sweden
|
Posted: Sat Nov 15, 2003 1:19 pm Post subject: |
[quote] |
|
The variable names in that code snippet look really counter-intuitive to me...or it might just be the fact that I didn't try that hard to get them to make any sense. _________________ http://www.weeaboo.se
|
|
Back to top |
|
|
BigManJones Scholar
Joined: 22 Mar 2003 Posts: 196
|
|
Back to top |
|
|
Mandrake elementry school minded asshole
Joined: 28 May 2002 Posts: 1341 Location: GNARR!
|
Posted: Fri Nov 28, 2003 11:38 pm Post subject: |
[quote] |
|
Xmark-
If it's going to slow, and yr too lazy to learn cos/sin effects, jsut create a simple look-up table and that should speed it up. The lookup table would get rid of the multiplacation/division stuff (something that slows down most drawing stuff) and use it before hand.
example:
Code: |
typedef struct
{
val1, val2, val3;
}LookupTable;
res = 2; // Set resolution to whatever value looks good without being too slow
LookupTable ltable[240];
for (x = 0; x < 240; x += res)
{
ltable[x].val1=x/4;
ltable[x].val2=320-x/2;
ltable[x].val3=x*2;
}
/*then you would have a function with this bit of code inside of it to call, which would speed things up. Only create the lookup table at the beg of the program, and only once or else your speed increase is pointless*/
for (x = 0; x < 240; x += res)
{
stretch_blit(buffer, screen, ltable[x].val1, x, ltable[x].val2, res, 0, ltable[x].val3, 640, res * 2);
}
// This example stretches from a 320x240 buffer into a 640*480 screen
|
_________________ "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 |
|
|
XMark Guitar playin' black mage
Joined: 30 May 2002 Posts: 870 Location: New Westminster, BC, Canada
|
Posted: Sat Nov 29, 2003 1:33 am Post subject: |
[quote] |
|
Ah, yes. Lookup tables. Actually, the main tile engine itself could do with some lookup tables to speed it up. I'll look into it (or lookup to it, heeheeheee)
Also, I found that it sped things up a heck of a lot but doing all those stretch blits to a buffer first, then blitting the whole thing to the screen. _________________ Mark Hall
Abstract Productions
I PLAYS THE MUSIC THAT MAKES THE PEOPLES FALL DOWN!
|
|
Back to top |
|
|
Mandrake elementry school minded asshole
Joined: 28 May 2002 Posts: 1341 Location: GNARR!
|
Posted: Sat Dec 06, 2003 1:05 am Post subject: |
[quote] |
|
oh yeah - in allegro memory to memory blits are always faster- esp while stretching. heh. _________________ "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 |
|
|
Mandrake elementry school minded asshole
Joined: 28 May 2002 Posts: 1341 Location: GNARR!
|
Posted: Sat Dec 06, 2003 1:52 am Post subject: |
[quote] |
|
also-
If you do release the source (like you said on your webpage), you mind if I port it to Python and release that openly as well? I think this is how the actual 'Mode 7' effects are on the snes, since Mode 7 is just a hardware-accel stretching mode.... _________________ "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 |
|
|