Example #1
0
		public PipeManager(Pipe.MeshCallback _meshCallback){
			meshCallback = _meshCallback;
			pipe_layout = new PipeLayout (this);
			root_position = new Vector3 (0,0,0);
			root_rotation = new Quaternion ();
			ResetLayout();
		}
		public void OnMoveHandle(Vector3 delta_pos, Pipe.HandleSelected handleCallback){
			for (int i = 0; i < selected_vertices.Count; i++) {
				if(selected_vertices[i] != Vector3.zero){
					vertices [i] -= delta_pos;
					selected_vertices [i] = vertices [i];
				}
			}
			pipe_layout.heading_pos -= (delta_pos*2);
		}
Example #3
0
		void OnSceneGUI() {
			pipeBuildTarget = (Pipe)target;
			Undo.RecordObject (pipeBuildTarget, "Moved pipe build target");//Ctrl+Z
			if(pipeBuildTarget != null){
				SetGUIMenu ();
				SetHandle ();
				CheckMouse ();
				DrawSelectionBox ();
			}
		}
Example #4
0
		void SetHandle() {
			pipeBuildTarget = (Pipe)target;
			if(pipeBuildTarget != null && pipeBuildTarget.handle_visible){
				int controlID = GUIUtility.GetControlID (FocusType.Passive);
				Vector3 screenPosition = Handles.matrix.MultiplyPoint(pipeBuildTarget.handle_position);
				Handles.color = Color.white;
				Vector3 handle_delta = Handles.PositionHandle (pipeBuildTarget.handle_position, Quaternion.Euler(pipeBuildTarget.handle_rotation));
				if (GUI.changed) {
					pipeBuildTarget.OnMoveHandle (handle_delta);
				}
			}
		}
		private void setHandleToAverage(List<Vector3> vector_list, Pipe.HandleSelected handleCallback){
			if(vector_list.Count > 0 && handleCallback != null){
				//not Average but the min and max's halfway point
				Vector3 average_vector = new Vector3 (
					vector_list.Average(x=>x.x),
					vector_list.Average(x=>x.y),
					vector_list.Average(x=>x.z)
				);

				setHandlePosition (average_vector, handleCallback);
			}
		}
		public void OnMouseSelection(Rect selection, Pipe.HandleSelected handleCallback){
			selected_vertices = Enumerable.Repeat(Vector3.zero, vertices.Count).ToList();
			List<Vector3> only_selected = new List<Vector3> ();
			for (int i = 0; i < vertices.Count; i++) {
				if(Camera.current != null){
					Vector2 screen_position = Camera.current.WorldToScreenPoint (vertices [i]);
					if(selection.Contains(new Vector2(screen_position.x, Screen.height - screen_position.y), true)){
						selected_vertices [i] = vertices [i];
						only_selected.Add (vertices [i]);
					}
				}
			}
			setHandleToAverage (only_selected, handleCallback);
		}
Example #7
0
		void UpdateHandlePosition(){
			pipeBuildTarget = (Pipe)target;
			if (pipeBuildTarget != null && pipeBuildTarget != null && pipeBuildTarget.pipe_manager != null) {
				pipeBuildTarget.handle_position = pipeBuildTarget.pipe_manager.pipe_layout.heading_pos;
				pipeBuildTarget.handle_rotation = pipeBuildTarget.pipe_manager.pipe_layout.heading_deg;
			}
		}
Example #8
0
//		Main Extruder Menu
		private void SetGUIMenu(){
			pipeBuildTarget = (Pipe)target;
			Handles.BeginGUI();
			Rect size = new Rect (0, 0, 310, 150);

			GUI.BeginGroup (new Rect (0, 0, size.width, size.height));
			GUI.color = getColor("#FFFFFF");
			GUI.Box (new Rect (4, 4, 300, 128), pipeBuildTarget.GUI_image);
			GUI.color = getColor("#DAEFF6F");
			buildPositionTextFields ();
			buildRotationTextFields ();

			GUI.Label(new Rect(19, 77, 100, 20), "Diameter");
			diameter = GUI.TextField(new Rect(102, 77, 50, 17), diameter, 25);

			GUI.Label(new Rect(19, 102, 100, 20), "Repeat");
			repeater = GUI.TextField(new Rect(102, 102, 50, 17), repeater, 25);

			if (GUI.Button (new Rect (225, 102, 70, 20), "Extrude")) {
				saveParams ();
				for (int i = 0; i < int.Parse(repeater); i++) {
					pipeBuildTarget.OnExtrudeRing ();
				}
			}

			if (GUI.Button (new Rect (170, 102, 50, 20), "Del")) {
				for (int i = 0; i < int.Parse(repeater); i++) {
					pipeBuildTarget.OnRemoveRing ();
				}
			}
			if (GUI.changed) {
				checkValidInput ();
			}

			GUI.EndGroup ();
			Handles.EndGUI ();
		}
Example #9
0
		void loadParams(){
			pipeBuildTarget = (Pipe)target;
			rotationX = pipeBuildTarget.rotation.x.ToString();
			rotationY = pipeBuildTarget.rotation.y.ToString();
			rotationZ = pipeBuildTarget.rotation.z.ToString();
			offset =  pipeBuildTarget.offset.ToString();
			diameter =  pipeBuildTarget.diameter.ToString();
			repeater = pipeBuildTarget.repeater.ToString();
		}
		private void setHandlePosition(Vector3 position, Pipe.HandleSelected handleCallback){
			handleCallback (position);
		}
Example #11
0
		public void OnMoveHandle(Vector3 delta_pos, Pipe.HandleSelected handleCallback){
			pipe_gizmos.OnMoveHandle (delta_pos);
			pipe_layout_to_mesh.OnMoveHandle (delta_pos, handleCallback);
			UpdateLayout ();
		}
Example #12
0
		public void OnMouseSelection(Rect selection, Pipe.HandleSelected handleCallback){
			if(pipe_gizmos != null && drawGizmos){
				pipe_gizmos.OnMouseSelection (selection);
				pipe_layout_to_mesh.OnMouseSelection (selection, handleCallback);
			}
		}