MapMagic 2 - infinite procedural land generator

I found it best to start with a new MM2 project and then add assets to check for compatibility.

Hey @Wright , congrats on the release, great job!
However, I have some questions/problems.

  1. How do I set MapMagic seed via script? WIth MM1 I just did MapMagic.instance.seed = something;
  2. I am trying to generate terrain via script at runtime, so I tried the StartGenerate method of the MM object, however I’m getting the following exception:
Exception: TileManager: No Camera in scene to generate tiles.
Den.Tools.TileManager`1[T].RefreshCamCoords (System.Single tileSize) (at Assets/3rdParty/MapMagic/Tools/TileManager.cs:152)
Den.Tools.TileManager`1[T].Update (UnityEngine.Vector3 tileSize, System.Object holder, System.Boolean distsOnly) (at Assets/3rdParty/MapMagic/Tools/TileManager.cs:99)
MapMagic.Core.MapMagicObject.Update () (at Assets/3rdParty/MapMagic/Core/MapMagicObject.cs:152)
MapMagic.Core.MapMagicObject.EditorUpdate () (at Assets/3rdParty/MapMagic/Core/MapMagicObject.cs:145)
System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at <437ba245d8404784b9fbab9b439ac908>:0)
Rethrow as TargetInvocationException: Exception has been thrown by the target of an invocation.
System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at <437ba245d8404784b9fbab9b439ac908>:0)
System.Reflection.MethodBase.Invoke (System.Object obj, System.Object[] parameters) (at <437ba245d8404784b9fbab9b439ac908>:0)
System.Delegate.DynamicInvokeImpl (System.Object[] args) (at <437ba245d8404784b9fbab9b439ac908>:0)
System.MulticastDelegate.DynamicInvokeImpl (System.Object[] args) (at <437ba245d8404784b9fbab9b439ac908>:0)
System.Delegate.DynamicInvoke (System.Object[] args) (at <437ba245d8404784b9fbab9b439ac908>:0)
UnityEditor.EditorApplication.Internal_CallUpdateFunctions () (at <90d4bcb003fb405fb09241aed2f178aa>:0)

I disabled the Infinite Terrains and also the Generate around main camera as I do not want to use these features and want to control the generation myself.
When I enable the “around main camera” option and still have the Infinite terrains disabled, MapMagic spawns a lot of unwanted tiles.

2 Likes

New version 2.0.1 in available at the asset store. It contains the Mac OS fix and some small changes.

I will check VS Pro compatibility with no objects module. For now you can just remove VSProObjectsOut.cs - at least it should not be in a core version. Probably it’s editor script should be removed too.

Now it’s a bit more complex. The seed value is not kept anywhere, but used to initialize the noise that is the part of the graph:

mapMagicObject.graph.random = new Noise(mySeed, 32768);

Where 32768 is a permutation count (i.e. “diversity” of the noise) = 2^15, no need to change it :slight_smile:

I think I’ll add some interface functions to mapMagicObject - like this one to set seed. Feel free to write your ideas of what else should be exposed this way.

Speaking of re-generating it’s already here: mapMagicObject.Refresh();

MapMagic should not generate anything when all “Around” checkboxes are disabled. Seems to be a bug, will look into it.

4 Likes

Thanks for the reply, will try the seed snippet. :slight_smile:
Regarding the other problem, I’m not sure we understand each other.
When all “Around…” checkboxes are disabled and Infinite generation is also disabled, MapMagic doesn’t generate around anything, but it throws the exception I posted, preventing me from just generating terrains at runtime via script. When I leave “Infinite” disabled but enable “Around camera”, it sitll generates new tiles.
I just want to generate (force generate, if you will) when the game starts, with random seed. I did that in MM1 with ease, I just used Generate with force set to true. So all in all, should I use Refresh() instead of StartGenerate()?

ya just curious how involved your spline tool plans to be, Easy roads, shoulders, is nice. So I was just curious . Thanks for the info.

@Wright Any plans for procedural lake placement? Like spline generation around isoheights?

How do we create custom generators for MM2? @Wright is it possible to have an equivalent of SampleGenerator.cs from MM1 and some instructions on the wiki?

I would like to validate, do we need the Object module to work with both Vegetation Studio Pro and Map Magic 2? I am getting those errors.

Congrats on the release, really excited about this one! So far, everything has been flawless, good job!

If you want to generate (or re-generate) the pinned tiles you’ve got to use Refresh(). To pin the tile you can use mapMagicObject.tiles.Pin(new Coord(int myTileX, int myTileZ), bool pinAsDraft, MapMagicObject mapMagicObject);
Just wondering if the method like PinAndGenerate (int tileX, int tileZ) be better for that?

I’ve reproduced and fixed the error you mentioned - the fix will be available in next release. I think I get it what you want to do, and you doing it right, however this error doesn’t let you to move further.

You could [place the lake planes]( https://discussions.unity.com/t/619852 page-77#post-4370131) in MM1. If you mean more complicated approach - feel free to share your idea.

Yes, isoline node - the one that will create a spline “slice” of the terrain at the given height - is planned.

Yep, will create one along with the documentation.

No. You’ve got to remove VSProObjectsOut.cs and VSProObjectsEditor.cs scripts. They were included in build by a mistake, and won’t be here in the next version. Obviously, you can use only the VSPro maps with the core package, not persistent storage objects.

Thanks!

2 Likes

I must have missed that approach for MM1. I’ll give it a try.

As for ideas, I was thinking (naively) with isolines, say you sample it at height H and get some closed splines, and do a second sample at (H - dy) and get a second set of splines. Wherever a bounding box of a spline from the first sample contains the entire bounding box of a spline from the second set, then it’d mean we have a depression in the topology that could accumulate water. Then one could generate a mesh from the containing spline and assign some water material to it or extrude it for a volume or something. I might be missing something with the logic of this of course, so excuse me if it’s a stupid idea.

New video - a biomes module tutorial. Showing the way to mix several graphs in one scene:

https://www.youtube.com/watch?v=cmY5W0jRbjI

Sounds to be an over-complicated to create lakes. In most cases the square plane is enough.

2 Likes

@Wright is there one for splines coming soon? Also I just picked up Polaris v2. It would be great to integrate a low poly generator like that as an output node for MM2 at some point.

Hey, just bought Map Magic 2, I just would like to know as we talked earlier in the Voxeland Thread about the compatibility from MM2 with Voxeland, is there an expectation when we could possibly use it together with voxeland?

1 Like

An announcement to all Vegetation Studio Pro and MapMagic 2 core (with no Objects module) users:

To make the compatibility work in a version 2.0.1 you’ve got to manually remove VSProObjectsOut.cs and VSProObjectsEditor.cs scripts. Their presence in the MM2 core module is a bug. They are part of the Objects module. On removing them you will not loose VS Pro compatibility, and still will be able to create maps for VS Pro (but obviously, not objects). The fixed version is currently pending Asset Store review.

Objects module users don’t have to remove anything, these files are required for VS Pro objects output.

The next one planned is devoted to functions, but the next one, after a while - yep, it will be the roads tutorial.

Tam, the author of Polaris V2 contacted me and showed interest in integrating assets. I will provide him the documentation on creating outputs when it’s ready, and will try to assist him in creating a Polaris output.

I plan to make a big update for Voxeland when I’ll finish the Splines module, and this update will bring in MM2 compatibility. But still it’s just a plan, no ETA or even promise that it ever will be done.

1 Like

I tried Scatter → Forest → Stroke → Texture, but i can’t connect the Texture node, the connection line is red. Though Scatter → Stroke → Texture works. What is going on with the Forest node and how can i paint textures for the forest node objects?

Lol you asked for a more complicated idea, you got one.

1 Like

@Wright Can you please fill the microsplat docs page? I can’t get the integration to work :frowning:

The shore node seems to be missing in MapMagic 2. That was really helpful for islands. How would we duplicate that functionality in MM2?

3 Likes

Hi Dennis!

I’ve modified the EditorWindow script’s lines 289-291 (well, not really, just added two extra lines after):

    //right click menu (should have access to cellObjs)
                if (!UI.current.layout  &&  Event.current.type == EventType.MouseDown  && Event.current.button == 1 )
                    RightClick.DrawRightClickItems(graphUI, graphUI.mousePos, graph);
                else if(!UI.current.layout  &&  Event.current.type == EventType.KeyDown  &&  Event.current.keyCode == KeyCode.Space )
                    RightClick.DrawRightClickItems(graphUI, graphUI.mousePos, graph);

many editors use the space key to display the add menu (I know for sure substance designer does, and I believe amplify does too). I’m so used to this that I’ve added the behaviour.

Do you think you could sometime include the option of selecting a key to trigger this behaviour in the settings window? Not to replace the right key necessarily, but to be an additional way of calling it.

It would be great if we didn’t have to stick to simply using the right mouse, I know it’s a dumb request but if you don’t mind I’m sure many users that are already familiar to those softwares would appreciate it.

It would also be nice if we could delete by right clicking the node or by pressing the delete key to delete the “active” node! but I know I’m just being picky. In all honest thanks a lot for the amazing work, I’m loving MM2 so far! Although I just started, gotta be honest… hehe.

2 Likes