//Imports a Motion3DSetup structure to populate the GUI fields public void PopulateFields(Motion3DSetup setup) { if (!(initialized)) { Start(); //TODO: we can avoid needing this by changing the render order I think } if (setup.Order == 1) { orderToggle.value = 0; } else { orderToggle.value = 1; } OnOrderSwitch(); expressionXInput.text = setup.ExpressionX; expressionYInput.text = setup.ExpressionY; expressionZInput.text = setup.ExpressionZ; string paramStr = ""; foreach (KeyValuePair <string, double> p in setup.Parameters) { paramStr += p.Key + ","; } if (paramStr.Length > 0) //strip off last comma { paramStr = paramStr.Substring(0, paramStr.Length - 1); } parametersInput.text = paramStr; //Validate all ValidateExpression(1); ValidateExpression(2); ValidateExpression(3); }
// Use this for initialization void Start() { //Instantiate simulated objects list simulatedObjects = new List <Motion3DObject>(); //Hook other GUI elements startStopButtonText = GameObject.Find("StartButton").GetComponentInChildren <Text>(); timeDisplayText = GameObject.Find("TimeInput").GetComponent <InputField>(); timeSlider = GameObject.Find("TimeSlider").GetComponent <TimeSlider>(); //TODO: conflict add //Hook Scene Controller sceneController = gameObject.GetComponent <Motion3DSceneController>(); //Initialize problem setup motion3Dsetup = new Motion3DSetup(DefaultProblem.exprX, DefaultProblem.exprY, DefaultProblem.exprZ, new Dictionary <string, double>(), DefaultProblem.order); //Set default forward solve time forwardSolveTime = Motion3DConstants.forwardSolveTime_default; //Set the object model to copy from objectModel = GameObject.Find("ObjectModel"); objectModel.SetActive(false); //Set valid data interval and reset time. Use internals to avoid bugs with one not being set yet allObjectsDataLowerBound_internal = 0; allObjectsDataUpperBound_internal = 0; resetTime_internal = 0; //Hook vector field vectorField = gameObject.GetComponent <Motion3DVectorField>(); vectorField.DisableVectorField(); }
public void ConfigView_OkButtonPress() { Motion3DSetup setup = configView.GetComponent <Motion3DConfigGui>().exportForSetup(); if (setup != null) { //Accept new problem definition simController.ApplyConfiguration(setup); //code for generating input fields for userdefinedview for (int i = 0; i < instance.Length; i++) { if (instance[i] != null) { Destroy(instance[i].gameObject); } if (instanceText[i] != null) { Destroy(instanceText[i].gameObject); } } string str = configView.transform.Find("ParametersListInput").gameObject.GetComponent <InputField>().text; Regex rgx = new Regex("[a-zA-Z]+"); foreach (Match match in rgx.Matches(str)) { if (match.Success) { if (match.Value == "x" || match.Value == "y" || match.Value == "z") { Debug.Log("error reserved variable used"); } else { Debug.Log(match.Value); instanceText[count] = Instantiate(inputText, new Vector3(0, 0, 0), transform.rotation, userDefinedView.transform); instanceText[count].text = match.Value + " = "; instance[count] = Instantiate(input, new Vector3(0, 0, 0), transform.rotation, userDefinedView.transform); instance[count].name = match.Value; instance[count].GetComponent <InputField>().text = "1"; count++; } } else { Debug.Log("no match found"); } } //end code for generating fields //Close config gui configView.SetActive(false); } }
//Exports user inputs on this form to set up a 3D motion problem public Motion3DSetup exportForSetup() { if (valid[0] && valid[1] && valid[2]) { Motion3DSetup setup = new Motion3DSetup(expressionXInput.text, expressionYInput.text, expressionZInput.text, parameters, order); return(setup); } Motion3DSetup empty = null; return(empty); }
//Applies a new problem configuration (equation set) public void ApplyConfiguration(Motion3DSetup setup) { if (setup != null) { motion3Dsetup = setup; //Apply new equations to each simulated object for (int i = 0; i < simulatedObjects.Count; i++) { ApplyConfigurationToObject(i); } vectorField.F = motion3Dsetup.F; } }
public void ConstructorWithParse1stOrder_CheckX() { Motion3DProblemIOManager sim = new Motion3DProblemIOManager(); sim.Load("rosslerAttractor.3dmotion"); Motion3DSetup ms = new Motion3DSetup( sim.expressionX, sim.expressionY, sim.expressionZ, sim.parameters, sim.order ); Assert.AreEqual(ms.ExpressionX, "-(y+z)"); }
public void ChangeParameterX() { Motion3DProblemIOManager sim = new Motion3DProblemIOManager(); sim.Load("rosslerAttractor.3dmotion"); Motion3DSetup ms = new Motion3DSetup( sim.expressionX, sim.expressionY, sim.expressionZ, sim.parameters, sim.order ); ms.ChangeParameter("expressionX", 3); Assert.AreNotEqual(ms.ExpressionX, 3); }
public void ConstructorWithParse1stOrder() { try { Motion3DProblemIOManager sim = new Motion3DProblemIOManager(); sim.Load("rosslerAttractor.3dmotion"); Motion3DSetup ms = new Motion3DSetup( sim.expressionX, sim.expressionY, sim.expressionZ, sim.parameters, sim.order ); } catch (Exception e) { Debug.LogAssertion(e); Assert.IsTrue(false); } }