#17233 - DarkPhantom - Thu Mar 04, 2004 6:17 pm
I've been trying to generate a perspective effect using 'mode 7.' Like what is seen in games like Mario Kart, and pretty much every Squaresoft game on the SNES. This can been done basically by changing the zoom after each scanline right? I think my math is wrong because instead of everything looking flatter and furher away as you look up screen things look like they curve upward as if the there was a sperical depression in the plane. Rotating creates the interesting effect of objects sort of following a sinewave as they move from the left to the center to the right of the screen. Anyhelp from those particulary adept at 3D math would be greatly appreicated.
_________________
"head straight for your goal by any means
there is a door that you've never opened
there is a window with a view you've never seen
get there no matter how long it takes"
-Theme of Shadow, Sonic Adventure 2
#17239 - poslundc - Thu Mar 04, 2004 8:24 pm
It would be a good idea to have a look at the code for the Pern Project Mode 7 demo. There are a bunch of similar tutorials and demos with source on the gbadev site and other related places.
I strongly suggest you start with perspective before attempting rotation. If you try to work on both at the same time you'll never be able to figure out where your problems are coming from.
For your curving problem: it depends on how you're calculating distance, but it sounds as though you might be generating a fisheye effect. Have a look at the raycasting tutorial at http://www.permadi.com/tutorial/raycast/ for an explanation, or you can google it if you find that insufficient. The easiest way is to calculate perspective in Mode 7 is just to divide the distance to the camera by the distance down the screen.
Good luck,
Dan.
#17245 - DarkPhantom - Thu Mar 04, 2004 11:35 pm
Thx alot. I got it working just fine after looking at PERN's code for about 3 minutes. Isn't there also a way that the zoom can be caculated using matrices?
Also, is there a way of changing the perspective using the PERN scaling method? You can change the height of the view easily but the map is always viewed from the same angle. I'd like to get a angle closer to the one used by the FF6 world map. Can that only be done using matrices?
_________________
"head straight for your goal by any means
there is a door that you've never opened
there is a window with a view you've never seen
get there no matter how long it takes"
-Theme of Shadow, Sonic Adventure 2
#17258 - poslundc - Fri Mar 05, 2004 3:49 am
You can use matrices if you want; it can certainly simplify things from a mathematical perspective and make it easier to do general geometric calculations. They don't affect your algorithms, though.
I don't bother with matrices in my Mode 7 program; I just use hard-coded equations.
The amount that you change the scale by on each scanline is what determines the angle. How you calculate this value for each scanline is up to you. I use raycasting for an accurate geometric model that lets me easily modify variables like the camera's pitch.
If you aren't already familar with 3D math and geometry, I'd suggest acquainting yourself before doing much more. Mode 7 is deceptively easy at first but you need to be able to do a good chunk of geometric problem solving if you want to do much that is practical with it.
Dan.
#17274 - Lupin - Fri Mar 05, 2004 3:42 pm
Maybe matrices will make your code easier to understand, but it's better to write fast code than easy to understand code!!
I would recommend using ASM for everything that depends on speed, the speed gain is very huge in most cases.
#17276 - poslundc - Fri Mar 05, 2004 4:01 pm
Lupin wrote: |
Maybe matrices will make your code easier to understand, but it's better to write fast code than easy to understand code!! |
Not always. Not even most of the time.
Dan.
#17284 - Miked0801 - Fri Mar 05, 2004 7:21 pm
Lupin, you're fired. :)
99.99% of the time, I want easy to read, easy to understand, and most importantly, EASY TO DEBUG AND EXTEND code on my projects. What's the point of making a menu system run at 100fps? Or a blindingly fast piece of code that is at most run once every few gameloops.
Yes, there are places where speed is of the utmost concern - and in those cases you need to do stuff that can't be easily understood. In those cases, your code comments had better make up for your code. There's nothing worse than trying to debug a blindingly fast routine that works "most" of the time, that has no comments, and the person who wrote it isn't available (or worse, you did it 6 months ago and can't remember what it does.)
Spend a few extra minutes now while writing the code to save yourself a few extra hours/days of time a few months from now when your product is Alpha/Beta and trying to be shipped.
Mike
#17290 - torne - Fri Mar 05, 2004 9:22 pm
This is very true. Premature optimisation is the root of all evil. Write the code to be clear and simple, and only change it if some part turns out to actually be too slow; and even then, only change the minimal amount. =)