// 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 StrokeSketchObject = Instantiate(Defaults.StrokeSketchObjectPrefab).GetComponent <StrokeSketchObject>(); Invoker = new CommandInvoker(); Invoker.ExecuteCommand(new AddControlPointCommand(this.StrokeSketchObject, new Vector3(1, 2, 3))); Invoker.ExecuteCommand(new AddControlPointCommand(this.StrokeSketchObject, new Vector3(1, 4, 2))); Invoker.ExecuteCommand(new AddControlPointCommand(this.StrokeSketchObject, new Vector3(1, 5, 3))); Invoker.ExecuteCommand(new AddControlPointCommand(this.StrokeSketchObject, 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(StrokeSketchObject, 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.StrokeSketchObject = GameObject.FindObjectOfType <StrokeSketchObject>(); yield return(null); }
// Start is called before the first frame update void Start() { invoker = new CommandInvoker(); strokeSketchObject = Instantiate(StrokeSketchObjectPrefab).GetComponent <StrokeSketchObject>(); invoker.ExecuteCommand(new AddObjectToSketchWorldRootCommand(strokeSketchObject, sketchWorld)); strokeSketchObject2 = Instantiate(StrokeSketchObjectPrefab).GetComponent <StrokeSketchObject>(); }
// Start is called before the first frame update void Start() { strokeSketchObject = Instantiate(StrokeSketchObjectPrefab).GetComponent <StrokeSketchObject>(); strokeSketchObject.SetStrokeDiameter(.5f); strokeSketchObject2 = Instantiate(defaults.LinearInterpolationStrokeSketchObjectPrefab).GetComponent <StrokeSketchObject>(); strokeSketchObject2.SetStrokeDiameter(.5f); }
// 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(); }
public IEnumerator Framerate_StrokeSketchObjects([Values(5, 10, 20)] int steps, [Values(100, 500, 1000, 2000, 4000, 6000, 8000, 10000)] int count) { List <Vector3> controlPoints = GenerateControlPointsYDirection(3); this.StrokeSketchObject.SetInterpolationSteps(steps); this.StrokeSketchObject.SetControlPointsLocalSpace(controlPoints); for (int i = 1; i < count; i++) { StrokeSketchObject currentStroke = GameObject.Instantiate(this.StrokeSketchObject).GetComponent <StrokeSketchObject>(); currentStroke.SetInterpolationSteps(steps); currentStroke.SetControlPointsLocalSpace(controlPoints); currentStroke.transform.position = new Vector3(i % 50, 0, i / 50); } yield return(Measure.Frames().Run()); }
private void XMLSerializeTest2() { string path = Serializer.WriteTestXmlFile <VRSketchingGeometry.Serialization.SerializableComponentData> ((strokeSketchObject as ISerializableComponent).GetData()); Serializer.DeserializeFromXmlFile(out StrokeSketchObjectData readData, System.IO.Path.Combine(Application.dataPath, "TestSerialization.xml")); StrokeSketchObject deserStroke = Instantiate(StrokeSketchObjectPrefab).GetComponent <StrokeSketchObject>(); readData.SketchMaterial.AlbedoColor = Color.red; (deserStroke as ISerializableComponent).ApplyData(readData); deserStroke.transform.position += new Vector3(0, 2, 0); Debug.Log(readData.ControlPoints.Count); }
/// <summary> /// Command for deleting control points within a radius around a point of a line sketch object. /// </summary> /// <param name="strokeSketchObject"></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(StrokeSketchObject strokeSketchObject, Vector3 point, float radius) { this.OriginalStrokeSketchObject = strokeSketchObject; this.Point = point; this.Radius = radius; }
public AddControlPointContinuousCommand(StrokeSketchObject strokeSketchObject, Vector3 controlPoint) { this.StrokeSketchObject = strokeSketchObject; this.NewControlPoint = controlPoint; }
public DeleteControlPointCommand(StrokeSketchObject strokeSketchObject) { this.StrokeSketchObject = strokeSketchObject; }
public RefineMeshCommand(StrokeSketchObject strokeSketchObject) { this.StrokeSketchObject = strokeSketchObject; OriginalControlPoints = strokeSketchObject.GetControlPoints(); }
private void OnTriggerStay(Collider other) { StrokeSketchObject.DeleteControlPoints(other.gameObject, transform.position, transform.lossyScale.x / 2); }