private void Calculate() { if (keyframes.Count == 0 || timeline.Count == 0) { return; } current_interp_index = InterpolatorsComboBox.SelectedIndex; Interpolator2D interpolator = (Interpolator2D)InterpolatorsComboBox.SelectedItem; trajectory.Clear(); SaveButton.Enabled = false; foreach (float timestamp in timeline) { trajectory.Add(interpolator.Calculate(timestamp, keyframes)); } if (trajectory.Count > 0) { Logger.Write("Calculated"); SaveButton.Enabled = true; } }
void Start() { if (myRend == null) { Debug.LogError(this + " material not assigned!"); } if (myLight == null) { Debug.LogError(this + " light not assigned!"); } if (glowDuration < 0) { Debug.LogError(this + " glowDuration not assigned correctly!"); } if (manager == null) { Debug.LogError(this + " manager not assigned correctly!"); } if ((manager == this) && (allRocks.Length <= 0)) { Debug.LogError(this + " is the manager, but allRocks array not assigned correctly!"); } if (intelligentSphere == null) { Debug.LogError(this + " intelligentSphere not assigned correctly!"); } if (glowTriggerSound == null) { Debug.LogError("glowTriggerSound not assigned correctly!"); } interp_emis = new Interpolator2D(); interp_light = new Interpolator2D(); interp_emerge = new Interpolator2D(); interp_emergeSfx = new Interpolator2D(); myRend.material.EnableKeyword("_EmissionColor"); // all glowrocks start tiny and fully turned off other than manager originalScale = transform.localScale; Vector3 verySmall = new Vector3(0.00001f, 0.00001f, 0.00001f); transform.localScale = verySmall; TurnStuffOnOff(false); if (manager != this) { gameObject.SetActive(false); } }
public AppForm() { InitializeComponent(); Logger.log = this.Log; Interpolator2D.LoadPlugins(); SaveButton.Enabled = false; OpenDataDialog.InitialDirectory = System.AppDomain.CurrentDomain.BaseDirectory; SaveDataDialog.InitialDirectory = System.AppDomain.CurrentDomain.BaseDirectory; }
// Use this for initialization void Start() { rend = GetComponent <Renderer>(); if (rend == null) { Debug.LogError("Object has no renderer!"); } interp = new Interpolator2D(); // start fade in - TODO this is a 1d vector but i don't have Interpolar1D yet interp.Initialize(new Vector2(1f, 0f), new Vector2(0f, 0f), fadeInTime); fadingIn = true; }
public AppForm() { InitializeComponent(); Interpolator2D.LoadPlugins(); foreach (Interpolator2D interp in Interpolator2D.interpolators) { AddInterpolator(interp); } SaveButton.Enabled = false; OpenDataDialog.InitialDirectory = System.AppDomain.CurrentDomain.BaseDirectory; SaveDataDialog.InitialDirectory = System.AppDomain.CurrentDomain.BaseDirectory; }
private void AddInterpolator(Interpolator2D interpolator) { InterpolatorsComboBox.Items.Add(interpolator); InterpolatorsComboBox.SelectedIndex = 0; }
public static Interpolator2D CreateInterpolator2D(this STFReader stf, bool tab) { List <double> xlist = new List <double>(); List <Interpolator> ilist = new List <Interpolator>(); bool errorFound = false; if (tab) { stf.MustMatchBlockStart(); int numOfRows = stf.ReadInt(0); if (numOfRows < 2) { STFException.TraceWarning(stf, "Interpolator must have at least two rows."); errorFound = true; } int numOfColumns = stf.ReadInt(0); string header = stf.ReadString().ToLower(); if (header == "throttle") { stf.MustMatchBlockStart(); int numOfThrottleValues = 0; while (!stf.EndOfBlock()) { xlist.Add(stf.ReadFloat(STFReader.Units.None, 0f)); ilist.Add(new Interpolator(numOfRows)); numOfThrottleValues++; } if (numOfThrottleValues != (numOfColumns - 1)) { STFException.TraceWarning(stf, "Interpolator throttle vs. num of columns mismatch."); errorFound = true; } if (numOfColumns < 3) { STFException.TraceWarning(stf, "Interpolator must have at least three columns."); errorFound = true; } int numofData = 0; string tableLabel = stf.ReadString().ToLower(); if (tableLabel == "table") { stf.MustMatchBlockStart(); for (int i = 0; i < numOfRows; i++) { float x = stf.ReadFloat(STFReader.Units.SpeedDefaultMPH, 0); numofData++; for (int j = 0; j < numOfColumns - 1; j++) { if (j >= ilist.Count) { STFException.TraceWarning(stf, "Interpolator throttle vs. num of columns mismatch. (missing some throttle values)"); errorFound = true; } ilist[j][x] = stf.ReadFloat(STFReader.Units.Force, 0); numofData++; } } stf.SkipRestOfBlock(); } else { STFException.TraceWarning(stf, "Interpolator didn't find a table to load."); errorFound = true; } //check the table for inconsistencies foreach (Interpolator checkMe in ilist) { if (checkMe.Size != numOfRows) { STFException.TraceWarning(stf, "Interpolator has found a mismatch between num of rows declared and num of rows given."); errorFound = true; } double dx = (checkMe.MaxX() - checkMe.MinX()) * 0.1f; if (dx <= 0f) { STFException.TraceWarning(stf, "Interpolator has found X data error - x values must be increasing. (Possible row number mismatch)"); errorFound = true; } else { for (double x = checkMe.MinX(); x <= checkMe.MaxX(); x += dx) { if (double.IsNaN(checkMe[x])) { STFException.TraceWarning(stf, "Interpolator has found X data error - x values must be increasing. (Possible row number mismatch)"); errorFound = true; break; } } } } if (numofData != (numOfRows * numOfColumns)) { STFException.TraceWarning(stf, "Interpolator has found a mismatch: num of data doesn't fit the header information."); errorFound = true; } } else { STFException.TraceWarning(stf, "Interpolator must have a 'throttle' header row."); errorFound = true; } stf.SkipRestOfBlock(); } else { stf.MustMatchBlockStart(); while (!stf.EndOfBlock()) { xlist.Add(stf.ReadFloat(STFReader.Units.Any, null)); ilist.Add(stf.CreateInterpolator()); } } int n = xlist.Count; if (n < 2) { STFException.TraceWarning(stf, "Interpolator must have at least two x values."); errorFound = true; } double[] xArray = new double[n]; Interpolator[] yArray = new Interpolator[n]; for (int i = 0; i < n; i++) { xArray[i] = xlist[i]; yArray[i] = ilist[i]; if (i > 0 && xArray[i - 1] >= xArray[i]) { STFException.TraceWarning(stf, "Interpolator x values must be increasing."); } } if (errorFound) { STFException.TraceWarning(stf, "Errors found in the Interpolator definition!!! The Interpolator will not work correctly!"); } Interpolator2D result = new Interpolator2D(xArray, yArray); return(result); }
// Use this for initialization void Start() { interp = new Interpolator2D(); }
// Use this for initialization void Start() { nextStart = Time.time + Random.Range(minWait, maxWait); interp = new Interpolator2D(); }