Page 1 of 2

Mode7 (The SNES way to make 3D)

PostPosted: Thu Jan 13, 2011 5:39 am
by Game A Gogo
For a couple of years now, I've wanted to create Mode7 inside GE, well now I have!
With the help of this site: http://pixwiki.bafsoft.com/mags/5/artic ... sincos.htm I was able to reproduce the Mode 7 effect used in many games on the SNES for 3D.
Most credit should go to the guy who wrote that, I did copy his code and made it work in GE.
Now before you get all too exited, this method is slow. Of course the code can be cleaned up a bit, I'm sure, but until GE can handle better things like that, yeah.
NOTE: remember to import your image with ImpBGBmp("Tile.bmp");

how to use Mode7:
Code: Select all
//void Mode7(int screen_w,int screen_h,double space_z,int horizon, double scale_x, double scale_y, double dangle, double cx, double cy)
Mode7(width,height,48,16,200,200,angle,x_pos,y_pos);

screen_w and screen_h is the size of the canvas
space_z is the Z position (height)
horizon is the offset vertically of the output picture
scale_x and scale_y are for scalling, I suggest 200 and 200
dangle is the angle you are facing in Degree
cx and cy is the position

enjoy!

Re: Mode7 (The SNES way to make 3D)

PostPosted: Thu Jan 13, 2011 11:32 am
by Turon
Cool! er is it complicated? :?

Re: Mode7 (The SNES way to make 3D)

PostPosted: Thu Jan 13, 2011 11:36 am
by Turon
I created this a couple of days back viewtopic.php?f=1&t=9692 . if we mix the ideas we would basically do 3D!

Re: Mode7 (The SNES way to make 3D)

PostPosted: Thu Jan 13, 2011 2:23 pm
by Game A Gogo
To include objects with this, you'd need to use Bee-Ant's demo or Tintran's demo.

Your method is very basic illusion, it doesn't have rotation nor distance scalling

Re: Mode7 (The SNES way to make 3D)

PostPosted: Thu Jan 13, 2011 3:18 pm
by Turon
I don't know how to do that can you teach me? :wink:

Re: Mode7 (The SNES way to make 3D)

PostPosted: Thu Jan 13, 2011 3:32 pm
by Game A Gogo
Then I'd suggest you read the website I used for refference

Re: Mode7 (The SNES way to make 3D)

PostPosted: Thu Jan 13, 2011 4:44 pm
by Game A Gogo
note: removed a useless round function that would distort slightly the image rendered
I'd also like to know if this is simply useless S:

Re: Mode7 (The SNES way to make 3D)

PostPosted: Fri Jan 14, 2011 1:00 am
by Bee-Ant
Pretty nice :D
Too bad it's slow...
Gonna take a look more then improve some ;)

Re: Mode7 (The SNES way to make 3D)

PostPosted: Fri Jan 14, 2011 12:45 pm
by lcl
Good job man! :D
1+ for you.

Re: Mode7 (The SNES way to make 3D)

PostPosted: Fri Jan 14, 2011 1:06 pm
by Lacotemale
Very nice but very slow... don't think this can be used for anything at this level of performance.

Re: Mode7 (The SNES way to make 3D)

PostPosted: Sat Jan 15, 2011 12:05 am
by Game A Gogo
Lacotemale wrote:Very nice but very slow... don't think this can be used for anything at this level of performance.


Unfortunatly, GE was not made to handle such things, it can be optimized, as I have a bit, I'm able to get 20 fps with somewhat good graphics, I'm making a mini game using this.
Plus there might be formulas out there that are more efficient

Re: Mode7 (The SNES way to make 3D)

PostPosted: Sat Jan 15, 2011 10:08 am
by akr
That looks promising. What ge support would u need?

Re: Mode7 (The SNES way to make 3D)

PostPosted: Sat Jan 15, 2011 2:54 pm
by Game A Gogo
putpixel has always been slow, because canvas drawing does no benefit from any hardware acceleration.
If you try a 640x480 canvas, with just a simple code that would draw every pixel one by one with putpixel and make a blinking effect. You get 7fps on my computer, imagine with more complicated ways of drawing! It's not very convenient since we are in the 21st centuary, not the 20th.

I don't think the trigonometry in this code is to blame, it actually gets read once for every line.

Re: Mode7 (The SNES way to make 3D)

PostPosted: Sun Jan 16, 2011 1:50 pm
by alexandrefredenucci
I like mode 7, awesome work Game A Gogo ^^

Re: Mode7 (The SNES way to make 3D)

PostPosted: Sun Jan 16, 2011 2:54 pm
by Game A Gogo
alexandrefredenucci wrote:I like mode 7, awesome work Game A Gogo ^^

thanks a lot :)

I'd also like to point out that 8x8 texture size will run as quick as 1024x1024 texture size, except loading the 1024x1024 in memory will take a couple of seconds