Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / if i want to make a randomly generated city, how should i do it?

Author
Message
T4r4ntul4
16
Years of Service
User Offline
Joined: 1st Jan 2010
Location: close to my pc
Posted: 28th May 2012 11:06
if i want to make a randomly generated city, how should i do it?

well, thats the question. iam not asking for code, just an theory how i should do it.
BatVink
Moderator
23
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 28th May 2012 11:34
If you wanted to do it in "blocks", then you could use a 2 dimensional array, and assign random values. On a very simple level, you can assign a number for the building type, and randomly rotate the building. If you make the building sides significantly different, 4 buildings gives you 16 possibilities.

You can get more complex by adding more variables, such as texture layers etc.

T4r4ntul4
16
Years of Service
User Offline
Joined: 1st Jan 2010
Location: close to my pc
Posted: 28th May 2012 12:37 Edited at: 28th May 2012 12:39
yeah, i already did that, but i had problems with my framerate.

had around 7000 to 10000 blocks, tried occlusion culling and camera range. but never get any higher than 120 fps.

see 2D image layout for the city plan:

its randomly generated everytime.


gray dots = buildings
blue = water
green = grass
white = nothing
black stripes = road

so iam looking for alternatives.
basjak
16
Years of Service
User Offline
Joined: 16th Apr 2010
Location: feel like signing up for mars
Posted: 28th May 2012 15:19
Quote: "never get any higher than 120 fps."


40-60 fps is enough. 60 fps is human eye.

T4r4ntul4
16
Years of Service
User Offline
Joined: 1st Jan 2010
Location: close to my pc
Posted: 28th May 2012 15:40
Quote: "40-60 fps is enough. 60 fps is human eye."


yes i agree. but the city is generated from boxes and plains. not even the art tiles.

if i gonna use physics the framerate will drop further down. so 120 fps for only boxes/plains is just crazy...
Pincho Paxton
23
Years of Service
User Offline
Joined: 8th Dec 2002
Location:
Posted: 28th May 2012 15:44 Edited at: 28th May 2012 16:04
If you take a look at a city, and split it up into its components, then decide what you can change the least of to get the city back again from as few parts as possible.

You get the shapes which are mostly rectangles.

And the textures which are mostly windows.

And the walls which are very limited brick, and concrete.

And doors, and entrances.

And finally the roofs.



Now, a lot of that can be made with plains split up into limbs. So go into a modeller, split a plain up into window sections. You want to make random window choices for each limb section. Windows are repeated, so don't try to make each section a single window.

Normal maps can be used to add details to the windows. Activate the normal maps at a close distance from the camera.

Now make jigsaw parts that fit together based on the parts that you see in a real city. Mostly rectangles, and a few special parts like steeples, and curved buildings.

Then finally, you need lots of textures to randomize.

MrValentine
AGK Backer
15
Years of Service
User Offline
Joined: 5th Dec 2010
Playing: FFVII
Posted: 28th May 2012 17:47
Very interesting

This had sparked my intrigue

T4r4ntul4 what culling system are you using and do you have a world builder?

T4r4ntul4
16
Years of Service
User Offline
Joined: 1st Jan 2010
Location: close to my pc
Posted: 28th May 2012 18:10
occlusion culling and backface culling.

dont have a world builder because the map is randomly generated in a 2D array, and then i convert that in 3D objects/models.
Matty H
17
Years of Service
User Offline
Joined: 7th Oct 2008
Location: England
Posted: 28th May 2012 18:12
This looks like an awesome project, I'm sure there are plenty of optimisations to be discovered.

Could you post some pics of the city in 3D?

Also, what frame-rate do you get without any optimisations?

Remember that physics/collision can run on another thread so it might not slow down as much as you think.

T4r4ntul4
16
Years of Service
User Offline
Joined: 1st Jan 2010
Location: close to my pc
Posted: 28th May 2012 18:39 Edited at: 28th May 2012 18:40
yeah sure here you go:
(dont look at the bad temporary programmer art)

this is without occlusion culling



this is with occlusion culling and a water shader. see the missing tiles on top of the bridge, thats why occlusion culling is slow.
Matty H
17
Years of Service
User Offline
Joined: 7th Oct 2008
Location: England
Posted: 28th May 2012 19:02
Looks very cool, I can see why you're concerned about frame-rate as the buildings are as low detail as you can get. I think occlusion culling will start pulling its weight a little more when you have higher poly buildings(if you do).

Drawing multiple building as one object will save you lots of computing power. How you achieve this may limit what buildings go where, but I think that should be acceptable as different parts of cities have their own style local to that area.

You could create an object with perhaps 4096 vertices, you could then create your buildings for one block by manipulating the vertex positions, index data and uv data. You would have a huge texture which has all images for all buildings in this block.

Your occlusion culling would then be testing lots of buildings at once as they are one object, same with frustum culling.

The above is more complicated than using objects but it is the way I would approach it.

david w
20
Years of Service
User Offline
Joined: 18th Dec 2005
Location: U.S.A. Michigan
Posted: 28th May 2012 22:29
Im interested in how you turn that map into a city. I am working on a project now where since I suck at level content and design, where I want to make everything generate itself and then I can make a game that is just generated and then I can control all the game play from there.

Any help you can give would be greatly appreciated.
WLGfx
18
Years of Service
User Offline
Joined: 1st Nov 2007
Location: NW United Kingdom
Posted: 28th May 2012 22:42 Edited at: 28th May 2012 22:44
@T4r4ntul4 - My next step is to move onto a planetary scale generator and I've looked into city scape generation. It was mainly youtube were I got my inspiration from. The road I'll be going down for generating cities is using a random number generator (as usual) but mixed with a noise algorithm. Noise produces excellent terrains, but it you blend two noise maps over each other you can determine a city layout and give a nice realistic city with city/town zones, waterways, etc. I don't know how long it will take me to put each individual piece together but I'll get there. The way I'm planning it, is that I can select an area and the scene will be generated, meaning an area from anywhere on a planet.

As I've already mentioned, youtube is a great source for inspiration.

EDIT: Have to add this, the code I'm going to be working on will also hopefully generate buildings that you can walk in and around... (Yup, gonna take some time...)

Keep up the good work man... Nice one...

Mental arithmetic? Me? (That's for computers) I can't subtract a fart from a plate of beans!
Warning! May contain Nuts!
MrValentine
AGK Backer
15
Years of Service
User Offline
Joined: 5th Dec 2010
Playing: FFVII
Posted: 28th May 2012 23:01
WLGfx - I was just about to link to your Dungeon thread ProcMapGen... but you beat me to it...

I look eagerly towards your new works!

T4r4ntul4
16
Years of Service
User Offline
Joined: 1st Jan 2010
Location: close to my pc
Posted: 28th May 2012 23:52 Edited at: 28th May 2012 23:54
@Pincho Paxton
looks like a cool idea, gonna try that one.

@Matty H
Quote: "The above is more complicated than using objects but it is the way I would approach it."


thanks for the ideas. iam gonna figure it out.

Quote: "Remember that physics/collision can run on another thread so it might not slow down as much as you think."


okay nice, iam waiting for the: Add advanced vehicle example. on Dark Dynamix =)
then i will buy it. i really liked the car physics of buggy fun.

@david w
Quote: "Im interested in how you turn that map into a city. "


generating the 2d map or making the 2d map to 3d?
if you meant the last one: just replace the pictures with 3D content =)
read the 2D array out per tile, if its a road tile place road if its a grass tile, grass tile.
not as simple as above, but you get the picture.


@WLGfx
thanks, good luck with your project, sounds great!
Matty H
17
Years of Service
User Offline
Joined: 7th Oct 2008
Location: England
Posted: 29th May 2012 00:45
Quote: "thanks for the ideas. iam gonna figure it out."


I think there is a few functions which would quickly allow you to test the theory out. I think there is a command which will allow you to make all objects be limbs of one main object. Then there is a command which will allow you to make a mesh from this object, then create a new object from the mesh. You will loose the different textures but you would see how much of a speed boost you get from having each city block as one object.

Quote: "okay nice, iam waiting for the: Add advanced vehicle example. on Dark Dynamix =)
then i will buy it. i really liked the car physics of buggy fun."


OK cool, although I was not hinting I will eventually change the free version back to collision only(limited features) with no time limit so everyone can use it for free, if they want to of course.

WLGfx
18
Years of Service
User Offline
Joined: 1st Nov 2007
Location: NW United Kingdom
Posted: 29th May 2012 02:58
Just before I hit the sack (go to bed)... This was one of the recent videos that made me think about creating random buildings...



Mental arithmetic? Me? (That's for computers) I can't subtract a fart from a plate of beans!
Warning! May contain Nuts!
Pincho Paxton
23
Years of Service
User Offline
Joined: 8th Dec 2002
Location:
Posted: 29th May 2012 15:39 Edited at: 29th May 2012 15:43
That doesn't really impress me much. If I was making one I would set my sights on more realism. Although, it might be a good test to make their version first.

WLGfx
18
Years of Service
User Offline
Joined: 1st Nov 2007
Location: NW United Kingdom
Posted: 29th May 2012 17:05
@Pincho - It was the idea the video gave me. Buildings are made of floors, stairs, doors, rooms, etc. The video only mixes up objects, which is only good for a scenery effect. I'm after the more realistic approach too. Plus, most city generators are all on flat land, I'm working on the idea to include hills and sloping landscape and then throwing the city on top of that. It's a large project but I'll work around it somehow...

Mental arithmetic? Me? (That's for computers) I can't subtract a fart from a plate of beans!
Warning! May contain Nuts!
T4r4ntul4
16
Years of Service
User Offline
Joined: 1st Jan 2010
Location: close to my pc
Posted: 29th May 2012 17:09
Quote: "Plus, most city generators are all on flat land, I'm working on the idea to include hills and sloping landscape and then throwing the city on top of that."


yes, iam working on that too =)

and iam figuring out how i can use bezier curves for my road, instead only straight roads.

Login to post a reply

Server time is: 2026-07-08 12:26:48
Your offset time is: 2026-07-08 12:26:48