// 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)); }
public IEnumerator SetUpScene() { yield return(SceneManager.LoadSceneAsync("CommandTestScene", LoadSceneMode.Single)); this.LineSketchObject = GameObject.FindObjectOfType <LineSketchObject>(); yield return(null); }
// Start is called before the first frame update void Start() { invoker = new CommandInvoker(); lineSketchObject = Instantiate(LineSketchObjectPrefab).GetComponent <LineSketchObject>(); invoker.ExecuteCommand(new AddObjectToSketchWorldRootCommand(lineSketchObject, sketchWorld)); lineSketchObject2 = Instantiate(LineSketchObjectPrefab).GetComponent <LineSketchObject>(); }
// Start is called before the first frame update void Start() { lineSketchObject = Instantiate(LineSketchObjectPrefab).GetComponent <LineSketchObject>(); lineSketchObject.SetLineDiameter(.5f); lineSketchObject2 = Instantiate(defaults.LinearInterpolationLineSketchObjectPrefab).GetComponent <LineSketchObject>(); lineSketchObject2.SetLineDiameter(.5f); }
public void Update() { //handle the touch input if (Input.touchCount > 0) { Touch currentTouch = Input.GetTouch(0); if (currentTouch.phase == TouchPhase.Began) { canStartTouchManipulation = CanStartTouchManipulation(); } if (canStartTouchManipulation) { if (currentTouch.phase == TouchPhase.Began) { startNewSketchObject = true; } else if (currentTouch.phase == TouchPhase.Stationary || (currentTouch.phase == TouchPhase.Moved && startNewSketchObject == false && currentLineSketchObject.getNumberOfControlPoints() > 0)) { if (startNewSketchObject) { //create a new sketch object CreateNewLineSketchObject(); startNewSketchObject = false; } else if (currentLineSketchObject) { //Add new control point according to current device position currentLineSketchObject.addControlPointContinuous(FirstPersonCamera.transform.position + FirstPersonCamera.transform.forward * .3f); } } else if (currentTouch.phase == TouchPhase.Ended) { //if an empty sketch object was created, delete it if (startNewSketchObject == false && currentLineSketchObject.getNumberOfControlPoints() < 1) { Destroy(currentLineSketchObject.gameObject); currentLineSketchObject = null; } //if a swipe occured and no new sketch object was created, delete the last sketch object if ((currentTouch.position - currentTouch.rawPosition).magnitude > Screen.width * 0.05 && ((startNewSketchObject == false && currentLineSketchObject == null) || startNewSketchObject == true)) { DeleteLastLineSketchObject(); } else { AddCurrentLineSketchObjectToStack(); } canStartTouchManipulation = false; } } } }
public IEnumerator SetUpScene() { yield return(SceneManager.LoadSceneAsync("CommandTestScene", LoadSceneMode.Single)); this.Ribbon = GameObject.FindObjectOfType <RibbonSketchObject>(); this.Line = GameObject.FindObjectOfType <LineSketchObject>(); this.Patch = GameObject.FindObjectOfType <PatchSketchObject>(); yield return(null); Invoker = new CommandInvoker(); }
/// <summary> /// Instatiates a new LineSketchObject and parants it to the world anchor /// </summary> private void CreateNewLineSketchObject() { //see if an anchor exists if (!worldAnchor) { worldAnchor = Session.CreateAnchor(Frame.Pose); } // Instantiate sketch object as child of anchor var gameObject = Instantiate(SketchObjectPrefab, worldAnchor.gameObject.transform); currentLineSketchObject = gameObject.GetComponent <LineSketchObject>(); }
public IEnumerator Framerate_LineSketchObjects([Values(5, 10, 20)] int steps, [Values(100, 500, 1000, 2000, 4000, 6000, 8000, 10000)] int count) { List <Vector3> controlPoints = GenerateControlPointsYDirection(3); this.LineSketchObject.SetInterpolationSteps(steps); this.LineSketchObject.SetControlPointsLocalSpace(controlPoints); for (int i = 1; i < count; i++) { LineSketchObject currentLine = GameObject.Instantiate(this.LineSketchObject).GetComponent <LineSketchObject>(); currentLine.SetInterpolationSteps(steps); currentLine.SetControlPointsLocalSpace(controlPoints); currentLine.transform.position = new Vector3(i % 50, 0, i / 50); } yield return(Measure.Frames().Run()); }
private void XMLSerializeTest2() { string path = Serializer.WriteTestXmlFile <VRSketchingGeometry.Serialization.SerializableComponentData> ((lineSketchObject as ISerializableComponent).GetData()); Serializer.DeserializeFromXmlFile(out LineSketchObjectData readData, System.IO.Path.Combine(Application.dataPath, "TestSerialization.xml")); LineSketchObject deserLine = Instantiate(LineSketchObjectPrefab).GetComponent <LineSketchObject>(); readData.SketchMaterial.AlbedoColor = Color.red; (deserLine as ISerializableComponent).ApplyData(readData); deserLine.transform.position += new Vector3(0, 2, 0); Debug.Log(readData.ControlPoints.Count); }
public DeleteControlPointCommand(LineSketchObject lineSketchObject) { this.LineSketchObject = lineSketchObject; }
public RefineMeshCommand(LineSketchObject lineSketchObject) { this.LineSketchObject = lineSketchObject; OriginalControlPoints = lineSketchObject.GetControlPoints(); }
public AddControlPointCommand(LineSketchObject lineSketchObject, Vector3 controlPoint) { this.LineSketchObject = lineSketchObject; this.NewControlPoint = controlPoint; }
// 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)); }
private void OnTriggerStay(Collider other) { LineSketchObject.DeleteControlPoints(other.gameObject, transform.position, transform.lossyScale.x / 2); }
/// <summary> /// Command for deleting control points within a radius around a point of a line sketch object. /// </summary> /// <param name="lineSketchObject"></param> /// <param name="point">Point around which the control points will be deleted.</param> /// <param name="radius">Radius around point in which the control points are deleted.</param> public DeleteControlPointsByRadiusCommand(LineSketchObject lineSketchObject, Vector3 point, float radius) { this.OriginalLineSketchObject = lineSketchObject; this.Point = point; this.Radius = radius; }