The VG Resource
Whats the math behind Outrun environments? - Printable Version

+- The VG Resource (https://www.vg-resource.com)
+-- Forum: Creativity (https://www.vg-resource.com/forum-126.html)
+--- Forum: Game Development (https://www.vg-resource.com/forum-129.html)
+--- Thread: Whats the math behind Outrun environments? (/thread-28279.html)



Whats the math behind Outrun environments? - rusty - 12-03-2015

Hello /vgr/ Unsure
Im doing a little project that involves recreating the maps of Outrun games for the SNES in Java. From what I can see, a little bit of math is involved and was wondering if someone can direct me to a quick guide or something that better explains it.

http://www.blitterandtwisted.com/wp-content/uploads/2011/04/out-run-screen1.png


http://3.bp.blogspot.com/-Zbp5zmrwDi0/UFnBSF9jh-I/AAAAAAAAI2U/JG6Bu4phSHU/s1600/outrun02.png


RE: Whats the math behind Outrun environments? - Raccoon Sam - 12-03-2015

Looks like the classic old F-Zero-ish HDMA+Mode7 trick.
Basically it's a 2D plane that lowest row of pixels is 100% width, the one above it a bit smaller, the one above it a bit smaller, etc. These days every toaster can do 3D math and digital displays have no concept of scanlines, so the method this was "really" done isn't realistic, but for legacy and historical purposes you can read more about it at http://www.coranac.com/tonc/text/mode7.htm


RE: Whats the math behind Outrun environments? - DarkGrievous7145 - 12-03-2015

looks to me like you have either 3d-rendering or psuedo-3d rendering going on there.

i'm not sure how to help you, but i might have a few tips.

Firstly, this game appears to be using 3d perspective projection, with the focal point(s) more or less in the center.

I will say for any of the misc. background objects, such as trees, it is fairly easy to reproduce this effect. you start them at the focal point(s) , and render them at a very small scale. as the car moves forward, you move them out to their respective bottom corner. you also need to account for the car's speed. I can't really say how that formula should work, however.

you also may want to take advantage of pre-rendering, and similar practices. Some good places to try this would be the cars, and maybe the road. Probably what you'd be doing, either yourself, or by a designated graphic artists, is drawing the possible rotations for your cars, and maybe the lines on the road as the appear o be moving towards you.

Ofc, seeing as you're using Java (or any modern language/console/platform) , you could easily utilize an actual 3d rendering program to handle a lot of the dirty work.

Which leaves you with the map format, itself.
I wouldn't know exactly how that works for these games.
Most developers don't use the same formats for anything.
Your best bet is google, or that someone else here can explain it.
You could also attempt to contact the original developers, ideally the programmers.

One way you could do it, let's just stick with the bare-bones basics, let's say a typical straight stretch of your track has, distributed evenly, six places to add an object. Three on the left, three on the right. One possible way you could store this (I'll use XML):

<track>
<part>
<type>straight</type>
<objs>
<o1>tree</o1>
<o2>tree</o2>
<o3>null</o3>
<o4>sign</o4>
<o5>tree</o5>
<o6>tree</o6>
</objs>
</part>
</track>

Now, this would correspond to a straight section of track, laid out as follows:
tree [road] tree
nothing [road] sign
tree [road] tree

There are many ways you can set-up the maps, themselves, and this is just one way.

Hope this is somewhat helpful?
I am going off what little information you've provided, and what little I would know about doing this kind of thing.

edit:
another very clear answer provided while i typed mine


RE: Whats the math behind Outrun environments? - rusty - 12-03-2015

(12-03-2015, 04:00 PM)DarkGrievous7145 Wrote: looks to me like you have either 3d-rendering or psuedo-3d rendering going on there.

i'm not sure how to help you, but i might have a few tips.

Firstly, this game appears to be using 3d perspective projection, with the focal point(s) more or less in the center.

I will say for any of the misc. background objects, such as trees, it is fairly easy to reproduce this effect. you start them at the focal point(s) , and render them at a very small scale. as the car moves forward, you move them out to their respective bottom corner. you also need to account for the car's speed. I can't really say how that formula should work, however.

you also may want to take advantage of pre-rendering, and similar practices. Some good places to try this would be the cars, and maybe the road. Probably what you'd be doing, either yourself, or by a designated graphic artists, is drawing the possible rotations for your cars, and maybe the lines on the road as the appear o be moving towards you.

Ofc, seeing as you're using Java (or any modern language/console/platform) , you could easily utilize an actual 3d rendering program to handle a lot of the dirty work.

Which leaves you with the map format, itself.
I wouldn't know exactly how that works for these games.
Most developers don't use the same formats for anything.
Your best bet is google, or that someone else here can explain it.
You could also attempt to contact the original developers, ideally the programmers.

One way you could do it, let's just stick with the bare-bones basics, let's say a typical straight stretch of your track has, distributed evenly, six places to add an object. Three on the left, three on the right. One possible way you could store this (I'll use XML):

<track>
<part>
<type>straight</type>
<objs>
<o1>tree</o1>
<o2>tree</o2>
<o3>null</o3>
<o4>sign</o4>
<o5>tree</o5>
<o6>tree</o6>
</objs>
</part>
</track>

Now, this would correspond to a straight section of track, laid out as follows:
tree      [road]     tree
nothing [road]     sign
tree      [road]     tree

There are many ways you can set-up the maps, themselves, and this is just one way.

Hope this is somewhat helpful?
I am going off what little information you've provided, and what little I would know about doing this kind of thing.

edit:
another very clear answer provided while i typed mine
Thanks for that. I think I have a little bit better idea how these environments work. It sounds like matrix geometry(which im not that good at)


RE: Whats the math behind Outrun environments? - DarkGrievous7145 - 12-03-2015

That mode7 explanation Racoon Sam linked to is probably your best bet for the rendering, besides using an actual 3d rendering setup like directx or opengl.

I agree, though, that kind of math is confusing.

Using Opengl or DirectX probably would be somewhat easier.

Then you just gotta handle the map format.

Good luck with your project!


RE: Whats the math behind Outrun environments? - einstein95 - 12-03-2015

I'd look at the source for Cannonball which is a recreation of the OutRun engine: https://github.com/djyt/cannonball/tree/master/src/main