private void OnMouseDown(object sender, MouseEventArgs e) { CreateCylinder newCylinder = new CreateCylinder(modelSpace.Project.CreateNewOperationId()); //The width,height,depth of cuboid is setted with default value now //We'll improve it next version by using mouse draging Length.LengthUnit unit = modelSpace.Project.Environment.DefaultLengthUnit; float value1 = modelSpace.Project.Environment.GridSize.Value; float value2 = modelSpace.Project.Environment.GridSize.Value * 2; newCylinder.Height = new Length(value2, unit); newCylinder.Radius = new Length(value1, unit); //Get the center Vector3 center = modelSpace.SceneRender.DisplayedGridPoint; newCylinder.Center = new Vector3WithUnit(center, modelSpace.Project.Environment.DefaultLengthUnit); //Set the aline axis switch (modelSpace.Project.Environment.GridPlane) { case GridPlane.XY: newCylinder.AlineAxis = Axis.Z; break; case GridPlane.XZ: newCylinder.AlineAxis = Axis.Y; break; case GridPlane.YZ: newCylinder.AlineAxis = Axis.X; break; default: newCylinder.AlineAxis = Axis.Z; break; } //Create the new single modelSpace.Project.CreateNewSingle(newCylinder); workspace.SelectTool(); }
private void CreateCylinderMesh() { var meshCreator = new CreateCylinder(spline); GUILayout.Space(5); EditorGUI.BeginChangeCheck(); float radius = EditorGUILayout.FloatField("Radius", master.radius1); if (EditorGUI.EndChangeCheck()) { Undo.RecordObject(master, "Variable change"); EditorUtility.SetDirty(master); master.radius1 = radius; } GUILayout.Space(5); EditorGUI.BeginChangeCheck(); int lenghtSegmentsCount = EditorGUILayout.IntField("Lenght Segments", master.LenghtSegmentsCount); if (EditorGUI.EndChangeCheck()) { Undo.RecordObject(master, "Variable change"); EditorUtility.SetDirty(master); master.LenghtSegmentsCount = lenghtSegmentsCount; } EditorGUI.BeginChangeCheck(); int widthSegmentsCount = EditorGUILayout.IntField("Width Segments", master.WidthSegmentsCount); if (EditorGUI.EndChangeCheck()) { Undo.RecordObject(master, "Variable change"); EditorUtility.SetDirty(master); master.WidthSegmentsCount = widthSegmentsCount; } GUILayout.Space(5); EditorGUI.BeginChangeCheck(); bool capStart = EditorGUILayout.Toggle("Cap Start", master.capStart); if (EditorGUI.EndChangeCheck()) { Undo.RecordObject(master, "Variable change"); EditorUtility.SetDirty(master); master.capStart = capStart; } EditorGUI.BeginChangeCheck(); bool capEnd = EditorGUILayout.Toggle("Cap End", master.capEnd); if (EditorGUI.EndChangeCheck()) { Undo.RecordObject(master, "Variable change"); EditorUtility.SetDirty(master); master.capEnd = capEnd; } GUILayout.Space(5); EditorGUI.BeginChangeCheck(); bool textureOrientation = EditorGUILayout.Toggle("Texture Orientation X/Y", master.textureOrientation); if (EditorGUI.EndChangeCheck()) { Undo.RecordObject(master, "Variable change"); EditorUtility.SetDirty(master); master.textureOrientation = textureOrientation; } meshCreator.LenghtSegmentsCount = master.LenghtSegmentsCount; meshCreator.WidthSegmentsCount = master.WidthSegmentsCount; meshCreator.radius1 = master.radius1; meshCreator.textureOrientation = textureOrientation; meshCreator.capStart = master.capStart; meshCreator.capEnd = master.capEnd; master.meshCreator = meshCreator; }