Jump to content

[Random map] Schwarzwald


niektb
 Share

Recommended Posts

I thought of the following map:



Schwarzwald


This is a map with a rich valley in the middle filled with a lot of resources. Players start on the hills near the edge of the map. This is a map with a high forest density (Like AOEII's Black Forest map)



The generation script is based on FeXor's Realistic Terrain Generation method.




Spoiler
LEWEDYA.png




The only thing I need to know is how to bias the realistic terrain generator to create a valley. Furthermore do I want to know how you made sure that the levels are playable.



I noticed BTW that a lot of other RM-scripts use a heightbased texture painting too without looking very tiled. I'll try and see if it works for me.



Some questions were raised during the process:



Okay, now since I'm trying to use the other texture mechanics I need to know how to select existing parts of the map by height and paint them with a class.



Paint with a class isn't too difficult. That just the following line:


paintClass([Classname]);



That little piece of code should be in a createArea call, with itself features a placer and a painter. In that painter the paintClass piece should be added.



But how do I select a height (For example all waterareas (= all places with height < waterheight).



Secondly I'm wondering whether there is a way to select tiles by slope rather than by height.



Edited by niektb
Link to comment
Share on other sites

Okay, now since I'm trying to use the other texture mechanics I need to know how to select existing parts of the map by height and paint them with a class.

Paint with a class isn't too difficult. That just the following line:

paintClass([Classname]);

That little piece of code should be in a createArea call, with itself features a placer and a painter. In that painter the paintClass piece should be added.

But how do I select a height (For example all waterareas (= all places with height < waterheight).

Secondly I'm wondering whether there is a way to select tiles by slope rather than by height.

A placer for a specific height would look like:

/////////////////////////////////////////////////////////////////////////////////////////// HeightPlacer//// Class for tiles of the same height//// lowerBound: Only tiles higher then this will be included// upperBound: Only tiles lower then this will be included///////////////////////////////////////////////////////////////////////////////////////////function HeightPlacer(lowerBound, upperBound){this.lowerBound = lowerBound;this.upperBound = upperBound;}HeightPlacer.prototype.place = function(constraint){var ret = []; for(var x = 0; x < g_Map.size; x++){for (var y = 0; y < g_Map.size; y++){if (g_Map.height[x, y] > this.lowerBound && g_Map.height[x, y] < this.upperBound  && constraint.allows(x, y)){ret.push(new PointXZ(x, y));}}}return ret;};

However, I try to avoid placer but it's up to you ofc.

I can't find placers for slopes. If you want to use slopes extensively perhaps look into the getGrad() of my erosion approach: http://www.wildfiregames.com/forum/index.php?showtopic=16233&page=5#entry274289

This will generate a "slope" map.

Edited by FeXoR
Link to comment
Share on other sites

I need some help with painting:

I want to paint the watertexture but somehow it doesn't work:

post-15513-0-33015700-1394548036_thumb.p

This is the painting code:

var placer = new HeightPlacer (ByHeight[0].height, ByHeight[3].height);var painter = new LayeredPainter([tWater, aReeds], [4,2], paintClass(clWater));createArea(placer, painter);

Also I used code to place paths through the forest but that does only work partially as it should avoid the water path (might be related to the problem above)

createArea(placer, painter, avoidClasses(clHill,0 ,clWater, 4, clBaseResource, 4));

I'm just curious on what that number does after clWater.

Attached is the full code.

post-15513-0-64039100-1394547999_thumb.p

Schwarzwald.zip

Link to comment
Share on other sites

I need some help with painting:

I want to paint the watertexture but somehow it doesn't work:

attachicon.gifscreenshot0001.png

This is the painting code:

var placer = new HeightPlacer (ByHeight[0].height, ByHeight[3].height);var painter = new LayeredPainter([tWater, aReeds], [4,2], paintClass(clWater));createArea(placer, painter);

Also I used code to place paths through the forest but that does only work partially as it should avoid the water path (might be related to the problem above)

createArea(placer, painter, avoidClasses(clHill,0 ,clWater, 4, clBaseResource, 4));

I'm just curious on what that number does after clWater.

Attached is the full code.

The water texture is not painted because the HeightPlacer() uses g_Map.height as heightmap while you modified myReliefmap and didn't apply it at the time you run the code.

Apply it by:

setReliefmap(myReliefmap);

(That's one reason I don't want to add a library prematurely. It should be working simple with other libs code.)

The path code does not generate the paths arround areas in avoidClasses(), the painter just doesn't paint it there (so it's interupted).

The two maps you choose in fact use painter/placers/avoid very rarely. Perhaps you should also try to avoid them if you want to go with those two maps code as a basis.

Or, if you want to use placers/painters/avoid you may want to use other heightmap manipulation functions that directly apply the changes to the heightmap (or you could just use setReliefmap(myReliefmap) simply every time you manipulate it).

Edited by FeXoR
Link to comment
Share on other sites

can you add some surprises in the Island? I said before the treasures.

Ah sorry, my sketch was a bit misleading, there is no island (not yet) because it is hard to do with the current terrain generation algorithm.

It is an open space without trees and in the center is a lake.

Maybe I will try to do so in future releases but it is not a priority yet.

Edited by niektb
Link to comment
Share on other sites

There where some additional bugs:

- My HeightPlacer() didn't work properly (I used [x, y] instead of [x][y] and if no constraint was given it failed)

- You gave an actor to the painter but it only takes "terrains" and you don't want to add the actor to every tile (so I changed that)

- The LayeredPainter() needs the "width" argument being an array of the length of the terrain array argument -1 (the center doesn't count. See: http://trac.wildfiregames.com/wiki/Rmgen_Library#Areapainters for an example)

- The RandomTerrain() class argument has to be a string of a terrain and optionally, separated with a "|", an entity from 0ad/binaries/data/mods/public/simulation/templates and a subdirectory (like "medit_sand_wet|gaia/flora_tree_dead" so without the ".xml"). You cannot use actors (from 0ad/binaries/data/mods/public/art) or templates (0ad/binaries/data/mods/public/simulation/templates without a subdirectory).

[This as a great inconvenience and one of the reasons why I try to avoid using the RandomTerrain() class and that includes painters etc.. Additionally doing simple things like adding a patch of terrain easily depends on 10 other functions/classes so it gets horrible to debug.]

- Additionally you used the UPPER height limit of the lowest level as the LOWER height limit for the painter (same for the upper height limit). I changed this accordingly.

Here's the map as far as possible working with your approach

(Since actors cannot be used I placed trees representative but you should avoid placing trees in water. The unit AI can't handle them.):

schwarzwald-fex_v1.zip

Additionally you should flatten the terrain where you place the paths (should be the SmoothElevationPainter()).

Edited by FeXoR
  • Like 3
Link to comment
Share on other sites

Here is the more info:

Paths are still placed in water, same goes for trees.

YXM1a8X.png
re0bQSG.png

Some questions:

- what are the numbers doing in the constraint of avoidClasses?

- How do I optimize to make the map run more fluently? (It currently scores ~20fps max, while normally it runs at 50~80fps (At Alpine lake skirmish)

- Currently there is an open space (near the edge) even though there doesn't run a path, how do I remove it?

Hz68sRm.png

schwarzwald.zip

Link to comment
Share on other sites

@ first glance:

- Trees in water: The tree placement function is from Deep Forest (AFAIK). It is based on a possibility derivation across the entire map and doesn't support constraints.

- Constraints/avoid classes: http://trac.wildfiregames.com/wiki/Rmgen_Library#ControllingPlacement:Constraints

- Framerate: The framerate is low due to the many trees. There's not much you can do about it. You can raise it a bit by only/mainly using low poly trees (e.g. gaia/flora_tree_pine) and avoid the higher poly ones (e.g. flora_tree_oak_large). It's the same with Deep Forest.

- Open space: Just remove the possibility factor based on the map radius (in the possibility derivation mentioned before).

General notes:

- Make sure the order of things is correct. It matters (e.g. in Deep Forest paths "overrider" woods so they have to be placed later).

- You use different concepts never meant to work with each other (Placers/Painters/Constraints/Avoids vs. Global tree density functionality vs. Height based placement). Maybe you should first get a concept of code in your mind ready, decide which one to use and then stick with it.

Edited by FeXoR
Link to comment
Share on other sites

I think it's pretty cool to have some trees in a flooded region at some times. Sparked another idea for our ventures: floods and tsunamis, vulcanic eruptions and earth quakes. Not to forget the climates influence on the ground textures, so your green valley might become a desert over the centuries. ;)

Edit: Actually I think it's quite common for forests having glades? You two: rock on. This realism is amazing.

Hz68sRm.png

Edited by Hephaestion
  • Like 1
Link to comment
Share on other sites

No, creating them, not setting them.

Ah, k.

They are placed in 0ad/binaries/data/mods/public/art/textures/skies/cirrus and the format is .dds.

Gimp can convert images to .dds with a plugin.

(Not sure if the existing ones are volume textures rather then plane images)

Why do we use a Microsoft format? Isn't there an open format for such things?

(Guess the specifications are open and Microsoft follows it for a change ^^ (?))

Edited by FeXoR
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...