public void createNewObject(ModelingObject.ObjectType type, Face groundface, ModelingObject original, Vector3 offSet, bool insideStage, Group group, Color color, GameObject complexObject) { Mesh mesh = new Mesh(); if (type == ModelingObject.ObjectType.triangle) { mesh = triangle; } else if (type == ModelingObject.ObjectType.square) { mesh = square; } else if (type == ModelingObject.ObjectType.octagon) { mesh = octagon; } GameObject newObject = Instantiate(modelingObject); if (insideStage) { newObject.transform.SetParent(objects); } else { newObject.transform.SetParent(library); } ModelingObject newModelingObject = newObject.GetComponent <ModelingObject>(); newObject.name = "Object " + objectIDcount; newModelingObject.ObjectID = objectIDcount; objectIDcount++; newModelingObject.typeOfObject = type; newObject.GetComponent <ModelingObject>().Initiate(mesh); if (groundface != null) { newObject.transform.localEulerAngles = new Vector3(0f, 0f, 0f); newObject.transform.position = groundface.center.transform.TransformPoint(groundface.center.coordinates + groundface.normal * 0.4f); newObject.transform.localScale = groundface.transform.parent.parent.transform.localScale; newModelingObject.bottomFace.ReplaceFaceOnOtherFace(groundface, new Vector3(0f, 0f, 0f), true); newModelingObject.topFace.ReplaceFaceOnOtherFace(groundface, groundface.normal.normalized * 0.1f, false); // recalculate centers newModelingObject.RecalculateCenters(); // recalculate normals newModelingObject.RecalculateNormals(); } else { if (insideStage) { newObject.transform.localScale = new Vector3(1f, 1f, 1f); newObject.transform.localEulerAngles = new Vector3(0f, 0f, 0f); newObject.transform.localPosition = new Vector3(0f, 0f, 0f); newObject.transform.localPosition = offSet; } else { newObject.transform.localPosition = offSet; newObject.transform.localScale = new Vector3(0.8f, 0.8f, 0.8f); } } if (original != null) { // SetVertexBundlePositions(Vector3[] topFaceCoordinates, Vector3[] bottomFaceCoordinates, Vector3 topFaceCenter, Vector3 bottomFaceCenter) Vector3[] topFaceCoordinates = new Vector3[original.topFace.vertexBundles.Length]; Vector3[] bottomFaceCoordinates = new Vector3[original.bottomFace.vertexBundles.Length]; for (int i = 0; i < topFaceCoordinates.Length; i++) { topFaceCoordinates[i] = original.topFace.vertexBundles[i].coordinates; } for (int i = 0; i < bottomFaceCoordinates.Length; i++) { bottomFaceCoordinates[i] = original.bottomFace.vertexBundles[i].coordinates; } newModelingObject.SetVertexBundlePositions(topFaceCoordinates, bottomFaceCoordinates, original.topFace.centerPosition, original.bottomFace.centerPosition); newObject.transform.localPosition = offSet; newModelingObject.coordinateSystem.transform.localRotation = original.coordinateSystem.transform.localRotation; } // newModelingObject.CorrectOffset(); newModelingObject.CalculateBoundingBox(); newModelingObject.InitiateHandles(); if (group != null) { ObjectsManager.Instance.AddObjectToGroup(group, newModelingObject); //newObject.transform.position = offSet; } newModelingObject.ChangeColor(color, false); latestModelingObject = newModelingObject; if (complexObject != null) { newModelingObject.InsertObject(complexObject); } }