In this recent post we looked at FormIt’s JavaScript API and learned how Brett Garrison was able to use it to develop a Maze Generator plugin. In this post we look at one way to find solutions for the mazes generated by this plugin using VASA from Dynamo.
When I first started looking into VASA with FormIt, Rhys Goldstein sent across a Dynamo graph he’d used to grab contextual building geometry from FormIt – to create a voxel model of the space – and then send the pathfinding results back afterwards. I’ve adapted this graph to work with the results of the Maze Generator plugin.
To get started with this, we need to install the plugin (something we saw in the previous post in the series) and then generate a maze with the settings of our choice. These settings will need to be transferred manually into the Dynamo graph if you change them from the defaults.
You can use FormIt for Web to created the graph – as the Maze Generator plugin will work there – but to work with Dynamo you’ll need to load the sketch (or run the plugin directly) in FormIt for Windows.
To launch the Dynamo graph, you’ll probably need to save it in a known location and then connect to that location via the “Link Dynamo Directory” button at the top-left of the Dynamo panel inside FormIt for Windows. You can then open the graph inside Dynamo via the pull-down on the graph.
When it first loads you’ll see warnings: this is completely expected, as you haven’t yet selected geometry inside FormIt. To do so, you’ll need to click on the “Select from FormIt” node.
At which point you should have the prompt inside FormIt to select maze geometry. I tend to use window-select for this.
After clicking the tick (or the checkmark) you should at least start to see maze geometry inside FormIt. If you’re lucky – and the settings don’t need changing – then it will hopefully already show a path, otherwise you’ll need to tweak the settings to match the ones specified in the UI for the Maze Generator.
At this point you should have a path shown in red.
You can see it clearly by switching to the geometry view.
Sometimes the path geometry – for me, anyway – doesn’t show up automatically inside FormIt, which may very well be a quirk of using it inside a Parallels VM on my Mac. In any case, clicking the Dynamo graph should cause it to run again and the “Send to FormIt” node to execute.
At which point selecting the origin will bring the path geometry into FormIt so that it matches the maze geometry. And solves it!
Here’s a video showing the full process (slightly sped up):
It’s worth noting that it’s important to use the right voxel resolution for your geometry: when I first ran the Dynamo graph it was using 16 times as many voxels as required, and it therefore took much longer to execute than expected. The video in this recent post talks in depth about how to change these resolution settings, so be sure to check it out if you’re experiencing performance issues with VASA.
That video also showed the scenario where we work with 2D geometry: I’ve chosen to keep the voxelization and pathfinding in 3D, despite the maze-solving problem being fundamentally 2D in nature. In the next part of this 2-part series we’ll take a look at how we can use 2D pathfinding with geometry generated by matterlab’s excellent 3D Context Creator plugin. In the post after that we’ll come back to solving mazes, taking a quick look at how it’s possible to call VASA from WebAssembly directly from a plugin (although as the WASM package for VASA hasn’t yet been published, this is more for reference or context than for people to be able to try themselves, for now).