How to Display Grade Quality Sensor in Unity

Grade Quality Sensors, dynamically simulated in Vortex Studio, can be rendered in Unity during simulation. When Grade Quality Sensors are loaded, a Grade Quality Sensors prefab is loaded from an asset bundle file located in the same directory as the Vortex file that contains the Grade Quality Sensors.

Manually creating prefabs and Asset Bundles

To manually create assets for the Grade Quality Sensors, a Unity project with the Vortex Integration Package is needed (such as VortexUnityTools or your own project), some Grade Quality Sensors prefabs must be added and the assets must be packaged in asset bundles.

For an overview of the assets workflow, refer to Workflow for Preparing and Using Assets for a Vortex Simulation with Unity Graphics.

Grade Quality Sensors Prefabs

At simulation time, when a Grade Quality Sensor instance is added, the Vortex Integration will look for a Grade Quality Sensor prefab with a specific name. The prefab name must contain the Graphics Point Cloud hierarchy with the Graphics Point Cloud name from the Vortex Editor explorer without the parent element that is contained in a Vortex file. The hierarchy levels are separated with period characters. Folders are omitted from the hierarchy. The name and hierarchy are case sensitive.

For example, for the following hierarchy, the prefab name would be Construction_Site.Grade Quality Sensor.Graphics.

Creating a Grade Quality Sensor Prefab

The Grade Quality Sensor prefab must have a Vortex Grade Quality Sensor component and a Vortex Grade Quality Sensor Renderer component.

  1. Create an empty GameObject
    image2021-2-16_9-47-6.png

  2. Rename it with the proper name (see the Grade Quality Sensors Prefabs section introduction)


  3. Select the created GameObject and add the VortexGradeQualitySensor the VortexGradeQualitySensorRenderer components in the inspector

  4. Import a mesh in the asset folder that will be assigned to Grade Quality Sensor

  5. In the VortexGradeQualitySensorRenderer component properties, assign the imported mesh to the mesh property


  6. Create a material based on the GradeQaulitySensorEmissiveShader shader


  7. On the Grade Quality Sensor game object, in the VortexGradeQualitySensorRenderer component properties, assign the created material to the Material field


  8. Drag and drop the GameObject somewhere in the asset bundle folder in the project pane to create the prefab


In the following section, we present in great detail the required components that compose a Grade Quality Sensors prefab.

The VortexGradeQualitySensor Component

The VortexGradeQualitySensor component is in charge of managing the Grade Quality Sensor data and to updating the renderer.

FieldDescription
Height Field Prefab NameOptional parameter to link a Grade Quality Sensor to an Earthwork Zone prefab. When this field is not empty, the VortexGradeQualitySensor will try to find get the point cloud position values directly from the rendered Earthwork Zone for better precision. 

The VortexGradeQualitySensorRenderer Component

The VortexGradeQualitySensorRenderer is in charge of rendering the sensor's data as a point cloud where each point is a mesh instance.

These public fields can be configured through the inspector:

Field

Description

MeshThe mesh that will be instantiated at each point 
Sub Mesh IndexThe sub mesh index to use
Mesh OffsetBase offset position in meters
Mesh OrientationBase offset orientation in degrees
Mesh ScaleBase mesh scale
MaterialThe material used to render the point cloud

The Grade Quality Sensor Emissive Material

The Grade Quality Sensor material must be based on the GradeQualitySensorEmissiveShader shader. The material interpolates between 3 colors based on the sensors data.

These public fields can be configured through the inspector:

Field

Description

Gradient Start ColorFirst color for interpolation
Gradient Middle ColorSecond color for interpolation
Gradient End ColorThird color for interpolation
Point Cloud OpacityThe point cloud global opacity

Creating an Asset Bundle

Once the Grade Quality Sensors prefabs are created, they can be packaged in asset bundles so that they can be loaded by VortexUnityApp, or your own similar Unity application with Vortex Integration.

The process for generating an asset bundle is described in this section. In short, you can use the Export Asset Bundle... command from the context menu when selecting the folder containing the prefab's assets.

Then, select the file's destination and name to create the file.

In order to get VortexUnityApp to load the asset bundles properly, the asset bundles files should be placed in the same folders where are stored the Vortex file that contains the Grade Quality Sensor.