Recently, I was asked by a community member if it were possible to send very simple geometry from Grasshopper (e.g. point/curve/simple meshes) to unreal and “asset swap” them to native Unreal geometry (trees, cars, etc.)
In response, I created a little proof of concept that I’d like now to share with all our community.
We don’t have any plans to implement a mapping tool in our Unreal Connector any time soon, which would be the perfect solution to this.
However, since Unreal (and Grasshopper) is such a dev friendly environment, it’s very possible for users to create their own custom mapping workflows.
There’s definitely multiple ways to achieve this depending on your requirements and workflow.
But one of the easiest ways is through customising the Unreal Connector’s converters. These are the conversion functions that convert Speckle objects to native Unreal objects.
A custom mesh converter could provide options mapping Speckle meshes to native unreal ones.
I would suggest starting by checking out our tutorial on how to create custom conversion functions. Here we go through how the process can be done in either C++ or blueprint.
I have a quick proof of concept (nothing more) that shows off some of the hurdles you may have to jump through, mostly regarding getting the position + rotation + scale data transferred between connectors.
Firstly, I created a custom mesh converter (see tutorial).
In the ToNative function, we are checking for a custom “OverideMesh” property on incoming meshes (red section)
if they don’t have it (blue section), we just use the normal mesh converter (“fallback”)
if they do have it (green section) we look up the key in a Map of string → Actor which tell us which actor to use to override which keys
We can specify these string → actor mappings in the BP instance.
From grasshopper, I grab some rhino geometry that’s centred on the origin, and transform it into many objects.
I extend the converted mesh with its transform data, and set the OverrideMesh property to be “Chair”.
It will just be this transformed data that our custom blueprint will pickup and use.
Over in unreal, with our custom converter added to the SpeckleUnrealManager, you can see when we receive the mapped meshes, we replace them with our specified chair actor.
This should work as is, and since we used a dictionary for the mappings, will work for any number of mappings.
The requirement to keep track of the transforms in grasshopper might not fit everyone’s needs. In which case, you may find more luck sending points, lines, or planes from Grasshopper, and receive into a custom object model in Unreal.