Browse Source

Process instances when converting mesh

Replaced redundant code to function call.  Process instances if this is
a prefab with instances
punkoffice 9 years ago
parent
commit
ef1c2b3fbd
1 changed files with 3 additions and 11 deletions
  1. 3 11
      Exporters/Unity 5/Unity3D2Babylon/SceneBuilder.Meshes.cs

+ 3 - 11
Exporters/Unity 5/Unity3D2Babylon/SceneBuilder.Meshes.cs

@@ -112,7 +112,7 @@ namespace Unity3D2Babylon
             }
         }
 
-        private void ConvertUnityMeshToBabylon(Mesh mesh, Transform transform, GameObject gameObject, float progress)
+        private void ConvertUnityMeshToBabylon(Mesh mesh, Transform transform, GameObject gameObject, float progress, BabylonAbstractMesh[] instances = null)
         {
             BabylonMesh babylonMesh = new BabylonMesh();
             var renderer = gameObject.GetComponent<Renderer>();
@@ -123,16 +123,8 @@ namespace Unity3D2Babylon
             babylonMesh.id = GetID(transform.gameObject);
             babylonMesh.receiveShadows = renderer.receiveShadows;
 
-            babylonMesh.parentId = GetParentID(transform);
-
-            babylonMesh.position = transform.localPosition.ToFloat();
-
-            babylonMesh.rotation = new float[3];
-            babylonMesh.rotation[0] = transform.localRotation.eulerAngles.x * (float)Math.PI / 180;
-            babylonMesh.rotation[1] = transform.localRotation.eulerAngles.y * (float)Math.PI / 180;
-            babylonMesh.rotation[2] = transform.localRotation.eulerAngles.z * (float)Math.PI / 180;
-
-            babylonMesh.scaling = transform.localScale.ToFloat();
+            babylonMesh.parentId = GetParentID(transform);
+            ConvertTransform(babylonMesh, transform, gameObject, instances);
 
             babylonMesh.positions = new float[mesh.vertexCount * 3];