Jump to content


Photo

Large 3d City Map Rendering


  • Please log in to reply
36 replies to this topic

#1 JMike

JMike

    GMC Member

  • New Member
  • 17 posts

Posted 16 September 2008 - 06:59 AM

Posted Image

Example of large city map using tiles for ground

Features:
* Large scalable map (adding more ground will not slow down the engine)
* Car with loose suspension
* Model loading
* Camera tracking
* Moving water
* Fake shadows/shading
* The buildings height and textures are randomized at startup

Features lacking
* There is a bug in the heightmap z lookup function, which causes the car to glitch near the boundary of the map

Download
gmroadtile.zip

The zip files is about 9mb large, due to some pretty heavy textures.

How does it work?
The map is drawn in the normal Room editor in Game Maker, using tiles and objects. Since GM tiles tend to be quite large if you need resolution I use two sets of tiles. The small tiles are thumbnails (16x16 or 32x32) and these are read and converted to 3d graphics by the engine when starting the demo. Another benefit of this is its possible to do some heightmapping, as shown in the demo. The map is 2000x2000 large, however tiles must be places on even 16 or 32 pixel boundaries as the scanner looks for tiles there. When rendering everything is scaled up 16 times for accuracy. This is how the apparently huge map is achieved. The tiles indices are put into a 2D grid which is 125x125. When rendering the nearest region around the camera is iterated over, and any tiles in that region are drawn using d3d. The fake shadowing on the road is done by scanning for objects near the tile, and darkening the colors of the 3d triangle. Any tiles that end up behind the camera are ignored for extra speed. If you want a free camera or top down view you might want to disable that optimization.

The frame rate may be a little slow on your system. This is due to the car model which is pretty heavy. For a real game a more economic car model would have be chosen.

Also note that only a small portion of the room is filled in this example, you could easily fill the whole room and there should be no or little slow down (unless you really put a lot of objects in there). If you want a huge amount of objects you might want to extend the tile grid idea above to do the same thing with objects.

Most of the models and textures come from Sketchup 3d warehouse. I wrote my own Sketchup model converter (actually from .obj to .mdl). I do not know the copyright status of using models and textures from Sketchup in productions, please refer to their license agreement for more info. The buildings are pretty much simple blocks.

This may be used freely by anyone, but if it is used in any production a mention of 'JMike' would be nice.

Hope this is useful for someone!

Update 20080920
* Texture widths are now fixed to 2^x
* Collision response on by default

--JMike

Edited by JMike, 20 September 2008 - 08:56 AM.

  • 0

#2 BattleRifle BR55

BattleRifle BR55

    Moo

  • GMC Member
  • 8297 posts
  • Version:GM7

Posted 16 September 2008 - 07:14 AM

Very cool, but it was the springy physics I liked the most :)
  • 0

#3 Boffel Production

Boffel Production

    TWP Developer

  • New Member
  • 350 posts

Posted 16 September 2008 - 09:45 AM

I dont know why, but when I start the game the camera moves, and after about 3 seconds everything turns gray. (it works fine in the first 3 seconds)

Perhaps you are hiding polygons in front of camera or something?

Ps: I'm using vista, perhaps that is the reason...
  • 0

#4 JMike

JMike

    GMC Member

  • New Member
  • 17 posts

Posted 16 September 2008 - 10:24 AM

I dont know why, but when I start the game the camera moves, and after about 3 seconds everything turns gray. (it works fine in the first 3 seconds)

Perhaps you are hiding polygons in front of camera or something?

Ps: I'm using vista, perhaps that is the reason...


I don't know why that happens. I'm using Vista here aswell, so I don't think that's it. What are your system specs, video card etc?
  • 0

#5 BattleRifle BR55

BattleRifle BR55

    Moo

  • GMC Member
  • 8297 posts
  • Version:GM7

Posted 16 September 2008 - 01:48 PM

Did you move the mouse? For me it started shooting upwards until I moved it back down.
  • 0

#6 paulman8888

paulman8888

    GMC Member

  • New Member
  • 140 posts

Posted 16 September 2008 - 03:57 PM

I like it but when the car hits a building i think it should stop and not go though.
Also i dont think cars can drive on water. (The blue thing).

Good.

Cant wait for later versions

Edited by paulman8888, 16 September 2008 - 04:02 PM.

  • 0

#7 them4n!ac

them4n!ac

    GMC Member

  • New Member
  • 1170 posts

Posted 16 September 2008 - 05:58 PM

that looks almost like my old racing game :)
just the city's ground is a bit weird..

the car model never would slow down the game, it's very simple.
But I like this example.
  • 0

#8 frankpiet

frankpiet

    ^destroyed evil chicken^

  • New Member
  • 760 posts

Posted 16 September 2008 - 09:56 PM

good great graphics, but no collisions. great physics as well
  • 0

#9 Rexhunter99

Rexhunter99

    GMC Member

  • GMC Member
  • 922 posts

Posted 16 September 2008 - 11:31 PM

This is fantastic, if only it had been done a year ago...
  • 0

#10 JMike

JMike

    GMC Member

  • New Member
  • 17 posts

Posted 17 September 2008 - 06:01 AM

If you want simple collision response, just add an event to obj_car:

Collision Event with object obj_building
//
vel = -0.5*vel;
  • 0

#11 paulman8888

paulman8888

    GMC Member

  • New Member
  • 140 posts

Posted 17 September 2008 - 03:05 PM

this is a really great example.

As you can tell i am not good at 3d but i found another bug. I was just driving the car and then i went flying into the sky.

@JMike
Thankyou for the extra code. it works well

@everybody
This is one of the best examples. I will recomend this to everyone
  • 0

#12 JMike

JMike

    GMC Member

  • New Member
  • 17 posts

Posted 18 September 2008 - 06:24 AM

I was just driving the car and then i went flying into the sky.


If the frame rate drops too low the physics gets instable and launches the car into the sky.. It might not be apparent in this example but the car can lift from the ground when going over hills and jumps (not that there are any in this map)..
  • 0

#13 grumpymonkey

grumpymonkey

    GMC Member

  • GMC Member
  • 1011 posts

Posted 18 September 2008 - 10:12 PM

sooooo im guessing this was made in gm6 since the textures arent powers of 2....aaaannnnnd the file is .gm6 =/

well whatever, seems cool though
  • 0

#14 JMike

JMike

    GMC Member

  • New Member
  • 17 posts

Posted 19 September 2008 - 05:41 AM

Actually its made in GM7. I wasn't aware of any texture limitations, but rescaling to 2^x should be easy enough. Are you having trouble running it?
  • 0

#15 sparkythecat101

sparkythecat101

    GMC Member

  • New Member
  • 50 posts

Posted 19 September 2008 - 05:47 PM

it looks awesome, and i love the pysics, but i got a weird glitch (i didn't mod the file at all, honest!)
pic~ http://www.majhost.c...stuff/error.bmp
  • 0

#16 xygthop3

xygthop3

    GMC Member

  • GMC Member
  • 2448 posts

Posted 19 September 2008 - 08:43 PM

The "glitch" is due to the textures not being resized to ^2, the OP should understand that alot of video cards do not automaticly resize images.
  • 0

#17 Pie Person!

Pie Person!

    GM 6+ Lover

  • GMC Member
  • 1973 posts

Posted 20 September 2008 - 12:26 AM

Ahh. It's GM7.
  • 0

#18 JMike

JMike

    GMC Member

  • New Member
  • 17 posts

Posted 20 September 2008 - 08:57 AM

The "glitch" is due to the textures not being resized to ^2, the OP should understand that alot of video cards do not automaticly resize images.


I just uploaded an update that fixes the texture widths to 2^x. It seems that Gm7 resizes the textures automatically while Gm6 does not.
  • 0

#19 RamboFox

RamboFox

    Tainted Fortune

  • New Member
  • 992 posts

Posted 22 September 2008 - 06:11 AM

This example is so good, i'll have to use it in one of my future games. love how you managed to make the car shift like it has suspension and such. <3

The buildings are still buggered, so you'll need to fix the way their' textures are being drawn. D:
  • 0

#20 ChikinSloat

ChikinSloat

    GMC Member

  • New Member
  • 115 posts

Posted 25 September 2008 - 08:16 PM

Very nice example - cool suspension type physics.


However: you gonna credit the guy who made those road textures? Lul, I can tell you print screened the box of a guy's item for sale in Second Life.


I'm stiff confused though - as to how I add hills to to road.
  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users