Inheritance: IObject, Node
Esempio n. 1
0
        public static Bezier ConstructSmoothSpline(IEnumerable<Vector3> points, bool closed = false)
        {
            var pointsArray = new List<Vector3>(points).ToArray();
            var ctrlPts = new List<ControlPoint>();

            for (int i = 0; i < pointsArray.Length; ++i)
            {
                var pnt = pointsArray[i];

                var lastPnt = LastPoint(pointsArray, i, closed);
                var nextPnt = NextPoint(pointsArray, i, closed);

                var lastToPntOvershoot = (pnt - lastPnt) + pnt;
                var nextToPntOvershoot = (pnt - nextPnt) + pnt;

                var inTangent = Vector3.Lerp(lastPnt, nextToPntOvershoot, 0.5f);
                var outTangent = Vector3.Lerp(nextPnt, lastToPntOvershoot, 0.5f);

                inTangent = Vector3.Lerp(pnt, inTangent, 0.5f);
                outTangent = Vector3.Lerp(pnt, outTangent, 0.5f);

                var cp = new ControlPoint(pnt, inTangent, outTangent);

                ctrlPts.Add(cp);
            }

            if (closed)
                ctrlPts.Add(ctrlPts.First());

            return new Bezier(ctrlPts);
        }
Esempio n. 2
0
 public ControlPoint(ControlPoint o)
 {
     pos = o.pos;
     rot = o.rot;
     time = o.time;
     easeIO = o.easeIO;
 }
Esempio n. 3
0
File: Program.cs Progetto: B0k0/xbmc
        private void Run()
        {
            log4net.Config.BasicConfigurator.Configure();

            Console.Title = "Press 'q' to quit; 'l' to list devices";

            Console.WriteLine("Starting...");

            using (var upnp = new UPnP())
            {
                upnp.Start();

                var cp = new ControlPoint(true);

                cp.DeviceAdded += new ControlPoint.DeviceAddedDelegate(cp_DeviceAdded);
                cp.DeviceRemoved += new ControlPoint.DeviceRemovedDelegate(cp_DeviceRemoved);
                cp.ActionResponse += new ControlPoint.ActionResponseDelegate(cp_ActionResponse);

                upnp.AddControlPoint(cp);

                #region handle keyboard

                for (bool quit = false; !quit; )
                {
                    switch (Console.ReadKey(true).KeyChar)
                    {
                        case 'q':
                            quit = true;

                            break;

                        case 'l':
                            {
                                var devs = cp.Devices;

                                Console.WriteLine("Devices (" + devs.Length + "):");

                                foreach (var d in devs)
                                {
                                    Console.WriteLine("  " + d.FriendlyName);
                                }

                                break;
                            }
                    }
                }

                #endregion

                cp.DeviceAdded -= new ControlPoint.DeviceAddedDelegate(cp_DeviceAdded);
                cp.DeviceRemoved -= new ControlPoint.DeviceRemovedDelegate(cp_DeviceRemoved);

                upnp.Stop();
            }

            Console.WriteLine("Stopped.");
        }
Esempio n. 4
0
			public static ControlPoint Lerp(ControlPoint a, ControlPoint b, float x)
			{
				ControlPoint result;
				result.Position = Vector3.Lerp(a.Position, b.Position, x);
				result.Orientation = Quaternion.Lerp(a.Orientation, b.Orientation, x);
				result.Offset = MathHelper.Lerp(a.Offset, b.Offset, x);
				result.FieldOfView = MathHelper.Lerp(a.FieldOfView, b.FieldOfView, x);
				return result;
			}
 private void ConquestVictoryInterrupt_CpAllegianceChanged(ControlPoint sender, int oldTeam, int newTeam)
 {
     if (newTeam != winningTeam)
     {
         winningTeam = -1;
         GameTime.Main.Dusk -= ConquestVictory_Dusk;
         foreach (ControlPoint cp in controlPoints)
         {
             cp.AllegianceChanged -= ConquestVictoryInterrupt_CpAllegianceChanged;
         }
     }
 }
Esempio n. 6
0
 public bool IsVisuallyRedundant(ControlPoint other) => other.GetType() == Point.GetType();
Esempio n. 7
0
 private void PrintDeviceInfo(string aPrologue, ControlPoint.CpDevice aDevice)
 {
     string location;
     aDevice.GetAttribute("Upnp.Location", out location);
     string friendlyName;
     aDevice.GetAttribute("Upnp.FriendlyName", out friendlyName);
     Console.Write(aPrologue +
                   "\n    udn = " + aDevice.Udn() + 
                   "\n    location = " + location +
                   "\n    name = " + friendlyName + "\n");
 }
Esempio n. 8
0
    public void InitInterpolators(float tension, float continuity, float bias)
    {
        //Keyframe to time
        ControlPoint[] controlPointsKF = new ControlPoint[Keys.Length];
        for (int i = 0; i < Keys.Length; i++) {
            controlPointsKF[i] = new ControlPoint();
            controlPointsKF[i].Point = new Vector3(Keys[i].FrameNo, 0, 0);
            controlPointsKF[i].TangentI = Vector3.zero;
            controlPointsKF[i].TangentO = Vector3.zero;
            controlPointsKF[i].Time = Keys[i].Time;
        }

        SIKeyTime = new TCBSpline(controlPointsKF, 0, 0, 0);

        for(int arm = 0; arm < 2; arm++) {

            //End effector
            ControlPoint[] controlPointsEE = new ControlPoint[Keys.Length];
            for(int i = 0; i< Keys.Length; i++) {
                controlPointsEE[i] = new ControlPoint();
                controlPointsEE[i].Point = Keys[i].EePos[arm];
                controlPointsEE[i].TangentI = Vector3.zero;
                controlPointsEE[i].TangentO = Vector3.zero;
                controlPointsEE[i].Time = Keys[i].Time;
            }

            SIee[arm] = new TCBSpline(controlPointsEE, tension, continuity, bias);

            //Elbow Rotation interpolator
            ControlPoint[] controlPointsEA = new ControlPoint[Keys.Length];
            for (int i = 0; i < Keys.Length; i++){
                controlPointsEA[i] = new ControlPoint();
                controlPointsEA[i].Rotation = Keys[i].ElbowRot[arm];
                controlPointsEA[i].TangentI = Vector3.zero;
                controlPointsEA[i].TangentO = Vector3.zero;
            }

            SIElbowAngle[arm] = new TCBSpline(controlPointsEA, tension, continuity, bias);

            /*
            //Elbow position
            ControlPoint[] controlPointsEP = new ControlPoint[Keys.Length];
            for (int i = 0; i < Keys.Length; i++) {
                controlPointsEP[i] = new ControlPoint();
                controlPointsEP[i].Point = Keys[i].ElbowPos[arm];
                controlPointsEP[i].TangentI = Vector3.zero;
                controlPointsEP[i].TangentO = Vector3.zero;
                controlPointsEP[i].FrameNo = Keys[i].FrameNo;
            }

            //Rotation interpolator

            SIElbowPos[arm] = new TCBSpline(controlPointsEP, tension, continuity, bias);
            */
        }
    }
Esempio n. 9
0
        //指定制御点の前後どちらかに制御点を挿入
        private ControlPoint InsertControlPoint(ControlPoint point, Insert position)
        {
            Debug.Assert(point != null);

            //挿入位置の制御点は配列の何番目か検索
            int index = controlPointList.IndexOf(point);
            Debug.Assert(index != -1);

            ControlPoint newControlPoint = null;

            //リストに制御点を挿入(前or後)
            switch (position)
            {
            case Insert.Before:
                //制御点を追加する座標を算出して作成(挿入元から30mm左上の位置にハードコード)
                newControlPoint = new ControlPoint(point.NativeX - 30, point.NativeY + 30, this);
                controlPointList.Insert(index, newControlPoint);
                break;

            case Insert.After:
                //制御点を追加する座標を算出して作成(挿入元から30mm右下の位置にハードコード)
                newControlPoint = new ControlPoint(point.NativeX + 30, point.NativeY - 30, this);
                controlPointList.Insert(index + 1, newControlPoint);
                break;

            default:
                Debug.Assert(false);
                break;
            }

            //コンテキストメニューを設定
            newControlPoint.ContextMenuStrip = controlPointMenu;

            //制御点を画面に反映
            this.containerPanel.Controls.Add(newControlPoint);
            newControlPoint.BringToFront();

            return newControlPoint;
        }
Esempio n. 10
0
        private void Update()
        {
            _points.Clear();
            for (int i = 0; i < _controlPoints.Count; i++)
            {
                Vector3      localPosition = _transformList[i].localPosition;
                ControlPoint point         = new ControlPoint
                {
                    point     = localPosition,
                    control01 = Vector3.Lerp(_controlPoints[i].control01, localPosition, Time.deltaTime * 12f),
                    control02 = (_controlPoints[i].control02 == Vector3.zero) ? localPosition : Vector3.Lerp(_controlPoints[i].control02, localPosition, Time.deltaTime * 12f)
                };
                _controlPoints[i] = point;
                if (i != 0)
                {
                    _points.Add(_controlPoints[i].control01);
                }
                _points.Add(_controlPoints[i].point);
                if (i != (_controlPoints.Count - 1))
                {
                    _points.Add(_controlPoints[i].control02);
                }
            }
            _path.SetControlPoints(_points);
            float x = 0f;

            for (int j = 1; j < _points.Count; j++)
            {
                x += Vector3.SqrMagnitude(_points[j] - _points[j - 1]);
            }
            x = Mathf.Lerp(0.1f, 0.02f, _stretchCurve.Evaluate(x * 0.05f));
            Matrix4x4      matrixx = new Matrix4x4();
            Vector3        forward = ActiveCameraManager.ActiveCamera.transform.forward;
            List <Vector3> list    = _path.GetDrawingPoints1();
            int            num2    = 0;

            for (int k = 0; k < (_verts.Count - 1); k += 2)
            {
                if (list.Count <= num2)
                {
                    _verts[k]     = Vector3.zero;
                    _verts[k + 1] = Vector3.zero;
                }
                else
                {
                    if (list.Count == (num2 + 1))
                    {
                        matrixx.SetTRS(list[num2], matrixx.rotation, Vector3.one);
                    }
                    else
                    {
                        Vector3 vector4 = Vector3.Cross(Vector3.Cross(forward, (list[num2] - list[num2 + 1]).normalized).normalized, Vector3.up);
                        if (vector4.normalized == Vector3.zero)
                        {
                            vector4 = -forward;
                        }
                        matrixx.SetTRS(list[num2], Quaternion.LookRotation(vector4.normalized), Vector3.one);
                    }
                    _verts[k]     = matrixx.MultiplyPoint3x4(new Vector3(-x, 0f, 0f));
                    _verts[k + 1] = matrixx.MultiplyPoint3x4(new Vector3(x, 0f, 0f));
                }
                num2++;
            }
            int num3 = 0;

            for (int m = 0; m < _tris.Count; m += 6)
            {
                if (((int)(num3 * 0.5f)) >= (list.Count - 1))
                {
                    _tris[m + 1] = 0;
                    _tris[m + 2] = 0;
                    _tris[m + 3] = 0;
                    _tris[m + 4] = 0;
                    _tris[m + 5] = 0;
                }
                else
                {
                    _tris[m]     = num3;
                    _tris[m + 1] = num3 + 2;
                    _tris[m + 2] = num3 + 1;
                    _tris[m + 3] = num3 + 1;
                    _tris[m + 4] = num3 + 2;
                    _tris[m + 5] = num3 + 3;
                }
                num3 += 2;
            }
            _mesh.SetVertices(_verts);
            _mesh.SetTriangles(_tris, 0);
            _mesh.RecalculateBounds();
        }
Esempio n. 11
0
        private Border CreateControlPoint(ControlPoint controlPoint)
        {
            var point = new Border();

            point.MouseDown += (s, e) =>
            {
                point.CaptureMouse();
                ControlPointMouseDown?.Invoke(this, controlPoint);
            };

            point.MouseLeave += (s, e) =>
            {
                if (e.LeftButton == MouseButtonState.Released)
                {
                    point.ReleaseMouseCapture();
                    ControlPointMouseUp?.Invoke(this, controlPoint);
                }
            };
            Binding binding = new Binding()
            {
                //Source = designItemModel,
                Path = new PropertyPath("ControlPointVisibility"),
                Mode = BindingMode.TwoWay,
                UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged
            };

            BindingOperations.SetBinding(point, VisibilityProperty, binding);
            point.Width        = 10;
            point.Height       = 10;
            point.CornerRadius = new System.Windows.CornerRadius()
            {
                TopLeft     = 10,
                TopRight    = 10,
                BottomLeft  = 10,
                BottomRight = 10
            };
            point.SetCurrentValue(Panel.ZIndexProperty, 2);
            point.Background = Project1UIColor.Get("#6495ED");

            var cursorEnter = Cursors.Hand;

            switch (controlPoint)
            {
            case ControlPoint.LeftTop:
                cursorEnter               = Cursors.SizeNWSE;
                point.VerticalAlignment   = System.Windows.VerticalAlignment.Top;
                point.HorizontalAlignment = System.Windows.HorizontalAlignment.Left;
                point.Margin              = new System.Windows.Thickness(-5, -5, 0, 0);
                break;

            case ControlPoint.RightTop:
                cursorEnter               = Cursors.SizeNESW;
                point.VerticalAlignment   = System.Windows.VerticalAlignment.Top;
                point.HorizontalAlignment = System.Windows.HorizontalAlignment.Right;
                point.Margin              = new System.Windows.Thickness(0, -5, -5, 0);
                break;

            case ControlPoint.LeftBottom:
                cursorEnter = Cursors.SizeNESW;

                point.VerticalAlignment   = System.Windows.VerticalAlignment.Bottom;
                point.HorizontalAlignment = System.Windows.HorizontalAlignment.Left;
                point.Margin = new System.Windows.Thickness(-5, 0, 0, -5);
                break;

            case ControlPoint.RightBottom:
                cursorEnter = Cursors.SizeNWSE;

                point.VerticalAlignment   = System.Windows.VerticalAlignment.Bottom;
                point.HorizontalAlignment = System.Windows.HorizontalAlignment.Right;
                point.Margin = new System.Windows.Thickness(0, 0, -5, -5);
                break;
            }
            point.Cursor = cursorEnter;

            return(point);
        }
Esempio n. 12
0
 /// <summary>
 /// Overrides the <see cref="Curve.Transform"/>-method, which transforms the Points A, B and the ControlPoint.
 /// </summary>
 /// <param name="m">Holds the Transformmatrix</param>
 public override void Transform(Matrix3x3 m)
 {
     A            = A.mul(m);
     B            = B.mul(m);
     ControlPoint = ControlPoint.mul(m);
 }
Esempio n. 13
0
 public AttributeProgressBar(ControlPoint controlPoint)
     : base(false)
 {
     this.controlPoint = controlPoint;
 }
Esempio n. 14
0
        /// <summary>
        /// Notify players within the CP whether they won, lost, or tied
        /// </summary>
        public void notifyPlayersOfCPResults(int rewardsDistributed,
                                             List <long> winningFleetIds, List <IMyPlayer> nearbyPlayers, ControlPoint cp)
        {
            bool tie            = (winningFleetIds.Count > 1);
            long winningFleetId = 0;

            if (!tie)
            {
                winningFleetId = winningFleetIds.First();
            }

            var winningPlayers = new List <long>();
            var tiedPlayers    = new List <long>();
            var losingPlayers  = new List <long>();

            foreach (IMyPlayer player in nearbyPlayers)
            {
                long fleetID = player.FleetID();

                if (!tie && fleetID == winningFleetId)
                {
                    winningPlayers.Add(player.PlayerID);
                }
                else if (tie && winningFleetIds.Contains(fleetID))
                {
                    tiedPlayers.Add(player.PlayerID);
                }
                else
                {
                    losingPlayers.Add(player.PlayerID);
                }
            }

            if (winningPlayers.Count > 0)
            {
                notifyPlayers(String.Format(
                                  "You control {0} and received {1} licenses.",
                                  cp.Name, rewardsDistributed),
                              winningPlayers, MyFontEnum.Green);
            }
            if (tiedPlayers.Count > 0)
            {
                notifyPlayers(String.Format(
                                  "You tied for control of {0} and received no licenses.",
                                  cp.Name), tiedPlayers, MyFontEnum.Red);
            }
            if (losingPlayers.Count > 0)
            {
                notifyPlayers("Someone else controls " + cp.Name,
                              losingPlayers, MyFontEnum.Red);
            }
        }
Esempio n. 15
0
 public override string ToString()
 {
     return("{ Keyframe:" + " ControlPoint = " + (ControlPoint == null ? "null" : ControlPoint.ToString()) + ";" + " InTangentStart = " + (InTangentStart == null ? "null" : InTangentStart.ToString()) + ";" + " OutTangentEnd = " + (OutTangentEnd == null ? "null" : OutTangentEnd.ToString()) + ";" + " }");
 }
Esempio n. 16
0
 private void Awake()
 {
     controlPoint = FindObjectOfType <ControlPoint>();
     cameraFollow = FindObjectOfType <CameraFollow>();
 }
 public BezierPatchForeignShell(ForeignLump parent, ControlPoint[,] vertices)
     : base(parent)
 {
     Debug.Assert(vertices != null);
     this.vertices = vertices;
 }
Esempio n. 18
0
 public override string ToString()
 {
     return("Q" + ControlPoint.ToSvgString() + " " + End.ToSvgString());
 }
        // hardwired to place on about inch-spaced points
        // Edge-only for now -- See EO comments
        static void MakeTabs_Executing(object sender, EventArgs e)
        {
            Window activeWindow = Window.ActiveWindow;

            Layer tabLayer = NoteHelper.CreateOrGetLayer(activeWindow.ActiveContext.Context.Document, "Tabs", System.Drawing.Color.Fuchsia);

            ICollection<ITrimmedCurve> trimmedCurves = AddInHelper.GetITrimmedCurvesOfSelectedTopology(activeWindow);

            // quantize with lines to points separated by approx targetDistance;
            TrimmedCurveChain curveChain = new TrimmedCurveChain(trimmedCurves);
            Point lastPoint = curveChain.Curves[0].StartPoint;
            double tolerance = 0.2 * inches;
            double targetDistance = 1 * inches;
            trimmedCurves = new List<ITrimmedCurve>();
            Dictionary<ITrimmedCurve, Direction> OriginalNormals = new Dictionary<ITrimmedCurve, Direction>();

            double extraLength = 0;
            foreach (OrientedTrimmedCurve curve in curveChain.Curves) {
                Point point = curve.EndPoint;

                if (Math.Abs((lastPoint - point).Magnitude - targetDistance) > tolerance) {
                    extraLength += (lastPoint - point).Magnitude;
                    continue;
                }

                CurveSegment curveSegment = null;
                //		if (extraLength == 0)
                curveSegment = CurveSegment.Create(lastPoint, point);
                //		else
                //			curveSegment = CurveSegment.Create(point - (lastPoint - point).Direction * ((lastPoint - point).Magnitude + extraLength), point);

                trimmedCurves.Add(curveSegment);

                Edge edge = curve.TrimmedCurve as Edge;
                if (edge != null) {
                    Face face = null;
                    foreach (Face testFace in edge.Faces) {
                        face = testFace;
                        break;
                    }

                    SurfaceEvaluation surfEval = face.ProjectPoint(curve.StartPoint);
                    OriginalNormals[curveSegment] = surfEval.Normal;
                }

                lastPoint = point;
                //		extraLength = 0;
            }

            curveChain = new TrimmedCurveChain(trimmedCurves);
            if (AreTabsFlipped)
                curveChain.Reverse();

            List<Window> curveWindows = new List<Window>(Document.Open(@"C:\Users\bcr.SPACECLAIM\Documents\Models\Pod Tent\TabCurve.scdoc", false));
            bool adjustEnds = true;
            #if false
            List<Window> curveWindows = new List<Window>(Document.Open(@"C:\Users\bcr.SPACECLAIM\Documents\Models\Pod Tent\TabStrapEdgeCurve.scdoc", false));
            bool adjustEnds = true;
            #endif
            NurbsCurve middle = GetFirstNurbsCurveFromPart(curveWindows[0].Scene as Part);
            Debug.Assert(middle != null);

            NurbsCurve endTab = null;
            NurbsCurve endSlot = null;
            foreach (Component component in (curveWindows[0].Scene as Part).Components) {
                if (component.Template.Name == "EndTab")
                    endTab = GetFirstNurbsCurveFromPart(component.Template);

                if (component.Template.Name == "EndSlot")
                    endSlot = GetFirstNurbsCurveFromPart(component.Template);
            }

            Debug.Assert(endTab != null);
            Debug.Assert(endSlot != null);

            Point startPoint = curveChain.Curves[0].StartPoint;
            Point endPoint = curveChain.Curves[0].EndPoint;
            Point startTail = startPoint + (endPoint - startPoint);
            bool mirror = false;

            if (IsTabStartSlot) {
                NurbsCurve tmp = endTab;
                endTab = endSlot;
                endSlot = tmp;

                mirror = !mirror;
            }

            for (int i = 0; i < curveChain.Curves.Count; i++) {
                Point endTail;
                if (i == curveChain.Curves.Count - 1)
                    endTail = curveChain.Curves[i].EndPoint + (curveChain.Curves[i].EndPoint - curveChain.Curves[i].StartPoint);
                else
                    endTail = curveChain.Curves[i + 1].EndPoint;

                Point mid = Point.Origin + (startPoint.Vector + endPoint.Vector) / 2;
                Direction startDirection = (startPoint - startTail).Direction;
                Direction lineDirection = (endPoint - startPoint).Direction;
                Direction endDirection = (endTail - endPoint).Direction;

                Direction upDirection = Direction.DirZ;
                //if (upDirection.IsParallelTo(lineDirection))
                //    upDirection = Direction.DirY;

                if (OriginalNormals.ContainsKey(curveChain.Curves[i].TrimmedCurve))
                    upDirection = OriginalNormals[curveChain.Curves[i].TrimmedCurve];

                Direction normalDirection = Direction.Cross(lineDirection, upDirection);

                Line startMidLine;
                if (startDirection.UnitVector == lineDirection.UnitVector)
                    startMidLine = Line.Create(startPoint, Direction.Cross(lineDirection, upDirection));
                else
                    startMidLine = Line.Create(startPoint, (startDirection.UnitVector - lineDirection.UnitVector).Direction);

                Line endMidLine;
                if (lineDirection.UnitVector == endDirection.UnitVector)
                    endMidLine = Line.Create(endPoint, Direction.Cross(lineDirection, upDirection));
                else
                    endMidLine = Line.Create(endPoint, (lineDirection.UnitVector - endDirection.UnitVector).Direction);

                NurbsCurve template = middle;

                if (mirror) {
                    lineDirection = -lineDirection;
                    Line tmp = startMidLine;
                    startMidLine = endMidLine;
                    endMidLine = tmp;
                }

                if (i == 0)
                    template = endSlot;

                if (i == curveChain.Curves.Count - 1) {
                    if (mirror ^ IsTabStartSlot)
                        template = endSlot;
                    else
                        template = endTab;
                }

                Frame frame = Frame.Create(mid, lineDirection, normalDirection);
                Matrix transform = Matrix.CreateMapping(frame);

                ControlPoint[] controlPoints = new ControlPoint[template.ControlPoints.Length];
                int j = 0;
                foreach (ControlPoint controlPoint in template.ControlPoints) {
                    controlPoints[j] = new ControlPoint(transform * controlPoint.Position, controlPoint.Weight);
                    j++;
                }

                //CurveEvaluation curveEval = null;
                //curveEval = startMidLine.Evaluate(1);
                //DesignCurve.Create(activeWindow.SubjectMatter as Part, CurveSegment.Create(startPoint, curveEval.Point));
                //curveEval = endMidLine.Evaluate(1);
                //DesignCurve.Create(activeWindow.SubjectMatter as Part, CurveSegment.Create(endPoint, curveEval.Point));

                MakeNurbsEndTangent(endMidLine, controlPoints, 0, 1);
                if (adjustEnds)
                    MakeNurbsEndTangent(startMidLine, controlPoints, controlPoints.Length - 1, controlPoints.Length - 2);

                Curve curve = NurbsCurve.Create(template.Data, controlPoints);
                CurveSegment curveSegment = CurveSegment.Create(curve, template.Parameterization.Range.Value);

                DesignCurve tab = DesignCurve.Create(activeWindow.ActiveContext.Context as Part, curveSegment);
                tab.Layer = tabLayer;

                startTail = startPoint;
                startPoint = endPoint;
                endPoint = endTail;
                mirror = !mirror;

            }

            foreach (Window window in curveWindows)
                window.Close();
        }
Esempio n. 20
0
 protected void InsertAtPos(int insertionPos, double inputValue, double outputValue)
 {
     ControlPoint newPoint = new ControlPoint {InputValue = inputValue, OutputValue = outputValue};
     controlPoints.Insert(insertionPos, newPoint);
 }
Esempio n. 21
0
 /// <summary>
 /// Sets the controlpoint of the curve at a given index
 /// </summary>
 /// <param name="index"></param>
 /// <param name="point"></param>
 private void SetPointOfMatchingCurve(int index, ControlPoint point)
 {
     MatchingCurve.Points.SetPoint(index, point.Location.X, point.Location.Y, point.Location.Z, point.Weight);
 }
Esempio n. 22
0
        private void Awake()
        {
            if (this.path == null || this.wps.Count < 1 || this.inspectorMode == DOTweenInspectorMode.OnlyPath)
            {
                return;
            }
            this.path.AssignDecoder(this.path.type);
            if (DOTween.isUnityEditor)
            {
                DOTween.GizmosDelegates.Add(new TweenCallback(this.path.Draw));
                this.path.gizmoColor = this.pathColor;
            }
            if (this.isLocal)
            {
                Transform transform = base.transform;
                if (transform.parent != null)
                {
                    transform = transform.parent;
                    Vector3 position = transform.position;
                    int     num      = this.path.wps.Length;
                    for (int i = 0; i < num; i++)
                    {
                        this.path.wps[i] = this.path.wps[i] - position;
                    }
                    num = this.path.controlPoints.Length;
                    for (int j = 0; j < num; j++)
                    {
                        ControlPoint controlPoint = this.path.controlPoints[j];
                        controlPoint.a            -= position;
                        controlPoint.b            -= position;
                        this.path.controlPoints[j] = controlPoint;
                    }
                }
            }
            if (this.relative)
            {
                this.ReEvaluateRelativeTween();
            }
            if (this.pathMode == PathMode.Full3D && base.GetComponent <SpriteRenderer>() != null)
            {
                this.pathMode = PathMode.TopDown2D;
            }
            Rigidbody component = base.GetComponent <Rigidbody>();
            TweenerCore <Vector3, Path, PathOptions> tweenerCore;

            if (this.tweenRigidbody && component != null)
            {
                tweenerCore = (this.isLocal ? component.DOLocalPath(this.path, this.duration, this.pathMode).SetOptions(this.isClosedPath, AxisConstraint.None, this.lockRotation) : component.DOPath(this.path, this.duration, this.pathMode).SetOptions(this.isClosedPath, AxisConstraint.None, this.lockRotation));
            }
            else
            {
                tweenerCore = (this.isLocal ? base.transform.DOLocalPath(this.path, this.duration, this.pathMode).SetOptions(this.isClosedPath, AxisConstraint.None, this.lockRotation) : base.transform.DOPath(this.path, this.duration, this.pathMode).SetOptions(this.isClosedPath, AxisConstraint.None, this.lockRotation));
            }
            switch (this.orientType)
            {
            case OrientType.ToPath:
                if (this.assignForwardAndUp)
                {
                    tweenerCore.SetLookAt(this.lookAhead, new Vector3?(this.forwardDirection), new Vector3?(this.upDirection));
                }
                else
                {
                    tweenerCore.SetLookAt(this.lookAhead, null, null);
                }
                break;

            case OrientType.LookAtTransform:
                if (this.lookAtTransform != null)
                {
                    if (this.assignForwardAndUp)
                    {
                        tweenerCore.SetLookAt(this.lookAtTransform, new Vector3?(this.forwardDirection), new Vector3?(this.upDirection));
                    }
                    else
                    {
                        tweenerCore.SetLookAt(this.lookAtTransform, null, null);
                    }
                }
                break;

            case OrientType.LookAtPosition:
                if (this.assignForwardAndUp)
                {
                    tweenerCore.SetLookAt(this.lookAtPosition, new Vector3?(this.forwardDirection), new Vector3?(this.upDirection));
                }
                else
                {
                    tweenerCore.SetLookAt(this.lookAtPosition, null, null);
                }
                break;
            }
            tweenerCore.SetDelay(this.delay).SetLoops(this.loops, this.loopType).SetAutoKill(this.autoKill).SetUpdate(this.updateType).OnKill(delegate
            {
                this.tween = null;
            });
            if (this.isSpeedBased)
            {
                tweenerCore.SetSpeedBased <TweenerCore <Vector3, Path, PathOptions> >();
            }
            if (this.easeType == Ease.INTERNAL_Custom)
            {
                tweenerCore.SetEase(this.easeCurve);
            }
            else
            {
                tweenerCore.SetEase(this.easeType);
            }
            if (!string.IsNullOrEmpty(this.id))
            {
                tweenerCore.SetId(this.id);
            }
            if (this.hasOnStart)
            {
                if (this.onStart != null)
                {
                    tweenerCore.OnStart(new TweenCallback(this.onStart.Invoke));
                }
            }
            else
            {
                this.onStart = null;
            }
            if (this.hasOnPlay)
            {
                if (this.onPlay != null)
                {
                    tweenerCore.OnPlay(new TweenCallback(this.onPlay.Invoke));
                }
            }
            else
            {
                this.onPlay = null;
            }
            if (this.hasOnUpdate)
            {
                if (this.onUpdate != null)
                {
                    tweenerCore.OnUpdate(new TweenCallback(this.onUpdate.Invoke));
                }
            }
            else
            {
                this.onUpdate = null;
            }
            if (this.hasOnStepComplete)
            {
                if (this.onStepComplete != null)
                {
                    tweenerCore.OnStepComplete(new TweenCallback(this.onStepComplete.Invoke));
                }
            }
            else
            {
                this.onStepComplete = null;
            }
            if (this.hasOnComplete)
            {
                if (this.onComplete != null)
                {
                    tweenerCore.OnComplete(new TweenCallback(this.onComplete.Invoke));
                }
            }
            else
            {
                this.onComplete = null;
            }
            if (this.hasOnRewind)
            {
                if (this.onRewind != null)
                {
                    tweenerCore.OnRewind(new TweenCallback(this.onRewind.Invoke));
                }
            }
            else
            {
                this.onRewind = null;
            }
            if (this.autoPlay)
            {
                tweenerCore.Play <TweenerCore <Vector3, Path, PathOptions> >();
            }
            else
            {
                tweenerCore.Pause <TweenerCore <Vector3, Path, PathOptions> >();
            }
            this.tween = tweenerCore;
            if (this.hasOnTweenCreated && this.onTweenCreated != null)
            {
                this.onTweenCreated.Invoke();
            }
        }
Esempio n. 23
0
        //選択されているコントロールポイントが変化したことを通知する
        public void ControlPointSelected(ControlPoint cp)
        {
            //選択が変化したか確認(選択済のコントロールポイントが再クリックされた可能性がある)
            if (cp != activeControlPoint)
            {
                //いままで選択されていたコントロールポイントにデアクティブを通知
                if (activeControlPoint != null)
                {
                    activeControlPoint.ControlPointDeactivated();
                }

                //現在の選択を更新
                activeControlPoint = cp;

                //クリックされたコントロールポイントにアクティブを通知
                if (cp != null)
                {
                    cp.ControlPointActivated();
                }

                //選択が変化したことを通知
                if (activeControlPointNotifier != null)
                {
                    activeControlPointNotifier(cp);
                }
            }

            return;
        }
Esempio n. 24
0
 public override bool EquivalentTo(ControlPoint other)
 => base.EquivalentTo(other) &&
 other is LegacySampleControlPoint legacy &&
Esempio n. 25
0
    public void AutoSetContext()
    {
        ControlPoint[] oldControlPoints = controlPoints;

        // 生成する制御点の数をカウント
        int createCount = 0;
        int index = 0;
        while (index < transform.childCount)
        {
            if (transform.GetChild(index).GetComponent<CurveNode>() != null)
            {
                createCount++;
                index += 3;
            }
            else
            {
                createCount++;
                index++;
            }
        }

        // 生成
        controlPoints = new ControlPoint[createCount];

        // 生成後、正しい値で初期化
        index = 0;
        int controlPointIndex = 0;
        while (index < transform.childCount)
        {
            Transform child = transform.GetChild(index);

            if (child.GetComponent<CurveNode>() != null)
            {
                Transform begin = child;
                Transform end = transform.GetChild(index + 3);
                if (controlPoints[controlPointIndex] == null) // 続けて書く場合、前回のループで生成したものがそのまま使えるはずなのでnullの時のみ生成
                {
                    controlPoints[controlPointIndex] = new ControlPoint(begin.localPosition, begin.localScale, begin.localRotation);
                    controlPoints[controlPointIndex].nextHandle = transform.GetChild(index + 1).localPosition;
                    if (oldControlPoints.Length >= controlPointIndex)
                    {
                        controlPoints[controlPointIndex].wait = oldControlPoints[controlPointIndex].wait;
                        controlPoints[controlPointIndex].travelTime = oldControlPoints[controlPointIndex].travelTime;
                    }
                }
                else
                {
                    controlPoints[controlPointIndex].nextHandle = transform.GetChild(index + 1).localPosition;
                }

                controlPoints[controlPointIndex + 1] = new ControlPoint(end.localPosition, end.localScale, end.localRotation);
                controlPoints[controlPointIndex + 1].prevHandle = transform.GetChild(index + 2).localPosition;
                if (oldControlPoints.Length >= controlPointIndex)
                {
                    controlPoints[controlPointIndex].wait = oldControlPoints[controlPointIndex].wait;
                    controlPoints[controlPointIndex].travelTime = oldControlPoints[controlPointIndex].travelTime;
                }
                controlPointIndex++;
                index += 3;
            }
            else
            {
                if (controlPoints[controlPointIndex] == null)
                {
                    controlPoints[controlPointIndex] = new ControlPoint(child.localPosition, child.localScale, child.localRotation);
                    if (oldControlPoints.Length >= controlPointIndex)
                    {
                        controlPoints[controlPointIndex].wait = oldControlPoints[controlPointIndex].wait;
                        controlPoints[controlPointIndex].travelTime = oldControlPoints[controlPointIndex].travelTime;
                    }
                }
                controlPointIndex++;
                index++;
            }
        }
    }
Esempio n. 26
0
        private void AddControlPoint(Vector3 position)
        {
            for (int i = 0; i < PointsBetweenControlPoints; i++)
            {
                AddPoint(new PCTrailPoint(), position);
            }

            AddPoint(new PCTrailPoint(), position);

            ControlPoint newCP = new ControlPoint { p = position };

            if (TrailData.UseForwardOverride)
            {
                newCP.forward = TrailData.ForwardOverrideRelative
                               ? _t.TransformDirection(TrailData.ForwardOverride.normalized)
                               : TrailData.ForwardOverride.normalized;
            }

            _controlPoints.Add(newCP);
        }
Esempio n. 27
0
 private void DeviceAdded(ControlPoint.CpDeviceList aList, ControlPoint.CpDevice aDevice)
 {
     lock (this)
     {
         if (!iListFrozen)
         {
             PrintDeviceInfo("Added", aDevice);
             aDevice.AddRef();
             iDeviceList.Add(aDevice);
         }
     }
 }
Esempio n. 28
0
 internal void AddControlPoint(ControlPoint controlPoint)
 {
     controlPoints.Add(controlPoint);
 }
 public BezierPatchForeignFin(ForeignLoop parent, ControlPoint[] points, int index)
     : base(parent)
 {
     Debug.Assert(points != null);
     this.points = points;
     this.index = index;
 }
Esempio n. 30
0
        internal void UpdatePendingChanges(bool forceUpdate = false)
        {
            //After timing changes are complete, we finally do an update or vars.
            if (forceUpdate || MouseManager.MouseLeft == ButtonState.Released)
            {
                changeInProgress = false;

                Modifier mod = Modifier.VariableChanges;

                if (SliderUpdatePending)
                {
                    changeManager.Dirty = true;

                    hitObjectManager.UpdateVariables(false);

                    if (!tickRateDirty)
                    {
                        changeManager.BeginAction(ChangeType.HitObject);
                        changeManager.PushAction(ActionType.ChangeLength, mod);

                        hitObjectManager.UpdateSliders(false, true);
                        editor.BreakDirty = true;
                    }

                    tickRateDirty = false;
                }

                if (OffsetUpdatePending)
                {
                    changeManager.Dirty = true;

                    if (checkboxOffsetMove.Checked || TimingWindowUpdatePending)
                    {
                        // Catch for a non-ineriting section being moved past an inheriting section,
                        // and ActiveTimingPointIndex becoming stale as a result. (Thanks Cyclone)
                        AudioEngine.UpdateActiveTimingPoint(true);

                        List <ControlPoint> timingPoints = AudioEngine.TimingPoints;
                        ControlPoint        activePoint  = currentActivePoint != null ? currentActivePoint : AudioEngine.ControlPoints[AudioEngine.ActiveTimingPointIndex];

                        int i = timingPoints.IndexOf(activePoint);

                        double start = activePoint.Offset;
                        double end   = (i < timingPoints.Count - 1 ? timingPoints[i + 1].Offset : AudioEngine.AudioLength);

                        int diff = (int)(start - offsetUpdateOrig);

                        List <HitObject> objs = hitObjectManager.hitObjects.FindAll(h => h.StartTime < end && h.StartTime >= offsetUpdateOrig);

                        if (objs.Count > 0)
                        {
                            changeManager.BeginAction(ChangeType.HitObject, true);
                            changeManager.PushAction(ActionType.MoveTimeline, mod | Modifier.MoveBoth);
                            changeManager.PushAction(ActionType.ChangeLength, mod);
                            changeManager.BackupData(objs);

                            objs.ForEach(h => h.ModifyTime(h.StartTime + diff));

                            editor.BreakDirty          = true;
                            changeManager.EnableBuffer = false;
                        }
                    }
                }

                if (BpmUpdatePending)
                {
                    changeManager.Dirty = true;

                    bool autoMove = checkboxOffsetMove.Checked;

                    List <ControlPoint> timingPoints = AudioEngine.TimingPoints;
                    ControlPoint        activePoint  = currentActivePoint != null ? currentActivePoint : AudioEngine.ControlPoints[AudioEngine.ActiveTimingPointIndex];

                    int i = timingPoints.IndexOf(activePoint);

                    double start = activePoint.Offset;
                    double end   = (i < timingPoints.Count - 1 ? timingPoints[i + 1].Offset : AudioEngine.AudioLength);

                    double change = activePoint.BeatLength / bpmUpdateOrig;

                    if (autoMove)
                    {
                        List <HitObject> objs = hitObjectManager.hitObjects.FindAll(h => h.StartTime < end && h.StartTime >= offsetUpdateOrig);

                        if (objs.Count > 0)
                        {
                            changeManager.BeginAction(ChangeType.HitObject, true);
                            changeManager.PushAction(ActionType.MoveTimeline, mod | Modifier.MoveBoth);
                            changeManager.PushAction(ActionType.ChangeLength, mod);
                            changeManager.BackupData(objs);

                            objs.ForEach(h => h.ModifyTime(BeatSnapValue((h.StartTime - start) * change + start, 8, 0)));
                            editor.BreakDirty          = true;
                            changeManager.EnableBuffer = false;
                        }
                    }
                }

                if (BpmUpdatePending || OffsetUpdatePending)
                {
                    hitObjectManager.Sort(true);
                }

                currentActivePoint = null;

                BpmUpdatePending          = false;
                OffsetUpdatePending       = false;
                SliderUpdatePending       = false;
                TimingWindowUpdatePending = false;
                editor.UpdateBreaks();
                changeManager.FinishAction();
            }
        }
Esempio n. 31
0
 public static void WritePoint(this MessageWriter Writer, ControlPoint Point)
 {
     Writer.Write(Point.No);
 }
Esempio n. 32
0
        // Get a regular 8-box line for a start or regular control.
        private DescriptionLine GetRegularLine(CourseView.CourseViewKind kind, int scoreColumn, CourseView.ControlView controlView, Dictionary <string, string> descriptionKey)
        {
            Event         ev      = eventDB.GetEvent();
            ControlPoint  control = eventDB.GetControl(controlView.controlId);
            CourseControl courseControl;

            if (controlView.courseControlIds[0].IsNone)
            {
                courseControl = null;
            }
            else
            {
                courseControl = eventDB.GetCourseControl(controlView.courseControlIds[0]);
            }

            Debug.Assert(control.kind == ControlPointKind.Normal || control.kind == ControlPointKind.Start || control.kind == ControlPointKind.MapExchange);

            DescriptionLine line = new DescriptionLine();

            line.kind  = DescriptionLineKind.Normal;
            line.boxes = new object[8];

            // Box A: ordinal or start triangle or points.
            if (control.kind == ControlPointKind.Start || control.kind == ControlPointKind.MapExchange)
            {
                line.boxes[0] = symbolDB["start"];
            }
            else if (kind != CourseView.CourseViewKind.AllControls && controlView.ordinal > 0)
            {
                line.boxes[0] = Convert.ToString(controlView.ordinal);
            }
            else
            {
                line.boxes[0] = null;
            }

            // Box B: code of the control
            if (control.kind == ControlPointKind.Normal)
            {
                line.boxes[1] = Convert.ToString(control.code);
            }

            // Boxes C-H, from the symbols
            for (int i = 2; i < 8; ++i)
            {
                String symbolID = control.symbolIds[i - 2];
                if (symbolID != null)
                {
                    line.boxes[i] = symbolDB[control.symbolIds[i - 2]];

                    // See if we need to add this to the key.
                    bool addToKey;
                    if (ev.customSymbolKey.TryGetValue(symbolID, out addToKey) && addToKey && Symbol.ContainsLanguage(ev.customSymbolText[symbolID], language))
                    {
                        descriptionKey[symbolID] = Symbol.GetBestSymbolText(symbolDB, ev.customSymbolText[symbolID], language, false, "", "");
                    }
                }
            }

            // Box F -- may be text instead of a symbol.
            if (control.columnFText != null)
            {
                Debug.Assert(line.boxes[5] == null);
                line.boxes[5] = control.columnFText;
            }

            // Put points in the score column, for a score course.
            if (control.kind == ControlPointKind.Normal && scoreColumn >= 0 && courseControl != null)
            {
                int points = courseControl.points;
                if (points > 0)
                {
                    line.boxes[scoreColumn] = Convert.ToString(courseControl.points);
                }
                else
                {
                    line.boxes[scoreColumn] = null;
                }
            }

            // Get the text version of the control using the Textifier.
            Textifier textifier = new Textifier(eventDB, symbolDB, language);

            line.textual = textifier.CreateTextForControl(controlView.controlId, "");

            // The course control ID, for use in coordinating the selection
            line.controlId       = controlView.controlId;
            line.courseControlId = controlView.courseControlIds[0];

            return(line);
        }
Esempio n. 33
0
	    protected void InsertAtPos(int insertionPos, double inputValue, double outputValue) {
		    ControlPoint newPoint = new ControlPoint {InputValue = inputValue, OutputValue = outputValue};
	        controlPoints.Insert(insertionPos, newPoint);
	    }
Esempio n. 34
0
        // Get a directive line for a finish or crossingpoint.
        private DescriptionLine GetDirectiveLine(CourseView.CourseViewKind kind, CourseView.ControlView controlView, CourseView.ControlView controlViewPrev)
        {
            ControlPoint  control = eventDB.GetControl(controlView.controlId);
            CourseControl courseControl;

            if (controlView.courseControlIds[0].IsNone)
            {
                courseControl = null;
            }
            else
            {
                courseControl = eventDB.GetCourseControl(controlView.courseControlIds[0]);
            }

            Debug.Assert(control.kind == ControlPointKind.Finish || control.kind == ControlPointKind.CrossingPoint || control.kind == ControlPointKind.MapIssue);

            DescriptionLine line = new DescriptionLine();

            line.kind  = DescriptionLineKind.Directive;
            line.boxes = new object[2];

            // Figure out the distance in the directive, rounded to nearest 10m.
            float  distance = float.NaN;
            string distanceText;

            if (control.kind == ControlPointKind.MapIssue)
            {
                if (controlView.legLength != null)
                {
                    distance = controlView.legLength[0];
                }
            }
            else
            {
                if (controlViewPrev != null && controlViewPrev.legLength != null)
                {
                    distance = controlViewPrev.legLength[0];
                }
            }

            if (!float.IsNaN(distance))
            {
                distance     = (float)(Math.Round(distance / 10.0) * 10.0);  // round to nearest 10 m.
                distanceText = string.Format("{0} m", distance);
            }
            else
            {
                distanceText = "";
            }


            // Box 1: directive graphics.
            string directiveId = control.symbolIds[0];

            // Based on the leg flagging, we may modify the finish directive symbol.
            if (control.kind == ControlPointKind.Finish && (kind == CourseView.CourseViewKind.Normal || kind == CourseView.CourseViewKind.AllVariations))
            {
                FlaggingKind flagging = FlaggingKind.None;
                if (controlView != null && controlViewPrev != null)
                {
                    flagging = QueryEvent.GetLegFlagging(eventDB, controlViewPrev.controlId, controlView.controlId);
                }
                if (flagging == FlaggingKind.All)
                {
                    directiveId = "14.1";  // If flagging is All, then finish id must be flagging to finish.
                }
                else if (flagging == FlaggingKind.End)
                {
                    directiveId = "14.2";  // If flagging is Partial, then finish id must be flagging to funnel.
                }
            }

            line.boxes[0] = symbolDB[directiveId];

            // Box 2: distance for the control, if any.
            if (control.kind == ControlPointKind.Finish || control.kind == ControlPointKind.MapIssue)
            {
                line.boxes[1] = distanceText;
            }

            // Get the text version of the control using the Textifier.
            Textifier textifier = new Textifier(eventDB, symbolDB, language);

            line.textual = textifier.CreateTextForDirective(directiveId, distanceText);

            // The course control ID, for use in coordinating the selection
            line.controlId       = controlView.controlId;
            line.courseControlId = controlView.courseControlIds[0];

            return(line);
        }
        private static void MakeNurbsEndTangent(Line cleaveLine, ControlPoint[] controlPoints, int endIndex, int tangentIndex)
        {
            Point initialPoint = controlPoints[endIndex].Position;
            CurveEvaluation curveEvaluation = cleaveLine.ProjectPoint(initialPoint);
            if (initialPoint == curveEvaluation.Point)
                return;

            controlPoints[endIndex] = new ControlPoint(curveEvaluation.Point, controlPoints[endIndex].Weight);

            Line tangentLine = Line.Create(curveEvaluation.Point, (initialPoint - curveEvaluation.Point).Direction);
            curveEvaluation = tangentLine.ProjectPoint(controlPoints[tangentIndex].Position);
            controlPoints[tangentIndex] = new ControlPoint(curveEvaluation.Point, controlPoints[tangentIndex].Weight);
        }
Esempio n. 36
0
        // Return true if this control should be included, false if not.
        private bool FilterControl(CourseView.CourseViewKind kind, ControlPoint control, ControlPoint controlPrev, ControlPoint controlNext)
        {
            switch (kind)
            {
            case CourseView.CourseViewKind.AllControls:
                // All controls list shows all kinds.
                return(true);

            case CourseView.CourseViewKind.Normal:
            case CourseView.CourseViewKind.AllVariations:
                // Normal list shows all control kinds.

                // filter out duplicate crossing points.
                if (control.kind == ControlPointKind.CrossingPoint && controlPrev != null && controlPrev.kind == ControlPointKind.CrossingPoint)
                {
                    return(false);
                }

                // Don't show map exchange that is the last control being shown.
                if (control.kind == ControlPointKind.MapExchange && controlNext == null)
                {
                    return(false);
                }

                return(true);

            case CourseView.CourseViewKind.Score:
                // Score course shows start, normal controls.
                return(control.kind == ControlPointKind.Normal || control.kind == ControlPointKind.Start || control.kind == ControlPointKind.MapIssue);

            default:
                Debug.Fail("bad course view kind");
                return(false);
            }
        }
Esempio n. 37
0
 /*
  * 選択されている制御点を更新する
  */
 private void UpdateSelectedControlPoint(ControlPoint cp)
 {
     controlPointProperty.SelectedObject = cp;
 }
Esempio n. 38
0
        // Create a set of description lines for a course. If "createKey" is true, then lines for a key are created based on any symbols
        // that have custom text. This is typically done only if text description are not already being printed.
        public DescriptionLine[] CreateDescription(bool createKey)
        {
            EventDB eventDB = courseView.EventDB;

            CourseView.CourseViewKind kind = courseView.Kind;
            int scoreColumn             = courseView.ScoreColumn;
            List <DescriptionLine> list = new List <DescriptionLine>(courseView.ControlViews.Count + 4);
            string          text;
            DescriptionLine line;

            DescriptionLine[]           lines;
            Dictionary <string, string> descriptionKey = new Dictionary <string, string>(); // dictionary for any symbols encountered with custom text.

            // Get the first title line.
            text = GetTitleLine1();
            Debug.Assert(text != null);
            lines = GetTitleLineFromText(DescriptionLineKind.Title, text);
            list.AddRange(lines);

            // Get the second title line.
            text = GetTitleLine2();
            if (text != null)
            {
                lines = GetTitleLineFromText(DescriptionLineKind.SecondaryTitle, text);
                list.AddRange(lines);
            }

            // Get the header line, depending on the kind of course.
            switch (kind)
            {
            case CourseView.CourseViewKind.Normal:
                line = GetNormalHeaderLine(); break;

            case CourseView.CourseViewKind.AllControls:
                line = GetAllControlsHeaderLine(); break;

            case CourseView.CourseViewKind.Score:
                line = GetScoreHeaderLine(); break;

            case CourseView.CourseViewKind.AllVariations:
                line = GetAllVariationsHeaderLine(); break;

            default:
                Debug.Fail("unknown CourseViewKind"); line = null;  break;
            }

            if (line != null)
            {
                list.Add(line);
            }

            // Do all the normal lines
            for (int iLine = 0; iLine < courseView.ControlViews.Count; ++iLine)
            {
                CourseView.ControlView controlView   = courseView.ControlViews[iLine];
                ControlPoint           control       = eventDB.GetControl(controlView.controlId);
                CourseControl          courseControl = controlView.courseControlIds[0].IsNone ? null : eventDB.GetCourseControl(controlView.courseControlIds[0]);

                // CONSIDER: this might need to be updated for relay or split controls.
                ControlPoint controlPrev = (iLine > 0) ? eventDB.GetControl(courseView.ControlViews[iLine - 1].controlId) : null;
                ControlPoint controlNext = (iLine < courseView.ControlViews.Count - 1) ? eventDB.GetControl(courseView.ControlViews[iLine + 1].controlId) : null;
                //Id<CourseControl> courseControlIdNext = (iLine < courseView.ControlViews.Count - 1) ? courseView.ControlViews[iLine + 1].courseControlId : Id<CourseControl>.None;
                //CourseControl courseControlNext = courseControlIdNext.IsNotNone ? eventDB.GetCourseControl(coruseControlIdNext) : null;

                // Do the control.control
                if (FilterControl(kind, control, controlPrev, controlNext))
                {
                    // Text associated with the course or course control (before)
                    AddTextLine(list, control.descTextBefore, controlView.courseControlIds[0], controlView.controlId, DescriptionLine.TextLineKind.BeforeControl);
                    if (courseControl != null)
                    {
                        AddTextLine(list, courseControl.descTextBefore, controlView.courseControlIds[0], controlView.controlId, DescriptionLine.TextLineKind.BeforeCourseControl);
                    }

                    // The control itself.
                    if (control.kind == ControlPointKind.Finish ||
                        control.kind == ControlPointKind.CrossingPoint ||
                        control.kind == ControlPointKind.MapIssue)
                    {
                        line = GetDirectiveLine(kind, controlView, iLine > 0 ? courseView.ControlViews[iLine - 1] : null);
                    }
                    else
                    {
                        line = GetRegularLine(kind, scoreColumn, controlView, descriptionKey);
                    }
                    Debug.Assert(line != null);
                    list.Add(line);

                    // Text associated with the course or course control (after)
                    if (courseControl != null)
                    {
                        AddTextLine(list, courseControl.descTextAfter, controlView.courseControlIds[0], controlView.controlId, DescriptionLine.TextLineKind.AfterCourseControl);
                    }
                    AddTextLine(list, control.descTextAfter, controlView.courseControlIds[0], controlView.controlId, DescriptionLine.TextLineKind.AfterControl);
                }

                // Add any map exchange lines.
                if (courseView.Kind == CourseView.CourseViewKind.Normal || courseView.Kind == CourseView.CourseViewKind.AllVariations)
                {
                    if (controlNext != null && controlNext.kind == ControlPointKind.MapExchange)
                    {
                        line = GetMapExchangeLine(controlView, courseView.ControlViews[controlView.legTo[0]]);
                        list.Add(line);
                    }
                    else if (courseControl != null && courseControl.exchange && control.kind != ControlPointKind.MapExchange && controlPrev != null)
                    {
                        line = GetMapExchangeAtControlLine(controlView);
                        list.Add(line);
                    }
                }

                // Do the leg (if any).
                if (controlView.legTo != null && controlView.legTo.Length > 0)
                {
                    Id <Leg> legId = controlView.legId[0];
                    Leg      leg   = (legId.IsNotNone) ? eventDB.GetLeg(legId) : null;
                    if (FilterLeg(kind, control, controlNext, leg))
                    {
                        line = GetMarkedRouteLine(controlView, courseView.ControlViews[controlView.legTo[0]], legId);
                        Debug.Assert(line != null);
                        list.Add(line);
                    }
                }
            }

            // Add the key if desired.
            if (createKey)
            {
                foreach (string symbolId in descriptionKey.Keys)
                {
                    line          = new DescriptionLine();
                    line.kind     = DescriptionLineKind.Key;
                    line.boxes    = new object[2];
                    line.boxes[0] = symbolDB[symbolId];
                    line.boxes[1] = descriptionKey[symbolId];

                    list.Add(line);
                }
            }

            // And we're done!
            return(list.ToArray());
        }
Esempio n. 39
0
        /// <summary>
        /// Matches the curve to the reference curve
        /// </summary>
        public void Match()
        {
            if (this.Continuity == CONTINUITY.None)
            {
                return;
            }

            if (this.Continuity == CONTINUITY.Flow || this.Continuity == CONTINUITY.Flow2)
            {
                throw new NotSupportedException("Flow is not supported yet");
            }

            // Make sure Curve has sufficent cps
            MatchingCurve.IncreaseDegree((int)this.Continuity);

            MatchingCurve.Domain = new Interval(0, 1);
            if (this.ReverseMatchingCurve)
            {
                MatchingCurve.Reverse();
            }

            // POSITIONAL MATCHING
            ControlPoint p0 = MatchingCurve.Points[0];
            Point3d      pointAtParameter = Reference.PointAt(_t);

            p0.Location = pointAtParameter;
            SetPointOfMatchingCurve(0, p0);

            if (this.Continuity == CONTINUITY.Position)
            {
                return;
            }

            // TANGENCY MATCHING
            int    c  = (int)this.Continuity + 1;
            double lf = MatchingCurve.GetLength() / c;

            ControlPoint p1 = MatchingCurve.Points[1];
            Vector3d     tangentAtParameter = Reference.TangentAt(_t);

            if (this.ReverseReference)
            {
                tangentAtParameter *= -1;
            }
            tangentAtParameter.Unitize();
            p1.Location = pointAtParameter + (tangentAtParameter * this.FactorTangency * lf);

            SetPointOfMatchingCurve(1, p1);

            if (this.Continuity == CONTINUITY.Tangency)
            {
                return;
            }

            // CURVATURE MATCHING
            // move p2 tangent to p1, the location of p2 in this direction does not affect the curvature continuity
            ControlPoint p2         = MatchingCurve.Points[2];
            double       curvatureA = Reference.CurvatureAt(_t).Length;

            p2.Location = p1.Location + (tangentAtParameter * this.FactorCurvature);

            // Update the curve
            SetPointOfMatchingCurve(2, p2);

            // Abort if the curvature is zero and keep it tangent instead
            if (Math.Abs(curvatureA) < Rhino.RhinoMath.ZeroTolerance)
            {
                return;
            }

            // Move orthogonal in curvature direction and measure the curvature
            double   tM = MatchingCurve.Domain.Min;
            Vector3d normalAtParameter = Reference.CurvatureAt(_t);

            normalAtParameter.Unitize();
            ControlPoint p2Copy      = p2;                                   // Copy the cp to remove from it later
            double       curvatureB0 = MatchingCurve.CurvatureAt(tM).Length; // measure curvature

            p2.Location = p2.Location + normalAtParameter;                   // move by the normalized curvature vector
            SetPointOfMatchingCurve(2, p2);                                  // update the curve

            double curvatureB1    = MatchingCurve.CurvatureAt(tM).Length;    // measure curvature again
            double deltaCurvature = curvatureB1 - curvatureB0;               // compute the delta of both measurements

            // compute the required length of the curvature vector to move p2 so that both curvatures match
            double factorN = 0.0;

            if (Math.Abs(deltaCurvature) >= Rhino.RhinoMath.ZeroTolerance)
            {
                factorN = curvatureA / deltaCurvature;
            }

            p2.Location = p2Copy.Location + (normalAtParameter * factorN);
            SetPointOfMatchingCurve(2, p2); // final update

            // Todo: Continue for Flow and Flow2
            // Idea: Also retreive the curvature at t + 0.0001 from the reference.
            //       Remap the length of both curvature vectors to an arbitry length
            //       Move points there, create a vector, which equals the curvature graphs tangent at t
            //       Do the same for the matching curve.
            //       Move the fourth point (p3), first in reference tangent direction and then in normal direction
            //       until both tangents are equal. Should be linear?! So do the same ratio-calculation as in curvature
            //       matching operation.
            //if (this.Continuity == CONTINUITY.Curvature) return;
        }
Esempio n. 40
0
 /// <summary>
 /// Adds the given alpha control point to the list of alpha control points.
 /// </summary>
 /// <param name="ap"></param>
 public void addAlphaPoint(ControlPoint ap)
 {
     alphaPoints.Add(ap);
     transferFunctionChanged = true;
 }
Esempio n. 41
0
        private void loadBarLines()
        {
            var taikoPlayfield = Playfield as TaikoPlayfield;

            if (taikoPlayfield == null)
            {
                return;
            }

            TaikoHitObject lastObject  = Beatmap.HitObjects[Beatmap.HitObjects.Count - 1];
            double         lastHitTime = 1 + (lastObject as IHasEndTime)?.EndTime ?? lastObject.StartTime;

            var timingPoints = Beatmap.TimingInfo.ControlPoints.FindAll(cp => cp.TimingChange);

            if (timingPoints.Count == 0)
            {
                return;
            }

            int currentIndex = 0;

            while (currentIndex < timingPoints.Count && Precision.AlmostEquals(timingPoints[currentIndex].BeatLength, 0))
            {
                currentIndex++;
            }

            double time          = timingPoints[currentIndex].Time;
            double measureLength = timingPoints[currentIndex].BeatLength * (int)timingPoints[currentIndex].TimeSignature;

            // Find the bar line time closest to 0
            time -= measureLength * (int)(time / measureLength);

            // Always start barlines from a positive time
            while (time < 0)
            {
                time += measureLength;
            }

            int currentBeat = 0;

            while (time <= lastHitTime)
            {
                ControlPoint current = timingPoints[currentIndex];

                if (time > current.Time || current.OmitFirstBarLine)
                {
                    bool isMajor = currentBeat % (int)current.TimeSignature == 0;

                    var barLine = new BarLine
                    {
                        StartTime = time,
                    };

                    barLine.ApplyDefaults(Beatmap.TimingInfo, Beatmap.BeatmapInfo.Difficulty);

                    taikoPlayfield.AddBarLine(isMajor ? new DrawableBarLineMajor(barLine) : new DrawableBarLine(barLine));

                    currentBeat++;
                }

                double bl = current.BeatLength;

                if (bl < 800)
                {
                    bl *= (int)current.TimeSignature;
                }

                time += bl;

                if (currentIndex + 1 >= timingPoints.Count || time < timingPoints[currentIndex + 1].Time)
                {
                    continue;
                }

                currentBeat = 0;
                currentIndex++;
                time = timingPoints[currentIndex].Time;
            }
        }
Esempio n. 42
0
 /// <summary>
 /// Adds the given color control point to the list of color control points.
 /// </summary>
 /// <param name="cp"></param>
 public void addColorPoint(ControlPoint cp)
 {
     colorPoints.Add(cp);
     transferFunctionChanged = true;
 }
        private Point GetFivePointNurbsAverage(int[,] indices)
        {
            var knots = new Knot[] {
                        new Knot(0, 4),
                        new Knot(1, 4)
                    };

            var controlPoints = new ControlPoint[] {
                        new ControlPoint(Point.Create(tabAngles[indices[0,0]][indices[0,1]], GetSpanAt(indices[0,0], indices[0,1]),0), 1),
                        new ControlPoint(Point.Create(tabAngles[indices[1,0]][indices[1,1]], GetSpanAt(indices[1,0], indices[1,1]),0), 1),
                        new ControlPoint(Point.Create(tabAngles[indices[2,0]][indices[2,1]], GetSpanAt(indices[2,0], indices[2,1]),0), 1),
                        new ControlPoint(Point.Create(tabAngles[indices[3,0]][indices[3,1]], GetSpanAt(indices[3,0], indices[3,1]),0), 1),
                        new ControlPoint(Point.Create(tabAngles[indices[4,0]][indices[4,1]], GetSpanAt(indices[4,0], indices[4,1]),0), 1)
                    };

            NurbsData data = new NurbsData(5, false, false, knots);
            NurbsCurve curve = NurbsCurve.CreateFromControlPoints(data, controlPoints);

            Point midpoint = curve.Evaluate(0.5).Point;
            return midpoint;
        }
Esempio n. 44
0
 /// <summary>
 /// Removes the given alpha control point from the list of alpha control points.
 /// </summary>
 /// <param name="ap"></param>
 public void removeAlphaPoint(ControlPoint ap)
 {
     alphaPoints.Remove(ap);
     transferFunctionChanged = true;
 }
Esempio n. 45
0
        //指定位置に制御点を追加
        private ControlPoint AddControlPoint(Point addLocation)
        {
            ControlPoint newControlPoint = new ControlPoint(addLocation.X, addLocation.Y, this);

            //リストの最後に制御点を追加
            controlPointList.Add(newControlPoint);

            //コンテキストメニューを設定
            newControlPoint.ContextMenuStrip = controlPointMenu;

            //制御点を画面に反映
            this.containerPanel.Controls.Add(newControlPoint);
            newControlPoint.BringToFront();
            newControlPoint.EnableCourseDraw = true;

            return newControlPoint;
        }
Esempio n. 46
0
 /// <summary>
 /// Removes the given color control points from the list of color control points.
 /// </summary>
 /// <param name="cp"></param>
 public void removeColorPoint(ControlPoint cp)
 {
     colorPoints.Remove(cp);
     transferFunctionChanged = true;
 }
Esempio n. 47
0
        //制御点を削除
        private void RemoveControlPoint(ControlPoint controlPoint)
        {
            //リストから制御点を削除
            controlPointList.Remove(controlPoint);

            //画面から制御点を削除
            this.containerPanel.Controls.Remove(controlPoint);

            //選択されていたら選択解除
            if (this.activeControlPoint == controlPoint)
            {
                this.ControlPointSelected(null);
            }

            controlPoint.Dispose();
        }
Esempio n. 48
0
 /// <summary>
 /// Sets the activeControlPoint reference to null so that this point is no longer modified.
 /// </summary>
 public void finalizeActivePoint()
 {
     activeControlPoint = null;
 }
Esempio n. 49
0
    public void InitInterpolators(int arm, List<ControlPoint> controlPoints, float tension, float continuity, float bias)
    {
        ControlPoint[] controlPointsEE = new ControlPoint[controlPoints.Count];
        for (int i = 0; i < controlPoints.Count; i++)
            controlPointsEE[i] = controlPoints[i];

        SIee[arm] = new TCBSpline(controlPointsEE, tension, continuity, bias);
    }
Esempio n. 50
0
 /// <summary>
 /// Updates the all fields in activeControlPoint by reference.
 /// </summary>
 /// <param name="newActivePoint"></param>
 public void updateActivePoint(ControlPoint newActivePoint)
 {
     activeControlPoint.updateColor(newActivePoint.color);
     activeControlPoint.isovalue = newActivePoint.isovalue;
     transferFunctionChanged     = true;
 }
Esempio n. 51
0
 public void Copy( ControlPoint from )
 {
     position = from.position;
     tangent = from.tangent;
     weight = from.weight;
 }
Esempio n. 52
0
 private static void parseTimingPointsSection(EditorBeatmap beatmap, StreamReader reader)
 {
     reader.ParseSectionLines(line => beatmap.controlPoints.Add(ControlPoint.Parse(line)));
     beatmap.controlPoints.Sort();
 }
Esempio n. 53
0
 private void DeviceRemoved(ControlPoint.CpDeviceList aList, ControlPoint.CpDevice aDevice)
 {
     lock (this)
     {
         if (!iListFrozen)
         {
             PrintDeviceInfo("Removed", aDevice);
             string udn = aDevice.Udn();
             int count = iDeviceList.Count;
             for (int i = 0; i < count; i++)
             {
                 if (iDeviceList[i].Udn() == udn)
                 {
                     iDeviceList[i].RemoveRef();
                     iDeviceList.RemoveAt(i);
                     break;
                 }
             }
         }
     }
 }
 private void DrawPoint(ControlPoint p, Color color)
 {
     var x1 = p.X - PointSizeHalf;
     var y1 = p.Y - PointSizeHalf;
     var x2 = p.X + PointSizeHalf;
     var y2 = p.Y + PointSizeHalf;
     writeableBmp.DrawRectangle(x1, y1, x2, y2, color);
 }
Esempio n. 55
0
 /// <summary>
 /// Adds a control point to the curve.
 ///
 /// No two control points have the same input value.
 ///
 /// @throw System.ArgumentException if two control points have the same input value.
 ///
 /// It does not matter which order these points are added.
 /// </summary>
 /// <param name="point"></param>
 public void AddControlPoint(ControlPoint point)
 {
     if(_controlPoints.Contains(point)) {
         throw new ArgumentException(String.Format("Cannont insert ControlPoint({0}, {1}) : Each control point is required to contain a unique input value", point.Input, point.Output));
     }//end if
     else {
         _controlPoints.Add(point);
         SortControlPoints();
     }//end else
 }
 private void Image_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
 {
     // Only add new control point is [DEL] wasn't pressed
     if (!isInDelete && PickedPoint == null)
     {
         points.Add(GetMousePoint(e));
     }
     PickedPoint = null;
     isInDelete = false;
     Draw();
 }
 private void RemovePickedPointPoint()
 {
     if (PickedPoint != null)
     {
         points.Remove(PickedPoint);
         PickedPoint = null;
         isInDelete = true;
         Draw();
     }
 }
Esempio n. 58
0
    public void InitInterpolators(float tension, float continuity, float bias)
    {
        //Keyframe to time
        ControlPoint[] controlPointsKF = new ControlPoint[Keys.Length];
        for (int i = 0; i < Keys.Length; i++)
        {
            controlPointsKF[i]          = new ControlPoint();
            controlPointsKF[i].Point    = new Vector3(Keys[i].FrameNo, 0, 0);
            controlPointsKF[i].TangentI = Vector3.zero;
            controlPointsKF[i].TangentO = Vector3.zero;
            controlPointsKF[i].Time     = Keys[i].Time;
        }

        SIKeyTime = new TCBSpline(controlPointsKF, 0, 0, 0);



        for (int arm = 0; arm < 2; arm++)
        {
            //End effector
            ControlPoint[] controlPointsEE = new ControlPoint[Keys.Length];
            for (int i = 0; i < Keys.Length; i++)
            {
                controlPointsEE[i]          = new ControlPoint();
                controlPointsEE[i].Point    = Keys[i].EePos[arm];
                controlPointsEE[i].TangentI = Vector3.zero;
                controlPointsEE[i].TangentO = Vector3.zero;
                controlPointsEE[i].Time     = Keys[i].Time;
            }

            SIee[arm] = new TCBSpline(controlPointsEE, tension, continuity, bias);

            //Elbow Rotation interpolator
            ControlPoint[] controlPointsEA = new ControlPoint[Keys.Length];
            for (int i = 0; i < Keys.Length; i++)
            {
                controlPointsEA[i]          = new ControlPoint();
                controlPointsEA[i].Rotation = Keys[i].ElbowRot[arm];
                controlPointsEA[i].TangentI = Vector3.zero;
                controlPointsEA[i].TangentO = Vector3.zero;
            }


            SIElbowAngle[arm] = new TCBSpline(controlPointsEA, tension, continuity, bias);

            /*
             * //Elbow position
             * ControlPoint[] controlPointsEP = new ControlPoint[Keys.Length];
             * for (int i = 0; i < Keys.Length; i++) {
             *  controlPointsEP[i] = new ControlPoint();
             *  controlPointsEP[i].Point = Keys[i].ElbowPos[arm];
             *  controlPointsEP[i].TangentI = Vector3.zero;
             *  controlPointsEP[i].TangentO = Vector3.zero;
             *  controlPointsEP[i].FrameNo = Keys[i].FrameNo;
             * }
             *
             * //Rotation interpolator
             *
             * SIElbowPos[arm] = new TCBSpline(controlPointsEP, tension, continuity, bias);
             */
        }
    }
 private void Image_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
 {
     // Pick control point
     var mp = GetMousePoint(e);
     PickedPoint = (from p in points
                    where p.X > mp.X - PointSizeHalf && p.X < mp.X + PointSizeHalf
                       && p.Y > mp.Y - PointSizeHalf && p.Y < mp.Y + PointSizeHalf
                    select p).FirstOrDefault();
     Draw();
 }
Esempio n. 60
0
        public override void LeftButtonDrag(Pane pane, PointF location, PointF locationStart, float pixelSize, ref bool displayUpdateNeeded)
        {
            Debug.Assert(pane == Pane.Map);

            currentLocation = location;

            // Update the highlight.
            courseObjectDrag = ((CourseObj)courseObjectStart.Clone());
            courseObjectDrag.Offset(location.X - startDrag.X, location.Y - startDrag.Y);

            // If we're dragging a control in a course (not all controls) then add additional highlights for the leg(s) to/from the control.
            if (AreDraggingControlPoint() && courseObjectStart.courseControlId.IsNotNone)
            {
                ControlPoint control    = eventDB.GetControl(courseObjectStart.controlId);
                CourseView   courseView = selectionMgr.ActiveCourseView;

                // Find index of this course control in the course view.
                int index;
                for (index = 0; index < courseView.ControlViews.Count; ++index)
                {
                    if (courseView.ControlViews[index].courseControlIds.Contains(courseObjectStart.courseControlId))
                    {
                        break;
                    }
                }

                if (index < courseView.ControlViews.Count)
                {
                    // Get previous and next controls.
                    int prevIndex = courseView.GetPrevControl(index), nextIndex = courseView.GetNextControl(index);
                    Id <CourseControl> prevCourseControl = (prevIndex >= 0) ? courseView.ControlViews[prevIndex].courseControlIds[0] : Id <CourseControl> .None;
                    Id <CourseControl> nextCourseControl = (nextIndex >= 0) ? courseView.ControlViews[nextIndex].courseControlIds[0] : Id <CourseControl> .None;

                    // Get additional highlights to and from those controls.
                    additionalHighlights = AddControlMode.CreateLegHighlights(eventDB, ((PointCourseObj)courseObjectDrag).location, courseObjectDrag.controlId, control.kind, prevCourseControl, nextCourseControl,
                                                                              courseView.CourseObjRatio(courseObjectStart.appearance), courseObjectStart.appearance);

                    // If we're dragging the start, update the angle of the start appropriately.
                    if ((control.kind == ControlPointKind.Start || control.kind == ControlPointKind.MapExchange || control.kind == ControlPointKind.MapIssue) &&
                        additionalHighlights.Length > 0 &&
                        (courseView.Kind == CourseView.CourseViewKind.Normal || courseView.Kind == CourseView.CourseViewKind.AllVariations))
                    {
                        SymPath  pathFromStart = ((LineCourseObj)additionalHighlights[additionalHighlights.Length - 1]).path;
                        PointF[] pts           = pathFromStart.FlattenedPoints;
                        double   angleOut      = Math.Atan2(pts[1].Y - pts[0].Y, pts[1].X - pts[0].X);
                        if (!double.IsNaN(angleOut))
                        {
                            float angleInDegrees = (float)Geometry.RadiansToDegrees(angleOut);
                            if (control.kind == ControlPointKind.MapIssue)
                            {
                                ((MapIssueCourseObj)courseObjectDrag).orientation = angleInDegrees;
                            }
                            else
                            {
                                ((StartCourseObj)courseObjectDrag).orientation = angleInDegrees;
                            }
                        }
                    }
                }
            }

            displayUpdateNeeded = true;
        }