public IEnumerator SetUpScene() { yield return(SceneManager.LoadSceneAsync("CommandTestScene", LoadSceneMode.Single)); this.PatchSketchObject = GameObject.FindObjectOfType <PatchSketchObject>(); yield return(null); }
// Start is called before the first frame update void Start() { //Create a SketchWorld, many commands require a SketchWorld to be present SketchWorld = Instantiate(Defaults.SketchWorldPrefab).GetComponent <SketchWorld>(); //Create a LineSketchObject LineSketchObject = Instantiate(Defaults.LineSketchObjectPrefab).GetComponent <LineSketchObject>(); Invoker = new CommandInvoker(); Invoker.ExecuteCommand(new AddControlPointCommand(this.LineSketchObject, new Vector3(1, 2, 3))); Invoker.ExecuteCommand(new AddControlPointCommand(this.LineSketchObject, new Vector3(1, 4, 2))); Invoker.ExecuteCommand(new AddControlPointCommand(this.LineSketchObject, new Vector3(1, 5, 3))); Invoker.ExecuteCommand(new AddControlPointCommand(this.LineSketchObject, new Vector3(1, 5, 2))); Invoker.Undo(); Invoker.Redo(); //Create a RibbonSketchObject RibbonSketchObject = Instantiate(Defaults.RibbonSketchObjectPrefab).GetComponent <RibbonSketchObject>(); Invoker.ExecuteCommand(new AddPointAndRotationCommand(RibbonSketchObject, new Vector3(1, 1, 1), Quaternion.identity)); Invoker.ExecuteCommand(new AddPointAndRotationCommand(RibbonSketchObject, new Vector3(1, 2, 2), Quaternion.Euler(25, 45, 0))); Invoker.ExecuteCommand(new AddPointAndRotationCommand(RibbonSketchObject, new Vector3(1, 2, 3), Quaternion.Euler(-25, 45, 0))); //Create a PatchSketchObject PatchSketchObject = Instantiate(Defaults.PatchSketchObjectPrefab).GetComponent <PatchSketchObject>(); PatchSketchObject.Width = 3; Invoker.ExecuteCommand(new AddSegmentCommand(PatchSketchObject, new List <Vector3> { new Vector3(0, 0, 1), new Vector3(0, 1, 2), new Vector3(0, 0, 3) })); Invoker.ExecuteCommand(new AddSegmentCommand(PatchSketchObject, new List <Vector3> { new Vector3(1, 1, 1), new Vector3(1, 0, 2), new Vector3(1, 1, 3) })); Invoker.ExecuteCommand(new AddSegmentCommand(PatchSketchObject, new List <Vector3> { new Vector3(2, 0, 1), new Vector3(2, 1, 2), new Vector3(2, 0, 3) })); //Add the LineSketchObject to the SketchWorld Invoker.ExecuteCommand(new AddObjectToSketchWorldRootCommand(LineSketchObject, SketchWorld)); //Create a SketchObjectGroup and add objects to it SketchObjectGroup = Instantiate(Defaults.SketchObjectGroupPrefab).GetComponent <SketchObjectGroup>(); Invoker.ExecuteCommand(new AddToGroupCommand(SketchObjectGroup, RibbonSketchObject)); Invoker.ExecuteCommand(new AddToGroupCommand(SketchObjectGroup, PatchSketchObject)); //Add the SketchObjectGroup to the SketchWorld Invoker.ExecuteCommand(new AddObjectToSketchWorldRootCommand(SketchObjectGroup, SketchWorld)); //Serialize the SketchWorld to a XML file SavePath = System.IO.Path.Combine(Application.dataPath, "YourSketch.xml"); SketchWorld.SaveSketchWorld(SavePath); //Create another SketchWorld and load the serialized SketchWorld DeserializedSketchWorld = Instantiate(Defaults.SketchWorldPrefab).GetComponent <SketchWorld>(); DeserializedSketchWorld.LoadSketchWorld(SavePath); DeserializedSketchWorld.transform.position += new Vector3(5, 0, 0); //Export the SketchWorld as an OBJ file SketchWorld.ExportSketchWorldToDefaultPath(); //Select the SketchObjectGroup SketchObjectSelection = Instantiate(Defaults.SketchObjectSelectionPrefab).GetComponent <SketchObjectSelection>(); Invoker.ExecuteCommand(new AddToSelectionAndHighlightCommand(SketchObjectSelection, SketchObjectGroup)); Invoker.ExecuteCommand(new ActivateSelectionCommand(SketchObjectSelection)); }
// Start is called before the first frame update void Start() { patchSketchObject = Instantiate(patchPrefab).GetComponent <PatchSketchObject>(); patchSketchObject.Width = 4; patchSketchObject.ResolutionHeight = 8; patchSketchObject.ResolutionWidth = 8; //StartCoroutine(AddSegmentTest()); }
// Start is called before the first frame update void Start() { strokeSketchObject = Instantiate(StrokeSketchObjectPrefab).GetComponent <StrokeSketchObject>(); strokeSketchObject.SetStrokeDiameter(.5f); //lineSketchObject2 = Instantiate(LineSketchObjectPrefab).GetComponent<LineSketchObject>(); strokeSketchObject2 = Instantiate(defaults.LinearInterpolationStrokeSketchObjectPrefab).GetComponent <StrokeSketchObject>(); patchSketchObject = Instantiate(defaults.PatchSketchObjectPrefab).GetComponent <PatchSketchObject>(); ribbonSketchObject = Instantiate(defaults.RibbonSketchObjectPrefab).GetComponent <RibbonSketchObject>(); }
public IEnumerator SetUpScene() { yield return(SceneManager.LoadSceneAsync("CommandTestScene", LoadSceneMode.Single)); this.Ribbon = GameObject.FindObjectOfType <RibbonSketchObject>(); this.Stroke = GameObject.FindObjectOfType <StrokeSketchObject>(); this.Patch = GameObject.FindObjectOfType <PatchSketchObject>(); yield return(null); Invoker = new CommandInvoker(); }
/// <summary> /// Delete the last segment of the patch sketch object. /// </summary> /// <param name="patchSketchObject"></param> public DeleteSegmentCommand(PatchSketchObject patchSketchObject) { this.PatchSketchObject = patchSketchObject; }
public AddSegmentCommand(PatchSketchObject patchSketchObject, List <Vector3> newSegment) { this.PatchSketchObject = patchSketchObject; this.NewSegment = newSegment; }
// Start is called before the first frame update void Start() { //Create a SketchWorld, many commands require a SketchWorld to be present SketchWorld = Instantiate(Defaults.SketchWorldPrefab).GetComponent <SketchWorld>(); //Create a LineSketchObject LineSketchObject = Instantiate(Defaults.LineSketchObjectPrefab).GetComponent <LineSketchObject>(); Invoker = new CommandInvoker(); Invoker.ExecuteCommand(new AddControlPointCommand(this.LineSketchObject, new Vector3(1, 2, 3))); Invoker.ExecuteCommand(new AddControlPointCommand(this.LineSketchObject, new Vector3(1, 4, 2))); Invoker.ExecuteCommand(new AddControlPointCommand(this.LineSketchObject, new Vector3(1, 5, 3))); Invoker.ExecuteCommand(new AddControlPointCommand(this.LineSketchObject, new Vector3(1, 5, 2))); Invoker.Undo(); Invoker.Redo(); LineBrush brush = this.LineSketchObject.GetBrush() as LineBrush; brush.CrossSectionVertices = CircularCrossSection.GenerateVertices(3); brush.CrossSectionNormals = CircularCrossSection.GenerateVertices(3, 1); Invoker.ExecuteCommand(new SetBrushCommand(this.LineSketchObject, brush)); //oder ohne Command //this.LineSketchObject.SetBrush(brush); //oder nur //this.LineSketchObject.SetLineCrossSection(... //Create a RibbonSketchObject RibbonSketchObject = Instantiate(Defaults.RibbonSketchObjectPrefab).GetComponent <RibbonSketchObject>(); Invoker.ExecuteCommand(new AddPointAndRotationCommand(RibbonSketchObject, new Vector3(1, 1, 1), Quaternion.identity)); Invoker.ExecuteCommand(new AddPointAndRotationCommand(RibbonSketchObject, new Vector3(1.5f, 1.1f, 1), Quaternion.Euler(0, 0, 0))); Invoker.ExecuteCommand(new AddPointAndRotationCommand(RibbonSketchObject, new Vector3(2f, 1.2f, 1), Quaternion.Euler(22, 0, 0))); Invoker.ExecuteCommand(new AddPointAndRotationCommand(RibbonSketchObject, new Vector3(2.5f, 1.3f, 1), Quaternion.Euler(45, 0, 0))); Invoker.ExecuteCommand(new AddPointAndRotationCommand(RibbonSketchObject, new Vector3(3f, 1.4f, 1), Quaternion.Euler(60, 0, 0))); //Create a PatchSketchObject PatchSketchObject = Instantiate(Defaults.PatchSketchObjectPrefab).GetComponent <PatchSketchObject>(); PatchSketchObject.Width = 3; Invoker.ExecuteCommand(new AddSegmentCommand(PatchSketchObject, new List <Vector3> { new Vector3(0, 0, 1), new Vector3(0, 1, 2), new Vector3(0, 0, 3) })); Invoker.ExecuteCommand(new AddSegmentCommand(PatchSketchObject, new List <Vector3> { new Vector3(1, 1, 1), new Vector3(1, 0, 2), new Vector3(1, 1, 3) })); Invoker.ExecuteCommand(new AddSegmentCommand(PatchSketchObject, new List <Vector3> { new Vector3(2, 0, 1), new Vector3(2, 1, 2), new Vector3(2, 0, 3) })); //Add the LineSketchObject to the SketchWorld Invoker.ExecuteCommand(new AddObjectToSketchWorldRootCommand(LineSketchObject, SketchWorld)); //Create a SketchObjectGroup and add objects to it SketchObjectGroup = Instantiate(Defaults.SketchObjectGroupPrefab).GetComponent <SketchObjectGroup>(); Invoker.ExecuteCommand(new AddToGroupCommand(SketchObjectGroup, RibbonSketchObject)); Invoker.ExecuteCommand(new AddToGroupCommand(SketchObjectGroup, PatchSketchObject)); //Add the SketchObjectGroup to the SketchWorld Invoker.ExecuteCommand(new AddObjectToSketchWorldRootCommand(SketchObjectGroup, SketchWorld)); //Serialize the SketchWorld to a XML file SavePath = System.IO.Path.Combine(Application.dataPath, "YourSketch.xml"); SketchWorld.SaveSketchWorld(SavePath); //Create another SketchWorld and load the serialized SketchWorld DeserializedSketchWorld = Instantiate(Defaults.SketchWorldPrefab).GetComponent <SketchWorld>(); DeserializedSketchWorld.LoadSketchWorld(SavePath); DeserializedSketchWorld.transform.position += new Vector3(5, 0, 0); //Export the SketchWorld as an OBJ file //SketchWorld.ExportSketchWorldToDefaultPath(); //Select the SketchObjectGroup SketchObjectSelection = Instantiate(Defaults.SketchObjectSelectionPrefab).GetComponent <SketchObjectSelection>(); Invoker.ExecuteCommand(new AddToSelectionAndHighlightCommand(SketchObjectSelection, SketchObjectGroup)); Invoker.ExecuteCommand(new ActivateSelectionCommand(SketchObjectSelection)); }