Hide menu
Integration with Unity

Overview

One possible custom scenario is to use CAD Exchanger together with the Unity game engine. CAD Exchanger supports integration with Unity game engine for the purpose of loading models in formats not supported by Unity itself.

Conversion of models to Unity objects

CadExUnity is a CAD Exchanger SDK module that allows you to convert ModelData_Model to Unity's GameObject.

Note
Since Unity scripts are implemented in C#, the CadExUnity module is only available as a .NET library.

ModelData_Model is mapped to Unity objects as follows:

  • Product structure is mapped to the hierarchy of GameObjects, implemented via parent-child relationships.
  • The geometry is stored in Unity.Mesh.
  • Appearance attributes are converted to Unity.Material.
Note
Since Unity does not support B-Rep geometry, for all models that do not contain a polygonal representation, the BRep-representation will be converted to polygons.

To perform the conversion one must use Unity_ObjectFactory.Create() which takes the ModelData_Model and an optional name and returns GameObject.

The following example demonstrates a typical workflow:

using cadex;
using UnityEngine;
STEP_Reader aReader = new STEP_Reader();
aReader.ReadFile(new Base_UTF16String("MyModel.stp"));
//convert STEP to MDM
ModelData_Model aLoadedModel = new ModelData_Model();
aReader.Transfer(aLoadedModel);
//convert MDM to GameObject
Unity_ObjectFactory aConventer = new Unity_ObjectFactory();
GameObject aTarget = aConventer.Create (aLoadedModel, "MyModel.stp");

Examples

Refer to Unity Example

Defines classes, types, and global functions related to CAD Exchanger.
Definition: cadexsdk.txt:172