Sign in to follow this  
Jinroh

Mode 7 Style Floors

Recommended Posts

Hello all, I recently revamped my tile engine and was thinking it would be cool to add a Mode 7 style floormapping algorithm to the mix. Like how Super Mario Kart (SNES) and F-Zero rendered their environments. It looks like it is a tile map that is just rotated to look like a floor. Which would be quite convenient. Anyway, if anyone has some simple code or anywhere I could get some more info that would be great. I looked on Google and some other search engines and came up rather empty handed. So thanks in advance, Jinroh.

Share this post


Link to post
Share on other sites
If you are using a 3D API (like DirectX or OpenGL) the easiest way would be to use a perspective projection and a camera with a slight angle on the X axis. Then you could draw your map as normal, but it would have a perspective slant to it.


In DirectX (not complete, pulled out of ass):

- Set your projection to perspective
D3DXMatrixPerspective<XXX>(&matrix)
SetTransform(D3DTS_PROJECTION, &matrix)

- Set your view matrix to a slight angle
D3DXMatrixRotationX(&matrix, angle);
SetTransform(D3DTS_VIEW, &matrix)

Share this post


Link to post
Share on other sites
Many thanks for the code.

I appreciate your prompt reply. *bows* Thank you. That is indeed how I would have done it with my old DirectX engine. However, I'm now one of those crazies that does everything with pixel by pixel software rendering. I'm sorry, I should have mentioned that.

I think I may have found some info that will point me in the right direction, however, I'd still like to hear anything else anyone has to say because you guys could have a better method.

This method is very similar to how a Raycasting engine, a la Wolf3D is implemented. Doing so in a raycasting method seems like a rather wasteful for just floors. The raycaster I did was lacking floors so I could be wrong. I just want to rotate my tilemaps to be like Mario Kart (SNES). So I'll attempt this method but if anyone else has any thoughts feel free.

Anyway, thanks again all,
Jinroh.

Share this post


Link to post
Share on other sites
I remember seeing a tutorial that was specific to this effect years ago, but I can't find it for the life of me. Anyway, this article might be useful.

Share this post


Link to post
Share on other sites
A particularly important hint for implementing mode 7-style graphics: only do the trigonometry in both the first and last pixels of a scanline, then interpolate the coordinate between them to fill that scanline.

If you need perspective correction and have a fixed camera attitude, you can store the correction factors as a constant table to further optimize the number of arithmetic instructions. I believe that some SNES games, like F-Zero, use multiple constant tables for different camera heights (an artifact of which manifests itself as slight jerkiness of motion as the camera looks about vertically during the end sequence of each track).

All this said, I would still use D3D or OpenGL for the both the sheer simplicity and the sheer power that they offer on this kind of stuff for free [smile]

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this