random urban maps

Hi
A while ago I made a topic about building maps from tiles and placing them together jigsaw style. I’ve finally made the time to get some of this done in the form of a basic random urban map generator. Just plain concrete and some roads on it, but I think it looks pretty nice, although in my mind it already has little houses, factories and shops on it :wink:

I’m getting a weird problem where the map isn’t visible so far off, I’ve tried to get a shot of this in the second screen.

The map:

A weird problem I’m getting:

The code is a bit big so I will post links to it for anyone who wants to have a look, any feedback and tips would be greatly appreciated.

http://www.thewilderzone.co.uk/random/urbanterrain04.py

http://www.thewilderzone.co.uk/random/randomtown.py

oops. here are additional files required to make this run.

http://www.thewilderzone.co.uk/random/tiles.txt

http://www.thewilderzone.co.uk/random/basicground.egg

http://www.thewilderzone.co.uk/random/basicroad.egg

you mean the far or near edge of the map is not visible?

This is usually the near/far clipping plane. It cuts off everything further or closer the the camera. There are already a lot of topis around covering this thematic, so i wont go into the details.

https://www.panda3d.org/manual/index.php/Lenses_and_Field_of_View

(setNear and setFar)

Further. Thanks for letting me know what the problem was.

wow that looks like a sweet future city :slight_smile:
c

Thanks snap.
Cant wait to get some buildings on there, although my modeling skills will need a lot of work 1st.

why don’t you try making the buildings procedurally, programing the meshes, and texturize them by prog, with random parameters, so you can generate really diferent random cities?
that would be nice!

I’m busy making my country side, maybe in the future we could share/mix both generators :slight_smile:

hmm… I hadn’t thought of that, it would probably save me lots of time as well. Certainly something I’m going to look into!

That would be cool. :slight_smile:
It seems we both like our random terrain! During this I had thought it may be possible to use the road building algorithm to make those sort of eroded paths you get in hills and mountains, or to make paths through forests. (I live in rural Scotland so I see this sort of stuff a lot in real life). It might need to be a little more twisty, but thats something I want to add anyway.

I’ve posted the links to the source on the 1st post if you see anything there you want to use. :smiley:

eroded paths:
sounds very good, would be good to implement that on my country once is more finished

for the moment i just finished the multitexture stuff and i’m developing the pathfinding routines, it’s going fine :slight_smile:
the astar algorythm takes in account diferent costs for each kind of terrain, so to add eroded roads should be cool!

i saw you posted the gadgets, i’ll give it a try!
c

this script might be of use to you, it’s not finished (texture coordinates and colors are missing/not working). But it takes a input map (just write a replacement for the randomMap class, which has the variable size, and the getGray as well as the getRGBA functions. it generates a town-like heightmap.

get the source from:
http://public.nouser.org/~rspoerri/Development/python/panda3d/projects/wall-generator/


hohoho :smiley:
wow hypnos that shurely is a nice random gen script
tks a lot for sharing!
c

Santa!! :smiley:

Seriously though, been away a few days and just catching up. Thanks for posting this code hypnos. I can see I have some reading to do.

i have found the color bug in the script. As soon as you call flattenStrong on the model the vertex color information is discarded. I wonder if this is supposed to happen?

here is a updated version of the script, which also has a “plugin” for PIL (python image library) images. It creates quite nice images if you take some a colorful photo (just scale it down to below 200*200 pixels).

One note, this script is not optimized for colorful images, it tries to optimize the triangles if the colors are the same value in a row (like gimp’s maze script). It makes the generation of the image slower, but might decrease the triangles by 10times (the roof/floor tiles are not yet optimized). If you want to change the height of the walls just change the output of the getGray function. the first parameter on analyzeMap defines the height of the walls (using the getGray function) the second parameter is the color of the walls/ground and requires the getRGBA function. The pil “plugin” is not really sure to work with any type of image, but i tried to make it work with rgb and rgba images.

just replace the line with images in the same directory:

a = analyzeMap(pilMap('bild.png'), pilMap('bild.png'))

get the sourcecode from (currently wallGenerator2_v0005.py):
http://public.nouser.org/~rspoerri/Development/python/panda3d/projects/wall-generator/

Thanks for the bug fix Hypnos.

discourse.panda3d.org/viewtopic.php?t=4185

Right, the new rule in Panda is: if you want to have vertex color respected, you need to put an explicit ColorAttrib.makeVertex() on the node. Otherwise the vertex color might be ignored, particularly after a call to flatten.

David

I have optimized the floor tiles as well in the latest version. it now uses the colors in a better way (in my opinion).

get the latest version (currently wallGenerator2_v0005.py) of the code from:
http://public.nouser.org/~rspoerri/Development/python/panda3d/projects/wall-generator/

if you write a different data “plugin” you may want to change the XMIN,XMAX,YMIN,YMAX values. (you will see when walls are missing that you may need to change them)

i’m amazed by this after looking inside a bit
i’ll try to mix that with my own terrain generator for adding walls and buildings
hope that is ok
congratulations
c

You can do whatever you want with the script as long as you respect the license i applied to it :slight_smile: (gpl). So you are free to change anything (except the license) as long as you release the outcome.