MapMagic 2 - infinite procedural land generator

I got this and “Objects” a while back and it is wonderful. I’ve run into a bit of a problem, i would like to access exposed variables at runtime and i’m not sure how to do this, i know to do the map seed i can just do something along the lines of -

MMObj.graph.random = new Den.Tools.Noise(seedValInt, permutationCount: 32768);

Where MMObj is my MapMagicObject but i’m not sure how to change the values of the exposed variables of say a Vector2 entry that i have exposed. I was looking at things like MMObj.guiExposedVariables but couldn’t get it to work.

Please help me!
Jason

What you want to do is to expose the value. In the graph, right click on the space for the value and then click Value->Expose and give it a name.
Now you can access that value by doing something like trrn.graph.defaults[“MyExposedValue”] = X;

Were trrn is the reference to your map magic object, you can call it whatever you want, and “MyExposedValue” is a string with the name of your exposed value. The string must be surrounded by “” because it’s a string. X is whatever you want to set that value to, make sure if you are exposing a float or an int, you set it to the same kind of variable.

If you set the name of the exposed value wrong I think you won’t have an error but nothing will happen. You can also retrieve the value it currently has like any other variable since it has a get as well as the set.

1 Like

Sir/Madam, you are amazing, thank you so very much. That worked like a charm and is exactly what i needed to do!

Just in case - if you want to change node variables from code you don’t even have to expose those: you can get node by id, cast to it’s type, and access all values directly:

Im presuming this will work for Map Magic 1 and 2.

Which has the better performance generating a graph:

Limiting a scatter node to cover only a limited area, then using that for forest trees?

OR

Scattering node > Forest trees then Cleaning that up after?

Or doesn’t really matter?

This one should be slightly faster - especially when the number of scatter is big. This will just avoid creating arrays of positions.

But the difference is not that drastic, if it’s convenient to work as second variant - go this way.

1 Like

Just wondering are new forums working? Or everyone just moved to Discord? If you have any unanswered question - please let me know via email. Sorry if I’m missing something.

It has suddenly been quiet on this thread since mid-August, but I’m still receiving notification when there’s a new post in the thread. :man_shrugging:

Seems like it’s happening to many threads. It’s just harder to use this format.

1 Like

in general I think Discord is much more useful to have a conversation in than the new unity forums and also it’s a more convenient place for you to post information and such

I am using various types of masks for things like microclimate zones, biomes, habitats etc, and am wondering if there is a way to somehow set something like a minimum “size” or “amount” for a mask that must be satisfied within a given area, and zero it out if its below a given threshold (not enough of that mask within the vicinity). For example an “area” must have a minimum radius of N meters with an average mask value above X for it to count.

I don’t know the exact mathematics that could be used to express this, but I hope the idea gets across anyway.

To elaborate on my use case, here is an image for reference. The mask represents wooded areas. I would like to be able to add a node that would select the large area to the right, where the wood is dense enough to have an impact on something like wind, while masking out the splotchier areas. I could use the same mechanism to control creature spawns so that they only spawn if the area is big enough to sustain life, for example left and right sides, while I just spawn vegetation on the base, unfiltered mask as seen in the image.

I hope this makes sense. Right now I am using a combination of blurring, contrast and levels to try to achieve this, but it seems like a pretty blunt tool for the job. Is there a better way to achieve it? For the record, I haven’t picked up the biomes pack yet (have most of the other ones) as I kind of invented my own workflow for this, but if that adds additional tools for this I’ll jump on it.

On that same note, is there a way to “center” an object spawn in the middle of a mask area, i.e. the place where the neighbouring area extending outwards would have the highest total mask value, so that I could drop a pin in the middle of the wooded area to the right? The exact definition and accuracy of middle here is not so important, just a rough eyeball kinda thing is fine.

This seem to be a right way, was going to say that while I was reading. I don’t have a better idea to do it rather than use a combination of blur+contrast.

Any idea how the center could be calculated?

Cool, thanks for confirming that it makes some kind of sense at least.

For finding the center, I’m not sure what’s a good way. My idea for now is to output to a direct matrix and use it as an influence map. I will downsample the resolution to a grid size of N meters. Then I will iterate over each tile, adding the values of the M/2 neighboring tiles in each direction (so that I’m checking across an area of size (MxN)^2) and then selecting the tile with the maximum total neighbor influence value. I think I will use blur to make sure the distribution is somewhat even within a conjoined area, and just sample the center of each tile for simplicity.

That is not guaranteed to be the exact center, but it will at least be a decent candidate assuming the total area is not significantly larger than (NM)^2. The larger the area checked, the closer you will be to the center, but at the cost of having to check more tiles. Center is probably the wrong term to use,maybe more like a local density maximum or whatever.

Sorry for formatting, these forums suck on mobile…

Or I would rather start the other way round. Scatter objects first, then use Stroke to add circles, and overlay with noise to make them less circular.