public void createTrunk(List <Branch> branches, FormBounds formBounds, IFormConfiguration formConfig, ColourConfiguration colourConfig) { Vector3 branchStartPosition = formConfig.getStartPosition(); Vector3 branchStartTwist = formConfig.getStartRotation(); Vector3 branchStartOrigin = formConfig.getStartPosition(); for (int i = 0; i < formConfig.getTrunkIterations(); i++) { formBounds.calculateNewBounds(branchStartPosition); Branch branch = new Branch(i, formConfig, colourConfig, branchStartPosition, branchStartTwist, branchStartOrigin, formBounds); branches.Add(branch); branchStartPosition.x += formConfig.getTrunkPositionDelta().x; branchStartPosition.y += formConfig.getTrunkPositionDelta().y; branchStartPosition.z += formConfig.getTrunkPositionDelta().z; branchStartTwist.x += formConfig.getTrunkRotationDelta().x; branchStartTwist.y += formConfig.getTrunkRotationDelta().y; branchStartTwist.z += formConfig.getTrunkRotationDelta().z; } }
public void mutateTrunk(List <Branch> branches, FormBounds formBounds, IFormConfiguration formConfig, ColourConfiguration colourConfig) { Vector3 branchStartPosition = formConfig.getStartPosition(); Vector3 branchStartTwist = formConfig.getStartRotation(); Vector3 branchStartOrigin = formConfig.getStartPosition(); int i = 0; foreach (Branch branch in branches) { formBounds.calculateNewBounds(branchStartPosition); branch.mutate(i, formConfig, colourConfig, branchStartPosition, branchStartTwist, branchStartOrigin, formBounds); branchStartPosition.x += formConfig.getTrunkPositionDelta().x; branchStartPosition.y += formConfig.getTrunkPositionDelta().y; branchStartPosition.z += formConfig.getTrunkPositionDelta().z; branchStartTwist.x += formConfig.getTrunkRotationDelta().x; branchStartTwist.y += formConfig.getTrunkRotationDelta().y; branchStartTwist.z += formConfig.getTrunkRotationDelta().z; i++; } }
public void createTrunk(List<Branch> branches, FormBounds formBounds, IFormConfiguration formConfig, ColourConfiguration colourConfig) { int offset = (formConfig.getTrunkIterations() * formConfig.getStackIterations() / 2) * -1; Vector3 branchStartPosition = formConfig.getStartPosition(); branchStartPosition.y = branchStartPosition.y + 10; Vector3 branchStartTwist = formConfig.getStartRotation(); Vector3 branchStartOrigin = formConfig.getStartPosition(); for (int i = 0; i < formConfig.getTrunkIterations(); i++) { formBounds.calculateNewBounds(branchStartPosition); Branch branch = new Branch (offset, formConfig, colourConfig, branchStartPosition, branchStartTwist, branchStartOrigin, formBounds); branches.Add(branch); offset += formConfig.getStackIterations(); } }
public void createTrunk(List<Branch> branches, FormBounds formBounds, IFormConfiguration formConfig, ColourConfiguration colourConfig) { Vector3 branchStartPosition = formConfig.getStartPosition(); Vector3 branchStartTwist = formConfig.getStartRotation(); Vector3 branchStartOrigin = formConfig.getStartPosition(); for (int i = 0; i < formConfig.getTrunkIterations(); i++) { formBounds.calculateNewBounds(branchStartPosition); Branch branch = new Branch (0, formConfig, colourConfig, branchStartPosition, branchStartTwist, branchStartOrigin, formBounds); //magic 0 no offset branches.Add(branch); //set origin to previous start position branchStartOrigin = branchStartPosition; branchStartTwist = GeometryUtility.addDeltaToRotation(branchStartTwist, formConfig.getTrunkRotationDelta()); branchStartPosition = GeometryUtility.addDeltaToPosition(branchStartPosition, formConfig.getTrunkPositionDelta(), 1); } }
public void sanitiseConfiguration(IFormConfiguration formConfiguration) { //RADIUS if (formConfiguration.getBranchPositionDelta().x < 0.2f) { Vector3 v = formConfiguration.getBranchPositionDelta(); v.x = 0.2f; formConfiguration.setBranchPositionDelta(v); } if (formConfiguration.getBranchPositionDelta().x > 1.0f) { Vector3 v = formConfiguration.getBranchPositionDelta(); v.x = 1.0f; formConfiguration.setBranchPositionDelta(v); } //RHUMB ANGLE if (formConfiguration.getStartRotation().x < 0) { Vector3 v = formConfiguration.getStartRotation(); v.x = 0; formConfiguration.setStartRotation(v); } if (formConfiguration.getStartRotation().x > 2f) { Vector3 v = formConfiguration.getStartRotation(); v.x = 2.0f; formConfiguration.setStartRotation(v); } }
public void mutateTrunk(List <Branch> branches, FormBounds formBounds, IFormConfiguration formConfig, ColourConfiguration colourConfig) { int offset = (formConfig.getTrunkIterations() * formConfig.getStackIterations() / 2) * -1; Vector3 branchStartPosition = formConfig.getStartPosition(); branchStartPosition.y = branchStartPosition.y + 10; Vector3 branchStartTwist = formConfig.getStartRotation(); Vector3 branchStartOrigin = formConfig.getStartPosition(); foreach (Branch branch in branches) { formBounds.calculateNewBounds(branchStartPosition); branch.mutate(offset, formConfig, colourConfig, branchStartPosition, branchStartTwist, branchStartOrigin, formBounds); offset += formConfig.getStackIterations(); } }
public void mutateTrunk(List <Branch> branches, FormBounds formBounds, IFormConfiguration formConfig, ColourConfiguration colourConfig) { Vector3 branchStartPosition = formConfig.getStartPosition(); Vector3 branchStartTwist = formConfig.getStartRotation(); Vector3 origin = formConfig.getStartPosition(); foreach (Branch branch in branches) { formBounds.calculateNewBounds(branchStartPosition); branch.mutate(0, formConfig, colourConfig, branchStartPosition, branchStartTwist, origin, formBounds); //set origin to previous start position origin = branchStartPosition; branchStartTwist = GeometryUtility.addDeltaToRotation(branchStartTwist, formConfig.getTrunkRotationDelta()); branchStartPosition = GeometryUtility.addDeltaToPosition(branchStartPosition, formConfig.getTrunkPositionDelta(), 1); } }
public static TagBuilder FormActionDropDown(this HtmlHelper html, IFormConfiguration formConfiguration) { var dropDown = new TagBuilder("li"); dropDown.AddCssClass("dropdown"); dropDown.AddCssClass("action"); var linkButton = new TagBuilder("a"); linkButton.AddCssClass("dropdown-toggle"); linkButton.Attributes["href"] = "#"; linkButton.Attributes["data-toggle"] = "dropdown"; linkButton.Attributes["role"] = "button"; linkButton.Attributes["aria-expanded"] = "false"; linkButton.InnerHtml += !string.IsNullOrEmpty(formConfiguration.ActionButtonDropDownLabel) ? formConfiguration.ActionButtonDropDownLabel : "<span class='fa fa-bars fa-fw' aria-hidden='true'></span> Actions"; var buttonInner = new TagBuilder("span"); buttonInner.AddCssClass("caret"); linkButton.InnerHtml += buttonInner.ToString(); dropDown.InnerHtml += linkButton.ToString(); return(dropDown); }
public void createTrunk(List <Branch> branches, FormBounds formBounds, IFormConfiguration formConfig, ColourConfiguration colourConfig) { Vector3 branchStartPosition = formConfig.getStartPosition(); Vector3 branchStartTwist = formConfig.getStartRotation(); Vector3 branchStartOrigin = formConfig.getStartPosition(); for (int i = 0; i < formConfig.getTrunkIterations(); i++) { formBounds.calculateNewBounds(branchStartPosition); Branch branch = new Branch(0, formConfig, colourConfig, branchStartPosition, branchStartTwist, branchStartOrigin, formBounds); //magic 0 no offset branches.Add(branch); //set origin to previous start position branchStartOrigin = branchStartPosition; branchStartTwist = GeometryUtility.addDeltaToRotation(branchStartTwist, formConfig.getTrunkRotationDelta()); branchStartPosition = GeometryUtility.addDeltaToPosition(branchStartPosition, formConfig.getTrunkPositionDelta(), 1); } }
public void mutateBranch(List <IStack> stacks, int offset, IFormConfiguration formConfig, ColourConfiguration colourConfig, Vector3 branchStartPosition, Vector3 branchStartTwist, Vector3 origin, FormBounds formBounds) { Vector3 position = origin; Vector3 stackTwist = formConfig.getStackStartTwist(); float radius = formConfig.getBranchPositionDelta().x * 20; float rhumbAngle = formConfig.getStartRotation().x * 0.032f; //colour stuff int iterations = formConfig.getStackIterations(); Color modelColour = new Color(colourConfig.getBaseRed(), colourConfig.getBaseGreen(), colourConfig.getBaseBlue(), 1); //if cycling override base colour if (colourConfig.getCycle()) { modelColour = colourConfig.getCycleColour(); } int i = offset; foreach (IStack stack in stacks) { position.x = formConfig.getStartPosition().x + (radius * (float)Math.Cos(i) / (float)Math.Cosh(Mathf.Rad2Deg * (Mathf.Deg2Rad * i * rhumbAngle))); position.y = formConfig.getStartPosition().y + (radius * (float)Math.Sin(i) / (float)Math.Cosh(Mathf.Rad2Deg * (Mathf.Deg2Rad * i * rhumbAngle))); position.z = formConfig.getStartPosition().z + (radius * (float)Math.Tanh(Mathf.Rad2Deg * (Mathf.Deg2Rad * i * rhumbAngle))); formBounds.calculateNewBounds(position); //colour stuff order is important Color stackColour = modelColour; if (colourConfig.getFadeColour()) { //fade colour in stackColour = ColourUtility.fadeModelColour(modelColour, iterations, i - offset); } if (colourConfig.getPulse()) { //do pulse stackColour = colourConfig.getPulseColourForStack(stackColour, i - offset); } stack.mutateTo(position, stackTwist, 0.5f, stackColour); stackTwist = GeometryUtility.addDeltaToRotation(stackTwist, formConfig.getStackTwistDelta()); i++; } }
public static void saveConfiguration(IFormConfiguration formConfiguration) { string fileSavePath = Application.persistentDataPath + "/FormConfigSlot" + (formConfiguration.getIndex() + 1) + ".xml"; Debug.Log("Save:" + fileSavePath); XmlDocument xmlDoc = new XmlDocument(); XmlElement root = xmlDoc.CreateElement("", "form", ""); //save data root.SetAttribute("branchPositionDeltaX", formConfiguration.getBranchPositionDelta().x.ToString()); root.SetAttribute("branchPositionDeltaY", formConfiguration.getBranchPositionDelta().y.ToString()); root.SetAttribute("branchPositionDeltaZ", formConfiguration.getBranchPositionDelta().z.ToString()); root.SetAttribute("branchTwistDeltaX", formConfiguration.getBranchTwistDelta().x.ToString()); root.SetAttribute("branchTwistDeltaY", formConfiguration.getBranchTwistDelta().y.ToString()); root.SetAttribute("branchTwistDeltaZ", formConfiguration.getBranchTwistDelta().z.ToString()); root.SetAttribute("index", formConfiguration.getIndex().ToString()); root.SetAttribute("mutationStrength", formConfiguration.getMutationStrength().ToString()); root.SetAttribute("scaleBranch", formConfiguration.getScaleBranch().ToString()); root.SetAttribute("scaleDelta", formConfiguration.getScaleDelta().ToString()); root.SetAttribute("scaleTrunk", formConfiguration.getScaleTrunk().ToString()); root.SetAttribute("stackIterations", formConfiguration.getStackIterations().ToString()); root.SetAttribute("stackShapeIndex", formConfiguration.getStackShapeIndex().ToString()); root.SetAttribute("stackStartTwistX", formConfiguration.getStackStartTwist().x.ToString()); root.SetAttribute("stackStartTwistY", formConfiguration.getStackStartTwist().y.ToString()); root.SetAttribute("stackStartTwistZ", formConfiguration.getStackStartTwist().z.ToString()); root.SetAttribute("stackTwistDeltaX", formConfiguration.getStackTwistDelta().x.ToString()); root.SetAttribute("stackTwistDeltaY", formConfiguration.getStackTwistDelta().y.ToString()); root.SetAttribute("stackTwistDeltaZ", formConfiguration.getStackTwistDelta().z.ToString()); root.SetAttribute("startPositionX", formConfiguration.getStartPosition().x.ToString()); root.SetAttribute("startPositionY", formConfiguration.getStartPosition().y.ToString()); root.SetAttribute("startPositionZ", formConfiguration.getStartPosition().z.ToString()); root.SetAttribute("startRotationX", formConfiguration.getStartRotation().x.ToString()); root.SetAttribute("startRotationY", formConfiguration.getStartRotation().y.ToString()); root.SetAttribute("startRotationZ", formConfiguration.getStartRotation().z.ToString()); root.SetAttribute("startScale", formConfiguration.getStartScale().ToString()); root.SetAttribute("trunkIterations", formConfiguration.getTrunkIterations().ToString()); root.SetAttribute("trunkPositionDeltaX", formConfiguration.getTrunkPositionDelta().x.ToString()); root.SetAttribute("trunkPositionDeltaY", formConfiguration.getTrunkPositionDelta().y.ToString()); root.SetAttribute("trunkPositionDeltaZ", formConfiguration.getTrunkPositionDelta().z.ToString()); root.SetAttribute("trunklRotationDeltaX", formConfiguration.getTrunkRotationDelta().x.ToString()); root.SetAttribute("trunklRotationDeltaY", formConfiguration.getTrunkRotationDelta().y.ToString()); root.SetAttribute("trunklRotationDeltaZ", formConfiguration.getTrunkRotationDelta().z.ToString()); xmlDoc.AppendChild(root); //save xmlDoc.Save(fileSavePath); }
public static void saveConfiguration(IFormConfiguration formConfiguration) { string fileSavePath = Application.persistentDataPath + "/FormConfigSlot" + (formConfiguration.getIndex() + 1) + ".xml"; Debug.Log ("Save:" + fileSavePath); XmlDocument xmlDoc = new XmlDocument(); XmlElement root = xmlDoc.CreateElement("", "form", ""); //save data root.SetAttribute("branchPositionDeltaX", formConfiguration.getBranchPositionDelta().x.ToString()); root.SetAttribute("branchPositionDeltaY", formConfiguration.getBranchPositionDelta().y.ToString()); root.SetAttribute("branchPositionDeltaZ", formConfiguration.getBranchPositionDelta().z.ToString()); root.SetAttribute("branchTwistDeltaX", formConfiguration.getBranchTwistDelta().x.ToString()); root.SetAttribute("branchTwistDeltaY", formConfiguration.getBranchTwistDelta().y.ToString()); root.SetAttribute("branchTwistDeltaZ", formConfiguration.getBranchTwistDelta().z.ToString()); root.SetAttribute("index", formConfiguration.getIndex().ToString()); root.SetAttribute("mutationStrength", formConfiguration.getMutationStrength().ToString()); root.SetAttribute("scaleBranch", formConfiguration.getScaleBranch().ToString()); root.SetAttribute("scaleDelta", formConfiguration.getScaleDelta().ToString()); root.SetAttribute("scaleTrunk", formConfiguration.getScaleTrunk().ToString()); root.SetAttribute("stackIterations", formConfiguration.getStackIterations().ToString()); root.SetAttribute("stackShapeIndex", formConfiguration.getStackShapeIndex().ToString()); root.SetAttribute("stackStartTwistX", formConfiguration.getStackStartTwist().x.ToString()); root.SetAttribute("stackStartTwistY", formConfiguration.getStackStartTwist().y.ToString()); root.SetAttribute("stackStartTwistZ", formConfiguration.getStackStartTwist().z.ToString()); root.SetAttribute("stackTwistDeltaX", formConfiguration.getStackTwistDelta().x.ToString()); root.SetAttribute("stackTwistDeltaY", formConfiguration.getStackTwistDelta().y.ToString()); root.SetAttribute("stackTwistDeltaZ", formConfiguration.getStackTwistDelta().z.ToString()); root.SetAttribute("startPositionX", formConfiguration.getStartPosition().x.ToString()); root.SetAttribute("startPositionY", formConfiguration.getStartPosition().y.ToString()); root.SetAttribute("startPositionZ", formConfiguration.getStartPosition().z.ToString()); root.SetAttribute("startRotationX", formConfiguration.getStartRotation().x.ToString()); root.SetAttribute("startRotationY", formConfiguration.getStartRotation().y.ToString()); root.SetAttribute("startRotationZ", formConfiguration.getStartRotation().z.ToString()); root.SetAttribute("startScale", formConfiguration.getStartScale().ToString()); root.SetAttribute("trunkIterations", formConfiguration.getTrunkIterations().ToString()); root.SetAttribute("trunkPositionDeltaX", formConfiguration.getTrunkPositionDelta().x.ToString()); root.SetAttribute("trunkPositionDeltaY", formConfiguration.getTrunkPositionDelta().y.ToString()); root.SetAttribute("trunkPositionDeltaZ", formConfiguration.getTrunkPositionDelta().z.ToString()); root.SetAttribute("trunklRotationDeltaX", formConfiguration.getTrunkRotationDelta().x.ToString()); root.SetAttribute("trunklRotationDeltaY", formConfiguration.getTrunkRotationDelta().y.ToString()); root.SetAttribute("trunklRotationDeltaZ", formConfiguration.getTrunkRotationDelta().z.ToString()); xmlDoc.AppendChild(root); //save xmlDoc.Save(fileSavePath); }
//create a new model public Trunk(IFormConfiguration formConfig, ColourConfiguration colourConfig) { localFormConfig = formConfig; localColourConfig = colourConfig; FormProcessor formProcessor = formConfig.getFormProcessor(); formBounds = new FormBounds(formConfig.getStartPosition()); formProcessor.createTrunk(branches, formBounds, formConfig, colourConfig); }
/* private methods */ private void saveForm() { if (brush != null) { //save current form to scene IFormConfiguration sceneFormConfig = new IFormConfiguration(currentConfig); ColourConfiguration sceneColourConfig = new ColourConfiguration(colourConfig); currentScene.Add(new Trunk(sceneFormConfig, sceneColourConfig)); clearBrush(); } }
public ComponentFactory( IFormConfiguration configuration, IComponentNameResolver nameResolver, IComponentIdResolver idResolver, IComponentLabelResolver labelResolver, IErrorProvider errorProvider) { this.ErrorProvider = errorProvider; this.configuration = configuration; this.NameResolver = nameResolver; this.IdResolver = idResolver; this.LabelResolver = labelResolver; }
// private bool waitForJuliaSetToRender = false; // Use this for initialization void Start() { IFormConfiguration formConfig1 = new FormConfig1(); IFormConfiguration formConfig2 = new FormConfig2(); IFormConfiguration formConfig3 = new FormConfig3(); IFormConfiguration formConfig4 = new FormConfig4(); IFormConfiguration formConfig5 = new FormConfig5(); IFormConfiguration formConfig6 = new FormConfig6(); IFormConfiguration formConfig7 = new FormConfig7(); IFormConfiguration formConfig8 = new FormConfig8(); IFormConfiguration formConfig9 = new FormConfig9(); allConfigs.Add(formConfig1); allConfigs.Add(formConfig2); allConfigs.Add(formConfig3); allConfigs.Add(formConfig4); allConfigs.Add(formConfig5); allConfigs.Add(formConfig6); allConfigs.Add(formConfig7); allConfigs.Add(formConfig8); allConfigs.Add(formConfig9); currentConfig = formConfig1; dawnMaterial = Resources.Load("DawnDusk Skybox") as Material; eerieMaterial = Resources.Load("Eerie Skybox") as Material; nightMaterial = Resources.Load("StarryNight Skybox") as Material; mainCamera = Camera.main; mainCamera.clearFlags = CameraClearFlags.Skybox; RenderSettings.skybox = dawnMaterial; backgroundCamera = GameObject.Find("Background Camera").GetComponent <Camera>(); backgroundCamera.enabled = false; formBuilderPalette = new FormBuilderPalette(this); colourPalette = new ColourPalette(this); helpPalette = new HelpPalette(); //initialiase with something createNewBrush(); //slot 1 //make it colourful colourConfig.setCycle(true); colourConfig.setPulse(true); colourConfig.setFadeColour(true); autoPreset = true; autoMutate1 = true; }
public void sanitiseConfiguration(IFormConfiguration formConfiguration) { //RADIUS if (formConfiguration.getBranchPositionDelta().x < 0.2f) { Vector3 v = formConfiguration.getBranchPositionDelta(); v.x = 0.2f; formConfiguration.setBranchPositionDelta(v); } if (formConfiguration.getBranchPositionDelta().x > 1.0f) { Vector3 v = formConfiguration.getBranchPositionDelta(); v.x = 1.0f; formConfiguration.setBranchPositionDelta(v); } }
private static TagBuilder FormActionNavbar(IFormConfiguration formConfiguration) { var navBar = new TagBuilder("div"); navBar.AddCssClass("navbar"); if (formConfiguration.ActionNavbarCssClass.Contains("navbar-default")) { //navBar.AddCssClass("navbar-default"); navBar.Attributes["style"] = "display: none;"; } navBar.AddCssClass(!string.IsNullOrEmpty(formConfiguration.ActionNavbarCssClass) ? formConfiguration.ActionNavbarCssClass : "Actions"); return(navBar); }
public void mutate(int offset, IFormConfiguration formConfig, ColourConfiguration colourConfig, Vector3 branchStartPosition, Vector3 branchStartTwist, Vector3 branchStartRotationOrigin, FormBounds formBounds) { FormProcessor formProcessor = formConfig.getFormProcessor (); formProcessor.mutateBranch(stacks, offset, formConfig, colourConfig, branchStartPosition, branchStartTwist, branchStartRotationOrigin, formBounds); }
public Branch(int offset, IFormConfiguration formConfig, ColourConfiguration colourConfig, Vector3 branchStartPosition, Vector3 branchStartTwist, Vector3 origin, FormBounds formBounds) { FormProcessor formProcessor = formConfig.getFormProcessor(); formProcessor.createBranch(stacks, offset, formConfig, colourConfig, branchStartPosition, branchStartTwist, origin, formBounds); }
public IFormConfiguration(IFormConfiguration config) { this.index = config.getIndex(); this.startPosition = config.getStartPosition(); this.startRotation = config.getStartRotation(); this.trunkPositionDelta = config.getTrunkPositionDelta(); this.trunkRotationDelta = config.getTrunkRotationDelta(); this.trunkIterations = config.getTrunkIterations(); this.scaleTrunk = config.getScaleTrunk(); this.branchPositionDelta = config.getBranchPositionDelta(); this.branchTwistDelta = config.getBranchTwistDelta(); this.stackIterations = config.getStackIterations(); this.startScale = config.getStartScale(); this.scaleDelta = config.getScaleDelta(); this.scaleBranch = config.getScaleBranch(); this.stackStartTwist = config.getStackStartTwist(); this.stackTwistDelta = config.getStackTwistDelta(); this.stackShape = config.getStackShape(); this.mutationStrength = config.getMutationStrength(); }
public IFormConfiguration(IFormConfiguration config) { this.index = config.getIndex (); this.startPosition = config.getStartPosition (); this.startRotation = config.getStartRotation (); this.trunkPositionDelta = config.getTrunkPositionDelta (); this.trunkRotationDelta = config.getTrunkRotationDelta (); this.trunkIterations = config.getTrunkIterations (); this.scaleTrunk = config.getScaleTrunk (); this.branchPositionDelta = config.getBranchPositionDelta (); this.branchTwistDelta = config.getBranchTwistDelta (); this.stackIterations = config.getStackIterations (); this.startScale = config.getStartScale (); this.scaleDelta = config.getScaleDelta (); this.scaleBranch = config.getScaleBranch (); this.stackStartTwist = config.getStackStartTwist (); this.stackTwistDelta = config.getStackTwistDelta (); this.stackShape = config.getStackShape (); this.mutationStrength = config.getMutationStrength (); }
protected override void Given() { Dependency<IComponentNameResolver>() .Stub(s => s.ResolveName<TestEntity, string>(null)) .IgnoreArguments() .Return("thename"); Dependency<IComponentIdResolver>() .Stub(s => s.ResolveId<TestEntity, string>(null, null)) .IgnoreArguments() .Return("theid"); Dependency<IComponentLabelResolver>() .Stub(s => s.ResolveLabel<TestEntity, string>(null)) .IgnoreArguments() .Return("thelabel"); this.configuration = Dependency<IFormConfiguration>(); this.entity = new TestEntity(); factory = Subject<ComponentFactory<TestEntity>>(); }
//mutate model public void mutate(IFormConfiguration formConfig, ColourConfiguration colourConfig) { //if we are receiving null configs then this is rendering on scene and not current brush //so use local configs if (formConfig == null) { formConfig = localFormConfig; } if (colourConfig == null) { colourConfig = localColourConfig; } //increment colour once for each trunk colourConfig.incrementDisplayColour(); //increment pulse once for each trunk colourConfig.incrementPulseCount(); FormProcessor formProcessor = formConfig.getFormProcessor(); formBounds = new FormBounds(formConfig.getStartPosition()); formProcessor.mutateTrunk(branches, formBounds, formConfig, colourConfig); }
protected override void Given() { Dependency <IComponentNameResolver>() .Stub(s => s.ResolveName <TestEntity, string>(null)) .IgnoreArguments() .Return("thename"); Dependency <IComponentIdResolver>() .Stub(s => s.ResolveId <TestEntity, string>(null, null)) .IgnoreArguments() .Return("theid"); Dependency <IComponentLabelResolver>() .Stub(s => s.ResolveLabel <TestEntity, string>(null)) .IgnoreArguments() .Return("thelabel"); this.configuration = Dependency <IFormConfiguration>(); this.entity = new TestEntity(); factory = Subject <ComponentFactory <TestEntity> >(); }
public void mutateTrunk(List<Branch> branches, FormBounds formBounds, IFormConfiguration formConfig, ColourConfiguration colourConfig) { Vector3 branchStartPosition = formConfig.getStartPosition(); Vector3 branchStartTwist = formConfig.getStartRotation(); Vector3 origin = formConfig.getStartPosition(); foreach (Branch branch in branches) { formBounds.calculateNewBounds(branchStartPosition); branch.mutate(0, formConfig, colourConfig, branchStartPosition, branchStartTwist, origin, formBounds); //set origin to previous start position origin = branchStartPosition; branchStartTwist = GeometryUtility.addDeltaToRotation(branchStartTwist, formConfig.getTrunkRotationDelta()); branchStartPosition = GeometryUtility.addDeltaToPosition(branchStartPosition, formConfig.getTrunkPositionDelta(), 1); } }
public void displayFormBuilderPalette(IFormConfiguration formConfig) { // Make a background box GUI.Box(new Rect(10, 10, 700, 590), "Builder Palette"); bool displayStarfishControls = false; bool displayLoxodromeControls = false; bool displayRingControls = false; if (formConfig.getFormProcessor().GetType() == typeof(StarfishForm)) { displayStarfishControls = true; } else if (formConfig.getFormProcessor().GetType() == typeof(LoxodromeForm)) { displayLoxodromeControls = true; } else if (formConfig.getFormProcessor().GetType() == typeof(RingForm)) { displayRingControls = true; } /* TRUNK */ //start position Vector3 startPosition = formConfig.getStartPosition(); startPositionX = startPosition.x; startPositionY = startPosition.y; startPositionZ = startPosition.z; GUI.Label(new Rect(20, 40, 150, 20), "Trunk Start Position X"); startPositionX = GUI.HorizontalSlider(new Rect(180, 45, 180, 20), startPositionX, -5, 5); GUI.Label(new Rect(20, 70, 150, 20), "Trunk Start Position Y"); startPositionY = GUI.HorizontalSlider(new Rect(180, 75, 180, 20), startPositionY, -5, 5); GUI.Label(new Rect(20, 100, 150, 20), "Trunk Start Position Z"); startPositionZ = GUI.HorizontalSlider(new Rect(180, 105, 180, 20), startPositionZ, -5, 5); startPosition.x = startPositionX; startPosition.y = startPositionY; startPosition.z = startPositionZ; formConfig.setStartPosition(startPosition); // start rotation Vector3 startRotation = formConfig.getStartRotation(); startRotationX = startRotation.x; startRotationY = startRotation.y; startRotationZ = startRotation.z; if (displayLoxodromeControls) { GUI.Label(new Rect(370, 40, 150, 20), "Rhumb Angle"); //startRotationX = GUI.HorizontalSlider (new Rect (520, 45, 180, 20), startRotationX, 0.1f, 2f); startRotationX = GUI.HorizontalSlider(new Rect(520, 45, 180, 20), startRotationX, 0, 2f); } if (displayStarfishControls) { GUI.Label(new Rect(370, 40, 150, 20), "Trunk Start Rotation X"); startRotationX = GUI.HorizontalSlider(new Rect(520, 45, 180, 20), startRotationX, 0, 360); } if (displayStarfishControls || displayRingControls) { GUI.Label(new Rect(370, 70, 150, 20), "Trunk Start Rotation Y"); startRotationY = GUI.HorizontalSlider(new Rect(520, 75, 180, 20), startRotationY, 0, 360); GUI.Label(new Rect(370, 100, 150, 20), "Trunk Start Rotation Z"); startRotationZ = GUI.HorizontalSlider(new Rect(520, 105, 180, 20), startRotationZ, 0, 360); } startRotation.x = startRotationX; startRotation.y = startRotationY; startRotation.z = startRotationZ; formConfig.setStartRotation(startRotation); //trunk position delta Vector3 trunkPositionDelta = formConfig.getTrunkPositionDelta(); trunkPositionDeltaX = trunkPositionDelta.x; trunkPositionDeltaY = trunkPositionDelta.y; trunkPositionDeltaZ = trunkPositionDelta.z; if (displayStarfishControls || displayRingControls) { GUI.Label(new Rect(20, 130, 150, 20), "Trunk Position Delta X"); trunkPositionDeltaX = GUI.HorizontalSlider(new Rect(180, 135, 180, 20), trunkPositionDeltaX, -1, 1); GUI.Label(new Rect(20, 160, 150, 20), "Trunk Position Delta Y"); trunkPositionDeltaY = GUI.HorizontalSlider(new Rect(180, 165, 180, 20), trunkPositionDeltaY, -1, 1); GUI.Label(new Rect(20, 190, 150, 20), "Trunk Position Delta Z"); trunkPositionDeltaZ = GUI.HorizontalSlider(new Rect(180, 195, 180, 20), trunkPositionDeltaZ, -1, 1); } trunkPositionDelta.x = trunkPositionDeltaX; trunkPositionDelta.y = trunkPositionDeltaY; trunkPositionDelta.z = trunkPositionDeltaZ; formConfig.setTrunkPositionDelta(trunkPositionDelta); //trunk rotation delta Vector3 trunkRotatiomnDelta = formConfig.getTrunkRotationDelta(); trunkRotationDeltaX = trunkRotatiomnDelta.x; trunkRotationDeltaY = trunkRotatiomnDelta.y; trunkRotationDeltaZ = trunkRotatiomnDelta.z; if (displayStarfishControls) { GUI.Label(new Rect(20, 220, 150, 20), "Trunk Rotation Delta X"); trunkRotationDeltaX = GUI.HorizontalSlider(new Rect(180, 225, 180, 20), trunkRotationDeltaX, -60, 60); } if (displayStarfishControls || displayRingControls) { GUI.Label(new Rect(20, 250, 150, 20), "Trunk Rotation Delta Y"); trunkRotationDeltaY = GUI.HorizontalSlider(new Rect(180, 255, 180, 20), trunkRotationDeltaY, -60, 60); GUI.Label(new Rect(20, 280, 150, 20), "Trunk Rotation Delta Z"); trunkRotationDeltaZ = GUI.HorizontalSlider(new Rect(180, 285, 180, 20), trunkRotationDeltaZ, -60, 60); } trunkRotatiomnDelta.x = trunkRotationDeltaX; trunkRotatiomnDelta.y = trunkRotationDeltaY; trunkRotatiomnDelta.z = trunkRotationDeltaZ; formConfig.setTrunkRotationDelta(trunkRotatiomnDelta); //trunk iterations trunkIterations = formConfig.getTrunkIterations(); GUI.Label(new Rect(20, 310, 150, 20), "Trunk Iterations *"); trunkIterations = GUI.HorizontalSlider(new Rect(180, 315, 180, 20), trunkIterations, 1, 24); formConfig.setTrunkIterations((int)trunkIterations); /* BRANCH */ //branch position delta Vector3 branchPositionDelta = formConfig.getBranchPositionDelta(); branchPositionDeltaX = branchPositionDelta.x; branchPositionDeltaY = branchPositionDelta.y; branchPositionDeltaZ = branchPositionDelta.z; if (displayRingControls || displayLoxodromeControls) { GUI.Label(new Rect(370, 130, 150, 20), "Radius"); branchPositionDeltaX = GUI.HorizontalSlider(new Rect(520, 135, 180, 20), branchPositionDeltaX, 0.2f, 1); } if (displayStarfishControls) { GUI.Label(new Rect(370, 130, 150, 20), "Branch Position Delta X"); branchPositionDeltaX = GUI.HorizontalSlider(new Rect(520, 135, 180, 20), branchPositionDeltaX, -1, 1); GUI.Label(new Rect(370, 160, 150, 20), "Branch Position Delta Y"); branchPositionDeltaY = GUI.HorizontalSlider(new Rect(520, 165, 180, 20), branchPositionDeltaY, -1, 1); GUI.Label(new Rect(370, 190, 150, 20), "Branch Position Delta Z"); branchPositionDeltaZ = GUI.HorizontalSlider(new Rect(520, 195, 180, 20), branchPositionDeltaZ, -1, 1); } branchPositionDelta.x = branchPositionDeltaX; branchPositionDelta.y = branchPositionDeltaY; branchPositionDelta.z = branchPositionDeltaZ; formConfig.setBranchPositionDelta(branchPositionDelta); //branch rotation delta Vector3 branchRotationDelta = formConfig.getBranchTwistDelta(); branchRotationDeltaX = branchRotationDelta.x; branchRotationDeltaY = branchRotationDelta.y; branchRotationDeltaZ = branchRotationDelta.z; if (displayStarfishControls) { GUI.Label(new Rect(370, 220, 150, 20), "Branch Rotation Delta X"); branchRotationDeltaX = GUI.HorizontalSlider(new Rect(520, 225, 180, 20), branchRotationDeltaX, -30, 30); GUI.Label(new Rect(370, 250, 150, 20), "Branch Rotation Delta Y"); branchRotationDeltaY = GUI.HorizontalSlider(new Rect(520, 255, 180, 20), branchRotationDeltaY, -30, 30); GUI.Label(new Rect(370, 280, 150, 20), "Branch Rotation Delta Z"); branchRotationDeltaZ = GUI.HorizontalSlider(new Rect(520, 285, 180, 20), branchRotationDeltaZ, -30, 30); } branchRotationDelta.x = branchRotationDeltaX; branchRotationDelta.y = branchRotationDeltaY; branchRotationDelta.z = branchRotationDeltaZ; formConfig.setBranchTwistDelta(branchRotationDelta); //branch iterations branchIterations = formConfig.getStackIterations(); GUI.Label(new Rect(370, 310, 150, 20), "Branch Iterations *"); branchIterations = GUI.HorizontalSlider(new Rect(520, 315, 180, 20), branchIterations, 1, 60); formConfig.setStackIterations((int)branchIterations); /* STACK */ //stack start rotation Vector3 stackStartRotation = formConfig.getStackStartTwist(); stackStartRotationX = stackStartRotation.x; stackStartRotationY = stackStartRotation.y; stackStartRotationZ = stackStartRotation.z; GUI.Label(new Rect(20, 340, 150, 20), "Stack Start Rotation X"); stackStartRotationX = GUI.HorizontalSlider(new Rect(180, 345, 180, 20), stackStartRotationX, 0, 360); GUI.Label(new Rect(20, 370, 150, 20), "Stack Start Rotation Y"); stackStartRotationY = GUI.HorizontalSlider(new Rect(180, 375, 180, 20), stackStartRotationY, 0, 360); GUI.Label(new Rect(20, 400, 150, 20), "Stack Start Rotation Z"); stackStartRotationZ = GUI.HorizontalSlider(new Rect(180, 405, 180, 20), stackStartRotationZ, 0, 360); stackStartRotation.x = stackStartRotationX; stackStartRotation.y = stackStartRotationY; stackStartRotation.z = stackStartRotationZ; formConfig.setStackStartTwist(stackStartRotation); //stack rotation delta Vector3 stackRotationDelta = formConfig.getStackTwistDelta(); stackRotationDeltaX = stackRotationDelta.x; stackRotationDeltaY = stackRotationDelta.y; stackRotationDeltaZ = stackRotationDelta.z; GUI.Label(new Rect(370, 340, 150, 20), "Stack Rotation Delta X"); stackRotationDeltaX = GUI.HorizontalSlider(new Rect(520, 345, 180, 20), stackRotationDeltaX, -30, 30); GUI.Label(new Rect(370, 370, 150, 20), "Stack Rotation Delta Y"); stackRotationDeltaY = GUI.HorizontalSlider(new Rect(520, 375, 180, 20), stackRotationDeltaY, -30, 30); GUI.Label(new Rect(370, 400, 150, 20), "Stack Rotation Delta Z"); stackRotationDeltaZ = GUI.HorizontalSlider(new Rect(520, 405, 180, 20), stackRotationDeltaZ, -30, 30); stackRotationDelta.x = stackRotationDeltaX; stackRotationDelta.y = stackRotationDeltaY; stackRotationDelta.z = stackRotationDeltaZ; formConfig.setStackTwistDelta(stackRotationDelta); /* MUTATION STRENGTH */ mutationStrength = formConfig.getMutationStrength(); GUI.Label(new Rect(20, 430, 150, 20), "Mutation Strength"); mutationStrength = GUI.HorizontalSlider(new Rect(180, 435, 180, 20), mutationStrength, 0.5f, 3.5f); formConfig.setMutationStrength(mutationStrength); /* SCALING */ scaling = formConfig.getScaleDelta(); GUI.Label(new Rect(370, 430, 150, 20), "Scaling *"); scaling = GUI.HorizontalSlider(new Rect(520, 435, 180, 20), scaling, 0.9f, 1.1f); formConfig.setScaleDelta(scaling); /* STACK SHAPE */ selectedShape = formConfig.getStackShapeIndex(); selectedShape = GUI.SelectionGrid(new Rect(20, 460, 200, 60), selectedShape, shapeGridStrings, 2); formConfig.setStackShape(selectedShape); /* Form Processor */ if (formConfig.getFormProcessor().GetType() == typeof(StarfishForm)) { selectedFormProcessor = 0; } else if (formConfig.getFormProcessor().GetType() == typeof(LoxodromeForm)) { selectedFormProcessor = 1; } else if (formConfig.getFormProcessor().GetType() == typeof(RingForm)) { selectedFormProcessor = 2; } selectedFormProcessor = GUI.SelectionGrid(new Rect(20, 525, 200, 60), selectedFormProcessor, formProcessorStrings, 2); if (selectedFormProcessor == 0) { formConfig.setFormProcessor(new StarfishForm()); } else if (selectedFormProcessor == 1) { formConfig.setFormProcessor(new LoxodromeForm()); } else if (selectedFormProcessor == 2) { formConfig.setFormProcessor(new RingForm()); } /* Configurations */ selectedConfiguration = formConfig.getIndex(); selectedConfiguration = GUI.SelectionGrid(new Rect(230, 460, 300, 90), selectedConfiguration, configurationGridStrings, 3); if (selectedConfiguration != formConfig.getIndex()) { //selected configuration changed callback.changeSelectedFormConfig(selectedConfiguration); } /* Control buttons */ if (GUI.Button(new Rect(540, 460, 160, 26), "Reset Config")) { formConfig.reset(); } if (GUI.Button(new Rect(540, 490, 160, 26), "Create Form")) { callback.createNewBrush(); } if (GUI.Button(new Rect(540, 520, 160, 26), "Clear Brush")) { callback.clearBrush(); } /* Load and Save buttons */ if (GUI.Button(new Rect(230, 560, 147, 26), "Load")) { ConfigXML.loadConfiguration(formConfig); } if (GUI.Button(new Rect(383, 560, 147, 26), "Save")) { ConfigXML.saveConfiguration(formConfig); } }
public void sanitiseConfiguration(IFormConfiguration formConfiguration) { }
// Update is called once per frame void Update() { /* Check for key input */ if (Input.GetKey("1")) { //config 1 currentConfig = allConfigs[0]; } if (Input.GetKey("2")) { //config 2 currentConfig = allConfigs[1]; } if (Input.GetKey("3")) { //config 3 currentConfig = allConfigs[2]; } if (Input.GetKey("4")) { //config 4 currentConfig = allConfigs[3]; } if (Input.GetKey("5")) { //config 5 currentConfig = allConfigs[4]; } if (Input.GetKey("6")) { //config 6 currentConfig = allConfigs[5]; } if (Input.GetKey("7")) { //config 7 currentConfig = allConfigs[6]; } if (Input.GetKey("8")) { //config 8 currentConfig = allConfigs[7]; } if (Input.GetKey("9")) { //config 9 currentConfig = allConfigs[8]; } if (Input.GetKey("n")) { //new form createNewBrush(); return; } if (Input.GetKey("b")) { //clear brush clearBrush(); } if (Input.GetKey("s")) { //save current form to scene saveForm(); return; } if (Input.GetKey("c")) { //clear scene clearScene(); return; } if (!keyDelayOn) { if (Input.GetKey("v")) { //branch scaling currentConfig.setScaleBranch(!currentConfig.getScaleBranch()); //switch on key delay to stop retrigger switchOnKeyDelay(); } } if (Input.GetKey("r")) { //symetrical random mutation currentConfig.randomiseValuesWithSymetry(); } if (Input.GetKey("t")) { //non symetrical random mutation currentConfig.randomiseValuesWithoutSymetry(); } if (!keyDelayOn) { if (Input.GetKey("p")) { //toggle colour palette displayColourPalette = !displayColourPalette; if (displayColourPalette) { displayHelp = false; } //switch on key delay to stop retrigger switchOnKeyDelay(); } } if (!keyDelayOn) { if (Input.GetKey("f")) { //toggle builder palette displayFormBuilderPalette = !displayFormBuilderPalette; if (displayFormBuilderPalette) { displayHelp = false; } //switch on key delay to stop retrigger switchOnKeyDelay(); } } if (!keyDelayOn) { if (Input.GetKey("j")) { autoPreset = !autoPreset; if (autoPreset) { int random = Random.Range(0, 9); currentConfig = allConfigs[random]; autoMutate1 = false; autoMutate2 = false; autoChangeCount = 0; } switchOnKeyDelay(); } } if (!keyDelayOn) { if (Input.GetKey("k")) { autoMutate1 = !autoMutate1; if (autoMutate1) { currentConfig.randomiseValuesWithSymetry(); autoPreset = false; autoMutate2 = false; autoChangeCount = 0; } switchOnKeyDelay(); } } if (!keyDelayOn) { if (Input.GetKey("l")) { autoMutate2 = !autoMutate2; if (autoMutate2) { currentConfig.randomiseValuesWithoutSymetry(); autoPreset = false; autoMutate1 = false; autoChangeCount = 0; } switchOnKeyDelay(); } } //help key if (!keyDelayOn) { if (Input.GetKey("h")) { displayHelp = !displayHelp; if (displayHelp) { //switch off any other open forms displayColourPalette = false; displayFormBuilderPalette = false; } switchOnKeyDelay(); } } /* key delay timer */ if (keyDelayOn) { if (keyDelayCount < keyDelayLength) { keyDelayCount++; } else { //finished delay keyDelayOn = false; } } /* Automated Stuff */ //random go through presets if (autoPreset) { if (autoChangeCount < 15) { autoChangeCount += Time.deltaTime; } else { autoChangeCount = 0; int random = Random.Range(0, 9); currentConfig = allConfigs[random]; } } //auto mutate1 if (autoMutate1) { if (autoChangeCount < 35) { autoChangeCount += Time.deltaTime; } else { autoChangeCount = 0; currentConfig.randomiseValuesWithSymetry(); } } //auto mutate 2 if (autoMutate2) { if (autoChangeCount < 25) { autoChangeCount += Time.deltaTime; } else { autoChangeCount = 0; currentConfig.randomiseValuesWithoutSymetry(); } } //default renderScene(); }
public void createBranch(List <IStack> stacks, int offset, IFormConfiguration formConfig, ColourConfiguration colourConfig, Vector3 branchStartPosition, Vector3 branchStartTwist, Vector3 origin, FormBounds formBounds) { float scale = formConfig.getStartScale(); Vector3 stackTwist = formConfig.getStackStartTwist(); Vector3 position = branchStartPosition; Vector3 twist = branchStartTwist; //rotate position araound previous branch start position position = GeometryUtility.rotateCoordinateAboutPoint(origin, position, branchStartTwist); //colour stuff int iterations = formConfig.getStackIterations(); Color modelColour = new Color(colourConfig.getBaseRed(), colourConfig.getBaseGreen(), colourConfig.getBaseBlue(), 1); //if cycling override base colour if (colourConfig.getCycle()) { modelColour = colourConfig.getCycleColour(); } for (int i = 0; i < iterations; i++) { formBounds.calculateNewBounds(position); //Stack Shape IStack stack = new SimpleStack(); //default if (formConfig.getStackShape() == IFormConfiguration.StackShape.Sphere) { //spehere stack = new SimpleStack(); } else if (formConfig.getStackShape() == IFormConfiguration.StackShape.Box) { //box stack = new SimpleBoxStack(); } else if (formConfig.getStackShape() == IFormConfiguration.StackShape.Complex1) { //complex 1 stack = new ComplexStack(); } else if (formConfig.getStackShape() == IFormConfiguration.StackShape.Complex2) { //complex 2 stack = new ComplexStack2(); } else if (formConfig.getStackShape() == IFormConfiguration.StackShape.SimpleTorus) { //simple Torus stack = new SimpleTorusStack(); } //colour stuff order is important Color stackColour = modelColour; if (colourConfig.getFadeColour()) { //fade colour in stackColour = ColourUtility.fadeModelColour(modelColour, iterations, i); } if (colourConfig.getPulse()) { //do pulse stackColour = colourConfig.getPulseColourForStack(stackColour, i); } stack.initialise(position, stackTwist, scale, stackColour); stacks.Add(stack); scale = scale * formConfig.getScaleDelta(); Vector3 newPosition = GeometryUtility.addDeltaToPosition(position, formConfig.getBranchPositionDelta(), scale); position = GeometryUtility.rotateCoordinateAboutPoint(position, newPosition, twist); twist = GeometryUtility.addDeltaToRotation(twist, formConfig.getBranchTwistDelta()); stackTwist = GeometryUtility.addDeltaToRotation(stackTwist, formConfig.getStackTwistDelta()); } }
public static void loadConfiguration(IFormConfiguration formConfiguration) { string fileSavePath = Application.persistentDataPath + "/FormConfigSlot" + (formConfiguration.getIndex() + 1) + ".xml"; Debug.Log ("Load:" + fileSavePath); XmlDocument xmlDoc = new XmlDocument(); if (System.IO.File.Exists (fileSavePath)) { xmlDoc.Load(new XmlTextReader(fileSavePath)); XmlElement root = xmlDoc.DocumentElement; float x = float.Parse(root.GetAttribute("branchPositionDeltaX")); float y = float.Parse(root.GetAttribute("branchPositionDeltaY")); float z = float.Parse(root.GetAttribute("branchPositionDeltaZ")); formConfiguration.setBranchPositionDelta(new Vector3(x, y, z)); x = float.Parse(root.GetAttribute("branchTwistDeltaX")); y = float.Parse(root.GetAttribute("branchTwistDeltaY")); z = float.Parse(root.GetAttribute("branchTwistDeltaZ")); formConfiguration.setBranchTwistDelta(new Vector3(x, y, z)); formConfiguration.setIndex(int.Parse(root.GetAttribute("index"))); formConfiguration.setMutationStrength(float.Parse(root.GetAttribute("mutationStrength"))); formConfiguration.setScaleBranch(bool.Parse(root.GetAttribute("scaleBranch"))); formConfiguration.setScaleDelta(float.Parse(root.GetAttribute("scaleDelta"))); formConfiguration.setScaleTrunk(bool.Parse(root.GetAttribute("scaleTrunk"))); formConfiguration.setStackIterations(int.Parse(root.GetAttribute("stackIterations"))); formConfiguration.setStackShape(int.Parse(root.GetAttribute("stackShapeIndex"))); x = float.Parse(root.GetAttribute("stackStartTwistX")); y = float.Parse(root.GetAttribute("stackStartTwistY")); z = float.Parse(root.GetAttribute("stackStartTwistZ")); formConfiguration.setStackStartTwist(new Vector3(x, y, z)); x = float.Parse(root.GetAttribute("stackTwistDeltaX")); y = float.Parse(root.GetAttribute("stackTwistDeltaY")); z = float.Parse(root.GetAttribute("stackTwistDeltaZ")); formConfiguration.setStackTwistDelta(new Vector3(x, y, z)); x = float.Parse(root.GetAttribute("startPositionX")); y = float.Parse(root.GetAttribute("startPositionY")); z = float.Parse(root.GetAttribute("startPositionZ")); formConfiguration.setStartPosition(new Vector3(x, y, z)); x = float.Parse(root.GetAttribute("startRotationX")); y = float.Parse(root.GetAttribute("startRotationY")); z = float.Parse(root.GetAttribute("startRotationZ")); formConfiguration.setStartRotation(new Vector3(x, y, z)); formConfiguration.setStartScale(float.Parse(root.GetAttribute("startScale"))); formConfiguration.setTrunkIterations(int.Parse(root.GetAttribute("trunkIterations"))); x = float.Parse(root.GetAttribute("trunkPositionDeltaX")); y = float.Parse(root.GetAttribute("trunkPositionDeltaY")); z = float.Parse(root.GetAttribute("trunkPositionDeltaZ")); formConfiguration.setTrunkPositionDelta(new Vector3(x, y, z)); x = float.Parse(root.GetAttribute("trunklRotationDeltaX")); y = float.Parse(root.GetAttribute("trunklRotationDeltaY")); z = float.Parse(root.GetAttribute("trunklRotationDeltaZ")); formConfiguration.setTrunkRotationDelta(new Vector3(x, y, z)); //perfom bounds checks and fix formConfiguration.validateAndFix(); } else { Debug.Log("File Not Found:" + fileSavePath); } }
public static TagBuilder FormActionNavbarInnerHtml(this HtmlHelper html, TagBuilder container, IFormConfiguration formConfiguration) { var collapsedNavbar = new TagBuilder("div"); collapsedNavbar.GenerateId("form-navbar-collapse"); collapsedNavbar.AddCssClass("collapse"); collapsedNavbar.AddCssClass("navbar-collapse"); var status = new TagBuilder("p"); status.AddCssClass("navbar-text"); status.AddCssClass("pull-right"); status.AddCssClass("action-status"); status.Attributes.Add("style", "margin-right:0;"); var statusIcon = new TagBuilder("span"); statusIcon.Attributes.Add("aria-hidden", "true"); statusIcon.AddCssClass("fa fa-fw"); status.InnerHtml += statusIcon; collapsedNavbar.InnerHtml += status; collapsedNavbar.InnerHtml += container; var navbarHeader = new TagBuilder("div"); navbarHeader.AddCssClass("navbar-header"); var collapseButton = new TagBuilder("button"); collapseButton.AddCssClass("navbar-toggle"); collapseButton.AddCssClass("collapsed"); collapseButton.Attributes["type"] = "button"; collapseButton.Attributes["data-toggle"] = "collapse"; collapseButton.Attributes["data-target"] = "#form-navbar-collapse"; var srOnly = new TagBuilder("span"); srOnly.AddCssClass("sr-only"); collapseButton.InnerHtml += srOnly; var collapseButtonBar = new TagBuilder("span"); collapseButtonBar.AddCssClass("icon-bar"); collapseButton.InnerHtml += collapseButtonBar; collapseButton.InnerHtml += collapseButtonBar; collapseButton.InnerHtml += collapseButtonBar; navbarHeader.InnerHtml += collapseButton; var containerFluid = new TagBuilder("div"); containerFluid.AddCssClass("container-fluid"); containerFluid.InnerHtml += navbarHeader; containerFluid.InnerHtml += collapsedNavbar; return(containerFluid); }
public void createBranch(List <IStack> stacks, int offset, IFormConfiguration formConfig, ColourConfiguration colourConfig, Vector3 branchStartPosition, Vector3 branchStartTwist, Vector3 origin, FormBounds formBounds) { int iterations = formConfig.getStackIterations(); float scale = formConfig.getStartScale(); for (int o = 0; o < offset; o++) { scale *= formConfig.getScaleDelta(); } //centre of ring Vector3 position = branchStartPosition; //add radius of ring float ringRadius = formConfig.getBranchPositionDelta().x * 10 * scale; //angle to calculate ring float zAngle = branchStartTwist.z * Mathf.Deg2Rad; float yAngle = branchStartTwist.y * Mathf.Deg2Rad; float ringSegmentAngle = 360 / iterations * Mathf.Deg2Rad; Vector3 stackTwist = formConfig.getStackStartTwist(); //colour stuff Color modelColour = new Color(colourConfig.getBaseRed(), colourConfig.getBaseGreen(), colourConfig.getBaseBlue(), 1); //if cycling override base colour if (colourConfig.getCycle()) { modelColour = colourConfig.getCycleColour(); } for (int i = offset; i < offset + iterations; i++) { position.x = (ringRadius * Mathf.Cos(zAngle) * Mathf.Sin(yAngle)) + branchStartPosition.x; position.y = (ringRadius * Mathf.Sin(zAngle) * Mathf.Sin(yAngle)) + branchStartPosition.y; position.z = (ringRadius * Mathf.Cos(yAngle)) + branchStartPosition.z; formBounds.calculateNewBounds(position); //Stack Shape IStack stack = new SimpleStack(); //default if (formConfig.getStackShape() == IFormConfiguration.StackShape.Sphere) { //spehere stack = new SimpleStack(); } else if (formConfig.getStackShape() == IFormConfiguration.StackShape.Box) { //box stack = new SimpleBoxStack(); } else if (formConfig.getStackShape() == IFormConfiguration.StackShape.Complex1) { //complex 1 stack = new ComplexStack(); } else if (formConfig.getStackShape() == IFormConfiguration.StackShape.Complex2) { //complex 2 stack = new ComplexStack2(); } else if (formConfig.getStackShape() == IFormConfiguration.StackShape.SimpleTorus) { //simple Torus stack = new SimpleTorusStack(); } //colour stuff order is important Color stackColour = modelColour; if (colourConfig.getFadeColour()) { //fade colour in stackColour = ColourUtility.fadeModelColour(modelColour, iterations, i); } if (colourConfig.getPulse()) { //do pulse stackColour = colourConfig.getPulseColourForStack(stackColour, i); } stack.initialise(position, stackTwist, 0.5f * scale, stackColour); stacks.Add(stack); yAngle += ringSegmentAngle; stackTwist = GeometryUtility.addDeltaToRotation(stackTwist, formConfig.getStackTwistDelta()); } }
public void displayFormBuilderPalette(IFormConfiguration formConfig) { // Make a background box GUI.Box(new Rect(10, 10, 700, 590), "Builder Palette"); bool displayStarfishControls = false; bool displayLoxodromeControls = false; bool displayRingControls = false; if (formConfig.getFormProcessor ().GetType () == typeof(StarfishForm)) { displayStarfishControls = true; } else if (formConfig.getFormProcessor ().GetType () == typeof(LoxodromeForm)) { displayLoxodromeControls = true; } else if (formConfig.getFormProcessor().GetType() == typeof(RingForm)) { displayRingControls = true; } /* TRUNK */ //start position Vector3 startPosition = formConfig.getStartPosition (); startPositionX = startPosition.x; startPositionY = startPosition.y; startPositionZ = startPosition.z; GUI.Label (new Rect (20, 40, 150, 20), "Trunk Start Position X"); startPositionX = GUI.HorizontalSlider (new Rect (180, 45, 180, 20), startPositionX, -5, 5); GUI.Label (new Rect (20, 70, 150, 20), "Trunk Start Position Y"); startPositionY = GUI.HorizontalSlider (new Rect (180, 75, 180, 20), startPositionY, -5, 5); GUI.Label (new Rect (20, 100, 150, 20), "Trunk Start Position Z"); startPositionZ = GUI.HorizontalSlider (new Rect (180, 105, 180, 20), startPositionZ, -5, 5); startPosition.x = startPositionX; startPosition.y = startPositionY; startPosition.z = startPositionZ; formConfig.setStartPosition (startPosition); // start rotation Vector3 startRotation = formConfig.getStartRotation (); startRotationX = startRotation.x; startRotationY = startRotation.y; startRotationZ = startRotation.z; if (displayLoxodromeControls) { GUI.Label (new Rect (370, 40, 150, 20), "Rhumb Angle"); //startRotationX = GUI.HorizontalSlider (new Rect (520, 45, 180, 20), startRotationX, 0.1f, 2f); startRotationX = GUI.HorizontalSlider (new Rect (520, 45, 180, 20), startRotationX, 0, 2f); } if (displayStarfishControls) { GUI.Label (new Rect (370, 40, 150, 20), "Trunk Start Rotation X"); startRotationX = GUI.HorizontalSlider (new Rect (520, 45, 180, 20), startRotationX, 0, 360); } if (displayStarfishControls || displayRingControls) { GUI.Label (new Rect (370, 70, 150, 20), "Trunk Start Rotation Y"); startRotationY = GUI.HorizontalSlider (new Rect (520, 75, 180, 20), startRotationY, 0, 360); GUI.Label (new Rect (370, 100, 150, 20), "Trunk Start Rotation Z"); startRotationZ = GUI.HorizontalSlider (new Rect (520, 105, 180, 20), startRotationZ, 0, 360); } startRotation.x = startRotationX; startRotation.y = startRotationY; startRotation.z = startRotationZ; formConfig.setStartRotation (startRotation); //trunk position delta Vector3 trunkPositionDelta = formConfig.getTrunkPositionDelta (); trunkPositionDeltaX = trunkPositionDelta.x; trunkPositionDeltaY = trunkPositionDelta.y; trunkPositionDeltaZ = trunkPositionDelta.z; if (displayStarfishControls || displayRingControls) { GUI.Label (new Rect (20, 130, 150, 20), "Trunk Position Delta X"); trunkPositionDeltaX = GUI.HorizontalSlider (new Rect (180, 135, 180, 20), trunkPositionDeltaX, -1, 1); GUI.Label (new Rect (20, 160, 150, 20), "Trunk Position Delta Y"); trunkPositionDeltaY = GUI.HorizontalSlider (new Rect (180, 165, 180, 20), trunkPositionDeltaY, -1, 1); GUI.Label (new Rect (20, 190, 150, 20), "Trunk Position Delta Z"); trunkPositionDeltaZ = GUI.HorizontalSlider (new Rect (180, 195, 180, 20), trunkPositionDeltaZ, -1, 1); } trunkPositionDelta.x = trunkPositionDeltaX; trunkPositionDelta.y = trunkPositionDeltaY; trunkPositionDelta.z = trunkPositionDeltaZ; formConfig.setTrunkPositionDelta (trunkPositionDelta); //trunk rotation delta Vector3 trunkRotatiomnDelta = formConfig.getTrunkRotationDelta (); trunkRotationDeltaX = trunkRotatiomnDelta.x; trunkRotationDeltaY = trunkRotatiomnDelta.y; trunkRotationDeltaZ = trunkRotatiomnDelta.z; if (displayStarfishControls) { GUI.Label (new Rect (20, 220, 150, 20), "Trunk Rotation Delta X"); trunkRotationDeltaX = GUI.HorizontalSlider (new Rect (180, 225, 180, 20), trunkRotationDeltaX, -60, 60); } if (displayStarfishControls || displayRingControls) { GUI.Label (new Rect (20, 250, 150, 20), "Trunk Rotation Delta Y"); trunkRotationDeltaY = GUI.HorizontalSlider (new Rect (180, 255, 180, 20), trunkRotationDeltaY, -60, 60); GUI.Label (new Rect (20, 280, 150, 20), "Trunk Rotation Delta Z"); trunkRotationDeltaZ = GUI.HorizontalSlider (new Rect (180, 285, 180, 20), trunkRotationDeltaZ, -60, 60); } trunkRotatiomnDelta.x = trunkRotationDeltaX; trunkRotatiomnDelta.y = trunkRotationDeltaY; trunkRotatiomnDelta.z = trunkRotationDeltaZ; formConfig.setTrunkRotationDelta (trunkRotatiomnDelta); //trunk iterations trunkIterations = formConfig.getTrunkIterations (); GUI.Label (new Rect (20, 310, 150, 20), "Trunk Iterations *"); trunkIterations = GUI.HorizontalSlider (new Rect (180, 315, 180, 20), trunkIterations, 1, 24); formConfig.setTrunkIterations ((int)trunkIterations); /* BRANCH */ //branch position delta Vector3 branchPositionDelta = formConfig.getBranchPositionDelta (); branchPositionDeltaX = branchPositionDelta.x; branchPositionDeltaY = branchPositionDelta.y; branchPositionDeltaZ = branchPositionDelta.z; if (displayRingControls || displayLoxodromeControls) { GUI.Label (new Rect (370, 130, 150, 20), "Radius"); branchPositionDeltaX = GUI.HorizontalSlider (new Rect (520, 135, 180, 20), branchPositionDeltaX, 0.2f, 1); } if (displayStarfishControls) { GUI.Label (new Rect (370, 130, 150, 20), "Branch Position Delta X"); branchPositionDeltaX = GUI.HorizontalSlider (new Rect (520, 135, 180, 20), branchPositionDeltaX, -1, 1); GUI.Label (new Rect (370, 160, 150, 20), "Branch Position Delta Y"); branchPositionDeltaY = GUI.HorizontalSlider (new Rect (520, 165, 180, 20), branchPositionDeltaY, -1, 1); GUI.Label (new Rect (370, 190, 150, 20), "Branch Position Delta Z"); branchPositionDeltaZ = GUI.HorizontalSlider (new Rect (520, 195, 180, 20), branchPositionDeltaZ, -1, 1); } branchPositionDelta.x = branchPositionDeltaX; branchPositionDelta.y = branchPositionDeltaY; branchPositionDelta.z = branchPositionDeltaZ; formConfig.setBranchPositionDelta (branchPositionDelta); //branch rotation delta Vector3 branchRotationDelta = formConfig.getBranchTwistDelta (); branchRotationDeltaX = branchRotationDelta.x; branchRotationDeltaY = branchRotationDelta.y; branchRotationDeltaZ = branchRotationDelta.z; if (displayStarfishControls) { GUI.Label (new Rect (370, 220, 150, 20), "Branch Rotation Delta X"); branchRotationDeltaX = GUI.HorizontalSlider (new Rect (520, 225, 180, 20), branchRotationDeltaX, -30, 30); GUI.Label (new Rect (370, 250, 150, 20), "Branch Rotation Delta Y"); branchRotationDeltaY = GUI.HorizontalSlider (new Rect (520, 255, 180, 20), branchRotationDeltaY, -30, 30); GUI.Label (new Rect (370, 280, 150, 20), "Branch Rotation Delta Z"); branchRotationDeltaZ = GUI.HorizontalSlider (new Rect (520, 285, 180, 20), branchRotationDeltaZ, -30, 30); } branchRotationDelta.x = branchRotationDeltaX; branchRotationDelta.y = branchRotationDeltaY; branchRotationDelta.z = branchRotationDeltaZ; formConfig.setBranchTwistDelta (branchRotationDelta); //branch iterations branchIterations = formConfig.getStackIterations (); GUI.Label (new Rect (370, 310, 150, 20), "Branch Iterations *"); branchIterations = GUI.HorizontalSlider (new Rect (520, 315, 180, 20), branchIterations, 1, 60); formConfig.setStackIterations ((int)branchIterations); /* STACK */ //stack start rotation Vector3 stackStartRotation = formConfig.getStackStartTwist (); stackStartRotationX = stackStartRotation.x; stackStartRotationY = stackStartRotation.y; stackStartRotationZ = stackStartRotation.z; GUI.Label (new Rect (20, 340, 150, 20), "Stack Start Rotation X"); stackStartRotationX = GUI.HorizontalSlider (new Rect (180, 345, 180, 20), stackStartRotationX, 0, 360); GUI.Label (new Rect (20, 370, 150, 20), "Stack Start Rotation Y"); stackStartRotationY = GUI.HorizontalSlider (new Rect (180, 375, 180, 20), stackStartRotationY, 0, 360); GUI.Label (new Rect (20, 400, 150, 20), "Stack Start Rotation Z"); stackStartRotationZ = GUI.HorizontalSlider (new Rect (180, 405, 180, 20), stackStartRotationZ, 0, 360); stackStartRotation.x = stackStartRotationX; stackStartRotation.y = stackStartRotationY; stackStartRotation.z = stackStartRotationZ; formConfig.setStackStartTwist (stackStartRotation); //stack rotation delta Vector3 stackRotationDelta = formConfig.getStackTwistDelta (); stackRotationDeltaX = stackRotationDelta.x; stackRotationDeltaY = stackRotationDelta.y; stackRotationDeltaZ = stackRotationDelta.z; GUI.Label (new Rect (370, 340, 150, 20), "Stack Rotation Delta X"); stackRotationDeltaX = GUI.HorizontalSlider (new Rect (520, 345, 180, 20), stackRotationDeltaX, -30, 30); GUI.Label (new Rect (370, 370, 150, 20), "Stack Rotation Delta Y"); stackRotationDeltaY = GUI.HorizontalSlider (new Rect (520, 375, 180, 20), stackRotationDeltaY, -30, 30); GUI.Label (new Rect (370, 400, 150, 20), "Stack Rotation Delta Z"); stackRotationDeltaZ = GUI.HorizontalSlider (new Rect (520, 405, 180, 20), stackRotationDeltaZ, -30, 30); stackRotationDelta.x = stackRotationDeltaX; stackRotationDelta.y = stackRotationDeltaY; stackRotationDelta.z = stackRotationDeltaZ; formConfig.setStackTwistDelta (stackRotationDelta); /* MUTATION STRENGTH */ mutationStrength = formConfig.getMutationStrength (); GUI.Label (new Rect (20, 430, 150, 20), "Mutation Strength"); mutationStrength = GUI.HorizontalSlider (new Rect (180, 435, 180, 20), mutationStrength, 0.5f, 3.5f); formConfig.setMutationStrength (mutationStrength); /* SCALING */ scaling = formConfig.getScaleDelta (); GUI.Label (new Rect (370, 430, 150, 20), "Scaling *"); scaling = GUI.HorizontalSlider (new Rect (520, 435, 180, 20), scaling, 0.9f, 1.1f); formConfig.setScaleDelta (scaling); /* STACK SHAPE */ selectedShape = formConfig.getStackShapeIndex (); selectedShape = GUI.SelectionGrid (new Rect (20, 460, 200, 60), selectedShape, shapeGridStrings, 2); formConfig.setStackShape (selectedShape); /* Form Processor */ if (formConfig.getFormProcessor().GetType() == typeof(StarfishForm)) { selectedFormProcessor = 0; } else if (formConfig.getFormProcessor().GetType() == typeof(LoxodromeForm)) { selectedFormProcessor = 1; } else if (formConfig.getFormProcessor().GetType() == typeof(RingForm)) { selectedFormProcessor = 2; } selectedFormProcessor = GUI.SelectionGrid (new Rect (20, 525, 200, 60), selectedFormProcessor, formProcessorStrings, 2); if (selectedFormProcessor == 0) { formConfig.setFormProcessor(new StarfishForm()); } else if (selectedFormProcessor == 1) { formConfig.setFormProcessor(new LoxodromeForm()); } else if (selectedFormProcessor == 2) { formConfig.setFormProcessor(new RingForm()); } /* Configurations */ selectedConfiguration = formConfig.getIndex (); selectedConfiguration = GUI.SelectionGrid (new Rect (230, 460, 300, 90), selectedConfiguration, configurationGridStrings, 3); if (selectedConfiguration != formConfig.getIndex ()) { //selected configuration changed callback.changeSelectedFormConfig(selectedConfiguration); } /* Control buttons */ if (GUI.Button(new Rect(540, 460, 160, 26), "Reset Config")) { formConfig.reset(); } if (GUI.Button(new Rect(540, 490, 160, 26), "Create Form")) { callback.createNewBrush(); } if (GUI.Button(new Rect(540, 520, 160, 26), "Clear Brush")) { callback.clearBrush(); } /* Load and Save buttons */ if (GUI.Button(new Rect(230, 560, 147, 26), "Load")) { ConfigXML.loadConfiguration(formConfig); } if (GUI.Button(new Rect(383, 560, 147, 26), "Save")) { ConfigXML.saveConfiguration(formConfig); } }
public void createBranch(List <IStack> stacks, int offset, IFormConfiguration formConfig, ColourConfiguration colourConfig, Vector3 branchStartPosition, Vector3 branchStartTwist, Vector3 origin, FormBounds formBounds) { Vector3 position = origin; Vector3 stackTwist = formConfig.getStackStartTwist(); float radius = formConfig.getBranchPositionDelta().x * 20; float rhumbAngle = formConfig.getStartRotation().x * 0.032f; //colour stuff int iterations = formConfig.getStackIterations(); Color modelColour = new Color(colourConfig.getBaseRed(), colourConfig.getBaseGreen(), colourConfig.getBaseBlue(), 1); //if cycling override base colour if (colourConfig.getCycle()) { modelColour = colourConfig.getCycleColour(); } for (int i = offset; i < offset + iterations; i++) { position.x = formConfig.getStartPosition().x + (radius * (float)Math.Cos(i) / (float)Math.Cosh(Mathf.Rad2Deg * (Mathf.Deg2Rad * i * rhumbAngle))); position.y = formConfig.getStartPosition().y + (radius * (float)Math.Sin(i) / (float)Math.Cosh(Mathf.Rad2Deg * (Mathf.Deg2Rad * i * rhumbAngle))); position.z = formConfig.getStartPosition().z + (radius * (float)Math.Tanh(Mathf.Rad2Deg * (Mathf.Deg2Rad * i * rhumbAngle))); formBounds.calculateNewBounds(position); //Stack Shape IStack stack = new SimpleStack(); //default if (formConfig.getStackShape() == IFormConfiguration.StackShape.Sphere) { //spehere stack = new SimpleStack(); } else if (formConfig.getStackShape() == IFormConfiguration.StackShape.Box) { //box stack = new SimpleBoxStack(); } else if (formConfig.getStackShape() == IFormConfiguration.StackShape.Complex1) { //complex 1 stack = new ComplexStack(); } else if (formConfig.getStackShape() == IFormConfiguration.StackShape.Complex2) { //complex 2 stack = new ComplexStack2(); } else if (formConfig.getStackShape() == IFormConfiguration.StackShape.SimpleTorus) { //simple Torus stack = new SimpleTorusStack(); } //colour stuff order is important Color stackColour = modelColour; if (colourConfig.getFadeColour()) { //fade colour in stackColour = ColourUtility.fadeModelColour(modelColour, iterations, i); } if (colourConfig.getPulse()) { //do pulse stackColour = colourConfig.getPulseColourForStack(stackColour, i); } stack.initialise(position, stackTwist, 0.5f, stackColour); stacks.Add(stack); stackTwist = GeometryUtility.addDeltaToRotation(stackTwist, formConfig.getStackTwistDelta()); } }
public void mutateTrunk(List<Branch> branches, FormBounds formBounds, IFormConfiguration formConfig, ColourConfiguration colourConfig) { Vector3 branchStartPosition = formConfig.getStartPosition(); Vector3 branchStartTwist = formConfig.getStartRotation(); Vector3 branchStartOrigin = formConfig.getStartPosition(); int i = 0; foreach (Branch branch in branches) { formBounds.calculateNewBounds(branchStartPosition); branch.mutate(i, formConfig, colourConfig, branchStartPosition, branchStartTwist, branchStartOrigin, formBounds); branchStartPosition.x += formConfig.getTrunkPositionDelta().x; branchStartPosition.y += formConfig.getTrunkPositionDelta().y; branchStartPosition.z += formConfig.getTrunkPositionDelta().z; branchStartTwist.x += formConfig.getTrunkRotationDelta().x; branchStartTwist.y += formConfig.getTrunkRotationDelta().y; branchStartTwist.z += formConfig.getTrunkRotationDelta().z; i++; } }
public void mutateBranch(List<IStack> stacks, int offset, IFormConfiguration formConfig, ColourConfiguration colourConfig, Vector3 branchStartPosition, Vector3 branchStartTwist, Vector3 origin, FormBounds formBounds) { float scale = formConfig.getStartScale(); Vector3 stackTwist = formConfig.getStackStartTwist(); Vector3 position = branchStartPosition; Vector3 twist = branchStartTwist; //rotate position araound previous branch start position position = GeometryUtility.rotateCoordinateAboutPoint(origin, position, branchStartTwist); //colour stuff int iterations = formConfig.getStackIterations(); Color modelColour = new Color (colourConfig.getBaseRed(), colourConfig.getBaseGreen(), colourConfig.getBaseBlue(), 1); //if cycling override base colour if (colourConfig.getCycle ()) { modelColour = colourConfig.getCycleColour(); } int i = 0; foreach (IStack stack in stacks) { formBounds.calculateNewBounds(position); //colour stuff order is important Color stackColour = modelColour; if (colourConfig.getFadeColour()) { //fade colour in stackColour = ColourUtility.fadeModelColour(modelColour, iterations, i); } if (colourConfig.getPulse()) { //do pulse stackColour = colourConfig.getPulseColourForStack(stackColour, i); } stack.mutateTo(position, stackTwist, scale, stackColour); scale = scale * formConfig.getScaleDelta(); float positionScale = scale; if (!formConfig.getScaleBranch()) { //ignore scale positionScale = 1; } Vector3 newPosition = GeometryUtility.addDeltaToPosition(position, formConfig.getBranchPositionDelta(), positionScale); position = GeometryUtility.rotateCoordinateAboutPoint(position, newPosition, twist); twist = GeometryUtility.addDeltaToRotation(twist, formConfig.getBranchTwistDelta()); stackTwist = GeometryUtility.addDeltaToRotation(stackTwist, formConfig.getStackTwistDelta()); i++; } }
public void createBranch(List<IStack> stacks, int offset, IFormConfiguration formConfig, ColourConfiguration colourConfig, Vector3 branchStartPosition, Vector3 branchStartTwist, Vector3 origin, FormBounds formBounds) { float scale = formConfig.getStartScale(); Vector3 stackTwist = formConfig.getStackStartTwist(); Vector3 position = branchStartPosition; Vector3 twist = branchStartTwist; //rotate position araound previous branch start position position = GeometryUtility.rotateCoordinateAboutPoint(origin, position, branchStartTwist); //colour stuff int iterations = formConfig.getStackIterations(); Color modelColour = new Color (colourConfig.getBaseRed(), colourConfig.getBaseGreen(), colourConfig.getBaseBlue(), 1); //if cycling override base colour if (colourConfig.getCycle ()) { modelColour = colourConfig.getCycleColour(); } for (int i = 0; i < iterations; i++) { formBounds.calculateNewBounds(position); //Stack Shape IStack stack = new SimpleStack(); //default if (formConfig.getStackShape() == IFormConfiguration.StackShape.Sphere) { //spehere stack = new SimpleStack(); } else if (formConfig.getStackShape() == IFormConfiguration.StackShape.Box) { //box stack = new SimpleBoxStack(); } else if (formConfig.getStackShape() == IFormConfiguration.StackShape.Complex1) { //complex 1 stack = new ComplexStack(); } else if (formConfig.getStackShape() == IFormConfiguration.StackShape.Complex2) { //complex 2 stack = new ComplexStack2(); } else if (formConfig.getStackShape() == IFormConfiguration.StackShape.SimpleTorus) { //simple Torus stack = new SimpleTorusStack(); } //colour stuff order is important Color stackColour = modelColour; if (colourConfig.getFadeColour()) { //fade colour in stackColour = ColourUtility.fadeModelColour(modelColour, iterations, i); } if (colourConfig.getPulse()) { //do pulse stackColour = colourConfig.getPulseColourForStack(stackColour, i); } stack.initialise(position, stackTwist, scale, stackColour); stacks.Add(stack); scale = scale * formConfig.getScaleDelta(); Vector3 newPosition = GeometryUtility.addDeltaToPosition(position, formConfig.getBranchPositionDelta(), scale); position = GeometryUtility.rotateCoordinateAboutPoint(position, newPosition, twist); twist = GeometryUtility.addDeltaToRotation(twist, formConfig.getBranchTwistDelta()); stackTwist = GeometryUtility.addDeltaToRotation(stackTwist, formConfig.getStackTwistDelta()); } }
public static void loadConfiguration(IFormConfiguration formConfiguration) { string fileSavePath = Application.persistentDataPath + "/FormConfigSlot" + (formConfiguration.getIndex() + 1) + ".xml"; Debug.Log("Load:" + fileSavePath); XmlDocument xmlDoc = new XmlDocument(); if (System.IO.File.Exists(fileSavePath)) { xmlDoc.Load(new XmlTextReader(fileSavePath)); XmlElement root = xmlDoc.DocumentElement; float x = float.Parse(root.GetAttribute("branchPositionDeltaX")); float y = float.Parse(root.GetAttribute("branchPositionDeltaY")); float z = float.Parse(root.GetAttribute("branchPositionDeltaZ")); formConfiguration.setBranchPositionDelta(new Vector3(x, y, z)); x = float.Parse(root.GetAttribute("branchTwistDeltaX")); y = float.Parse(root.GetAttribute("branchTwistDeltaY")); z = float.Parse(root.GetAttribute("branchTwistDeltaZ")); formConfiguration.setBranchTwistDelta(new Vector3(x, y, z)); formConfiguration.setIndex(int.Parse(root.GetAttribute("index"))); formConfiguration.setMutationStrength(float.Parse(root.GetAttribute("mutationStrength"))); formConfiguration.setScaleBranch(bool.Parse(root.GetAttribute("scaleBranch"))); formConfiguration.setScaleDelta(float.Parse(root.GetAttribute("scaleDelta"))); formConfiguration.setScaleTrunk(bool.Parse(root.GetAttribute("scaleTrunk"))); formConfiguration.setStackIterations(int.Parse(root.GetAttribute("stackIterations"))); formConfiguration.setStackShape(int.Parse(root.GetAttribute("stackShapeIndex"))); x = float.Parse(root.GetAttribute("stackStartTwistX")); y = float.Parse(root.GetAttribute("stackStartTwistY")); z = float.Parse(root.GetAttribute("stackStartTwistZ")); formConfiguration.setStackStartTwist(new Vector3(x, y, z)); x = float.Parse(root.GetAttribute("stackTwistDeltaX")); y = float.Parse(root.GetAttribute("stackTwistDeltaY")); z = float.Parse(root.GetAttribute("stackTwistDeltaZ")); formConfiguration.setStackTwistDelta(new Vector3(x, y, z)); x = float.Parse(root.GetAttribute("startPositionX")); y = float.Parse(root.GetAttribute("startPositionY")); z = float.Parse(root.GetAttribute("startPositionZ")); formConfiguration.setStartPosition(new Vector3(x, y, z)); x = float.Parse(root.GetAttribute("startRotationX")); y = float.Parse(root.GetAttribute("startRotationY")); z = float.Parse(root.GetAttribute("startRotationZ")); formConfiguration.setStartRotation(new Vector3(x, y, z)); formConfiguration.setStartScale(float.Parse(root.GetAttribute("startScale"))); formConfiguration.setTrunkIterations(int.Parse(root.GetAttribute("trunkIterations"))); x = float.Parse(root.GetAttribute("trunkPositionDeltaX")); y = float.Parse(root.GetAttribute("trunkPositionDeltaY")); z = float.Parse(root.GetAttribute("trunkPositionDeltaZ")); formConfiguration.setTrunkPositionDelta(new Vector3(x, y, z)); x = float.Parse(root.GetAttribute("trunklRotationDeltaX")); y = float.Parse(root.GetAttribute("trunklRotationDeltaY")); z = float.Parse(root.GetAttribute("trunklRotationDeltaZ")); formConfiguration.setTrunkRotationDelta(new Vector3(x, y, z)); //perfom bounds checks and fix formConfiguration.validateAndFix(); } else { Debug.Log("File Not Found:" + fileSavePath); } }
public void createBranch(List<IStack> stacks, int offset, IFormConfiguration formConfig, ColourConfiguration colourConfig, Vector3 branchStartPosition, Vector3 branchStartTwist, Vector3 origin, FormBounds formBounds) { Vector3 position = origin; Vector3 stackTwist = formConfig.getStackStartTwist(); float radius = formConfig.getBranchPositionDelta ().x * 20; float rhumbAngle = formConfig.getStartRotation().x * 0.032f; //colour stuff int iterations = formConfig.getStackIterations(); Color modelColour = new Color (colourConfig.getBaseRed(), colourConfig.getBaseGreen(), colourConfig.getBaseBlue(), 1); //if cycling override base colour if (colourConfig.getCycle ()) { modelColour = colourConfig.getCycleColour(); } for (int i = offset; i < offset + iterations; i++) { position.x = formConfig.getStartPosition().x + (radius * (float) Math.Cos(i) / (float) Math.Cosh (Mathf.Rad2Deg * (Mathf.Deg2Rad * i * rhumbAngle))); position.y = formConfig.getStartPosition().y + (radius * (float) Math.Sin(i) / (float) Math.Cosh (Mathf.Rad2Deg * (Mathf.Deg2Rad * i * rhumbAngle))); position.z = formConfig.getStartPosition().z + (radius * (float) Math.Tanh(Mathf.Rad2Deg * (Mathf.Deg2Rad * i * rhumbAngle))); formBounds.calculateNewBounds(position); //Stack Shape IStack stack = new SimpleStack(); //default if (formConfig.getStackShape() == IFormConfiguration.StackShape.Sphere) { //spehere stack = new SimpleStack(); } else if (formConfig.getStackShape() == IFormConfiguration.StackShape.Box) { //box stack = new SimpleBoxStack(); } else if (formConfig.getStackShape() == IFormConfiguration.StackShape.Complex1) { //complex 1 stack = new ComplexStack(); } else if (formConfig.getStackShape() == IFormConfiguration.StackShape.Complex2) { //complex 2 stack = new ComplexStack2(); } else if (formConfig.getStackShape() == IFormConfiguration.StackShape.SimpleTorus) { //simple Torus stack = new SimpleTorusStack(); } //colour stuff order is important Color stackColour = modelColour; if (colourConfig.getFadeColour()) { //fade colour in stackColour = ColourUtility.fadeModelColour(modelColour, iterations, i); } if (colourConfig.getPulse()) { //do pulse stackColour = colourConfig.getPulseColourForStack(stackColour, i); } stack.initialise(position, stackTwist, 0.5f, stackColour); stacks.Add(stack); stackTwist = GeometryUtility.addDeltaToRotation(stackTwist, formConfig.getStackTwistDelta()); } }
public void mutateBranch(List <IStack> stacks, int offset, IFormConfiguration formConfig, ColourConfiguration colourConfig, Vector3 branchStartPosition, Vector3 branchStartTwist, Vector3 origin, FormBounds formBounds) { float scale = formConfig.getStartScale(); Vector3 stackTwist = formConfig.getStackStartTwist(); Vector3 position = branchStartPosition; Vector3 twist = branchStartTwist; //rotate position araound previous branch start position position = GeometryUtility.rotateCoordinateAboutPoint(origin, position, branchStartTwist); //colour stuff int iterations = formConfig.getStackIterations(); Color modelColour = new Color(colourConfig.getBaseRed(), colourConfig.getBaseGreen(), colourConfig.getBaseBlue(), 1); //if cycling override base colour if (colourConfig.getCycle()) { modelColour = colourConfig.getCycleColour(); } int i = 0; foreach (IStack stack in stacks) { formBounds.calculateNewBounds(position); //colour stuff order is important Color stackColour = modelColour; if (colourConfig.getFadeColour()) { //fade colour in stackColour = ColourUtility.fadeModelColour(modelColour, iterations, i); } if (colourConfig.getPulse()) { //do pulse stackColour = colourConfig.getPulseColourForStack(stackColour, i); } stack.mutateTo(position, stackTwist, scale, stackColour); scale = scale * formConfig.getScaleDelta(); float positionScale = scale; if (!formConfig.getScaleBranch()) { //ignore scale positionScale = 1; } Vector3 newPosition = GeometryUtility.addDeltaToPosition(position, formConfig.getBranchPositionDelta(), positionScale); position = GeometryUtility.rotateCoordinateAboutPoint(position, newPosition, twist); twist = GeometryUtility.addDeltaToRotation(twist, formConfig.getBranchTwistDelta()); stackTwist = GeometryUtility.addDeltaToRotation(stackTwist, formConfig.getStackTwistDelta()); i++; } }
public void mutateBranch(List<IStack> stacks, int offset, IFormConfiguration formConfig, ColourConfiguration colourConfig, Vector3 branchStartPosition, Vector3 branchStartTwist, Vector3 origin, FormBounds formBounds) { Vector3 position = origin; Vector3 stackTwist = formConfig.getStackStartTwist(); float radius = formConfig.getBranchPositionDelta ().x * 20; float rhumbAngle = formConfig.getStartRotation().x * 0.032f; //colour stuff int iterations = formConfig.getStackIterations(); Color modelColour = new Color (colourConfig.getBaseRed(), colourConfig.getBaseGreen(), colourConfig.getBaseBlue(), 1); //if cycling override base colour if (colourConfig.getCycle ()) { modelColour = colourConfig.getCycleColour(); } int i = offset; foreach (IStack stack in stacks) { position.x = formConfig.getStartPosition().x + (radius * (float) Math.Cos(i) / (float) Math.Cosh (Mathf.Rad2Deg * (Mathf.Deg2Rad * i * rhumbAngle))); position.y = formConfig.getStartPosition().y + (radius * (float) Math.Sin(i) / (float) Math.Cosh (Mathf.Rad2Deg * (Mathf.Deg2Rad * i * rhumbAngle))); position.z = formConfig.getStartPosition().z + (radius * (float) Math.Tanh(Mathf.Rad2Deg * (Mathf.Deg2Rad * i * rhumbAngle))); formBounds.calculateNewBounds(position); //colour stuff order is important Color stackColour = modelColour; if (colourConfig.getFadeColour()) { //fade colour in stackColour = ColourUtility.fadeModelColour(modelColour, iterations, i - offset); } if (colourConfig.getPulse()) { //do pulse stackColour = colourConfig.getPulseColourForStack(stackColour, i - offset); } stack.mutateTo(position, stackTwist, 0.5f, stackColour); stackTwist = GeometryUtility.addDeltaToRotation(stackTwist, formConfig.getStackTwistDelta()); i++; } }
public void mutateBranch(List <IStack> stacks, int offset, IFormConfiguration formConfig, ColourConfiguration colourConfig, Vector3 branchStartPosition, Vector3 branchStartTwist, Vector3 origin, FormBounds formBounds) { int iterations = formConfig.getStackIterations(); float scale = formConfig.getStartScale(); for (int o = 0; o < offset; o++) { scale *= formConfig.getScaleDelta(); } //centre of ring Vector3 position = branchStartPosition; //add radius of ring float ringRadius = formConfig.getBranchPositionDelta().x * 10 * scale; //first element of ring on radius float zAngle = branchStartTwist.z * Mathf.Deg2Rad; float yAngle = branchStartTwist.y * Mathf.Deg2Rad; float ringSegmentAngle = 360 / iterations * Mathf.Deg2Rad; Vector3 stackTwist = formConfig.getStackStartTwist(); //colour stuff Color modelColour = new Color(colourConfig.getBaseRed(), colourConfig.getBaseGreen(), colourConfig.getBaseBlue(), 1); //if cycling override base colour if (colourConfig.getCycle()) { modelColour = colourConfig.getCycleColour(); } int i = 0; foreach (IStack stack in stacks) { position.x = (ringRadius * Mathf.Cos(zAngle) * Mathf.Sin(yAngle)) + branchStartPosition.x; position.y = (ringRadius * Mathf.Sin(zAngle) * Mathf.Sin(yAngle)) + branchStartPosition.y; position.z = (ringRadius * Mathf.Cos(yAngle)) + branchStartPosition.z; formBounds.calculateNewBounds(position); //colour stuff order is important Color stackColour = modelColour; if (colourConfig.getFadeColour()) { //fade colour in stackColour = ColourUtility.fadeModelColour(modelColour, iterations, i); } if (colourConfig.getPulse()) { //do pulse stackColour = colourConfig.getPulseColourForStack(stackColour, i); } stack.mutateTo(position, stackTwist, 0.5f * scale, stackColour); yAngle += ringSegmentAngle; yAngle += ringSegmentAngle; stackTwist = GeometryUtility.addDeltaToRotation(stackTwist, formConfig.getStackTwistDelta()); i++; } }
public void changeSelectedFormConfig(int index) { currentConfig = allConfigs [index]; }
// Update is called once per frame void Update() { /* Check for key input */ if (Input.GetKey("1")) { //config 1 currentConfig = allConfigs[0]; } if (Input.GetKey("2")) { //config 2 currentConfig = allConfigs[1]; } if (Input.GetKey("3")) { //config 3 currentConfig = allConfigs[2]; } if (Input.GetKey("4")) { //config 4 currentConfig = allConfigs[3]; } if (Input.GetKey("5")) { //config 5 currentConfig = allConfigs[4]; } if (Input.GetKey("6")) { //config 6 currentConfig = allConfigs[5]; } if (Input.GetKey("7")) { //config 7 currentConfig = allConfigs[6]; } if (Input.GetKey("8")) { //config 8 currentConfig = allConfigs[7]; } if (Input.GetKey("9")) { //config 9 currentConfig = allConfigs[8]; } if (Input.GetKey("n")) { //new form createNewBrush(); return; } if (Input.GetKey ("b")) { //clear brush clearBrush(); } if (Input.GetKey("s")) { //save current form to scene saveForm(); return; } if (Input.GetKey("c")) { //clear scene clearScene(); return; } if (!keyDelayOn) { if (Input.GetKey("v")) { //branch scaling currentConfig.setScaleBranch(!currentConfig.getScaleBranch()); //switch on key delay to stop retrigger switchOnKeyDelay(); } } if (Input.GetKey ("r")) { //symetrical random mutation currentConfig.randomiseValuesWithSymetry(); } if (Input.GetKey ("t")) { //non symetrical random mutation currentConfig.randomiseValuesWithoutSymetry(); } if (!keyDelayOn) { if (Input.GetKey ("p")) { //toggle colour palette displayColourPalette = !displayColourPalette; if (displayColourPalette) { displayHelp = false; } //switch on key delay to stop retrigger switchOnKeyDelay(); } } if (!keyDelayOn) { if (Input.GetKey ("f")) { //toggle builder palette displayFormBuilderPalette = !displayFormBuilderPalette; if (displayFormBuilderPalette) { displayHelp = false; } //switch on key delay to stop retrigger switchOnKeyDelay(); } } if (!keyDelayOn) { if (Input.GetKey("j")) { autoPreset = !autoPreset; if (autoPreset) { int random = Random.Range(0, 9); currentConfig = allConfigs[random]; autoMutate1 = false; autoMutate2 = false; autoChangeCount = 0; } switchOnKeyDelay(); } } if (!keyDelayOn) { if (Input.GetKey("k")) { autoMutate1 = !autoMutate1; if (autoMutate1) { currentConfig.randomiseValuesWithSymetry(); autoPreset = false; autoMutate2 = false; autoChangeCount = 0; } switchOnKeyDelay(); } } if (!keyDelayOn) { if (Input.GetKey("l")) { autoMutate2 = !autoMutate2; if (autoMutate2) { currentConfig.randomiseValuesWithoutSymetry(); autoPreset = false; autoMutate1 = false; autoChangeCount = 0; } switchOnKeyDelay(); } } //help key if (!keyDelayOn) { if (Input.GetKey("h")) { displayHelp = !displayHelp; if (displayHelp) { //switch off any other open forms displayColourPalette = false; displayFormBuilderPalette = false; } switchOnKeyDelay(); } } /* key delay timer */ if (keyDelayOn) { if (keyDelayCount < keyDelayLength) { keyDelayCount++; } else { //finished delay keyDelayOn = false; } } /* Automated Stuff */ //random go through presets if (autoPreset) { if (autoChangeCount < 15) { autoChangeCount += Time.deltaTime; } else { autoChangeCount = 0; int random = Random.Range(0, 9); currentConfig = allConfigs[random]; } } //auto mutate1 if (autoMutate1) { if (autoChangeCount < 35) { autoChangeCount += Time.deltaTime; } else { autoChangeCount = 0; currentConfig.randomiseValuesWithSymetry(); } } //auto mutate 2 if (autoMutate2) { if (autoChangeCount < 25) { autoChangeCount += Time.deltaTime; } else { autoChangeCount = 0; currentConfig.randomiseValuesWithoutSymetry(); } } //default renderScene (); }
public void mutateBranch(List<IStack> stacks, int offset, IFormConfiguration formConfig, ColourConfiguration colourConfig, Vector3 branchStartPosition, Vector3 branchStartTwist, Vector3 origin, FormBounds formBounds) { int iterations = formConfig.getStackIterations(); float scale = formConfig.getStartScale(); for (int o = 0; o < offset; o++) { scale *= formConfig.getScaleDelta(); } //centre of ring Vector3 position = branchStartPosition; //add radius of ring float ringRadius = formConfig.getBranchPositionDelta().x * 10 * scale; //first element of ring on radius float zAngle = branchStartTwist.z * Mathf.Deg2Rad; float yAngle = branchStartTwist.y * Mathf.Deg2Rad; float ringSegmentAngle = 360 / iterations * Mathf.Deg2Rad; Vector3 stackTwist = formConfig.getStackStartTwist(); //colour stuff Color modelColour = new Color (colourConfig.getBaseRed(), colourConfig.getBaseGreen(), colourConfig.getBaseBlue(), 1); //if cycling override base colour if (colourConfig.getCycle ()) { modelColour = colourConfig.getCycleColour(); } int i = 0; foreach (IStack stack in stacks) { position.x = (ringRadius * Mathf.Cos(zAngle) * Mathf.Sin(yAngle)) + branchStartPosition.x; position.y = (ringRadius * Mathf.Sin(zAngle) * Mathf.Sin(yAngle)) + branchStartPosition.y; position.z = (ringRadius * Mathf.Cos(yAngle)) + branchStartPosition.z; formBounds.calculateNewBounds(position); //colour stuff order is important Color stackColour = modelColour; if (colourConfig.getFadeColour()) { //fade colour in stackColour = ColourUtility.fadeModelColour(modelColour, iterations, i); } if (colourConfig.getPulse()) { //do pulse stackColour = colourConfig.getPulseColourForStack(stackColour, i); } stack.mutateTo(position, stackTwist, 0.5f * scale, stackColour); yAngle += ringSegmentAngle; yAngle += ringSegmentAngle; stackTwist = GeometryUtility.addDeltaToRotation(stackTwist, formConfig.getStackTwistDelta()); i++; } }
// private bool waitForJuliaSetToRender = false; // Use this for initialization void Start() { IFormConfiguration formConfig1 = new FormConfig1 (); IFormConfiguration formConfig2 = new FormConfig2 (); IFormConfiguration formConfig3 = new FormConfig3 (); IFormConfiguration formConfig4 = new FormConfig4 (); IFormConfiguration formConfig5 = new FormConfig5 (); IFormConfiguration formConfig6 = new FormConfig6 (); IFormConfiguration formConfig7 = new FormConfig7 (); IFormConfiguration formConfig8 = new FormConfig8 (); IFormConfiguration formConfig9 = new FormConfig9 (); allConfigs.Add (formConfig1); allConfigs.Add (formConfig2); allConfigs.Add (formConfig3); allConfigs.Add (formConfig4); allConfigs.Add (formConfig5); allConfigs.Add (formConfig6); allConfigs.Add (formConfig7); allConfigs.Add (formConfig8); allConfigs.Add (formConfig9); currentConfig = formConfig1; dawnMaterial = Resources.Load("DawnDusk Skybox") as Material; eerieMaterial = Resources.Load("Eerie Skybox") as Material; nightMaterial = Resources.Load("StarryNight Skybox") as Material; mainCamera = Camera.main; mainCamera.clearFlags = CameraClearFlags.Skybox; RenderSettings.skybox = dawnMaterial; backgroundCamera = GameObject.Find ("Background Camera").GetComponent<Camera>(); backgroundCamera.enabled = false; formBuilderPalette = new FormBuilderPalette (this); colourPalette = new ColourPalette (this); helpPalette = new HelpPalette (); //initialiase with something createNewBrush(); //slot 1 //make it colourful colourConfig.setCycle (true); colourConfig.setPulse (true); colourConfig.setFadeColour (true); autoPreset = true; autoMutate1 = true; }
public void createBranch(List<IStack> stacks, int offset, IFormConfiguration formConfig, ColourConfiguration colourConfig, Vector3 branchStartPosition, Vector3 branchStartTwist, Vector3 origin, FormBounds formBounds) { int iterations = formConfig.getStackIterations(); float scale = formConfig.getStartScale(); for (int o = 0; o < offset; o++) { scale *= formConfig.getScaleDelta(); } //centre of ring Vector3 position = branchStartPosition; //add radius of ring float ringRadius = formConfig.getBranchPositionDelta().x * 10 * scale; //angle to calculate ring float zAngle = branchStartTwist.z * Mathf.Deg2Rad; float yAngle = branchStartTwist.y * Mathf.Deg2Rad; float ringSegmentAngle = 360 / iterations * Mathf.Deg2Rad; Vector3 stackTwist = formConfig.getStackStartTwist(); //colour stuff Color modelColour = new Color (colourConfig.getBaseRed(), colourConfig.getBaseGreen(), colourConfig.getBaseBlue(), 1); //if cycling override base colour if (colourConfig.getCycle ()) { modelColour = colourConfig.getCycleColour(); } for (int i = offset; i < offset + iterations; i++) { position.x = (ringRadius * Mathf.Cos(zAngle) * Mathf.Sin(yAngle)) + branchStartPosition.x; position.y = (ringRadius * Mathf.Sin(zAngle) * Mathf.Sin(yAngle)) + branchStartPosition.y; position.z = (ringRadius * Mathf.Cos(yAngle)) + branchStartPosition.z; formBounds.calculateNewBounds(position); //Stack Shape IStack stack = new SimpleStack(); //default if (formConfig.getStackShape() == IFormConfiguration.StackShape.Sphere) { //spehere stack = new SimpleStack(); } else if (formConfig.getStackShape() == IFormConfiguration.StackShape.Box) { //box stack = new SimpleBoxStack(); } else if (formConfig.getStackShape() == IFormConfiguration.StackShape.Complex1) { //complex 1 stack = new ComplexStack(); } else if (formConfig.getStackShape() == IFormConfiguration.StackShape.Complex2) { //complex 2 stack = new ComplexStack2(); } else if (formConfig.getStackShape() == IFormConfiguration.StackShape.SimpleTorus) { //simple Torus stack = new SimpleTorusStack(); } //colour stuff order is important Color stackColour = modelColour; if (colourConfig.getFadeColour()) { //fade colour in stackColour = ColourUtility.fadeModelColour(modelColour, iterations, i); } if (colourConfig.getPulse()) { //do pulse stackColour = colourConfig.getPulseColourForStack(stackColour, i); } stack.initialise(position, stackTwist, 0.5f * scale, stackColour); stacks.Add(stack); yAngle += ringSegmentAngle; stackTwist = GeometryUtility.addDeltaToRotation(stackTwist, formConfig.getStackTwistDelta()); } }
public void createTrunk(List<Branch> branches, FormBounds formBounds, IFormConfiguration formConfig, ColourConfiguration colourConfig) { Vector3 branchStartPosition = formConfig.getStartPosition(); Vector3 branchStartTwist = formConfig.getStartRotation(); Vector3 branchStartOrigin = formConfig.getStartPosition(); for (int i = 0; i < formConfig.getTrunkIterations(); i++) { formBounds.calculateNewBounds(branchStartPosition); Branch branch = new Branch (i, formConfig, colourConfig, branchStartPosition, branchStartTwist, branchStartOrigin, formBounds); branches.Add(branch); branchStartPosition.x += formConfig.getTrunkPositionDelta().x; branchStartPosition.y += formConfig.getTrunkPositionDelta().y; branchStartPosition.z += formConfig.getTrunkPositionDelta().z; branchStartTwist.x += formConfig.getTrunkRotationDelta().x; branchStartTwist.y += formConfig.getTrunkRotationDelta().y; branchStartTwist.z += formConfig.getTrunkRotationDelta().z; } }