Inheritance: MonoBehaviour
Beispiel #1
0
        private void LoadButton_Click(object sender, EventArgs e)
        {
            OpenFileDialog dialog = new OpenFileDialog();

            dialog.Filter = "XML file | *.xml";
            if (dialog.ShowDialog() == DialogResult.OK)
            {
                var serializer = new XmlSerializer(typeof(List <Point>));
                using (var stream = File.OpenRead(dialog.FileName))
                {
                    var points = (List <Point>)(serializer.Deserialize(stream));
                    ControlPoints.Clear();
                    foreach (Point p in points)
                    {
                        ControlPoints.Add(new Vertex(p.X, p.Y));
                    }

                    Start       = ControlPoints[0];
                    End         = ControlPoints[ControlPoints.Count - 1];
                    Start.Size  = 11;
                    End.Size    = 11;
                    Start.Color = Color.DarkRed;
                    End.Color   = Color.DarkRed;
                    RefreshCanvas();
                }
            }
        }
Beispiel #2
0
        private void CalculatePath()
        {
            calculatedPath.Clear();

            // Sliders may consist of various subpaths separated by two consecutive vertices
            // with the same position. The following loop parses these subpaths and computes
            // their shape independently, consecutively appending them to calculatedPath.

            int start = 0;
            int end   = 0;

            for (int i = 0; i < ControlPoints.Length(); ++i)
            {
                end++;

                if (i == ControlPoints.Length() - 1 || ControlPoints[i] == ControlPoints[i + 1] && i != ControlPoints.Length() - 2)
                {
                    List <Vector2> cpSpan = ControlPoints.GetRange(start, end - start);

                    foreach (Vector2 t in CalculateSubpath(cpSpan))
                    {
                        if (calculatedPath.Count == 0 || calculatedPath.Last() != t)
                        {
                            calculatedPath.Add(t);
                        }
                    }

                    start = end;
                }
            }
        }
Beispiel #3
0
        internal override void load()
        {
            base.load();

            Music.sharedInstance.play(GameMusic.MusicType.menu);

            gameWorld.loadStars();

            PlayerData playerData = MemoryCard.current.playerData;

            buttonBack = new Button("button_55x55", 8, 604, HorizontalAlignment.left, VerticalAlignment.bottom);
            buttonBack.setIcon("Back");
            buttonBack.set(GameColors.controlBlue, BlendState.Additive);
            addChild(buttonBack);


            control      = new Control("box_xx89", 0.0f, -2.0f);
            control.size = new Vector2(currentSize.X, control.size.Y);
            addChild(control);

            ControlPremiumPoints controlPremiumPoints = new ControlPremiumPoints(8, 15);

            controlPremiumPoints.setLabelText(playerData.premiumPoints);
            addChild(controlPremiumPoints);

            ControlPoints controlPoints = new ControlPoints(223, 15);

            controlPoints.setLabelText(playerData.points);
            addChild(controlPoints);
        }
Beispiel #4
0
        private List <Vector2> CalculateSubpath(List <Vector2> subControlPoints)
        {
            switch (Type)
            {
            case PathType.Linear:
                return(PathApproximator.ApproximateLinear(subControlPoints));

            case PathType.PerfectCurve:
                //we can only use CircularArc iff we have exactly three control points and no dissection.
                if (ControlPoints.Length() != 3 || subControlPoints.Length() != 3)
                {
                    break;
                }

                // Here we have exactly 3 control points. Attempt to fit a circular arc.
                List <Vector2> subpath = PathApproximator.ApproximateCircularArc(subControlPoints);

                // If for some reason a circular arc could not be fit to the 3 given points, fall back to a numerically stable bezier approximation.
                if (subpath.Count == 0)
                {
                    break;
                }

                return(subpath);

            case PathType.Catmull:
                return(PathApproximator.ApproximateCatmull(subControlPoints));
            }

            return(PathApproximator.ApproximateBezier(subControlPoints));
        }
        /// <summary>
        /// Adds the given point to the shape.
        /// </summary>
        /// <param name="point">The new <c>SKPoint</c> to add.</param>
        public void AddPoint(SKPoint point)
        {
            // is this the first point added?
            if (Points.Count > 0)
            {
                // No, grab first point
                var firstPoint = Points[0];

                // Is the new point within five pixels of the first point?
                if (point.X > (firstPoint.X - 5) && point.X < (firstPoint.X + 5) &&
                    point.Y > (firstPoint.Y - 5) && point.Y < (firstPoint.Y + 5))
                {
                    // Yes, close the shape and complete editing
                    point = firstPoint;
                    State = KimonoShapeState.Finalizing;
                }
            }

            // Add point and recalculate bounds
            Points.Add(point);
            RecalculateVectorBounds();

            // Are we in the editing mode?
            if (State == KimonoShapeState.Editing || State == KimonoShapeState.Finalizing)
            {
                // Add a new drag handle for the new point
                ControlPoints.Add(new KimonoHandle(point.X - KimonoHandle.DrawOffset, point.Y - KimonoHandle.DrawOffset));
            }
        }
Beispiel #6
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Evaluator1D"/> class.
 /// </summary>
 /// <param name="points">The points.</param>
 public Evaluator1D(int points)
 {
     //    Create a single line of points.
     ControlPoints.CreateGrid(points, 1);
     Name = "1D Evaluator (Bezier Curve)";
     Transformation.RotateX = 180;
 }
Beispiel #7
0
        /// <summary>
        /// Calculates the partial v derivation of the <see cref="BSplineSurface"/>.
        /// </summary>
        /// <param name="u">Parameter u.</param>
        /// <param name="v">Parameter v.</param>
        /// <returns>The partial v derivation.</returns>
        public override xyz vDerivation(double u, double v)
        {
            if ((UKnots == null) || (VKnots == null))
            {
                return(new xyz(0, 0, 0));
            }
            Utils.SplineExValue[] VCoeffs = Utils.CoeffSplineEx(VKnots, ControlPoints.GetLength(1), VDegree, VPeriodicity, v);
            double[] UCoeffs  = Utils.CoeffSpline(UKnots, ControlPoints.GetLength(0), UDegree, UPeriodicity, u);
            double   WDerived = 0;
            double   W        = 0;

            for (int i = 0; i < UCoeffs.Length; i++)
            {
                for (int j = 0; j < VCoeffs.Length; j++)
                {
                    W        = W + Weights[i, j] * UCoeffs[i] * VCoeffs[j].Value;
                    WDerived = WDerived + Weights[i, j] * UCoeffs[i] * VCoeffs[j].Derivation;
                }
            }


            xyz Result = new xyz();

            for (int i = 0; i < ControlPoints.GetLength(0); i++)
            {
                for (int k = 0; k < ControlPoints.GetLength(1); k++)
                {
                    Result = Result + ControlPoints[i, k] * (Weights[i, k] * UCoeffs[i] * (VCoeffs[k].Derivation * W - WDerived * VCoeffs[k].Value) / (W * W));
                }
            }
            return(Base.Absolut(Result) - Base.BaseO);
        }
Beispiel #8
0
        /// <summary>
        /// Render to the provided instance of OpenGL.
        /// </summary>
        /// <param name="gl">The OpenGL instance.</param>
        /// <param name="renderMode">The render mode.</param>
        public override void Render(OpenGL gl, Core.RenderMode renderMode)
        {
            base.Render(gl, renderMode);

            //    Begin drawing a NURBS surface.
            gl.BeginSurface(nurbsRenderer);

            //    Draw the surface.
            gl.NurbsSurface(nurbsRenderer,                //    The internal nurbs object.
                            sKnots.Length,                //    Number of s-knots.
                            sKnots,                       //    The s-knots themselves.
                            tKnots.Length,                //    The number of t-knots.
                            tKnots,                       //    The t-knots themselves.
                            ControlPoints.Width * 3,      //    The size of a row of control points.
                            3,                            //    The size of a control points.
                            ControlPoints.ToFloatArray(), //    The control points.
                            ControlPoints.Width,          //    The order, i.e degree + 1.
                            ControlPoints.Height,         //    The order, i.e degree + 1.
                            OpenGL.GL_MAP2_VERTEX_3);     //    Type of data to generate.

            //    End the surface.
            gl.EndSurface(nurbsRenderer);

            //    Draw the control points.
            ControlPoints.Draw(gl, DrawControlPoints, DrawControlGrid);
        }
        /// <summary>
        /// Removes a control point and its data.
        /// </summary>
        /// <param name="controlId"></param>
        public void RemoveDragPoint(int controlId)
        {
            var idx = ControlPoints.FindIndex(controlPoint => controlPoint.ControlId == controlId);

            if (idx < 0)
            {
                return;
            }
            var removalOk = !ControlPoints[idx].DragPoint.IsLocked;

            if (!removalOk)
            {
                removalOk = EditorUtility.DisplayDialog("Locked DragPoint Removal", "This drag point is locked!\nAre you really sure you want to remove it?", "Yes", "No");
            }
            if (!removalOk)
            {
                return;
            }
            var dragPoints = DragPointInspector.DragPoints.ToList();

            dragPoints.RemoveAt(idx);
            DragPointInspector.DragPoints = dragPoints.ToArray();

            RebuildControlPoints();
        }
Beispiel #10
0
        /// <summary>
        /// Render to the provided instance of OpenGL.
        /// </summary>
        /// <param name="gl">The OpenGL instance.</param>
        /// <param name="renderMode">The render mode.</param>
        public override void Render(OpenGL gl, RenderMode renderMode)
        {
            //    Create the evaluator.
            gl.Map1(OpenGL.GL_MAP1_VERTEX_3,       //    Use and produce 3D points.
                    0,                             //    Low order value of 'u'.
                    1,                             //    High order value of 'u'.
                    3,                             //    Size (bytes) of a control point.
                    ControlPoints.Width,           //    Order (i.e degree plus one).
                    ControlPoints.ToFloatArray()); //    The control points.

            //    Enable the type of evaluator we wish to use.
            gl.Enable(OpenGL.GL_MAP1_VERTEX_3);

            //    Beging drawing a line strip.
            gl.Begin(OpenGL.GL_LINE_STRIP);

            //    Now draw it.
            for (int i = 0; i <= segments; i++)
            {
                gl.EvalCoord1((float)i / segments);
            }

            gl.End();

            //    Draw the control points.
            ControlPoints.Draw(gl, DrawControlPoints, DrawControlGrid);
        }
Beispiel #11
0
        /// <summary>
        /// Adds a new control point to the scene view and its drag point data
        /// to the game object.
        /// </summary>
        public void AddDragPointOnTraveller()
        {
            if (CurveTravellerControlPointIdx < 0 || CurveTravellerControlPointIdx >= ControlPoints.Count)
            {
                return;
            }

            var dragPoint = new DragPointData(DragPointEditable.GetDragPoints()[CurveTravellerControlPointIdx])
            {
                IsLocked = false
            };

            var   newIdx            = CurveTravellerControlPointIdx + 1;
            float ratio             = (float)newIdx / (DragPointEditable.GetDragPoints().Length - 1);
            var   dragPointPosition = Transform.worldToLocalMatrix.MultiplyPoint(CurveTravellerPosition);

            dragPointPosition -= DragPointEditable.GetEditableOffset();
            dragPointPosition -= DragPointEditable.GetDragPointOffset(ratio);
            dragPoint.Vertex   = dragPointPosition.ToVertex3D();
            var dragPoints = DragPointEditable.GetDragPoints().ToList();

            dragPoints.Insert(newIdx, dragPoint);
            DragPointEditable.SetDragPoints(dragPoints.ToArray());

            ControlPoints.Insert(newIdx,
                                 new ControlPoint(
                                     DragPointEditable.GetDragPoints()[newIdx],
                                     GUIUtility.GetControlID(FocusType.Passive),
                                     newIdx,
                                     ratio
                                     ));
            RebuildControlPoints();
        }
Beispiel #12
0
        protected override DxfEntity PostParse()
        {
            Debug.Assert((_controlPointX.Count == _controlPointY.Count) && (_controlPointX.Count == _controlPointZ.Count));
            for (int i = 0; i < _controlPointX.Count; i++)
            {
                var weight = _controlPointX.Count == _weights.Count ? _weights[i] : 1.0;
                ControlPoints.Add(new DxfControlPoint(new DxfPoint(_controlPointX[i], _controlPointY[i], _controlPointZ[i]), weight));
            }

            _controlPointX.Clear();
            _controlPointY.Clear();
            _controlPointZ.Clear();

            Debug.Assert((_fitPointX.Count == _fitPointY.Count) && (_fitPointX.Count == _fitPointZ.Count));
            for (int i = 0; i < _fitPointX.Count; i++)
            {
                FitPoints.Add(new DxfPoint(_fitPointX[i], _fitPointY[i], _fitPointZ[i]));
            }

            _fitPointX.Clear();
            _fitPointY.Clear();
            _fitPointZ.Clear();

            return(this);
        }
Beispiel #13
0
        protected void CalculateAngle()
        {
            //Create line from the base of the whisker to the point on the whisker
            IWhiskerPoint baseWhiskerPoint = ControlPoints.Last();

            BasePoint = new Point(baseWhiskerPoint.XRatio * VideoWidth, baseWhiskerPoint.YRatio * VideoHeight);
            Point  anglePoint;
            Vector gradient;

            if (TValue == 1)
            {
                //If TValue == 1 (Point on whisker == base), calculate gradient at TValue = 1
                gradient      = GetBezierGradientVideoSize();
                gradient     *= -1;
                anglePoint    = BasePoint;
                anglePoint.X += gradient.X;
                anglePoint.Y += gradient.Y;
            }
            else
            {
                anglePoint = GetTValuePoint();
                gradient   = new Vector(anglePoint.X - BasePoint.X, anglePoint.Y - BasePoint.Y);
            }

            //Create line which will determine angle
            gradient.Normalize();
            TargetPoint = anglePoint;

            AngleLine = gradient;
            Angle     = AngleType.CalculateAngle(AngleLine);
        }
Beispiel #14
0
        public void CalculateCurve()
        {
            if (ControlPoints.Count == 0)
            {
                BezierPoints = null;
                return;
            }

            var n = ControlPoints.Count - 1;

            var controlPointArray = ControlPoints.ToArray();

            BezierPoints    = new BezierPoint[Count];
            BezierPoints[0] = controlPointArray[0];

            var calcs = 1;

            for (var t = 1 / (decimal)Count; t <= ((decimal)Count - 1) / Count; t += 1 / (decimal)Count)
            {
                var result = new BezierPoint();

                for (var i = 0; i <= n; i++)
                {
                    result += (CalculateBinomial(n, i) * Math.Pow((double)t, i) * Math.Pow(1 - (double)t, n - i)) * controlPointArray[i];
                }

                BezierPoints[calcs++] = result;
            }

            BezierPoints[Count - 1] = controlPointArray[n];
        }
Beispiel #15
0
        public override string ToString()
        {
            var sb = new StringBuilder(); //stringbuilder for performance

            sb.Append(base.ToString());
            sb.Append(",");
            sb.Append(SliderType.ToString().Substring(0, 1));
            sb.Append("|");
            sb.Append(ControlPoints.Skip(1).Select(c => $"{c.XForHitobject}:{c.YForHitobject}").ToString("|"));
            sb.Append(",");
            sb.Append(SegmentCount);
            sb.Append(",");
            sb.Append(Length);

            //TODO check if additions should be added
            if (PointHitsounds.All(p => p.IsDefault()))
            {
                return(sb.ToString());
            }
            sb.Append(",");
            sb.Append(PointHitsounds.Select(p => (int)p.SoundType).ToString("|"));
            sb.Append(",");
            sb.Append(PointHitsounds.Select(p => "" + (int)p.SampleSet + ":" + (int)p.AdditionSampleSet).ToString("|"));
            sb.Append(",");
            sb.Append(AdditionsForString);
            return(sb.ToString());
        }
Beispiel #16
0
        // Create the control points for this Skin2D
        public void CreateControlPoints(SkinnedMeshRenderer skin)
        {
            if (skin.sharedMesh != null)
            {
                controlPoints = new ControlPoints.Point[skin.sharedMesh.vertices.Length];

                if (points == null)
                {
                    points = gameObject.GetComponent <ControlPoints>();

                    if (points == null)
                    {
                        points = gameObject.AddComponent <ControlPoints>();
                    }
                }

                for (int i = 0; i < skin.sharedMesh.vertices.Length; i++)
                {
                    Vector3 originalPos = skin.sharedMesh.vertices[i];

                    controlPoints[i]       = new ControlPoints.Point(originalPos);
                    controlPoints[i].index = i;
                    points.SetPoint(controlPoints[i]);
                }
            }
            else
            {
                Debug.LogError("There is no shared mesh for this Skin2D: " + name);
            }
        }
        public void Interpolate(List <Vector2> segmentPoints, float curvatureScale)
        {
            ControlPoints.Clear();

            if (segmentPoints.Count == 0)
            {
                segmentPoints.Add(Vector2.zero);
            }

            if (segmentPoints.Count == 1)
            {
                segmentPoints.Add(segmentPoints[0]);
            }

            Vector3 p0;
            Vector3 p1;
            Vector3 p2;
            Vector3 q0;
            Vector3 q1;
            Vector3 tangent;

            for (int i = 0; i < segmentPoints.Count; i++)
            {
                if (i == 0)
                {
                    p1      = segmentPoints[i];
                    p2      = segmentPoints[i + 1];
                    tangent = (p2 - p1);
                    q1      = p1 + curvatureScale * tangent;

                    ControlPoints.Add(p1);
                    ControlPoints.Add(q1);
                }
                else if (i == segmentPoints.Count - 1)
                {
                    p0      = segmentPoints[i - 1];
                    p1      = segmentPoints[i];
                    tangent = (p1 - p0);
                    q0      = p1 - curvatureScale * tangent;

                    ControlPoints.Add(q0);
                    ControlPoints.Add(p1);
                }
                else
                {
                    p0      = segmentPoints[i - 1];
                    p1      = segmentPoints[i];
                    p2      = segmentPoints[i + 1];
                    tangent = (p2 - p0).normalized;
                    q0      = p1 - curvatureScale * tangent * (p1 - p0).magnitude;
                    q1      = p1 + curvatureScale * tangent * (p2 - p1).magnitude;

                    ControlPoints.Add(q0);
                    ControlPoints.Add(p1);
                    ControlPoints.Add(q1);
                }
            }

            CurveCount = (ControlPoints.Count - 1) / 3;
        }
        /// <summary>
        /// Adds the handles for the given bezier point.
        /// </summary>
        /// <param name="index">The index of the <c>KimonoBezierPoint</c> that handles are
        /// being created for.</param>
        /// <param name="bezierPoint">The <c>KimonoBezierPoint</c> that is getting handles.</param>
        public void AddHandlesForPoint(int index, KimonoBezierPoint bezierPoint)
        {
            // Add new control point handle
            var controlPoint = new KimonoHandle(bezierPoint.ControlPoint.X - KimonoHandle.DrawOffset,
                                                bezierPoint.ControlPoint.Y - KimonoHandle.DrawOffset)
            {
                Index      = index,
                HandleType = KimonoHandleType.BezierControlPoint
            };

            controlPoint.Moved += (pt) =>
            {
                // Move attached point
                Points[controlPoint.Index].ControlPoint = pt;
            };
            ControlPoints.Add(controlPoint);

            // Add new end point handle
            var endPoint = new KimonoHandle(bezierPoint.EndPoint.X - KimonoHandle.DrawOffset,
                                            bezierPoint.EndPoint.Y - KimonoHandle.DrawOffset)
            {
                Index = index
            };

            endPoint.Moved += (pt) =>
            {
                // Move attached point
                Points[endPoint.Index].EndPoint = pt;
            };
            ControlPoints.Add(endPoint);
        }
Beispiel #19
0
            public override void GenerateControlPoints(OpenGL gl)
            {
                Point point1 = new Point(Start.X, Start.Y);
                Point point2 = new Point(End.X, End.Y);

                ControlPoints.Add(point1);
                ControlPoints.Add(point2);
            }
        public ICurve ToCurve()
        {
            var propsDouble  = PropsDouble;
            var knots        = KnotVectorU;
            var ctrlPtCoords = ControlPoints.SelectMany(p => p.ToDoubles()).ToArray();

            return((ICurve)SwAddinBase.Active.Modeler.CreateBsplineCurve(propsDouble, knots, ctrlPtCoords));
        }
Beispiel #21
0
        internal override void WriteParameters(List <object> parameters, IgesWriterBinder binder)
        {
            Debug.Assert(Weights != null);
            Debug.Assert(ControlPoints != null);
            Debug.Assert(Weights.GetLength(0) == ControlPoints.GetLength(0));
            Debug.Assert(Weights.GetLength(1) == ControlPoints.GetLength(1));

            var k1 = Weights.GetLength(0) - 1;
            var k2 = Weights.GetLength(1) - 1;
            var a  = FirstKnotValueSequence.Count - 1;
            var b  = SecondKnotValueSequence.Count - 1;
            var m1 = a - 1 - k1;
            var m2 = b - 1 - k2;

            parameters.Add(k1);
            parameters.Add(k2);
            parameters.Add(m1);
            parameters.Add(m2);
            parameters.Add(IsClosedInFirstParametricVariable ? 1 : 0);
            parameters.Add(IsClosedInSecondParametricVariable ? 1 : 0);
            parameters.Add(IsPolynomial ? 1 : 0);
            parameters.Add(IsPeriodicInFirstParametricVariable ? 1 : 0);
            parameters.Add(IsPeriodicInSecondParametricVariable ? 1 : 0);

            for (int i = 0; i < FirstKnotValueSequence.Count; i++)
            {
                parameters.Add(FirstKnotValueSequence[i]);
            }

            for (int i = 0; i < SecondKnotValueSequence.Count; i++)
            {
                parameters.Add(SecondKnotValueSequence[i]);
            }

            for (int j = 0; j < k2 + 1; j++)
            {
                for (int i = 0; i < k1 + 1; i++)
                {
                    parameters.Add(Weights[i, j]);
                }
            }

            for (int j = 0; j < k2 + 1; j++)
            {
                for (int i = 0; i < k1 + 1; i++)
                {
                    var point = ControlPoints[i, j];
                    parameters.Add(point.X);
                    parameters.Add(point.Y);
                    parameters.Add(point.Z);
                }
            }

            parameters.Add(FirstParametricStartingValue);
            parameters.Add(FirstParametricEndingValue);
            parameters.Add(SecondParametricStartingValue);
            parameters.Add(SecondParametricEndingValue);
        }
Beispiel #22
0
        protected virtual void OnResizingDelta(ResizingDirection direction, double horizontalChange, double verticalChange)
        {
            var selectedPoints = ControlPoints.Where(c => c.IsSelected).ToList();

            foreach (IResizingTarget c in selectedPoints)
            {
                c.OnResizingDelta(direction, horizontalChange, verticalChange);
            }
        }
Beispiel #23
0
        protected virtual void OnResizingStarted(ResizingDirection direction)
        {
            var selectedPoints = ControlPoints.Where(c => c.IsSelected).ToList();

            foreach (IResizingTarget c in selectedPoints)
            {
                c.OnResizingStarted(direction);
            }
        }
 public TestPattern(Vector2 startPosition, float speed) : base(startPosition, speed)
 {
     ControlPoints.Add(new Vector2(75, 300));
     ControlPoints.Add(new Vector2(400, 200));
     ControlPoints.Add(new Vector2(400, 400));
     ControlPoints.Add(new Vector2(100, 100));
     ControlPoints.Add(new Vector2(500, 600));
     ControlPoints.Add(new Vector2(500, 600));
 }
Beispiel #25
0
 /// <summary>
 /// Removes a Control Point from this connection
 /// </summary>
 /// <param name="controlPoint">the Control Point to remove</param>
 /// <param name="destroySelfIfEmpty">whether the connection should be destroyed when empty afterwards</param>
 public void RemoveControlPoint(CurvySplineSegment controlPoint, bool destroySelfIfEmpty = true)
 {
     controlPoint.Connection = null;
     ControlPoints.Remove(controlPoint);
     if (ControlPoints.Count == 0 && destroySelfIfEmpty)
     {
         Delete();
     }
 }
        //public int NewNo { get; set; }

        // Display Info of the RFEM Objects on Panels
        // Parameters are separated by ";". The component split text can be used to break the string down into a list.
        public override string ToString()
        {
            return(string.Format($"RFEM-Line;No:{No};Length:{Length}[m];Type:{Type};NodeList:{((NodeList == "") ? "-" : NodeList)};" +
                                 $"NodeCount:{NodeCount};Nodes:{ControlPoints.ToLabelString()};Tag:{((Tag == "") ? "-" : Tag)};" +
                                 $"IsValid:{IsValid};IsGenerated:{IsGenerated};ID:{((ID == "") ? "-" : ID)};RotationAngle:{RotationAngle}[rad];" +
                                 $"RotationHelpNodeNo:{RotationHelpNodeNo};RotationPlane:{RotationPlane};RotationType:{RotationType};" +
                                 $"Order:{((Order == 0) ? "-" : Order.ToString())};" +
                                 $"Weights:{(Weights.ToLabelString())};Knots:{(Knots.ToLabelString())};" +
                                 $"ToModify:{ToModify};ToDelete:{ToDelete};Comment:{((Comment == "") ? "-" : Comment)};"));
        }
Beispiel #27
0
        public ControlPoint AddControlPoint(Point point)
        {
            var controlPoint = new ControlPoint(ControlPoints.Count + 1, point);

            ControlPoints.Add(controlPoint);

            CalculateCurve();

            return(controlPoint);
        }
Beispiel #28
0
 public override int GetHashCode()
 {
     unchecked
     {
         var hashCode = ControlPoints.Cast <Vector3>().GetHashCode(v => v.GetHashCode());
         hashCode = (hashCode * 397) ^ KnotVectorU.GetHashCode(v => v.GetHashCode());
         hashCode = (hashCode * 397) ^ Order;
         return(hashCode);
     }
 }
Beispiel #29
0
        public MultiplierControlPoint ControlPointAt(double time)
        {
            int result = ControlPoints.BinarySearch(new MultiplierControlPoint(time));

            if (result < 0)
            {
                result = Math.Clamp(~result - 1, 0, ControlPoints.Count);
            }
            return(ControlPoints[result]);
        }
Beispiel #30
0
        //--------------------------------------------------------------------------
        public GraphNodeDataLink(GraphReferenceItem item) : base(item)
        {
            LinkNoEvent = GraphReferenceItem.WrappedItem?.GraphNode;

            GraphReferenceItem.PropertyChanged += (e, args) =>
            {
                if (args.PropertyName == "WrappedItem")
                {
                    Link = GraphReferenceItem.WrappedItem?.GraphNode;
                }
                else if (args.PropertyName == "TextBrush")
                {
                    RaisePropertyChangedEvent("FontBrush");
                }
                else if (args.PropertyName == "Name")
                {
                    RaisePropertyChangedEvent("Title");
                }
                else if (args.PropertyName == "IsVisible")
                {
                    RaisePropertyChangedEvent("Link");
                }
            };

            if (GraphReferenceItem.Parent is StructItem && GraphReferenceItem.ReferenceDef.UseParentDescription)
            {
                GraphReferenceItem.Parent.PropertyChanged += (e, args) =>
                {
                    if (args.PropertyName == "Description")
                    {
                        RaisePropertyChangedEvent("Title");
                    }
                    else if (args.PropertyName == "TextBrush")
                    {
                        RaisePropertyChangedEvent("FontBrush");
                    }
                };
            }

            foreach (var controlPoint in GraphReferenceItem.ControlPoints)
            {
                ControlPoints.Add(new LinkControlPoint(this, controlPoint));
            }

            PropertyChanged += (e, args) =>
            {
                if (args.PropertyName == "Node")
                {
                    if (Link != null)
                    {
                        Link.ParentNodes.Add(Node);
                    }
                }
            };
        }
Beispiel #31
0
    public void RemoveControlPoints()
    {
        controlPoints = null;

        if (points != null) {
            DestroyImmediate(points);
        }

        points = null;
    }
Beispiel #32
0
    public void CreateControlPoints(SkinnedMeshRenderer skin)
    {
        if (skin.sharedMesh != null)
        {
            controlPoints = new ControlPoints.Point[skin.sharedMesh.vertices.Length];
            if (points == null) {
                points = gameObject.AddComponent<ControlPoints>();
            }
            for (int i = 0; i < skin.sharedMesh.vertices.Length; i++) {
                Vector3 originalPos = skin.sharedMesh.vertices[i];

                controlPoints[i] = new ControlPoints.Point(originalPos);
                controlPoints[i].index = i;
                points.SetPoint(controlPoints[i]);
            }
        }
    }