private void Init() { this.InitialiseLists(); if (this.initialised) { return; } CameraPathControlPoint cameraPathControlPoint = base.get_gameObject().AddComponent <CameraPathControlPoint>(); CameraPathControlPoint cameraPathControlPoint2 = base.get_gameObject().AddComponent <CameraPathControlPoint>(); CameraPathControlPoint cameraPathControlPoint3 = base.get_gameObject().AddComponent <CameraPathControlPoint>(); CameraPathControlPoint cameraPathControlPoint4 = base.get_gameObject().AddComponent <CameraPathControlPoint>(); cameraPathControlPoint.set_hideFlags(2); cameraPathControlPoint2.set_hideFlags(2); cameraPathControlPoint3.set_hideFlags(2); cameraPathControlPoint4.set_hideFlags(2); cameraPathControlPoint.localPosition = new Vector3(-20f, 0f, -20f); cameraPathControlPoint2.localPosition = new Vector3(20f, 0f, -20f); cameraPathControlPoint3.localPosition = new Vector3(20f, 0f, 20f); cameraPathControlPoint4.localPosition = new Vector3(-20f, 0f, 20f); cameraPathControlPoint.forwardControlPoint = new Vector3(0f, 0f, -20f); cameraPathControlPoint2.forwardControlPoint = new Vector3(40f, 0f, -20f); cameraPathControlPoint3.forwardControlPoint = new Vector3(0f, 0f, 20f); cameraPathControlPoint4.forwardControlPoint = new Vector3(-40f, 0f, 20f); this.AddPoint(cameraPathControlPoint); this.AddPoint(cameraPathControlPoint2); this.AddPoint(cameraPathControlPoint3); this.AddPoint(cameraPathControlPoint4); this.initialised = true; }
public CameraPathControlPoint InsertPoint(int index) { CameraPathControlPoint cameraPathControlPoint = base.get_gameObject().AddComponent <CameraPathControlPoint>(); cameraPathControlPoint.set_hideFlags(2); this._points.Insert(index, cameraPathControlPoint); this.RecalculateStoredValues(); this.PathPointAddedEvent(cameraPathControlPoint); return(cameraPathControlPoint); }
public CameraPathControlPoint AddPoint(Vector3 position) { CameraPathControlPoint cameraPathControlPoint = base.get_gameObject().AddComponent <CameraPathControlPoint>(); cameraPathControlPoint.set_hideFlags(2); cameraPathControlPoint.localPosition = position; this._points.Add(cameraPathControlPoint); if (this._addOrientationsWithPoints) { this.orientationList.AddOrientation(cameraPathControlPoint); } this.RecalculateStoredValues(); this.PathPointAddedEvent(cameraPathControlPoint); return(cameraPathControlPoint); }
public void RecalculateStoredValues() { if (!this._normalised) { this._storedTotalArcLength = 0f; this._storedArcLengths = new float[0]; this._storedArcLengthsFull = new float[0]; this._storedPoints = new Vector3[0]; this._normalisedPercentages = new float[0]; this._storedPathDirections = new Vector3[0]; return; } if (this.autoSetStoedPointRes && this._storedTotalArcLength > 0f) { this._storedPointResolution = this._storedTotalArcLength / 1000f; } for (int i = 0; i < this.realNumberOfPoints; i++) { CameraPathControlPoint cameraPathControlPoint = this._points.get_Item(i); cameraPathControlPoint.percentage = this.GetPathPercentage(i); cameraPathControlPoint.normalisedPercentage = this.CalculateNormalisedPercentage(this._points.get_Item(i).percentage); cameraPathControlPoint.givenName = "Point " + i; cameraPathControlPoint.fullName = base.get_name() + " Point " + i; cameraPathControlPoint.index = i; cameraPathControlPoint.set_hideFlags(2); } if (this._points.get_Count() < 2) { return; } this._storedTotalArcLength = 0f; for (int j = 0; j < this.numberOfCurves; j++) { CameraPathControlPoint point = this.GetPoint(j); CameraPathControlPoint point2 = this.GetPoint(j + 1); float num = 0f; num += Vector3.Distance(point.worldPosition, point.forwardControlPointWorld); num += Vector3.Distance(point.forwardControlPointWorld, point2.backwardControlPointWorld); num += Vector3.Distance(point2.backwardControlPointWorld, point2.worldPosition); this._storedTotalArcLength += num; } this._storedValueArraySize = Mathf.Max(Mathf.RoundToInt(this._storedTotalArcLength / this._storedPointResolution), 1); float num2 = 1f / (float)(this._storedValueArraySize * 10); float num3 = 0f; float num4 = this._storedTotalArcLength / (float)(this._storedValueArraySize - 1); List <Vector3> list = new List <Vector3>(); List <Vector3> list2 = new List <Vector3>(); List <float> list3 = new List <float>(); List <float> list4 = new List <float>(); List <float> list5 = new List <float>(); float num5 = 0f; float num6 = num4; float num7 = 0f; Vector3 vector = this.GetPathPosition(0f, true); list.Add(vector); list2.Add((this.GetPathPosition(num2, true) - vector).get_normalized()); list3.Add(0f); while (num3 < 1f) { Vector3 pathPosition = this.GetPathPosition(num3, true); float num8 = Vector3.Distance(vector, pathPosition); if (num5 + num8 >= num6) { float num9 = Mathf.Clamp01((num6 - num5) / num8); float num10 = Mathf.Lerp(num3, num3 + num2, num9); list3.Add(num10); list.Add(pathPosition); float percentage = Mathf.Clamp(num3 - this._directionWidth, 0f, 1f); Vector3 pathPosition2 = this.GetPathPosition(percentage, true); float percentage2 = Mathf.Clamp(num3 + this._directionWidth, 0f, 1f); Vector3 pathPosition3 = this.GetPathPosition(percentage2, true); Vector3 normalized = (vector - pathPosition2 + (pathPosition3 - vector)).get_normalized(); list2.Add(normalized); list4.Add(num5); list5.Add(num7); num5 = num6; num6 += num4; } num5 += num8; num7 += num8; vector = pathPosition; num3 += num2; } list3.Add(1f); list.Add(this.GetPathPosition(1f, true)); Vector3 pathPosition4 = this.GetPathPosition(1f, true); Vector3 pathPosition5 = this.GetPathPosition(1f - num2, true); Vector3 normalized2 = (pathPosition4 - pathPosition5).get_normalized(); list2.Add(normalized2); this._storedValueArraySize = list3.get_Count(); this._normalisedPercentages = list3.ToArray(); this._storedTotalArcLength = num7; this._storedPoints = list.ToArray(); this._storedPathDirections = list2.ToArray(); this._storedArcLengths = list4.ToArray(); this._storedArcLengthsFull = list5.ToArray(); if (this.RecalculateCurvesEvent != null) { this.RecalculateCurvesEvent(); } }