Mapping Vortex dynamics to Unity graphics
In Vortex, Mechanisms are created that contain Parts, Constraints and other simulated objects. With the Vortex Unity integration, the usual method to associate Vortex dynamics to Unity graphics is to connect the Dynamics Part to the Graphics Node in Unity.
Mapping Vortex dynamic Parts to Unity graphics objects is the main way to animate Unity objects according to the Vortex real-time dynamics simulation.
To get familiar with creating real-time simulations using Vortex Mechanisms and their components, first consult the documentation on how to create Mechanisms in Vortex Studio.
How to map Vortex dynamics to Unity graphics
To use Unity graphics with Vortex dynamics, some considerations must be taken concerning the graphics object hierarchy:
1) Keep the same object hierarchy between Vortex and Unity
The hierarchy in the graphics in Vortex and in Unity must be the same. This is usually accomplished by importing the same FBX file in Unity and in Vortex. For more information on importing 3D models in Unity, consult this page: Unity - Manual: Importing a model. For example, we can compare the imported model in Unity of the demo scene Excavator, to its graphics gallery in the Vortex Editor:
Vortex Editor - Excavator Graphics Gallery hierarchy | Unity Editor - Excavator imported model (FBX) hierarchy
|
This means that a Vortex Graphics Gallery should have the same hierarchy (including its root and its graphics nodes) as a Unity 3D model prefab imported from an FBX file. To help keep the same hierarchy between both, simply check the Preserve Hierarchy option in the Import Settings of the FBX files. The Bake Axis Conversion should be unchecked. See here:
After importing the model in Unity, it is recommended to create a separate prefab file from it, which will be useful later.
2) In Vortex, connect Graphics Node to Dynamics Part
In Vortex, the graphics are located in a Graphics Gallery file that is usually added to a Mechanism or Assembly. Then, Graphics Nodes are connected to moving dynamics Parts: that is the Part-Node mapping. Parts are added and configured in the Assembly document, and can be connected to graphics nodes of a graphics gallery from the Assembly or Mechanism document containing the Graphics Gallery. In the following example, a graphics node is getting connected to a part using the “Connect to Part“ option from the contextual menu:
Doing this results in a Connection Container extension named Skin being added to the document. In the Connection Editor, the resulting graph looks like this:
The next steps will be entirely within the Unity Editor.
3) Associate a Unity scene to a Vortex scene
When associating a Unity scene to a Vortex scene, the Vortex Scene hierarchy will be recreated in Unity. If it is a new Vortex scene created from Unity, first add your mechanisms or assemblies. Correctly associated objects will have the Graphics Gallery or Graphics Node icon next to their name in the scene hierarchy, as well as having either the Vortex Graphics Gallery or Vortex Node components attached. This is also the case for other extensions such as Mechanisms, Assemblies, and VHL interfaces, that are all supported by the Vortex Unity integration.
By default, game objects corresponding to graphics nodes that are connected to dynamic parts are added automatically when the scenes are associated. These can be easily spotted by the cubes that are added to the scene. At this point, running the simulation (by entering Play mode and starting the Vortex simulation) will show these placeholder cubes moving according to the Vortex physics simulation.
4) Replace placeholder graphics with your own
To replace these placeholder graphics with your own, we suggest to do the following:
Replace (or modify) the graphics gallery game objects with a different one containing your actual graphics. Again, it must keep the same hierarchy!
To replace it, simply delete the default object, then add your own one in its place. Then, save your scene and reload it. If the hierarchy matches, the Vortex Graphics Gallery and Vortex Node components will be added automatically when the scene reloads.
At this point, we also suggest saving your mechanism, assembly or graphics gallery as a Vortex prefab in your Unity project. Doing this will allow you to re-use it easily in other scenes. In fact, if the corresponding Vortex documents are in a different existing Vortex scene, these prefabs will be added automatically to a Unity scene when it is first associated to this Vortex scene.