void OnEnable ()
		{
			//Get target MeshFilter
			targetMeshFilter = (target as MeshFilter);
			if (menuExpanded) {
				ejmmesh = new EJMMesh(targetMeshFilter);
				LoadCurrentEditor();
			}
			//LOAD ICONS
			OpenGUI = new GUIContent(Resources.Load("Icons/wrench_icon") as Texture2D, "Edit");
			if (OpenGUI.image == null){OpenGUI.text = "EDIT";}
			OpenUniqueGUI = new GUIContent(Resources.Load("Icons/wrench_plus_icon") as Texture2D, "Edit as Unique");
			if (OpenUniqueGUI.image == null){OpenUniqueGUI.text = "EDIT";}
			CloseGUI = new GUIContent(Resources.Load("Icons/exit_icon") as Texture2D, "Save and Exit");
			if (CloseGUI.image == null){CloseGUI.text = "DONE";}
			ObjectGUI = new GUIContent (Resources.Load("Icons/object_icon") as Texture2D, "Object Tools");
			if (ObjectGUI.image == null){ObjectGUI.text = "OBJ";}
			VertexGUI = new GUIContent (Resources.Load("Icons/vertex_icon") as Texture2D, "Vertex Tools");
			if (VertexGUI.image == null){VertexGUI.text = "VERT";}
			TriangleGUI = new GUIContent (Resources.Load("Icons/triangle_icon") as Texture2D, "Triangle Tools");
			if (TriangleGUI.image == null){TriangleGUI.text = "TRIS";}
			NormalGUI = new GUIContent(Resources.Load("Icons/normal_icon") as Texture2D, "Normal Tools");
			if (NormalGUI.image == null){NormalGUI.text = "NORM";}
			UVsGUI = new GUIContent(Resources.Load("Icons/uv_icon") as Texture2D, "UV Tools");
			if (UVsGUI.image == null){UVsGUI.text = "UVs";}
			PrimitivesGUI = new GUIContent(Resources.Load("Icons/primitives_icon") as Texture2D, "Primitives");
			if (PrimitivesGUI.image == null){PrimitivesGUI.text = "PRIM";}
			RevertGUI = new GUIContent(Resources.Load("Icons/undo_icon") as Texture2D, "Revert Mesh");
			if (RevertGUI.image == null){RevertGUI.text = "UNDO";}
			ToolbarIcons = new GUIContent[6]{ObjectGUI, VertexGUI, TriangleGUI, NormalGUI, UVsGUI, PrimitivesGUI};
		}
示例#2
0
		public static GameObject DetachToNewObject(ref EJMMesh ejmmesh, HashSet<int> indices){
			// Create new Gameobject
			GameObject obj = new GameObject ();
			MeshFilter filter = obj.AddComponent<MeshFilter> ();
			filter.sharedMesh = new Mesh ();
			obj.AddComponent<MeshRenderer> ();
			EJMMesh newejmmesh = new EJMMesh (filter);
			// Import data from ejmmesh
			newejmmesh.ImportData (ejmmesh.SharedMesh);
			//Remove the old triangles
			int submeshStartIndex = 0;
			for (int i=0; i<ejmmesh.SharedMesh.subMeshCount; i++) {
				List<int> tris = ejmmesh.SharedMesh.GetTriangles(i).ToList();
				int trisLength = tris.Count;
				List<int> removedtris = new List<int>();
				for (int j=submeshStartIndex+trisLength-3;j>=submeshStartIndex;j-=3){
					if (indices.Contains(j/3)){
						removedtris.AddRange(tris.GetRange(j-submeshStartIndex, 3));
						tris.RemoveRange(j-submeshStartIndex, 3);
					}
				}
				ejmmesh.SharedMesh.SetTriangles(tris.ToArray(), i);
				newejmmesh.SharedMesh.SetTriangles(removedtris.ToArray(), i);
				submeshStartIndex += trisLength;
			}
			return obj;
		}
		void ClosedToolbarWindow(int windowID){
			GUI.DragWindow (DragRect);
			if (GUI.Button (new Rect (5, 20, buttonsize.x, buttonsize.y), OpenGUI)) {
				ejmmesh = new EJMMesh(targetMeshFilter);
				//Set previous Mesh
				previousMesh = (Mesh)Instantiate((Object)ejmmesh.SharedMesh);
				previousMaterials = new Material[ejmmesh.mRenderer.sharedMaterials.Length];
				System.Array.Copy(ejmmesh.mRenderer.sharedMaterials, previousMaterials, ejmmesh.mRenderer.sharedMaterials.Length);
				//Hide the default Handles
				EditorTools.HideDefaultHandles = true;
				//Expand the menu
				menuExpanded = true;
			} else if (GUI.Button (new Rect (10+buttonsize.x, 20, buttonsize.x, buttonsize.y), OpenUniqueGUI)){
				ejmmesh = new EJMMesh(targetMeshFilter);
				ejmmesh.MakeUnique();
				//Set previous Mesh
				previousMesh = (Mesh)Instantiate((Object)ejmmesh.SharedMesh);
				previousMaterials = new Material[ejmmesh.mRenderer.sharedMaterials.Length];
				System.Array.Copy(ejmmesh.mRenderer.sharedMaterials, previousMaterials, ejmmesh.mRenderer.sharedMaterials.Length);
				//Hide the default Handles
				EditorTools.HideDefaultHandles = true;
				//Expand the menu
				menuExpanded = true;
			}
		}
示例#4
0
		public NormalsEditor(EJMMesh target){
			ejmmesh = target;
			ReloadData ();
		}
		public PrimitivesEditor(EJMMesh target){
			ejmmesh = target;
			ReloadData ();
		}
		//bool selectDoubles = true;
		#endregion

		#region INHERITED METHODS
		public VerticesEditor(EJMMesh target){
			ejmmesh = target;
			ReloadData ();
		}
示例#7
0
		public ObjectEditor(EJMMesh target){
			ejmmesh = target;
			ReloadData ();
		}
示例#8
0
 public TrianglesEditor(EJMMesh target)
 {
     ejmmesh = target;
     ReloadData ();
 }