Esempio n. 1
0
        private static BigIntegerPoint GetPoint(StreamReader file, CurveType curveType)
        {
            var xRaw = file.ReadLine();
            var yRaw = file.ReadLine();

            BigInteger x;
            BigInteger y;

            if (xRaw.Contains("h") || xRaw.Contains("x"))
            {
                x = BigInteger.Parse(xRaw.Substring(2), NumberStyles.AllowHexSpecifier);
                y = BigInteger.Parse(yRaw.Substring(2), NumberStyles.AllowHexSpecifier);
            }
            else if (curveType.Type == CurveType.Nonsupersingular || curveType.Type == CurveType.Supersingular)
            {
                x = BitString.BinaryToBigInteger(xRaw);
                y = BitString.BinaryToBigInteger(yRaw);
            }
            else
            {
                x = BigInteger.Parse(xRaw);
                y = BigInteger.Parse(yRaw);
            }

            return(new BigIntegerPoint(x, y));
        }
Esempio n. 2
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="pos"></param>
 /// <param name="curveType"></param>
 public GPathPoint(Vector3 pos, CurveType curveType)
 {
     this.pos       = pos;
     this.control1  = Vector3.zero;
     this.control2  = Vector3.zero;
     this.curveType = curveType;
 }
    public void SetVariables(string _name, ControlType _controlType, AddressType _addressType, ValueRange _range, DefaultValueType _defaultValueType,
                             MIDIChannel _channel, CurveType _curveType, int _ccNumber, float _smoothTime)
    {
        //add channel if not set to all channels
        address = "/vkb_midi/" + (_channel == MIDIChannel.All ? "" : (int)_channel + "/");

        //sets address based on address type
        SetAddress(_addressType, _ccNumber);

        //assign min and max values from value range
        SetRange(_range);

        //sets default value to value type
        SetDefault(_defaultValueType);

        channel           = _channel;
        name              = _name;
        controlObjectName = _name + " " + _controlType;
        controlType       = _controlType;
        range             = _range;
        defaultType       = _defaultValueType;
        smoothTime        = _smoothTime;
        curveType         = _curveType;
        addressType       = _addressType;
    }
        private void CurveTypeRadioButton_Checked(object sender, RoutedEventArgs e)
        {
            if (!this.IsLoaded)
            {
                return;
            }


            if (CurveThrougPointsRadioButton.IsChecked ?? false)
            {
                _selectedCurveType = CurveType.CurveThroughPoints;
            }

            else if (BezierCurveRadioButton.IsChecked ?? false)
            {
                _selectedCurveType = CurveType.BezierCurve;
            }

            else if (BSplineRadioButton.IsChecked ?? false)
            {
                _selectedCurveType = CurveType.BSpline;
            }

            else // if (NURBSCurveRadioButton.IsChecked ?? false)
            {
                _selectedCurveType = CurveType.NURBSCurve;
            }


            UpdateCurvesData();
            ShowCurvesData();
            RecreateCurve();
        }
        /// <summary>
        /// Returns the required size, in bytes, of each key parameters
        /// (X, Y and D), or -1 if the curve is unsupported.
        /// </summary>
        /// <param name="type">The curve for which key parameter size is
        /// required.</param>
        /// <returns></returns>
        public static int GetKeyParameterSize(this CurveType type)
        {
            switch (type)
            {
            case CurveType.P256:
                return(32);

            case CurveType.P384:
                return(48);

            case CurveType.P521:
                return(66);

            case CurveType.P256K:
                return(32);

            case CurveType.Brainpool_P160r1:
                break;     // TODO

            case CurveType.Brainpool_P160t1:
                break;

            case CurveType.Brainpool_P192r1:
                break;

            case CurveType.Brainpool_P192t1:
                break;

            case CurveType.Brainpool_P224r1:
                break;

            case CurveType.Brainpool_P224t1:
                break;

            case CurveType.Brainpool_P256r1:
                break;

            case CurveType.Brainpool_P256t1:
                break;

            case CurveType.Brainpool_P320r1:
                break;

            case CurveType.Brainpool_P320t1:
                break;

            case CurveType.Brainpool_P384r1:
                break;

            case CurveType.Brainpool_P384t1:
                break;

            case CurveType.Brainpool_P512r1:
                break;

            case CurveType.Brainpool_P512t1:
                break;
            }
            throw new ArgumentException($"Unknown curve {type}");
        }
Esempio n. 6
0
            public static float EvaluateCurve(CurveType type, float t, AnimationCurve curve)
            {
                switch (type)
                {
                case CurveType.ConstantOne:
                    return(1.0f);

                case CurveType.ConstantHalf:
                    return(0.5f);

                case CurveType.ConstantZero:
                    return(0.0f);

                case CurveType.RootOneTailHalf:
                    return(1.0f - 0.5f * Mathf.Clamp01(t));

                case CurveType.RootOneTailZero:
                    return(1.0f - Mathf.Clamp01(t));

                case CurveType.RootHalfTailOne:
                    return(0.5f + 0.5f * Mathf.Clamp01(t));

                case CurveType.RootZeroTailOne:
                    return(Mathf.Clamp01(t));

                case CurveType.Custom:
                    return(curve.Evaluate(t));
                }

                return(0.0f);
            }
        /// <summary>
        ///     Checks if specified curve is selectable
        /// </summary>
        /// <param name="cursorId">Cursor ID (1 or 2)</param>
        /// <param name="curveType">Ranorex path to menu entry</param>
        /// <returns>
        ///     <br>True: if curve is selectable</br>
        ///     <br>False: if curve is not selectable</br>
        /// </returns>
        public bool IsCurveSelectable(int cursorId, CurveType curveType)
        {
            bool isSelectable = false;

            switch (cursorId)
            {
            case 1:
                if ((new RunCursor1()).ViaMenu() != null)
                {
                    isSelectable = this.CheckCurve(curveType);
                }

                break;

            case 2:
                if ((new RunCursor2()).ViaMenu() != null)
                {
                    isSelectable = this.CheckCurve(curveType);
                }

                break;

            default:
                Log.Error(LogInfo.Namespace(MethodBase.GetCurrentMethod()), "Invalid cursor ID. ID must be 1 or 2.");
                break;
            }

            return(isSelectable);
        }
Esempio n. 8
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="pos"></param>
 /// <param name="control"></param>
 public GPathPoint(Vector3 pos, Vector3 control)
 {
     this.pos       = pos;
     this.control1  = control;
     this.control2  = Vector3.zero;
     this.curveType = CurveType.Bezier;
 }
Esempio n. 9
0
		public Curve(Curve prototype): base(prototype)
		{
			mCurveType = prototype.CurveType;
			mTension = prototype.Tension;
			mControlPoints = (PointF[]) prototype.ControlPoints.Clone();
			DrawPath();
		}
Esempio n. 10
0
    void GetControlPoints(CurveType type)
    {
        // points are in the 1/4 and 3/4 of the way between start and target...
        // if the Y is larger, it should bend outwards
        float deltaY = start.transform.position.y - end.transform.position.y;
        float deltaX = start.transform.position.x - end.transform.position.x;

        float widthStep  = Mathf.Abs(deltaX) / 4;
        float heightStep = deltaY * curveWidth;

        points[0] = start.transform.position;
        switch (type)
        {
        case CurveType.LOW_S:
            points[1] = new Vector3(end.transform.position.x - widthStep, end.transform.position.y - heightStep, end.transform.position.z);
            points[2] = new Vector3(start.transform.position.x + widthStep, start.transform.position.y + heightStep, start.transform.position.z);
            break;

        case CurveType.HIGH_S:
            points[1] = new Vector3(end.transform.position.x - widthStep, end.transform.position.y + heightStep, end.transform.position.z);
            points[2] = new Vector3(start.transform.position.x + widthStep, start.transform.position.y - heightStep, start.transform.position.z);
            break;

        default:
            points[1] = new Vector3(end.transform.position.x - widthStep, end.transform.position.y + heightStep, end.transform.position.z);
            points[2] = new Vector3(start.transform.position.x + widthStep, start.transform.position.y + heightStep, start.transform.position.z);
            break;
        }

        points[3] = end.transform.position;
    }
Esempio n. 11
0
        public double Length;                                //seems to be length in o!p, so it doesn't have to be calculated?

        public void ParseSliderSegments(string sliderString)
        {
            string[] split = sliderString.Split('|');
            foreach (var s in split)
            {
                if (s.Length == 1)     //curve type
                {
                    switch (s[0])
                    {
                    case 'L':
                        CurveType = CurveType.Linear;
                        break;

                    case 'C':
                        CurveType = CurveType.Catmull;
                        break;

                    case 'P':
                        CurveType = CurveType.Perfect;
                        break;

                    case 'B':
                        CurveType = CurveType.Bezier;
                        break;
                    }
                    continue;
                }
                string[] split2 = s.Split(':');
                Debug.Assert(split2.Length == 2);

                Points.Add(new Vector2(
                               int.Parse(split2[0]),
                               int.Parse(split2[1])));
            }
        }
Esempio n. 12
0
        internal override async void UpdateFeedback()
        {
            CurveType  curveType = DeriveCurveType(LineType);
            LinearUnit lu        = DeriveUnit(LineDistanceType);

            if (LineFromType == LineFromTypes.Points)
            {
                if (Point1 == null || Point2 == null)
                {
                    return;
                }

                var segment = QueuedTask.Run(() =>
                {
                    return(LineBuilder.CreateLineSegment(Point1, Point2));
                }).Result;


                UpdateAzimuth(segment.Angle);

                await UpdateFeedbackWithGeoLine(segment, curveType, lu);
            }
            else
            {
                UpdateManualFeedback();
            }
        }
Esempio n. 13
0
        private Geometry CreatePolyline()
        {
            if (Point1 == null || Point2 == null)
            {
                return(null);
            }
            CurveType  curveType = DeriveCurveType(LineType);
            LinearUnit lu        = DeriveUnit(LineDistanceType);

            try
            {
                // create line
                var polyline = QueuedTask.Run(() =>
                {
                    var segment = LineBuilder.CreateLineSegment(Point1, Point2);
                    return(PolylineBuilder.CreatePolyline(segment));
                }).Result;
                Geometry newline = GeometryEngine.GeodeticDensifyByLength(polyline, 0, lu, curveType);
                AddGraphicToMap(newline);
                ResetPoints();

                return(newline as Geometry);
            }
            catch (Exception ex)
            {
                // do nothing
                return(null);
            }
        }
Esempio n. 14
0
        public Slider(string[] anArgs, Beatmap aBeatmap)
            : base(anArgs, aBeatmap)
        {
            curveType     = GetSliderType(anArgs);
            nodePositions = GetNodes(anArgs).ToList();
            edgeAmount    = GetEdgeAmount(anArgs);
            pixelLength   = GetPixelLength(anArgs);

            // hit sounding
            var edgeHitSounds = GetEdgeHitSounds(anArgs);
            var edgeAdditions = GetEdgeAdditions(anArgs);

            startHitSound  = edgeHitSounds.Item1;
            startSampleset = edgeAdditions.Item1;
            startAddition  = edgeAdditions.Item2;

            endHitSound  = edgeHitSounds.Item2;
            endSampleset = edgeAdditions.Item3;
            endAddition  = edgeAdditions.Item4;

            reverseHitSounds  = edgeHitSounds.Item3.ToList();
            reverseSamplesets = edgeAdditions.Item5.ToList();
            reverseAdditions  = edgeAdditions.Item6.ToList();

            // non-explicit
            if (beatmap != null)
            {
                redAnchorPositions = GetRedAnchors().ToList();
                pathPxPositions    = GetPathPxPositions();
                endTime            = GetEndTime();
                sliderTickTimes    = GetSliderTickTimes();

                UnstackedEndPosition = edgeAmount % 2 == 1 ? pathPxPositions.Last() : UnstackedPosition;
            }
        }
Esempio n. 15
0
 public CustomToolStripMenuItem(CurveType Type)
 {
     Text       = CurveItems[Type].Name;
     CheckState = CurveItems[Type].Curve.IsVisible ? CheckState.Checked : CheckState.Unchecked;
     this.Type  = Type;
     Click     += MenuItem_Click;
 }
Esempio n. 16
0
        /// <summary>
        /// Convert to domain parameters
        /// </summary>
        /// <param name="type"></param>
        /// <returns></returns>
        internal static ECDomainParameters ToECDomainParameters(this CurveType type)
        {
            var curveParams = type.ToX9ECParameters();

            return(new ECDomainParameters(curveParams.Curve, curveParams.G,
                                          curveParams.N, curveParams.H, curveParams.GetSeed()));
        }
Esempio n. 17
0
 public Segment(Vector point, Vector inHandle, Vector outHandle, CurveType curveType)
 {
     Point     = point;
     InHandle  = inHandle;
     OutHandle = outHandle;
     CurveType = curveType;
 }
Esempio n. 18
0
        public static Metronome Create(CurveType type, double targetElapsedTimeMs, double frequencyMs)
        {
            Metronome metronome = new Metronome(targetElapsedTimeMs, frequencyMs);

            switch (type)
            {
                case CurveType.Linear:
                    metronome.Path.Initialize(new List<float>() { 0, 1 }, new List<float> { 0, 1 });
                    break;

                case CurveType.Exponential:
                    metronome.Path.Initialize(new List<float>() { 0, 0.1f, 1 }, new List<float> { 0, 0.8f, 1 });
                    break;

                case CurveType.Log:
                    metronome.Path.Initialize(new List<float>() { 0, 0.8f, 1 }, new List<float> { 0, 0.1f, 1 });
                    break;

                case CurveType.Sine:
                    metronome.Path.Initialize(new List<float>() { 0, 1f, 0 }, new List<float> { 0, 0.5f, 1 });
                    break;
            }

            return metronome;
        }
Esempio n. 19
0
        /// <summary>
        /// Get curve parameters
        /// </summary>
        /// <param name="type"></param>
        /// <returns></returns>
        internal static X9ECParameters ToX9ECParameters(this CurveType type)
        {
            switch (type)
            {
            case CurveType.P256:
                return(ECNamedCurveTable.GetByName("P-256"));

            case CurveType.P384:
                return(ECNamedCurveTable.GetByName("P-384"));

            case CurveType.P521:
                return(ECNamedCurveTable.GetByName("P-521"));

            case CurveType.P256K:
                return(ECNamedCurveTable.GetByName("K-283"));

            case CurveType.Brainpool_P160r1:
                return(ECNamedCurveTable.GetByName("brainpoolP160r1"));

            case CurveType.Brainpool_P160t1:
                return(ECNamedCurveTable.GetByName("brainpoolP160t1"));

            case CurveType.Brainpool_P192r1:
                return(ECNamedCurveTable.GetByName("brainpoolP192r1"));

            case CurveType.Brainpool_P192t1:
                return(ECNamedCurveTable.GetByName("brainpoolP192t1"));

            case CurveType.Brainpool_P224r1:
                return(ECNamedCurveTable.GetByName("brainpoolP224r1"));

            case CurveType.Brainpool_P224t1:
                return(ECNamedCurveTable.GetByName("brainpoolP224t1"));

            case CurveType.Brainpool_P256r1:
                return(ECNamedCurveTable.GetByName("brainpoolP256r1"));

            case CurveType.Brainpool_P256t1:
                return(ECNamedCurveTable.GetByName("brainpoolP256t1"));

            case CurveType.Brainpool_P320r1:
                return(ECNamedCurveTable.GetByName("brainpoolP320r1"));

            case CurveType.Brainpool_P320t1:
                return(ECNamedCurveTable.GetByName("brainpoolP320t1"));

            case CurveType.Brainpool_P384r1:
                return(ECNamedCurveTable.GetByName("brainpoolP384r1"));

            case CurveType.Brainpool_P384t1:
                return(ECNamedCurveTable.GetByName("brainpoolP384t1"));

            case CurveType.Brainpool_P512r1:
                return(ECNamedCurveTable.GetByName("brainpoolP512r1"));

            case CurveType.Brainpool_P512t1:
                return(ECNamedCurveTable.GetByName("brainpoolP512t1"));
            }
            throw new ArgumentException($"Unknown curve {type}");
        }
Esempio n. 20
0
    public CurveSegment(CurveType curveType, float p0, float p1, float p2, float p3)
    {
        // set B and M

        if (curveType == CurveType.Bezier)
        {
            M = setBezier();
        }
        if (curveType == CurveType.CatmullRom)
        {
            M = setCatmullRom();
        }
        if (curveType == CurveType.Hermite)
        {
            M = setHermite();
        }
        if (curveType == CurveType.BSpline)
        {
            M = setBSpline();
        }
        // Debug.Log(M.ToString());

        B[0] = p0;
        B[1] = p1;
        B[2] = p2;
        B[3] = p3;

        // p : spline function
        // u : conversion table
        // s : speed control function
    }
Esempio n. 21
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="pos"></param>
 public GPathPoint(Vector3 pos)
 {
     this.pos       = pos;
     this.control1  = Vector3.zero;
     this.control2  = Vector3.zero;
     this.curveType = CurveType.CRSpline;
 }
        private void Load()
        {
            InterpCurveTracks = new List <InterpCurve>();

            List <PropertyReader.Property> props = PropertyReader.getPropList(expEntry);
            CurveType throwaway = CurveType.InterpCurveVector;

            foreach (var p in props)
            {
                if (p.TypeVal == PropertyType.StructProperty)
                {
                    if (Enum.TryParse(pcc.getNameEntry(p.Value.IntValue), out throwaway))
                    {
                        InterpCurveTracks.Add(new InterpCurve(pcc, p));
                    }
                }
            }

            Action saveChanges = () => Commit();

            foreach (var interpCurve in InterpCurveTracks)
            {
                foreach (var curve in interpCurve.Curves)
                {
                    curve.SaveChanges = saveChanges;
                }
            }

            TrackList.ItemsSource = InterpCurveTracks;
            graph.Paint();
        }
Esempio n. 23
0
        public TriggerCurve(CurveType type)
        {
            CurveType = type;

            ushort stretchMidValue = (ushort)(ushort.MaxValue / 100.0 - 1);

            switch (type)
            {
            case CurveType.Linear:
                HorizontalShift   = 0;
                VerticalShift     = 0;
                HorizontalStretch = stretchMidValue;
                VerticalStretch   = stretchMidValue;
                break;

            case CurveType.Log:
                HorizontalShift   = 64;
                VerticalShift     = 39;
                HorizontalStretch = 7746;
                VerticalStretch   = 65435;
                break;

            case CurveType.Exp:
                HorizontalShift   = 105;
                VerticalShift     = -21;
                HorizontalStretch = 42215;
                VerticalStretch   = 25894;
                break;

            default:
                throw new ArgumentOutOfRangeException(nameof(type), type, null);
            }
        }
        /// <summary>
        /// Get curve name
        /// </summary>
        /// <param name="type"></param>
        /// <returns></returns>
        public static ECCurve ToECCurve(this CurveType type)
        {
            switch (type)
            {
            case CurveType.P256:
                return(ECCurve.NamedCurves.nistP256);

            case CurveType.P384:
                return(ECCurve.NamedCurves.nistP384);

            case CurveType.P521:
                return(ECCurve.NamedCurves.nistP521);

            case CurveType.P256K:
                return(ECCurve.CreateFromFriendlyName("secP256r1"));

            case CurveType.Brainpool_P160r1:
                return(ECCurve.NamedCurves.brainpoolP160r1);

            case CurveType.Brainpool_P160t1:
                return(ECCurve.NamedCurves.brainpoolP160t1);

            case CurveType.Brainpool_P192r1:
                return(ECCurve.NamedCurves.brainpoolP192r1);

            case CurveType.Brainpool_P192t1:
                return(ECCurve.NamedCurves.brainpoolP192t1);

            case CurveType.Brainpool_P224r1:
                return(ECCurve.NamedCurves.brainpoolP224r1);

            case CurveType.Brainpool_P224t1:
                return(ECCurve.NamedCurves.brainpoolP224t1);

            case CurveType.Brainpool_P256r1:
                return(ECCurve.NamedCurves.brainpoolP256r1);

            case CurveType.Brainpool_P256t1:
                return(ECCurve.NamedCurves.brainpoolP256t1);

            case CurveType.Brainpool_P320r1:
                return(ECCurve.NamedCurves.brainpoolP320r1);

            case CurveType.Brainpool_P320t1:
                return(ECCurve.NamedCurves.brainpoolP320t1);

            case CurveType.Brainpool_P384r1:
                return(ECCurve.NamedCurves.brainpoolP384r1);

            case CurveType.Brainpool_P384t1:
                return(ECCurve.NamedCurves.brainpoolP384t1);

            case CurveType.Brainpool_P512r1:
                return(ECCurve.NamedCurves.brainpoolP512r1);

            case CurveType.Brainpool_P512t1:
                return(ECCurve.NamedCurves.brainpoolP512t1);
            }
            throw new ArgumentException($"Unknown curve {type}");
        }
Esempio n. 25
0
        const float floatHalfPi = (float)(Math.PI / 2); // * 0.5f);

        public void DecayHitValue(float decay, CurveType decayCurveType, float delta = 1.0f)
        {
            float decayRelative = (((float)decay / 1000) * delta);

            switch (decayCurveType)
            {
            case CurveType.Smooth:
                HitValue = HitValue - (Math.Clamp((float)Math.Sin(floatPi * HitValue) * (decayRelative), 0.0001f, 1.0f));
                break;

            case CurveType.Fast:
                HitValue = HitValue - (Math.Clamp((float)Math.Cos(floatHalfPi * HitValue) * (decayRelative), 0.0001f, 1.0f));
                break;

            case CurveType.Slow:
                HitValue = HitValue - (Math.Clamp((float)Math.Sin(floatHalfPi * HitValue) * (decayRelative), 0.0001f, 1.0f));
                break;

            case CurveType.Default:
            default:
                HitValue = HitValue - (decayRelative);
                //Console.WriteLine($"Debug: Subtracting {decayRelative} from {HitValue}");
                break;
            }
        }
        /// <summary>
        /// Get curve name
        /// </summary>
        /// <param name="type"></param>
        /// <returns></returns>
        public static string GetName(this CurveType type)
        {
            switch (type)
            {
            case CurveType.P256:
                return("P-256");

            case CurveType.P384:
                return("P-384");

            case CurveType.P521:
                return("P-521");

            case CurveType.P256K:
                return("P-256K");

            case CurveType.Brainpool_P160r1:
                return("Brainpool-P-160-r1");

            case CurveType.Brainpool_P160t1:
                return("Brainpool-P-160-t1");

            case CurveType.Brainpool_P192r1:
                return("Brainpool-P-192-r1");

            case CurveType.Brainpool_P192t1:
                return("Brainpool-P-192-t1");

            case CurveType.Brainpool_P224r1:
                return("Brainpool-P-224-r1");

            case CurveType.Brainpool_P224t1:
                return("Brainpool-P-224-t1");

            case CurveType.Brainpool_P256r1:
                return("Brainpool-P-256-r1");

            case CurveType.Brainpool_P256t1:
                return("Brainpool-P-256-t1");

            case CurveType.Brainpool_P320r1:
                return("Brainpool-P-320-r1");

            case CurveType.Brainpool_P320t1:
                return("Brainpool-P-320-t1");

            case CurveType.Brainpool_P384r1:
                return("Brainpool-P-384-r1");

            case CurveType.Brainpool_P384t1:
                return("Brainpool-P-384-t1");

            case CurveType.Brainpool_P512r1:
                return("Brainpool-P-512-r1");

            case CurveType.Brainpool_P512t1:
                return("Brainpool-P-512-t1");
            }
            throw new ArgumentException($"Unknown curve {type}");
        }
Esempio n. 27
0
 public CurveAttributes(Curve curveName, CurveType curveType, int degreeOfPolynomial, int exactBitLengthOrderN)
 {
     CurveName            = curveName;
     CurveType            = curveType;
     DegreeOfPolynomial   = degreeOfPolynomial;
     ExactBitLengthOrderN = exactBitLengthOrderN;
 }
Esempio n. 28
0
 public Curve(Curve prototype) : base(prototype)
 {
     mCurveType     = prototype.CurveType;
     mTension       = prototype.Tension;
     mControlPoints = (PointF[])prototype.ControlPoints.Clone();
     DrawPath();
 }
Esempio n. 29
0
        public void AutoGetDots()
        {
            if (_fingerDots == null)
            {
                _childCount = -1;
            }
            if (_previousCurveType != TypeOfCurve)
            {
                WorkWithExtraDots();
                _previousCurveType = TypeOfCurve;
            }

            if (_childCount != _transform.childCount)
            {
                _childCount = _transform.childCount;
                List <FingerDot> childDots = new List <FingerDot>();
                for (int i = 0; i < _transform.childCount; i++)
                {
                    Transform child     = _transform.GetChild(i);
                    FingerDot fingerDot = child.GetComponent <FingerDot>();
                    if (fingerDot != null)
                    {
                        childDots.Add(fingerDot);
                    }
                }
                _fingerDots = childDots.ToArray();
                WorkWithExtraDots();
            }
        }
Esempio n. 30
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="pos"></param>
 /// <param name="control1"></param>
 /// <param name="control2"></param>
 public GPathPoint(Vector3 pos, Vector3 control1, Vector3 control2)
 {
     this.pos       = pos;
     this.control1  = control1;
     this.control2  = control2;
     this.curveType = CurveType.CubicBezier;
 }
    public static AnimationCurve GetCurve(CurveType ct)
    {
        switch (ct)
        {
        case CurveType.EaseLinear:               return(Tween.EaseLinear);

        case CurveType.EaseIn:                   return(Tween.EaseIn);

        case CurveType.EaseInStrong:             return(Tween.EaseInStrong);

        case CurveType.EaseOut:                  return(Tween.EaseOut);

        case CurveType.EaseOutStrong:            return(Tween.EaseOutStrong);

        case CurveType.EaseInOut:                return(Tween.EaseInOut);

        case CurveType.EaseInOutStrong:          return(Tween.EaseInOutStrong);

        case CurveType.EaseInBack:               return(Tween.EaseInBack);

        case CurveType.EaseOutBack:              return(Tween.EaseOutBack);

        case CurveType.EaseInOutBack:            return(Tween.EaseInOutBack);

        case CurveType.EaseSpring:               return(Tween.EaseSpring);

        case CurveType.EaseBounce:               return(Tween.EaseBounce);

        case CurveType.EaseWobble:               return(Tween.EaseWobble);

        default: return(null);
        }
    }
Esempio n. 32
0
 public CadObject2DDrawPart(CadObject2DDrawPart src)
 {
     ShowMode = src.ShowMode;
     for (int i = 0; i < 3; i++)
     {
         Color[i] = src.Color[i];
     }
     Type        = src.Type;
     CadId       = src.CadId;
     MeshId      = src.MeshId;
     ElemCount   = src.ElemCount;
     ElemPtCount = src.ElemPtCount;
     Indexs      = null;
     if (src.Indexs != null)
     {
         Indexs = new uint[src.Indexs.Length];
         src.Indexs.CopyTo(Indexs, 0);
     }
     Height    = src.Height;
     DispX     = src.DispX;
     DispY     = src.DispY;
     CurveType = src.CurveType;
     CtrlPoints.Clear();
     for (int i = 0; i < src.CtrlPoints.Count; i++)
     {
         CtrlPoints.Add(src.CtrlPoints[i]);
     }
 }
Esempio n. 33
0
 void SetLastCurveOperationType(Location location) {
     switch(location.CommandType) {
         case PathCommandType.CurveTo:
         case PathCommandType.SmoothCurveTo: lastCurveOperationType = CurveType.Cubic; break;
         case PathCommandType.QuadraticCurveTo:
         case PathCommandType.SmoothQuadraticCurveTo: lastCurveOperationType = CurveType.Quadratic; break;
         default: lastCurveOperationType = CurveType.None; break;
     }
 }
Esempio n. 34
0
 public Curve(CurveType type)
 {
     switch (type)
     {
         case CurveType.RampUp:
             Points = new PointPairList(new[] { 0.0, 100.0 }, new[] { 0.0, 100.0 });
             break;
         case CurveType.RampDown:
             Points = new PointPairList(new[] { 0.0, 100.0 }, new[] { 100.0, 0.0 });
             break;
         case CurveType.Flat100:
             Points = new PointPairList(new[] { 0.0, 100.0 }, new[] { 100.0, 100.0 });
             break;
     }
 }
Esempio n. 35
0
	public static Vector2 EvaluateSplineTangent(float t, Vector2[] points, CurveType cType){
		t = Mathf.Clamp01(t);	

		int segments = points.Length -1;

		if(cType == CurveType.Closed){
			segments += 1;
		}

		float totalT = (t * segments);
		int segment = Mathf.Clamp((int)(t * segments),0,segments-1);
		float segmentT = totalT - segment;
		int initialPoint = segment;
		
		return EvaluateTangent(segmentT, initialPoint, points, cType);
	}
Esempio n. 36
0
	//[HideInInspector]
	//[SerializeField] private Vector2[] points;
	//[SerializeField] private int segments;

	
//	public void SetSegments(int segmentCount){
//		segments = segmentCount;
//		
//		points = new Vector2[3*segments + 1];	
//	}
	

	public static float GetSplineLength(Vector2[] points, CurveType cType, int samples){

		float totalLength = 0;
		Vector2 previousPosition = EvaluateSplinePosition(0, points, cType);
		

		for(int i=1; i<samples; i++){
			float t = (float)(i)/(samples-1);
			Vector2 position = CatmullRomSpline2D.EvaluateSplinePosition(t, points, cType);

			totalLength += (position - previousPosition).magnitude;
			previousPosition = position;
		}

		return totalLength;
	}
Esempio n. 37
0
 public CurveItemTypePair(CurveItem curve, CurveType type, String name, int nC)
 {
     Curve = curve;
     Type = type;
     Scale = GlobalVars.DEFAULTSCALE(type);
     CurrCoordinates = new CurveItemTypePair.CurrentCoordinates();
     DrawCursorDot = true;
     DrawCursorLines = true;
     HorizontalCursorLine = new LineObj();
     VerticalCursorLine = new LineObj();
     SymbolsOn = true;
     Name = name;
     ComputeInterestingValues();
     CurveObj = new CurveObject((PointPairList)curve.Points, nC);
     CurveObj.XMAX = this.XMax;
     CurveObj.YMAX = this.YMax;
     NCurves = nC;
 }
Esempio n. 38
0
	//should use newtons method instead, this is just brute force
	public static ClosestPoint2D GetApproximateClosestPoint(Vector2 position, Vector2[] points, CurveType cType, int samples){
		
		Vector2 closestPosition = EvaluateSplinePosition(0, points, cType);
		float closestDistance = (position -  closestPosition).magnitude;
		float closestPoint = 0;


		for(int i=1; i<samples; i++){
			float t = (float)(i)/(samples-1);
			Vector2 pos = EvaluateSplinePosition(t, points, cType);
			float dist = (position -  pos).magnitude;

			if(dist < closestDistance){
				closestDistance = dist;
				closestPoint = t;
				closestPosition = pos;
			}

		}

		return new ClosestPoint2D(closestPoint, closestPosition, closestDistance);
	}
Esempio n. 39
0
 private void ShowAllGraphs(CurveType type, GraphType dim)
 {
     if (dim == GraphType.ThreeD)
     {
         Controller.Create3DDocument(type);
     }
     else if (dim == GraphType.TwoD)
     {
         Controller.Create2DDocument(type);
     }
 }
        internal static PointF[] GetCurveTangents(int terms, PointF [] points, int count, float tension, CurveType type)
        {
            float coefficient = tension / 3f;
            PointF [] tangents = new PointF [count];

            if (count <= 2)
                return tangents;

            for (int i = 0; i < count; i++) {
                int r = i + 1;
                int s = i - 1;

                if (r >= count)
                    r = count - 1;
                if (type == CurveType.Open) {
                    if (s < 0)
                        s = 0;
                }
                else
                {
                    if (s < 0)
                        s += count;
                }

                tangents [i].X += (coefficient * (points [r].X - points [s].X));
                tangents [i].Y += (coefficient * (points [r].Y - points [s].Y));
            }

            return tangents;
        }
Esempio n. 41
0
        void MakeCurve(PointF [] points, PointF [] tangents, int offset, int length, CurveType type)
        {
            MoveTo (points [offset].X, points [offset].Y);
            int i = offset;

            for (; i < offset + length; i++) {
                int j = i + 1;

                float x1 = points [i].X + tangents [i].X;
                float y1 = points [i].Y + tangents [i].Y;

                float x2 = points [j].X - tangents [j].X;
                float y2 = points [j].Y - tangents [j].Y;

                float x3 = points [j].X;
                float y3 = points [j].Y;

                context.AddCurveToPoint (x1, y1, x2, y2, x3, y3);
            }

            if (type == CurveType.Close) {
                /* complete (close) the curve using the first point */
                float x1 = points [i].X + tangents [i].X;
                float y1 = points [i].Y + tangents [i].Y;

                float x2 = points [0].X - tangents [0].X;
                float y2 = points [0].Y - tangents [0].Y;

                float x3 = points [0].X;
                float y3 = points [0].Y;

                context.AddCurveToPoint (x1, y1, x2, y2, x3, y3);

                context.ClosePath ();
            }
        }
Esempio n. 42
0
 public void RemoveCurve(CurveItem curve, CurveType type, String fileName)
 {
     GraphInformation.Remove(curve,type);
 }
 public void SetAnalogInputCurveType(CurveType type)
 {
     analogInputCurve = type;
     if (iface != null)
     {
         iface.analogEvaluationCurve = CurveFactory.Instantiate(type);
     }
 }
Esempio n. 44
0
		public Curve(Port start,Port end): base(start,end)
		{
			mCurveType = CurveType.Spline;
			mTension = 0.5F;
			CreateControlPoints();
		}
Esempio n. 45
0
		//Constructors
		public Curve(): base()
		{
			mCurveType = CurveType.Spline;			
			mTension = 0.5F;
			CreateControlPoints();
		}
Esempio n. 46
0
	// public static Vector2 EvaluateSecondDerivative(float t, Vector2[] points, CurveType cType){
	// 	t = Mathf.Clamp01(t);	

	// 	int segments = points.Length -1;

	// 	if(cType == CurveType.Closed){
	// 		segments += 1;
	// 	}

	// 	float totalT = (t * segments);
	// 	int segment = Mathf.Clamp((int)(t * segments),0,segments-1);
	// 	float segmentT = totalT - segment;
	// 	int initialPoint = segment;
		
	// 	return SecondDerivative(segmentT, initialPoint, points, cType);
	// }

	private static Vector2 EvaluatePosition(float t, int initialPoint, Vector2[] points, CurveType cType){
		
		int pointCount = points.Length;

		int pMinusOne = initialPoint-1;
		int pPlusOne = initialPoint+1;
		int pPlusTwo = initialPoint+2;

		if(cType == CurveType.Closed){
			pMinusOne = (initialPoint-1 + pointCount) % pointCount;
			pPlusOne = (initialPoint+1) % pointCount;
			pPlusTwo = (initialPoint+2) % pointCount;
		}
		else{
			if(pMinusOne < 0){
				pMinusOne = 0;
			}
			if(!(pPlusTwo < pointCount) ){
				pPlusTwo = pPlusOne;
			}
		}

		Vector2 previousPoint = points[pMinusOne];
		Vector2 tangent1 = 0.5f*(points[pPlusOne] - previousPoint);  
		Vector2 nextPoint = points[pPlusTwo];
		Vector2 tangent2 = 0.5f*(nextPoint - points[initialPoint]);  
		
		float tSquared = t*t;
		float tCubed = t*tSquared;

		return 	(2*tCubed - 3*tSquared + 1)	*	points[initialPoint] + //First point
				(tCubed - 2*tSquared + t)	*	tangent1 + //first tangent
				(-2*tCubed + 3*tSquared)	*	points[pPlusOne] + //second point
				(tCubed - tSquared)			*	tangent2; //second tangent
		
	}
Esempio n. 47
0
 public virtual void UpdateLastCurveControlPoints(CurveType curveType , params PointF[] controlPoints) {
     lastCurveOperationType = curveType;
     lastCurveLocations = controlPoints;
 }
Esempio n. 48
0
    public static ScriptReturnStatus Edit( VsqFileEx vsq )
    {
        // 選択状態のアイテムがなければ戻る
        if ( AppManager.itemSelection.getEventCount() <= 0 ) {
            return ScriptReturnStatus.NOT_EDITED;
        }

        // 現在のトラック
        int selected = AppManager.getSelected();
        VsqTrack vsq_track = vsq.Track.get( selected );
        vsq_track.sortEvent();

        // プラグイン情報の定義ファイル(plugin.txt)があるかどうかチェック
        string pluginTxtPath = s_plugin_txt_path;
        if ( pluginTxtPath == "" ) {
            AppManager.showMessageBox( "pluginTxtPath=" + pluginTxtPath );
            return ScriptReturnStatus.ERROR;
        }
        if ( !System.IO.File.Exists( pluginTxtPath ) ) {
            AppManager.showMessageBox( "'" + pluginTxtPath + "' does not exists" );
            return ScriptReturnStatus.ERROR;
        }

        // plugin.txtがあれば,プラグインの実行ファイルのパスを取得する
        System.Text.Encoding shift_jis = System.Text.Encoding.GetEncoding( "Shift_JIS" );
        string name = "";
        string exe_path = "";
        using ( StreamReader sr = new StreamReader( pluginTxtPath, shift_jis ) ) {
            string line = "";
            while ( (line = sr.ReadLine()) != null ) {
                string[] spl = line.Split( new char[] { '=' }, StringSplitOptions.RemoveEmptyEntries );
                if ( line.StartsWith( "name=" ) ) {
                    name = spl[1];
                } else if ( line.StartsWith( "execute=" ) ) {
                    exe_path = Path.Combine( Path.GetDirectoryName( pluginTxtPath ), spl[1] );
                }
            }
        }
        if ( exe_path == "" ) {
            return ScriptReturnStatus.ERROR;
        }
        if ( !System.IO.File.Exists( exe_path ) ) {
            AppManager.showMessageBox( "'" + exe_path + "' does not exists" );
            return ScriptReturnStatus.ERROR;
        }

        // 選択状態のアイテムの最初と最後がどこか調べる
        // clock_start, clock_endは,最終的にはPREV, NEXTを含んだ範囲を表すことになる
        // sel_start, sel_endはPREV, NEXTを含まない選択範囲を表す
        int id_start = -1;
        int clock_start = int.MaxValue;
        int id_end = -1;
        int clock_end = int.MinValue;
        int sel_start = 0;
        int sel_end = 0;
        for ( Iterator<SelectedEventEntry> itr = AppManager.itemSelection.getEventIterator(); itr.hasNext(); ) {
            SelectedEventEntry item = itr.next();
            if ( item.original.ID.type != VsqIDType.Anote ) {
                continue;
            }
            int clock = item.original.Clock;
            if ( clock < clock_start ) {
                id_start = item.original.InternalID;
                clock_start = clock;
                sel_start = clock;
            }
            clock += item.original.ID.getLength();
            if ( clock_end < clock ) {
                id_end = item.original.InternalID;
                clock_end = clock;
                sel_end = clock;
            }
        }

        // 選択範囲の前後の音符を探す
        VsqEvent ve_prev = null;
        VsqEvent ve_next = null;
        VsqEvent l = null;
        for ( Iterator<VsqEvent> itr = vsq_track.getNoteEventIterator(); itr.hasNext(); ) {
            VsqEvent item = itr.next();
            if ( item.InternalID == id_start ) {
                if ( l != null ) {
                    ve_prev = l;
                }
            }
            if ( l != null ) {
                if ( l.InternalID == id_end ) {
                    ve_next = item;
                }
            }
            l = item;
            if ( ve_prev != null && ve_next != null ) {
                break;
            }
        }
        int next_rest_clock = -1;
        bool prev_is_rest = false;
        if ( ve_prev != null ) {
            // 直前の音符がある場合
            if ( ve_prev.Clock + ve_prev.ID.getLength() == clock_start ) {
                // 接続している
                clock_start = ve_prev.Clock;
            } else {
                // 接続していない
                int new_clock_start = ve_prev.Clock + ve_prev.ID.getLength();
                clock_start = new_clock_start;
            }
        } else {
            // 無い場合
            if ( vsq.getPreMeasureClocks() < clock_start ) {
                prev_is_rest = true;
            }
            int new_clock_start = vsq.getPreMeasureClocks();
            clock_start = new_clock_start;
        }
        if ( ve_next != null ) {
            // 直後の音符がある場合
            if ( ve_next.Clock == clock_end ) {
                // 接続している
                clock_end = ve_next.Clock + ve_next.ID.getLength();
            } else {
                // 接続していない
                next_rest_clock = clock_end;
                clock_end = ve_next.Clock;
            }
        }

        // 作業用のVSQに,選択範囲のアイテムを格納
        VsqFileEx v = (VsqFileEx)vsq.clone();// new VsqFile( "Miku", 1, 4, 4, 500000 );
        // 選択トラックだけ残して他を削る
        for ( int i = 1; i < selected; i++ ) {
            v.Track.removeElementAt( 1 );
        }
        for ( int i = selected + 1; i < v.Track.size(); i++ ) {
            v.Track.removeElementAt( selected + 1 );
        }
        // 選択トラックの音符を全消去する
        VsqTrack v_track = v.Track.get( 1 );
        v_track.MetaText.getEventList().clear();
        for ( Iterator<VsqEvent> itr = vsq_track.getNoteEventIterator(); itr.hasNext(); ) {
            VsqEvent item = itr.next();
            if ( clock_start <= item.Clock && item.Clock + item.ID.getLength() <= clock_end ) {
                v_track.addEvent( (VsqEvent)item.clone(), item.InternalID );
            }
        }
        // 最後のRを手動で追加.これは自動化できない
        if ( next_rest_clock != -1 ) {
            VsqEvent item = (VsqEvent)ve_next.clone();
            item.ID.LyricHandle.L0.Phrase = "R";
            item.Clock = next_rest_clock;
            item.ID.setLength( clock_end - next_rest_clock );
            v_track.addEvent( item );
        }
        // 0~選択範囲の開始位置までを削除する
        v.removePart( 0, clock_start );

        // vsq -> ustに変換
        // キーがustのIndex, 値がInternalID
        TreeMap<int, int> map = new TreeMap<int, int>();
        UstFile u = new UstFile( v, 1, map );

        u.write( Path.Combine( PortUtil.getApplicationStartupPath(), "u.ust" ) );

        // PREV, NEXTのIndex値を設定する
        if ( ve_prev != null || prev_is_rest ) {
            u.getTrack( 0 ).getEvent( 0 ).Index = UstFile.PREV_INDEX;
        }
        if ( ve_next != null ) {
            u.getTrack( 0 ).getEvent( u.getTrack( 0 ).getEventCount() - 1 ).Index = UstFile.NEXT_INDEX;
        }

        // ustファイルに出力
        UstFileWriteOptions option = new UstFileWriteOptions();
        option.settingCacheDir = false;
        option.settingOutFile = false;
        option.settingProjectName = false;
        option.settingTempo = true;
        option.settingTool1 = true;
        option.settingTool2 = true;
        option.settingTracks = false;
        option.settingVoiceDir = true;
        option.trackEnd = false;
        string temp = Path.GetTempFileName();
        u.write( temp, option );

        StringBuilder before = new StringBuilder();
        using ( StreamReader sr = new StreamReader( temp, System.Text.Encoding.GetEncoding( "Shift_JIS" ) ) ) {
            string line = "";
            while ( (line = sr.ReadLine()) != null ) {
                before.AppendLine( line );
            }
        }
        String md5_before = PortUtil.getMD5FromString( before.ToString() );
        // プラグインの実行ファイルを起動
        Utau_Plugin_Invoker dialog = new Utau_Plugin_Invoker( exe_path, temp );
        dialog.ShowDialog();
        StringBuilder after = new StringBuilder();
        using ( StreamReader sr = new StreamReader( temp, System.Text.Encoding.GetEncoding( "Shift_JIS" ) ) ) {
            string line = "";
            while ( (line = sr.ReadLine()) != null ) {
                after.AppendLine( line );
            }
        }
        String md5_after = PortUtil.getMD5FromString( after.ToString() );
        if ( md5_before == md5_after ) {
            // 編集されなかったようだ
            return ScriptReturnStatus.NOT_EDITED;
        }

        // プラグインの実行結果をustオブジェクトにロード
        UstFile r = new UstFile( temp );
        if ( r.getTrackCount() < 1 ) {
            return ScriptReturnStatus.ERROR;
        }

        // 変更のなかったものについてはプラグインは記録してこないので,
        // 最初の値を代入するようにする
        UstTrack utrack_src = u.getTrack( 0 );
        UstTrack utrack_dst = r.getTrack( 0 );
        for ( int i = 0; i < utrack_dst.getEventCount(); i++ ) {
            UstEvent ue_dst = utrack_dst.getEvent( i );
            int index = ue_dst.Index;
            UstEvent ue_src = utrack_src.findEventFromIndex( index );
            if ( ue_src == null ) {
                continue;
            }
            if ( !ue_dst.isEnvelopeSpecified() && ue_src.isEnvelopeSpecified() ) {
                ue_dst.setEnvelope( ue_src.getEnvelope() );
            }
            if ( !ue_dst.isIntensitySpecified() && ue_src.isIntensitySpecified() ) {
                ue_dst.setIntensity( ue_src.getIntensity() );
            }
            if ( !ue_dst.isLengthSpecified() && ue_src.isLengthSpecified() ) {
                ue_dst.setLength( ue_src.getLength() );
            }
            if ( !ue_dst.isLyricSpecified() && ue_src.isLyricSpecified() ) {
                ue_dst.setLyric( ue_src.getLyric() );
            }
            if ( !ue_dst.isModurationSpecified() && ue_src.isModurationSpecified() ) {
                ue_dst.setModuration( ue_src.getModuration() );
            }
            if ( !ue_dst.isNoteSpecified() && ue_src.isNoteSpecified() ) {
                ue_dst.setNote( ue_src.getNote() );
            }
            if ( !ue_dst.isPBTypeSpecified() && ue_src.isPBTypeSpecified() ) {
                ue_dst.setPBType( ue_src.getPBType() );
            }
            if ( !ue_dst.isPitchesSpecified() && ue_src.isPitchesSpecified() ) {
                ue_dst.setPitches( ue_src.getPitches() );
            }
            if ( !ue_dst.isPortamentoSpecified() && ue_src.isPortamentoSpecified() ) {
                ue_dst.setPortamento( ue_src.getPortamento() );
            }
            if ( !ue_dst.isPreUtteranceSpecified() && ue_src.isPreUtteranceSpecified() ) {
                ue_dst.setPreUtterance( ue_src.getPreUtterance() );
            }
            if ( !ue_dst.isStartPointSpecified() && ue_src.isStartPointSpecified() ) {
                ue_dst.setStartPoint( ue_src.getStartPoint() );
            }
            if ( !ue_dst.isTempoSpecified() && ue_src.isTempoSpecified() ) {
                ue_dst.setTempo( ue_src.getTempo() );
            }
            if ( !ue_dst.isVibratoSpecified() && ue_src.isVibratoSpecified() ) {
                ue_dst.setVibrato( ue_src.getVibrato() );
            }
            if ( !ue_dst.isVoiceOverlapSpecified() && ue_src.isVoiceOverlapSpecified() ) {
                ue_dst.setVoiceOverlap( ue_src.getVoiceOverlap() );
            }
        }

        // PREVとNEXT含めて,clock_startからclock_endまでプラグインに渡したけれど,
        // それが伸びて帰ってきたか縮んで帰ってきたか.
        int ret_length = 0;
        UstTrack r_track = r.getTrack( 0 );
        int size = r_track.getEventCount();
        for ( int i = 0; i < size; i++ ) {
            UstEvent ue = r_track.getEvent( i );
            // 戻りのustには,変更があったものしか記録されていない
            int ue_length = ue.getLength();
            if ( !ue.isLengthSpecified() && map.ContainsKey( ue.Index ) ) {
                int internal_id = map[ue.Index];
                VsqEvent found_item = vsq_track.findEventFromID( internal_id );
                if ( found_item != null ) {
                    ue_length = found_item.ID.getLength();
                }
            }
            // PREV, ENDの場合は長さに加えない
            if ( ue.Index != UstFile.NEXT_INDEX &&
                 ue.Index != UstFile.PREV_INDEX ) {
                ret_length += ue_length;
            }
        }

        // 伸び縮みがあった場合
        // 伸ばしたり縮めたりするよ
        int delta = ret_length - (sel_end - sel_start);
        if ( delta > 0 ) {
            // のびた
            vsq.insertBlank( selected, sel_end, delta );
        } else if ( delta < 0 ) {
            // 縮んだ
            vsq.removePart( selected, sel_end + delta, sel_end );
        }

        // r_trackの内容をvsq_trackに転写
        size = r_track.getEventCount();
        int c = clock_start;
        for ( int i = 0; i < size; i++ ) {
            UstEvent ue = r_track.getEvent( i );
            if ( ue.Index == UstFile.NEXT_INDEX || ue.Index == UstFile.PREV_INDEX ) {
                // PREVとNEXTは単に無視する
                continue;
            }
            int ue_length = ue.getLength();
            if ( map.containsKey( ue.Index ) ) {
                // 既存の音符の編集
                VsqEvent target = vsq_track.findEventFromID( map[ue.Index] );
                if ( target == null ) {
                    // そんなばかな・・・
                    continue;
                }
                if ( !ue.isLengthSpecified() ) {
                    ue_length = target.ID.getLength();
                }
                if ( target.UstEvent == null ) {
                    target.UstEvent = (UstEvent)ue.clone();
                }
                // utau固有のパラメータを転写
                // pitchは後でやるので無視していい
                // テンポもあとでやるので無視していい
                if ( ue.isEnvelopeSpecified() ) {
                    target.UstEvent.setEnvelope( ue.getEnvelope() );
                }
                if ( ue.isModurationSpecified() ) {
                    target.UstEvent.setModuration( ue.getModuration() );
                }
                if ( ue.isPBTypeSpecified() ) {
                    target.UstEvent.setPBType( ue.getPBType() );
                }
                if ( ue.isPortamentoSpecified() ) {
                    target.UstEvent.setPortamento( ue.getPortamento() );
                }
                if ( ue.isPreUtteranceSpecified() ) {
                    target.UstEvent.setPreUtterance( ue.getPreUtterance() );
                }
                if ( ue.isStartPointSpecified() ) {
                    target.UstEvent.setStartPoint( ue.getStartPoint() );
                }
                if ( ue.isVibratoSpecified() ) {
                    target.UstEvent.setVibrato( ue.getVibrato() );
                }
                if ( ue.isVoiceOverlapSpecified() ) {
                    target.UstEvent.setVoiceOverlap( ue.getVoiceOverlap() );
                }
                // vocaloid, utauで同じ意味のパラメータを転写
                if ( ue.isIntensitySpecified() ) {
                    target.UstEvent.setIntensity( ue.getIntensity() );
                    target.ID.Dynamics = ue.getIntensity();
                }
                if ( ue.isLengthSpecified() ) {
                    target.UstEvent.setLength( ue.getLength() );
                    target.ID.setLength( ue.getLength() );
                }
                if ( ue.isLyricSpecified() ) {
                    target.UstEvent.setLyric( ue.getLyric() );
                    target.ID.LyricHandle.L0.Phrase = ue.getLyric();
                }
                if ( ue.isNoteSpecified() ) {
                    target.UstEvent.setNote( ue.getNote() );
                    target.ID.Note = ue.getNote();
                }
            } else {
                // マップに入っていないので,新しい音符の追加だと思う
                if ( ue.getLyric() == "R" ) {
                    // 休符.なにもしない
                } else {
                    VsqEvent newe = new VsqEvent();
                    newe.Clock = c;
                    newe.UstEvent = (UstEvent)ue.clone();
                    newe.ID = new VsqID();
                    AppManager.editorConfig.applyDefaultSingerStyle( newe.ID );
                    if ( ue.isIntensitySpecified() ) {
                        newe.ID.Dynamics = ue.getIntensity();
                    }
                    newe.ID.LyricHandle = new LyricHandle( "あ", "a" );
                    if ( ue.isLyricSpecified() ) {
                        newe.ID.LyricHandle.L0.Phrase = ue.getLyric();
                    }
                    newe.ID.Note = ue.getNote();
                    newe.ID.setLength( ue.getLength() );
                    newe.ID.type = VsqIDType.Anote;
                    // internal id はaddEventメソッドで自動で割り振られる
                    vsq_track.addEvent( newe );
                }
            }

            // テンポの追加がないかチェック
            if ( ue.isTempoSpecified() ) {
                insertTempoInto( vsq, c, ue.getTempo() );
            }

            c += ue_length;
        }

        // ピッチを転写
        // pitのデータがほしいので,PREV, NEXTを削除して,VsqFileにコンバートする
        UstFile uf = (UstFile)r.clone();
        // prev, nextを削除
        UstTrack uf_track = uf.getTrack( 0 );
        for ( int i = 0; i < uf_track.getEventCount(); ) {
            UstEvent ue = uf_track.getEvent( i );
            if ( ue.Index == UstFile.NEXT_INDEX ||
                 ue.Index == UstFile.PREV_INDEX ) {
                uf_track.removeEventAt( i );
            } else {
                i++;
            }
        }
        uf.updateTempoInfo();
        // VsqFileにコンバート
        VsqFile uf_vsq = new VsqFile( uf );
        // uf_vsqの最初のトラックの0からret_lengthクロックまでが,
        // vsq_trackのsel_startからsel_start+ret_lengthクロックまでに対応する.
        // まずPBSをコピーする
        CurveType[] type = new CurveType[] { CurveType.PBS, CurveType.PIT };
        foreach ( CurveType ct in type ) {
            // コピー元を取得
            VsqBPList src = uf_vsq.Track[1].getCurve( ct.getName() );
            if ( src != null ) {
                // コピー先を取得
                VsqBPList dst = vsq_track.getCurve( ct.getName() );
                if ( dst == null ) {
                    // コピー先がnullだった場合は作成
                    dst = new VsqBPList( ct.getName(), ct.getDefault(), ct.getMinimum(), ct.getMaximum() );
                    vsq_track.setCurve( ct.getName(), dst );
                }
                // あとで復元するので,最終位置での値を保存しておく
                int value_at_end = dst.getValue( sel_start + ret_length );
                // 復元するかどうか.最終位置にそもそもデータ点があれば復帰の必要がないので.
                bool do_revert = (dst.findIndexFromClock( sel_start + ret_length ) < 0);
                // [sel_start, sel_start + ret_length)の範囲の値を削除しておく
                size = dst.size();
                for ( int i = size - 1; i >= 0; i-- ) {
                    int cl = dst.getKeyClock( i );
                    if ( sel_start <= cl && cl < sel_start + ret_length ) {
                        dst.removeElementAt( i );
                    }
                }
                // コピーを実行
                size = src.size();
                for ( int i = 0; i < size; i++ ) {
                    int cl = src.getKeyClock( i );
                    if ( ret_length <= cl ) {
                        break;
                    }
                    int value = src.getElementA( i );
                    dst.add( cl + sel_start, value );
                }
                // コピー後,最終位置での値が元と異なる場合,元に戻すようにする
                if ( do_revert && dst.getValue( sel_start + ret_length ) != value_at_end ) {
                    dst.add( sel_start + ret_length, value_at_end );
                }
            }
        }

        return ScriptReturnStatus.EDITED;
    }
Esempio n. 49
0
 public virtual bool HasSavedLastCurveLocations(CurveType curveType) {
     return curveType == lastCurveOperationType;
 }
Esempio n. 50
0
	// private static Vector2 SecondDerivative(float t, int initialPoint, Vector2[] points, CurveType cType){
		
	// 	int pointCount = points.Length;

	// 	int pMinusOne = initialPoint-1;
	// 	int pPlusOne = initialPoint+1;
	// 	int pPlusTwo = initialPoint+2;

	// 	if(cType == CurveType.Closed){
	// 		pMinusOne = (initialPoint-1 + pointCount) % pointCount;
	// 		pPlusOne = (initialPoint+1) % pointCount;
	// 		pPlusTwo = (initialPoint+2) % pointCount;
	// 	}
	// 	else{
	// 		if(pMinusOne < 0){
	// 			pMinusOne = 0;
	// 		}
	// 		if(!(pPlusTwo < pointCount) ){
	// 			pPlusTwo = pPlusOne;
	// 		}
	// 	}

	// 	Vector2 previousPoint = points[pMinusOne];
	// 	Vector2 tangent1 = 0.5f*(points[pPlusOne] - previousPoint);  
	// 	Vector2 nextPoint = points[pPlusTwo];
	// 	Vector2 tangent2 = 0.5f*(nextPoint - points[initialPoint]);  
		

	// 	return 	(12*t - 6)		*	points[initialPoint] + //First point
	// 			(6*t - 4)		*	tangent1 + //first tangent
	// 			(-6*t + 6)		*	points[pPlusOne] + //second point
	// 			(3*t - 2)		*	tangent2; //second tangent
		
	// }

//	
//	
//	private Vector2 SecondDerivative(float d, int initialPoint){
//			
//		float invD = 1-d;
//		
//		return 6*invD*points[initialPoint] + 3*(-4+6*d)*points[initialPoint+1] + 3*(2-6*d)*points[initialPoint+2] + 6*d*points[initialPoint+3];
//		
//		
//	}
	
	
	public static void DrawGizmos(Vector2[] points, CurveType cType){
		


		if(points != null && (points.Length-1) > 0){

			int segments = points.Length-1;


			for(int i=0; i<points.Length; i++){
				Gizmos.DrawSphere(points[i], 0.125f);
			}
			
			int lineCount = 20*segments;
			
			Vector2 lastPosition = EvaluateSplinePosition(0, points, cType);
			for(int i=1; i<lineCount+1; i++){
				float percent = (float)i / (float)lineCount;
				Vector2 newPosition = EvaluateSplinePosition(percent, points, cType);
				Gizmos.DrawLine(lastPosition, newPosition);
				lastPosition = newPosition;
			}
		}
	}
Esempio n. 51
0
        protected override void OnStylusDown(StylusEventArgs e)
        {
            bool callBase = false;

            if (!this.inCurveMode)
            {
                callBase = true;
            }
            else
            {
                PointF mousePtF = new PointF(e.Fx, e.Fy);
                Point mousePt = Point.Truncate(mousePtF);
                float minDistance = float.MaxValue;

                for (int i = 0; i < this.moveNubs.Length; ++i)
                {
                    if (this.moveNubs[i].IsPointTouching(mousePt, true))
                    {
                        float distance = Utility.Distance(mousePtF, this.moveNubs[i].Location);

                        if (distance < minDistance)
                        {
                            minDistance = distance;
                            this.draggingNubIndex = i;
                        }
                    }
                }

                if (this.draggingNubIndex == -1)
                {
                    callBase = true;
                }
                else
                {
                    this.Cursor = this.handCursorMouseDown;

                    if (this.curveType == CurveType.NotDecided)
                    {
                        if (e.Button == MouseButtons.Right)
                        {
                            this.curveType = CurveType.Bezier;
                        }
                        else
                        {
                            this.curveType = CurveType.Spline;
                        }
                    }

                    for (int i = 0; i < this.moveNubs.Length; ++i)
                    {
                        this.moveNubs[i].Visible = false;
                    }

                    string helpText2 = PdnResources.GetString("LineTool.CurvingHelpText");
                    SetStatus(null, helpText2);
                    OnStylusMove(e);
                }
            }

            if (callBase)
            {
                base.OnStylusDown(e);
                Cursor = this.lineToolMouseDownCursor;
            }
        }
Esempio n. 52
0
        protected override void OnShapeCommitting()
        {
            for (int i = 0; i < this.moveNubs.Length; ++i)
            {
                this.moveNubs[i].Visible = false;
            }
            
            this.inCurveMode = false;
            this.curveType = CurveType.NotDecided;
            this.Cursor = this.lineToolCursor;
            this.draggingNubIndex = -1;

            DocumentWorkspace.UpdateStatusBarToToolHelpText();
        }
Esempio n. 53
0
 private void ChangeAllSymbols(CurveType? type, String symbol)
 {
     if (type == null)
     {
         return;
     }
     else
     {
         foreach (Document doc in Controller.DockList)
         {
             for (int i = 0; i < doc.GraphInformation.CurveTypeItems.Count; i++)
             {
                 if (doc.GraphInformation.CurveTypeItems[i].Type == type)
                 {
                     doc.ChangeSymbol(i, symbol);
                 }
             }
         }
     }
 }
Esempio n. 54
0
        public static Path2D CreateCurve(CurveType type, double time)
        {
            Path2D path = new Path2D();

            switch (type)
            {
                case CurveType.Linear:
                    path.Initialize(new List<Vector2>() { Vector2.Zero, Vector2.One }, new List<double> { 0, time });
                    break;

                case CurveType.Exponential:
                    path.Initialize(new List<Vector2>() { Vector2.Zero, new Vector2(0.8f, 0.1f), Vector2.One }, new List<double> { 0, time / 2, time });
                    break;

                case CurveType.Log:
                    path.Initialize(new List<Vector2>() { Vector2.Zero, new Vector2(0.1f, 0.8f), Vector2.One }, new List<double> { 0, time / 2, time });
                    break;
            }

            return path;
        }
Esempio n. 55
0
        private void ChangeAllColors(CurveType? type, Color color)
        {
            if (type == null)
            {
                return;
            }
            else
            {
                foreach (Document doc in Controller.DockList)
                {
                    GraphDock gd = doc as GraphDock;
                    if (gd != null)
                    {
                        gd.ChangeCurveTypeColor(type, color);
                    }

                }
            }
        }
Esempio n. 56
0
        void AppendCurve(PointF [] points, PointF [] tangents, int offset, int length, CurveType type)
        {
            PathPointType ptype = ((type == CurveType.Close) || (points.Length == 0)) ? PathPointType.Start : PathPointType.Line;
            int i;

            AppendPoint (points [offset], ptype, true);
            for (i = offset; i < offset + length; i++) {
                int j = i + 1;

                float x1 = points [i].X + tangents [i].X;
                float y1 = points [i].Y + tangents [i].Y;

                float x2 = points [j].X - tangents [j].X;
                float y2 = points [j].Y - tangents [j].Y;

                float x3 = points [j].X;
                float y3 = points [j].Y;

                AppendBezier (x1, y1, x2, y2, x3, y3);
            }

                /* complete (close) the curve using the first point */
            if (type == CurveType.Close) {
                float x1 = points [i].X + tangents [i].X;
                float y1 = points [i].Y + tangents [i].Y;

                float x2 = points [0].X - tangents [0].X;
                float y2 = points [0].Y - tangents [0].Y;

                float x3 = points [0].X;
                float y3 = points [0].Y;

                AppendBezier (x1, y1, x2, y2, x3, y3);
                CloseFigure ();
            }
        }
Esempio n. 57
0
		public Curve(Shape start,Shape end): base(start,end)
		{
			mCurveType = CurveType.Spline;
			mTension = 0.5F;
			CreateControlPoints();
		}
Esempio n. 58
0
 private DataGridViewComboBoxCell UpdateScaleValues(int rowValue, CurveType type)
 {
     DataGridViewComboBoxCell dbc = new DataGridViewComboBoxCell();
     switch (type)
     {
         case CurveType.Acceleration:
             dbc.Items.Clear();
             dbc.Items.AddRange(GlobalVars.AccelerationScales);
             break;
         case CurveType.Velocity:
             dbc.Items.Clear();
             dbc.Items.AddRange(GlobalVars.VelocityScales);
             break;
         case CurveType.Magnitude:
             dbc.Items.Clear();
             dbc.Items.AddRange(GlobalVars.MagnitudeScales);
             break;
         case CurveType.Power:
             dbc.Items.Clear();
             dbc.Items.AddRange(GlobalVars.PowerScales);
             break;
         default:
             break;
     }
     return dbc;
 }
Esempio n. 59
0
 public virtual void UpdateLastCurveControlPoints(CurveType curveType) {
     lastCurveOperationType = curveType;
 }
Esempio n. 60
0
        public InterpCurve(IMEPackage _pcc, PropertyReader.Property p)
        {
            pcc = _pcc;

            Curves = new ObservableCollection<Curve>();
            Name = pcc.getNameEntry(p.Name);
            curveType = (CurveType)Enum.Parse(typeof(CurveType), pcc.getNameEntry(p.Value.IntValue));

            float InVal = 0f;
            CurveMode InterpMode = CurveMode.CIM_Linear;
            var points = PropertyReader.ReadStructArrayProp(pcc, PropertyReader.getPropOrNull(pcc, p.raw, 32, "Points"));
            switch (curveType)
            {
                case CurveType.InterpCurveQuat:
                    throw new NotImplementedException($"InterpCurveQuat has not been implemented yet.");
                case CurveType.InterpCurveFloat:
                    float OutVal = 0f;
                    float ArriveTangent = 0f;
                    float LeaveTangent = 0f;
                    LinkedList<CurvePoint> vals = new LinkedList<CurvePoint>();
                    foreach (var point in points)
                    {
                        foreach (var prop in point)
                        {
                            switch (pcc.getNameEntry(prop.Name))
                            {
                                case "InVal":
                                    InVal = BitConverter.ToSingle(prop.raw, 24);
                                    break;
                                case "OutVal":
                                    OutVal = BitConverter.ToSingle(prop.raw, 24);
                                    break;
                                case "ArriveTangent":
                                    ArriveTangent = BitConverter.ToSingle(prop.raw, 24);
                                    break;
                                case "LeaveTangent":
                                    LeaveTangent = BitConverter.ToSingle(prop.raw, 24);
                                    break;
                                case "InterpMode":
                                    InterpMode = (CurveMode)Enum.Parse(typeof(CurveMode), pcc.getNameEntry(prop.Value.IntValue));
                                    break;
                                default:
                                    break;
                            }
                        }
                        vals.AddLast(new CurvePoint(InVal, OutVal, ArriveTangent, LeaveTangent, InterpMode));
                    }
                    Curves.Add(new Curve("X", vals));
                    break;
                case CurveType.InterpCurveVector:
                    Vector OutValVec = new Vector(0, 0, 0);
                    Vector ArriveTangentVec = new Vector(0, 0, 0);
                    Vector LeaveTangentVec = new Vector(0, 0, 0);
                    LinkedList<CurvePoint> x = new LinkedList<CurvePoint>();
                    LinkedList<CurvePoint> y = new LinkedList<CurvePoint>();
                    LinkedList<CurvePoint> z = new LinkedList<CurvePoint>();
                    foreach (var point in points)
                    {
                        foreach (var prop in point)
                        {
                            switch (pcc.getNameEntry(prop.Name))
                            {
                                case "InVal":
                                    InVal = BitConverter.ToSingle(prop.raw, 24);
                                    break;
                                case "OutVal":
                                    OutValVec = GetVector(prop);
                                    break;
                                case "ArriveTangent":
                                    ArriveTangentVec = GetVector(prop);
                                    break;
                                case "LeaveTangent":
                                    LeaveTangentVec = GetVector(prop);
                                    break;
                                case "InterpMode":
                                    InterpMode = (CurveMode)Enum.Parse(typeof(CurveMode), pcc.getNameEntry(prop.Value.IntValue));
                                    break;
                                default:
                                    break;
                            }
                        }
                        x.AddLast(new CurvePoint(InVal, OutValVec.X, ArriveTangentVec.X, LeaveTangentVec.X, InterpMode));
                        y.AddLast(new CurvePoint(InVal, OutValVec.Y, ArriveTangentVec.Y, LeaveTangentVec.Y, InterpMode));
                        z.AddLast(new CurvePoint(InVal, OutValVec.Z, ArriveTangentVec.Z, LeaveTangentVec.Z, InterpMode));
                    }
                    if (Name == "EulerTrack")
                    {
                        Curves.Add(new Curve("Roll", x));
                        Curves.Add(new Curve("Pitch", y));
                        Curves.Add(new Curve("Yaw", z));
                    }
                    else
                    {
                        Curves.Add(new Curve("X", x));
                        Curves.Add(new Curve("Y", y));
                        Curves.Add(new Curve("Z", z)); 
                    }
                    break;
                case CurveType.InterpCurveVector2D:
                    throw new NotImplementedException($"InterpCurveVector2D has not been implemented yet.");
                case CurveType.InterpCurveTwoVectors:
                    throw new NotImplementedException($"InterpCurveTwoVectors has not been implemented yet.");
                case CurveType.InterpCurveLinearColor:
                    throw new NotImplementedException($"InterpCurveLinearColor has not been implemented yet.");
                default:
                    break;
            }
            foreach (var curve in Curves)
            {
                curve.SharedValueChanged += Curve_SharedValueChanged;
                curve.ListModified += Curve_ListModified;
            }
        }