コード例 #1
0
ファイル: DistanceCurve.cs プロジェクト: numo16/SharpDX
        public static unsafe IntPtr FromCurvePoints(CurvePoint[] points)
        {
            if (points == null || points.Length == 0)
                return IntPtr.Zero;

            var pDistanceCurve = (DistanceCurve*)Marshal.AllocHGlobal(Utilities.SizeOf<DistanceCurve>() + points.Length * Utilities.SizeOf<CurvePoint>());
            var pPoints = (CurvePoint*)&pDistanceCurve[1];
            pDistanceCurve->PointCount = points.Length;
            pDistanceCurve->PointsPointer = new IntPtr(pPoints);
            Utilities.Write(pDistanceCurve->PointsPointer, points, 0, points.Length);
            return (IntPtr) pDistanceCurve;
        }
コード例 #2
0
ファイル: UICurves.xaml.cs プロジェクト: kergalym/Materia
        void AddPoint(MathHelpers.Point p)
        {
            int m = (int)mode;

            CurvePoint cp = new CurvePoint(this);

            cp.HorizontalAlignment = HorizontalAlignment.Left;
            cp.VerticalAlignment   = VerticalAlignment.Top;
            cp.Width      = 8;
            cp.Height     = 8;
            cp.MouseDown += Point_MouseDown;
            cp.MouseUp   += Point_MouseUp;
            cp.MouseMove += Point_MouseMove;
            cp.Position   = p;

            Points[m].Add(cp);
            CurveView.Children.Add(cp);

            UpdatePath();
            UpdateProperty();
        }
コード例 #3
0
ファイル: UICurves.xaml.cs プロジェクト: kergalym/Materia
        private void Point_MouseMove(object sender, MouseEventArgs e)
        {
            if (target == sender)
            {
                e.Handled = true;
                Point  ep = e.GetPosition(CurveView);
                double dx = ep.X - mouseStart.X;
                double dy = ep.Y - mouseStart.Y;

                CurvePoint        cp = target as CurvePoint;
                MathHelpers.Point p  = cp.Position;
                p.X        += dx;
                p.Y        += dy;
                cp.Position = p;

                mouseStart = ep;
                //update curve
                UpdatePath();
                UpdateProperty();
            }
        }
コード例 #4
0
ファイル: Bezier.cs プロジェクト: FredZvt/BezierStudy
    public static CurvePoint[] GetPointsInPath(Curve[] curves, byte resolutionPerSegment)
    {
        var pathPoints = new CurvePoint[(resolutionPerSegment * curves.Length) + 1];

        for (var i = 0; i < curves.Length; i++)
        {
            var points = GetPointsInCurve(curves[i], resolutionPerSegment);
            var pointsToGetInThisSegment = resolutionPerSegment;

            if (i == curves.Length - 1)
            {
                pointsToGetInThisSegment++;
            }

            var offset = resolutionPerSegment * i;
            for (var j = 0; j < pointsToGetInThisSegment; j++)
            {
                pathPoints[offset + j] = points[j];
            }
        }
        return(pathPoints);
    }
コード例 #5
0
ファイル: Bezier.cs プロジェクト: FredZvt/BezierStudy
    public static CurvePoint[] GetPointsInCurve(
        Vector3 start,
        Vector3 startControlPoint,
        Vector3 end,
        Vector3 endControlPoint,
        byte resolution)
    {
        if (resolution < 2)
        {
            throw new ArgumentException("Resolution must be greater than two.");
        }

        var path      = new CurvePoint[resolution + 1];
        var increment = 1f / resolution;

        for (var i = 0; i < resolution + 1; i++)
        {
            path[i] = GetPointInCurve(start, startControlPoint, end, endControlPoint, i * increment);
        }

        return(path);
    }
コード例 #6
0
    public CurvePoint[] SimulateLerpedCurve()
    {
        Quaternion monsterRotation = monsterController.transform.localRotation;
        Vector3    moveDir         = monsterController.GetMoveDirection().normalized;
        Quaternion targetRotation  = Quaternion.LookRotation(moveDir, transform.up);

        CurvePoint[] tempCurvePoints = new CurvePoint[4];
        Vector3      prevPoint       = Vector3.zero;

        for (int i = 0; i < tempCurvePoints.Length; i++)
        {
            Vector3 tempPos = prevPoint + Quaternion.Slerp(monsterRotation, targetRotation, i * 0.25f + 0.25f) * Vector3.forward * 0.1f;

            Vector3 tempFwd = (tempPos - prevPoint).normalized;

            prevPoint          = tempPos;
            tempPos            = transform.worldToLocalMatrix.MultiplyVector(tempPos);
            tempFwd            = transform.worldToLocalMatrix.MultiplyVector(tempFwd);
            tempCurvePoints[i] = new CurvePoint(tempPos, tempFwd);
        }

        return(tempCurvePoints);
    }
コード例 #7
0
    private void CreateAnimationCurve()
    {
        motionCurves = new MotionCurve[baseCurveDatas.Count];
        for (int i = 0; i < baseCurveDatas.Count; i++)
        {
            CurvePoint[] tempCurvePoints = new CurvePoint[curveTimePoints.Count];

            /*for (int j = (i - prevTrail) < 0 ? 0 : i - prevTrail; j < i + nextTrail && j < baseCurveDatas.Count; j++)
             * {
             *  Vector3 tempPos = baseCurveDatas[i].RootWorldToLocalMatrix
             *      .MultiplyPoint3x4(baseCurveDatas[j].CurvePointPosition);
             *  Vector3 tempFwd = baseCurveDatas[i].RootWorldToLocalMatrix
             *      .MultiplyVector(baseCurveDatas[j].CurvePointForward);
             *  tempCurvePoints[j] = new CurvePoint(tempPos, tempFwd);
             * }*/
            for (var j = 0; j < curveTimePoints.Count; j++)
            {
                float t         = curveTimePoints[j];
                int   frameTime = Mathf.RoundToInt(t / Time.fixedDeltaTime);
                if (i + frameTime >= 0 && i + frameTime < baseCurveDatas.Count &&
                    baseCurveDatas[i + frameTime].AnimName == baseCurveDatas[i].AnimName)
                {
                    Vector3 tempPos = baseCurveDatas[i].RootWorldToLocalMatrix
                                      .MultiplyPoint3x4(baseCurveDatas[i + frameTime].CurvePointPosition);
                    Vector3 tempFwd = baseCurveDatas[i].RootWorldToLocalMatrix
                                      .MultiplyVector(baseCurveDatas[i + frameTime].CurvePointForward);
                    tempCurvePoints[j] = new CurvePoint(tempPos, tempFwd);
                }
            }


            motionCurves[i] =
                new MotionCurve(i, baseCurveDatas[i].AnimName, baseCurveDatas[i].TimeStamp, tempCurvePoints);
        }

        Debug.Log("Motion Curve created for " + _clipNames[0]);
    }
コード例 #8
0
        public static void HandleDBReply(Packet packet)
        {
            var type  = packet.ReadUInt32E <DB2Hash>("DB2 File");
            var entry = (uint)packet.ReadInt32("Entry");

            packet.ReadTime("Hotfix date");

            var size    = packet.ReadInt32("Size");
            var data    = packet.ReadBytes(size);
            var db2File = new Packet(data, packet.Opcode, packet.Time, packet.Direction, packet.Number, packet.Writer, packet.FileName);

            if ((int)entry < 0)
            {
                packet.WriteLine("Row {0} has been removed.", -(int)entry);
                return;
            }

            switch (type)
            {
            case DB2Hash.BroadcastText:
            {
                var broadcastText = new BroadcastText();

                var id = db2File.ReadEntry("Id");
                broadcastText.language = db2File.ReadInt32("Language");
                var maletextLength = db2File.ReadUInt16();
                broadcastText.MaleText = db2File.ReadWoWString("Male Text", maletextLength);
                var femaletextLength = db2File.ReadUInt16();
                broadcastText.FemaleText = db2File.ReadWoWString("Female Text", femaletextLength);

                broadcastText.EmoteID    = new uint[3];
                broadcastText.EmoteDelay = new uint[3];
                for (var i = 0; i < 3; ++i)
                {
                    broadcastText.EmoteID[i] = (uint)db2File.ReadInt32("Emote ID", i);
                }
                for (var i = 0; i < 3; ++i)
                {
                    broadcastText.EmoteDelay[i] = (uint)db2File.ReadInt32("Emote Delay", i);
                }

                broadcastText.soundId = db2File.ReadUInt32("Sound Id");
                broadcastText.unk1    = db2File.ReadUInt32("Unk MoP 1");  // unk emote
                broadcastText.unk2    = db2File.ReadUInt32("Unk MoP 2");  // kind of type?

                Storage.BroadcastTexts.Add((uint)id.Key, broadcastText, packet.TimeSpan);
                packet.AddSniffData(StoreNameType.BroadcastText, id.Key, "BROADCAST_TEXT");
                break;
            }

            case DB2Hash.Creature:     // New structure - 6.0.2
            {
                db2File.ReadUInt32("Creature ID");
                db2File.ReadInt32E <CreatureType>("Type");

                for (var i = 0; i < 3; ++i)
                {
                    db2File.ReadUInt32 <ItemId>("Item ID", i);
                }

                db2File.ReadUInt32("Mount");
                for (var i = 0; i < 4; ++i)
                {
                    db2File.ReadInt32("Display ID", i);
                }

                for (var i = 0; i < 4; ++i)
                {
                    db2File.ReadSingle("Display ID Probability", i);
                }

                if (db2File.ReadUInt16() > 0)
                {
                    db2File.ReadCString("Name");
                }

                if (db2File.ReadUInt16() > 0)
                {
                    db2File.ReadCString("Female Name");
                }

                if (db2File.ReadUInt16() > 0)
                {
                    db2File.ReadCString("SubName");
                }

                if (db2File.ReadUInt16() > 0)
                {
                    db2File.ReadCString("Female SubName");
                }

                db2File.ReadUInt32("Rank");
                db2File.ReadUInt32("Inhabit Type");
                break;
            }

            case DB2Hash.CreatureDifficulty:
            {
                var creatureDifficulty = new CreatureDifficulty();

                var id = db2File.ReadEntry("Id");
                creatureDifficulty.CreatureID = db2File.ReadUInt32("Creature Id");
                creatureDifficulty.FactionID  = db2File.ReadUInt32("Faction Template Id");
                creatureDifficulty.Expansion  = db2File.ReadInt32("Expansion");
                creatureDifficulty.MinLevel   = db2File.ReadInt32("Min Level");
                creatureDifficulty.MaxLevel   = db2File.ReadInt32("Max Level");

                creatureDifficulty.Flags = new uint[5];
                for (var i = 0; i < 5; ++i)
                {
                    creatureDifficulty.Flags[i] = db2File.ReadUInt32("Flags", i);
                }

                Storage.CreatureDifficultys.Add((uint)id.Key, creatureDifficulty, packet.TimeSpan);
                break;
            }

            case DB2Hash.CurvePoint:
            {
                var curvePoint = new CurvePoint();
                var id         = db2File.ReadUInt32("ID");
                curvePoint.CurveID = db2File.ReadUInt32("CurveID");
                curvePoint.Index   = db2File.ReadUInt32("Index");
                curvePoint.X       = db2File.ReadSingle("X");
                curvePoint.Y       = db2File.ReadSingle("Y");

                Storage.CurvePoints.Add(id, curvePoint, packet.TimeSpan);
                break;
            }

            case DB2Hash.GameObjects:     // New structure - 6.0.2
            {
                var gameObjectTemplateDB2 = new GameObjectTemplateDB2();

                var id = db2File.ReadEntry("ID");

                gameObjectTemplateDB2.MapID = db2File.ReadUInt32("Map");

                gameObjectTemplateDB2.DisplayId = db2File.ReadUInt32("DisplayID");

                gameObjectTemplateDB2.PositionX = db2File.ReadSingle("PositionX");
                gameObjectTemplateDB2.PositionY = db2File.ReadSingle("PositionY");
                gameObjectTemplateDB2.PositionZ = db2File.ReadSingle("PositionZ");
                gameObjectTemplateDB2.RotationX = db2File.ReadSingle("RotationX");
                gameObjectTemplateDB2.RotationY = db2File.ReadSingle("RotationY");
                gameObjectTemplateDB2.RotationZ = db2File.ReadSingle("RotationZ");
                gameObjectTemplateDB2.RotationW = db2File.ReadSingle("RotationW");

                gameObjectTemplateDB2.Size = db2File.ReadSingle("Size");

                db2File.ReadInt32("Phase Use Flags");
                gameObjectTemplateDB2.PhaseId      = db2File.ReadInt32("PhaseID");
                gameObjectTemplateDB2.PhaseGroupId = db2File.ReadInt32("PhaseGroupID");

                gameObjectTemplateDB2.Type = db2File.ReadInt32E <GameObjectType>("Type");

                gameObjectTemplateDB2.Data = new int[8];
                for (var i = 0; i < gameObjectTemplateDB2.Data.Length; i++)
                {
                    gameObjectTemplateDB2.Data[i] = db2File.ReadInt32("Data", i);
                }

                if (db2File.ReadUInt16() > 0)
                {
                    gameObjectTemplateDB2.Name = db2File.ReadCString("Name");
                }

                Storage.GameObjectTemplateDB2s.Add((uint)id.Key, gameObjectTemplateDB2, packet.TimeSpan);
                break;
            }

            case DB2Hash.Item:     // New structure - 6.0.2
            {
                var item = Storage.ItemTemplates.ContainsKey(entry)
                        ? Storage.ItemTemplates[entry].Item1
                        : new ItemTemplate();

                db2File.ReadUInt32 <ItemId>("Item ID");
                item.Class    = db2File.ReadInt32E <ItemClass>("Class");
                item.SubClass = db2File.ReadUInt32("Sub Class");
                item.SoundOverrideSubclass = db2File.ReadInt32("Sound Override Subclass");
                item.Material      = db2File.ReadInt32E <Material>("Material");
                item.InventoryType = db2File.ReadUInt32E <InventoryType>("Inventory Type");
                item.SheathType    = db2File.ReadInt32E <SheathType>("Sheath Type");
                db2File.ReadInt32("Icon File Data ID");
                db2File.ReadInt32("Item Group Sounds ID");

                Storage.ItemTemplates.Add(entry, item, packet.TimeSpan);
                packet.AddSniffData(StoreNameType.Item, (int)entry, "DB_REPLY");
                break;
            }

            case DB2Hash.ItemExtendedCost:     // New structure - 6.0.2
            {
                db2File.ReadUInt32("Item Extended Cost ID");
                db2File.ReadUInt32("Required Honor Points");
                db2File.ReadUInt32("Required Arena Points");
                db2File.ReadUInt32("Required Arena Slot");
                for (var i = 0; i < 5; ++i)
                {
                    db2File.ReadUInt32("Required Item", i);
                }

                for (var i = 0; i < 5; ++i)
                {
                    db2File.ReadUInt32("Required Item Count", i);
                }

                db2File.ReadUInt32("Required Personal Arena Rating");
                db2File.ReadUInt32("Item Purchase Group");
                for (var i = 0; i < 5; ++i)
                {
                    db2File.ReadUInt32("Required Currency", i);
                }

                for (var i = 0; i < 5; ++i)
                {
                    db2File.ReadUInt32("Required Currency Count", i);
                }

                db2File.ReadUInt32("Required Faction ID");
                db2File.ReadUInt32("Required Faction Standing");
                db2File.ReadUInt32("Requirement Flags");
                db2File.ReadInt32 <AchievementId>("Required Achievement");
                break;
            }

            case DB2Hash.ItemCurrencyCost:
            {
                db2File.ReadUInt32("ID");
                db2File.ReadUInt32 <ItemId>("Item ID");
                break;
            }

            case DB2Hash.RulesetItemUpgrade:
            {
                db2File.ReadUInt32("ID");
                db2File.ReadUInt32("Item Upgrade Level");
                db2File.ReadUInt32("Item Upgrade ID");
                db2File.ReadUInt32 <ItemId>("Item ID");
                break;
            }

            case DB2Hash.Item_sparse:     // New structure - 6.0.2
            {
                var item = Storage.ItemTemplates.ContainsKey(entry)
                        ? Storage.ItemTemplates[entry].Item1
                        : new ItemTemplate();

                db2File.ReadUInt32 <ItemId>("Item Sparse Entry");
                item.Quality            = db2File.ReadInt32E <ItemQuality>("Quality");
                item.Flags1             = db2File.ReadUInt32E <ItemProtoFlags>("Flags 1");
                item.Flags2             = db2File.ReadInt32E <ItemFlagExtra>("Flags 2");
                item.Flags3             = db2File.ReadUInt32("Flags 3");
                item.Unk430_1           = db2File.ReadSingle("Unk430_1");
                item.Unk430_2           = db2File.ReadSingle("Unk430_2");
                item.BuyCount           = db2File.ReadUInt32("Buy count");
                item.BuyPrice           = db2File.ReadUInt32("Buy Price");
                item.SellPrice          = db2File.ReadUInt32("Sell Price");
                item.InventoryType      = db2File.ReadInt32E <InventoryType>("Inventory Type");
                item.AllowedClasses     = db2File.ReadInt32E <ClassMask>("Allowed Classes");
                item.AllowedRaces       = db2File.ReadInt32E <RaceMask>("Allowed Races");
                item.ItemLevel          = db2File.ReadUInt32("Item Level");
                item.RequiredLevel      = db2File.ReadUInt32("Required Level");
                item.RequiredSkillId    = db2File.ReadUInt32("Required Skill ID");
                item.RequiredSkillLevel = db2File.ReadUInt32("Required Skill Level");
                item.RequiredSpell      = (uint)db2File.ReadInt32 <SpellId>("Required Spell");
                item.RequiredHonorRank  = db2File.ReadUInt32("Required Honor Rank");
                item.RequiredCityRank   = db2File.ReadUInt32("Required City Rank");
                item.RequiredRepFaction = db2File.ReadUInt32("Required Rep Faction");
                item.RequiredRepValue   = db2File.ReadUInt32("Required Rep Value");
                item.MaxCount           = db2File.ReadInt32("Max Count");
                item.MaxStackSize       = db2File.ReadInt32("Max Stack Size");
                item.ContainerSlots     = db2File.ReadUInt32("Container Slots");

                item.StatTypes = new ItemModType[10];
                for (var i = 0; i < 10; i++)
                {
                    var statType = db2File.ReadInt32E <ItemModType>("Stat Type", i);
                    item.StatTypes[i] = statType == ItemModType.None ? ItemModType.Mana : statType;     // TDB
                }

                item.StatValues = new int[10];
                for (var i = 0; i < 10; i++)
                {
                    item.StatValues[i] = db2File.ReadInt32("Stat Value", i);
                }

                item.ScalingValue = new int[10];
                for (var i = 0; i < 10; i++)
                {
                    item.ScalingValue[i] = db2File.ReadInt32("Scaling Value", i);
                }

                item.SocketCostRate = new int[10];
                for (var i = 0; i < 10; i++)
                {
                    item.SocketCostRate[i] = db2File.ReadInt32("Socket Cost Rate", i);
                }

                item.ScalingStatDistribution = db2File.ReadInt32("Scaling Stat Distribution");
                item.DamageType = db2File.ReadInt32E <DamageType>("Damage Type");
                item.Delay      = db2File.ReadUInt32("Delay");
                item.RangedMod  = db2File.ReadSingle("Ranged Mod");
                item.Bonding    = db2File.ReadInt32E <ItemBonding>("Bonding");

                var nameLength = db2File.ReadUInt16();
                item.Name = db2File.ReadWoWString("Name", nameLength, 0);

                for (var i = 1; i < 4; ++i)
                {
                    if (db2File.ReadUInt16() > 0)
                    {
                        db2File.ReadCString("Name", i);
                    }
                }

                var descriptionLength = db2File.ReadUInt16();
                item.Description = db2File.ReadWoWString("Description", descriptionLength);

                item.PageText      = db2File.ReadUInt32("Page Text");
                item.Language      = db2File.ReadInt32E <Language>("Language");
                item.PageMaterial  = db2File.ReadInt32E <PageMaterial>("Page Material");
                item.StartQuestId  = (uint)db2File.ReadInt32 <QuestId>("Start Quest");
                item.LockId        = db2File.ReadUInt32("Lock ID");
                item.Material      = db2File.ReadInt32E <Material>("Material");
                item.SheathType    = db2File.ReadInt32E <SheathType>("Sheath Type");
                item.RandomPropery = db2File.ReadInt32("Random Property");
                item.RandomSuffix  = db2File.ReadUInt32("Random Suffix");
                item.ItemSet       = db2File.ReadUInt32("Item Set");
                item.AreaId        = db2File.ReadUInt32 <AreaId>("Area");
                item.MapId         = db2File.ReadInt32 <MapId>("Map ID");
                item.BagFamily     = db2File.ReadInt32E <BagFamilyMask>("Bag Family");
                item.TotemCategory = db2File.ReadInt32E <TotemCategory>("Totem Category");

                item.ItemSocketColors = new ItemSocketColor[3];
                for (var i = 0; i < 3; i++)
                {
                    item.ItemSocketColors[i] = db2File.ReadInt32E <ItemSocketColor>("Socket Color", i);
                }

                item.SocketBonus               = db2File.ReadInt32("Socket Bonus");
                item.GemProperties             = db2File.ReadInt32("Gem Properties");
                item.ArmorDamageModifier       = db2File.ReadSingle("Armor Damage Modifier");
                item.Duration                  = db2File.ReadUInt32("Duration");
                item.ItemLimitCategory         = db2File.ReadInt32("Limit Category");
                item.HolidayId                 = db2File.ReadInt32E <Holiday>("Holiday");
                item.StatScalingFactor         = db2File.ReadSingle("Stat Scaling Factor");
                item.CurrencySubstitutionId    = db2File.ReadUInt32("Currency Substitution Id");
                item.CurrencySubstitutionCount = db2File.ReadUInt32("Currency Substitution Count");
                item.flagsCustom               = db2File.ReadUInt32("Flags Custom");

                Storage.ObjectNames.Add(entry, new ObjectName {
                        ObjectType = ObjectType.Item, Name = item.Name
                    },
                                        packet.TimeSpan);
                packet.AddSniffData(StoreNameType.Item, (int)entry, "DB_REPLY");
                break;
            }

            case DB2Hash.KeyChain:
            {
                db2File.ReadUInt32("Key Chain ID");
                db2File.ReadBytes("Key", 32);
                break;
            }

            case DB2Hash.SceneScript:     // lua ftw!
            {
                db2File.ReadUInt32("Scene Script ID");
                var nameLength = db2File.ReadUInt16();
                db2File.ReadWoWString("Name", nameLength);

                var scriptLength = db2File.ReadUInt16();
                db2File.ReadWoWString("Script", scriptLength);
                db2File.ReadUInt32("Previous Scene Script Part");
                db2File.ReadUInt32("Next Scene Script Part");
                break;
            }

            case DB2Hash.SpellMisc:     // New structure - 6.0.2
            {
                var spellMisc = new SpellMisc();

                var id = db2File.ReadEntry("ID");

                spellMisc.Attributes       = db2File.ReadUInt32("Attributes");
                spellMisc.AttributesEx     = db2File.ReadUInt32("AttributesEx");
                spellMisc.AttributesExB    = db2File.ReadUInt32("AttributesExB");
                spellMisc.AttributesExC    = db2File.ReadUInt32("AttributesExC");
                spellMisc.AttributesExD    = db2File.ReadUInt32("AttributesExD");
                spellMisc.AttributesExE    = db2File.ReadUInt32("AttributesExE");
                spellMisc.AttributesExF    = db2File.ReadUInt32("AttributesExF");
                spellMisc.AttributesExG    = db2File.ReadUInt32("AttributesExG");
                spellMisc.AttributesExH    = db2File.ReadUInt32("AttributesExH");
                spellMisc.AttributesExI    = db2File.ReadUInt32("AttributesExI");
                spellMisc.AttributesExJ    = db2File.ReadUInt32("AttributesExJ");
                spellMisc.AttributesExK    = db2File.ReadUInt32("AttributesExK");
                spellMisc.AttributesExL    = db2File.ReadUInt32("AttributesExL");
                spellMisc.AttributesExM    = db2File.ReadUInt32("AttributesExM");
                spellMisc.CastingTimeIndex = db2File.ReadUInt32("CastingTimeIndex");
                spellMisc.DurationIndex    = db2File.ReadUInt32("DurationIndex");
                spellMisc.RangeIndex       = db2File.ReadUInt32("RangeIndex");
                spellMisc.Speed            = db2File.ReadSingle("Speed");

                spellMisc.SpellVisualID = new uint[2];
                for (var i = 0; i < 2; ++i)
                {
                    spellMisc.SpellVisualID[i] = db2File.ReadUInt32("SpellVisualID", i);
                }

                spellMisc.SpellIconID         = db2File.ReadUInt32("SpellIconID");
                spellMisc.ActiveIconID        = db2File.ReadUInt32("ActiveIconID");
                spellMisc.SchoolMask          = db2File.ReadUInt32("SchoolMask");
                spellMisc.MultistrikeSpeedMod = db2File.ReadSingle("MultistrikeSpeedMod");

                Storage.SpellMiscs.Add((uint)id.Key, spellMisc, packet.TimeSpan);
                break;
            }

            case DB2Hash.Toy:     // New structure - 6.0.2
            {
                db2File.ReadUInt32("ID");
                db2File.ReadUInt32 <ItemId>("Item ID");
                db2File.ReadUInt32("Flags");

                var descriptionLength = db2File.ReadUInt16();
                db2File.ReadWoWString("Description", descriptionLength);

                db2File.ReadInt32("Source Type");
                break;
            }

            case DB2Hash.Vignette:
            {
                db2File.ReadUInt32("Vignette ID");
                var nameLength = db2File.ReadUInt16();
                db2File.ReadWoWString("Name", nameLength);

                db2File.ReadUInt32("Icon");
                db2File.ReadUInt32("Flag");     // not 100% sure (8 & 32 as values only) - todo verify with more data
                db2File.ReadSingle("Unk Float 1");
                db2File.ReadSingle("Unk Float 2");
                break;
            }

            case DB2Hash.WbAccessControlList:
            {
                db2File.ReadUInt32("Id");

                var addressLength = db2File.ReadUInt16();
                db2File.ReadWoWString("Address", addressLength);

                db2File.ReadUInt32("Unk MoP 1");
                db2File.ReadUInt32("Unk MoP 2");
                db2File.ReadUInt32("Unk MoP 3");
                db2File.ReadUInt32("Unk MoP 4");     // flags?
                break;
            }

            default:
            {
                db2File.AddValue("Unknown DB2 file type", string.Format("{0} (0x{0:x})", type));
                for (var i = 0;; ++i)
                {
                    if (db2File.Length - 4 >= db2File.Position)
                    {
                        var    blockVal = db2File.ReadUpdateField();
                        string key      = "Block Value " + i;
                        string value    = blockVal.UInt32Value + "/" + blockVal.SingleValue;
                        packet.AddValue(key, value);
                    }
                    else
                    {
                        var left = db2File.Length - db2File.Position;
                        for (var j = 0; j < left; ++j)
                        {
                            string key   = "Byte Value " + i;
                            var    value = db2File.ReadByte();
                            packet.AddValue(key, value);
                        }
                        break;
                    }
                }
                break;
            }
            }

            if (db2File.Length != db2File.Position)
            {
                packet.WriteLine("Packet not fully read! Current position is {0}, length is {1}, and diff is {2}.",
                                 db2File.Position, db2File.Length, db2File.Length - db2File.Position);

                if (db2File.Length < 300) // If the packet isn't "too big" and it is not full read, print its hex table
                {
                    packet.AsHex();
                }

                packet.Status = ParsedStatus.WithErrors;
            }
        }
コード例 #9
0
        public override void drawControlHandles(ref List <string> visited, Matrix4x4 consumerM, bool beingDrawnFromConsumer)
        {
            Matrix4x4 prevHandlesMatrix = Handles.matrix;

            FreeCurve gener = (FreeCurve)parametricObject.generator;



            base.drawControlHandles(ref visited, consumerM, true);

            if (alreadyVisited(ref visited, "FreeCurveHandler"))
            {
                return;
            }



            AXParameter p = parametricObject.getParameter("Output Shape");

            if (p == null || p.getPaths() == null)
            {
                return;
            }


            parametricObject.model.addActiveFreeCurve(parametricObject);

            Event e = Event.current;

            if (ArchimatixEngine.sceneViewState == ArchimatixEngine.SceneViewState.AddPoint && e.type == EventType.keyDown && (e.keyCode == KeyCode.Escape || e.keyCode == KeyCode.Return))
            {
                ArchimatixEngine.setSceneViewState(ArchimatixEngine.SceneViewState.Default);


                e.Use();
            }


            handlePoints = new List <Vector2>();


            bool handleHasChanged = false;

            /*
             * Matrix4x4 context        = parametricObject.model.transform.localToWorldMatrix * generator.parametricObject.worldDisplayMatrix;
             * if (generator.hasOutputsConnected() || parametricObject.is2D())
             *      context *= generator.localMatrix.inverse;
             * else
             *      context *= parametricObject.getAxisRotationMatrix().inverse  * generator.localMatrix.inverse * parametricObject.getAxisRotationMatrix();
             *
             * Handles.matrix = context;
             */
            Handles.matrix = parametricObject.model.transform.localToWorldMatrix * generator.parametricObject.worldDisplayMatrix;            // * generator.localMatrix.inverse;


            float gridDim = parametricObject.model.snapSizeGrid * 100;

            // axis
            Handles.color = Color.red;
            Handles.DrawLine(new Vector3(-gridDim / 2, 0, 0), new Vector3(gridDim / 2, 0, 0));
            Handles.color = Color.green;
            Handles.DrawLine(new Vector3(0, -gridDim / 2, 0), new Vector3(0, gridDim / 2, 0));

            // grid

            if (ArchimatixEngine.snappingOn())
            {
                Handles.color = new Color(1, .5f, .65f, .15f);
            }
            else
            {
                Handles.color = new Color(1, .5f, .65f, .05f);
            }


            AXEditorUtilities.DrawGrid3D(gridDim, parametricObject.model.snapSizeGrid);



            //Handles.matrix = Matrix4x4.identity;

            CurvePoint newCurvePoint      = null;;
            int        newCurvePointIndex = -1;

            if (parametricObject.curve != null)
            {
                //if (Event.current.type == EventType.mouseDown)
                //	selectedIndex = -1;

                //Vector3 pos;



                for (int i = 0; i < parametricObject.curve.Count; i++)
                {
                    //Debug.Log (i + ": "+ parametricObject.curve[i].position);

                    // Control points in Curve

                    bool pointIsSelected = (generator.selectedIndices != null && generator.selectedIndices.Contains(i));



                    Vector3 pos = new Vector3(parametricObject.curve[i].position.x, parametricObject.curve[i].position.y, 0);



                    Handles.color = (pointIsSelected) ? Color.white :  Color.magenta;

                    float capSize = .13f * HandleUtility.GetHandleSize(pos);

                    if (pointIsSelected)
                    {
                        capSize = .17f * HandleUtility.GetHandleSize(pos);
                    }



                    // POSITION
                    //pos = new Vector3(parametricObject.curve[i].position.x, parametricObject.curve[i].position.y, 0);

//					pos = Handles.FreeMoveHandle(
//						pos,
//						Quaternion.identity,
//						capSize,
//						Vector3.zero,
//						(controlID, positione, rotation, size) =>
//					{
//						if (GUIUtility.hotControl > 0 && controlID == GUIUtility.hotControl)
//						Debug.Log("YOP");
//						Handles.SphereCap(controlID, positione, rotation, size);
//					});


                    pos = Handles.FreeMoveHandle(
                        pos,
                        Quaternion.identity,
                        capSize,
                        Vector3.zero,
                        (controlID, position, rotation, size) =>
                    {
                        if (GUIUtility.hotControl > 0 && controlID == GUIUtility.hotControl)
                        {
                            //Debug.Log("*** " + e.type + " -" + e.keyCode + "-");

                            // MOUSE DOWN ON HANDLE!

                            Undo.RegisterCompleteObjectUndo(parametricObject.model, "FreeCurve");
                            //Debug.Log(controlID + ": " + e.type);

                            ArchimatixEngine.selectedFreeCurve = gener;

                            //Debug.Log("SELECT NODE " +i + " ci="+controlID);

                            if (i == 0 && ArchimatixEngine.sceneViewState == ArchimatixEngine.SceneViewState.AddPoint)
                            {
                                generator.P_Output.shapeState = ShapeState.Closed;
                                ArchimatixEngine.setSceneViewState(ArchimatixEngine.SceneViewState.Default);
                            }
                            else if (e.shift && !ArchimatixEngine.mouseIsDownOnHandle)
                            {
                                generator.toggleItem(i);
                            }

                            else if (gener.selectedIndices == null || gener.selectedIndices.Count < 2)
                            {
                                if (!generator.isSelected(i))
                                {
                                    generator.selectOnlyItem(i);
                                }
                            }
                            ArchimatixEngine.isPseudoDraggingSelectedPoint = i;

                            // CONVERT TO BEZIER
                            if (e.alt)
                            {
                                gener.convertToBezier(i);
                            }



                            for (int j = 0; j < generator.P_Output.Dependents.Count; j++)
                            {
                                generator.P_Output.Dependents [j].parametricObject.generator.adjustWorldMatrices();
                            }


                            ArchimatixEngine.mouseDownOnSceneViewHandle();
                        }


                        Handles.SphereCap(controlID, position, rotation, size);
                    });



                    // MID_SEGEMNET HANDLE

                    if (i < parametricObject.curve.Count)
                    {
                        //Handles.matrix = parametricObject.model.transform.localToWorldMatrix * generator.parametricObject.worldDisplayMatrix * generator.localMatrix.inverse;

                        Handles.color = Color.cyan;

                        //Debug.Log("mid handle "+i);

                        CurvePoint a = parametricObject.curve[i];

                        int next_i = (i == parametricObject.curve.Count - 1) ? 0 : i + 1;

                        CurvePoint b = parametricObject.curve[next_i];

                        if (a.isPoint() && b.isPoint())
                        {
                            pos = Vector2.Lerp(a.position, b.position, .5f);
                        }
                        else
                        {
                            Vector2 pt = FreeCurve.bezierValue(a, b, .5f);
                            pos = (Vector3)pt;
                        }

                        EditorGUI.BeginChangeCheck();

                                                #if UNITY_5_6_OR_NEWER
                        pos = Handles.FreeMoveHandle(
                            pos,
                            Quaternion.identity,
                            .06f * HandleUtility.GetHandleSize(pos),
                            Vector3.zero,
                            (controlID, positione, rotation, size, eventType) =>
                        {
                            if (GUIUtility.hotControl > 0 && controlID == GUIUtility.hotControl)
                            {
                                ArchimatixEngine.selectedFreeCurve = gener;
                            }
                            Handles.CubeHandleCap(controlID, positione, rotation, size, eventType);
                        });
                                                #else
                        pos = Handles.FreeMoveHandle(
                            pos,
                            Quaternion.identity,
                            .06f * HandleUtility.GetHandleSize(pos),
                            Vector3.zero,
                            (controlID, positione, rotation, size) =>
                        {
                            if (GUIUtility.hotControl > 0 && controlID == GUIUtility.hotControl)
                            {
                                ArchimatixEngine.selectedFreeCurve = gener;
                            }
                            Handles.CubeCap(controlID, positione, rotation, size);
                        });
                                                #endif

                        if (EditorGUI.EndChangeCheck())
                        {
                            // add point to spline at i using pos.x, pos.y
                            Undo.RegisterCompleteObjectUndo(parametricObject.model, "New Midpoint");

                            //Debug.Log(pos);
                            //Debug.Log(ArchimatixEngine.isPseudoDraggingSelectedPoint + " ::: " + (i));

                            //if (ArchimatixEngine.isPseudoDraggingSelectedPoint != (i+1))
                            if (ArchimatixEngine.isPseudoDraggingSelectedPoint == -1)
                            {
                                //Debug.Log("CREATE!!!!");
                                newCurvePoint = new CurvePoint(pos.x, pos.y);

                                newCurvePointIndex = i + 1;

                                parametricObject.curve.Insert(newCurvePointIndex, newCurvePoint);
                                ArchimatixEngine.isPseudoDraggingSelectedPoint = newCurvePointIndex;
                                generator.selectedIndex = newCurvePointIndex;

                                generator.selectOnlyItem(newCurvePointIndex);
                            }

                            parametricObject.model.isAltered();
                        }
                    }
                }                 // \loop


                // BEZIER HANDLES LOOP
                for (int i = 0; i < parametricObject.curve.Count; i++)
                {
                    //Debug.Log (i + ": "+ parametricObject.curve[i].position);

                    // Control points in Curve

                    bool pointIsSelected = (generator.selectedIndices != null && generator.selectedIndices.Contains(i));



                    Vector3 pos  = new Vector3(parametricObject.curve[i].position.x, parametricObject.curve[i].position.y, 0);
                    Vector3 posA = new Vector3(parametricObject.curve[i].position.x + parametricObject.curve[i].localHandleA.x, parametricObject.curve[i].position.y + parametricObject.curve[i].localHandleA.y, 0);
                    Vector3 posB = new Vector3(parametricObject.curve[i].position.x + parametricObject.curve[i].localHandleB.x, parametricObject.curve[i].position.y + parametricObject.curve[i].localHandleB.y, 0);


                    Handles.color = (pointIsSelected) ? Color.white :  Color.magenta;



                    if (pointIsSelected)
                    {
                        Handles.color = Color.magenta;

                        if (parametricObject.curve[i].isBezierPoint())
                        {
                            Handles.color = Color.white;
                            Handles.DrawLine(pos, posA);
                            Handles.DrawLine(pos, posB);



                            EditorGUI.BeginChangeCheck();
                            posA = Handles.FreeMoveHandle(
                                posA,
                                Quaternion.identity,
                                .1f * HandleUtility.GetHandleSize(pos),
                                Vector3.zero,
                                Handles.SphereCap
                                );

                            if (EditorGUI.EndChangeCheck())
                            {
                                Undo.RegisterCompleteObjectUndo(parametricObject.model, "FreeformShapee");
                                handleHasChanged = true;

                                parametricObject.curve[i].setHandleA(new Vector2(posA.x, posA.y));



                                //parametricObject.curve[i].localHandleA = new Vector2(pos.x, pos.y) - parametricObject.curve[i].position;
                                //parametricObject.model.generate("Move FreeForm Shape Handle");
                                parametricObject.model.isAltered();
                            }



                            // HANDLE_B


                            EditorGUI.BeginChangeCheck();
                            posB = Handles.FreeMoveHandle(
                                posB,
                                Quaternion.identity,
                                .1f * HandleUtility.GetHandleSize(pos),
                                Vector3.zero,
                                Handles.SphereCap
                                );

                            if (EditorGUI.EndChangeCheck())
                            {
                                Undo.RegisterCompleteObjectUndo(parametricObject.model, "FreeformShapee");
                                handleHasChanged = true;
                                //parametricObject.curve[i].localHandleB = new Vector2(pos.x, pos.y) - parametricObject.curve[i].position;
                                parametricObject.curve[i].setHandleB(new Vector2(posB.x, posB.y));



                                //parametricObject.model.generate("Move FreeForm Shape Handle");
                                parametricObject.model.isAltered();
                            }
                        }
                    }             // selected
                }                 // \bezier handles loop



                if (handleHasChanged)
                {
                }
            }

            Handles.matrix = prevHandlesMatrix;
        }
コード例 #10
0
ファイル: Spline.cs プロジェクト: burkewm/Unigine-Spline
    public CubicBezierCurveSegment(int index, SplinePosition startPoint, SplinePosition endPoint, CurvePoint curvePoint_1, CurvePoint curvePoint_2)
    {
        _index        = index;
        start_point   = startPoint;
        end_point     = endPoint;
        curve_point_1 = curvePoint_1;
        curve_point_2 = curvePoint_2;
        _useMainSpeed = true;
        startSpeed    = 1;
        endSpeed      = 1;

        CalcLength();
    }
コード例 #11
0
        private void UserControl_Loaded(object sender, RoutedEventArgs e)
        {
            Points[0] = new List <CurvePoint>();
            Points[1] = new List <CurvePoint>();
            Points[2] = new List <CurvePoint>();
            Points[3] = new List <CurvePoint>();

            foreach (MathHelpers.Point pt in Input[0])
            {
                CurvePoint cp = new CurvePoint(this);
                cp.HorizontalAlignment = HorizontalAlignment.Left;
                cp.VerticalAlignment   = VerticalAlignment.Top;
                cp.Width      = 8;
                cp.Height     = 8;
                cp.MouseDown += Point_MouseDown;
                cp.MouseUp   += Point_MouseUp;
                cp.MouseMove += Point_MouseMove;
                cp.Normalized = pt;

                Points[0].Add(cp);
                CurveView.Children.Add(cp);
            }

            foreach (MathHelpers.Point pt in Input[1])
            {
                CurvePoint cp = new CurvePoint(this);
                cp.HorizontalAlignment = HorizontalAlignment.Left;
                cp.VerticalAlignment   = VerticalAlignment.Top;
                cp.Width      = 8;
                cp.Height     = 8;
                cp.MouseDown += Point_MouseDown;
                cp.MouseUp   += Point_MouseUp;
                cp.MouseMove += Point_MouseMove;
                cp.Normalized = pt;

                Points[1].Add(cp);
            }

            foreach (MathHelpers.Point pt in Input[2])
            {
                CurvePoint cp = new CurvePoint(this);
                cp.HorizontalAlignment = HorizontalAlignment.Left;
                cp.VerticalAlignment   = VerticalAlignment.Top;
                cp.Width      = 8;
                cp.Height     = 8;
                cp.MouseDown += Point_MouseDown;
                cp.MouseUp   += Point_MouseUp;
                cp.MouseMove += Point_MouseMove;
                cp.Normalized = pt;

                Points[2].Add(cp);
            }

            foreach (MathHelpers.Point pt in Input[3])
            {
                CurvePoint cp = new CurvePoint(this);
                cp.HorizontalAlignment = HorizontalAlignment.Left;
                cp.VerticalAlignment   = VerticalAlignment.Top;
                cp.Width      = 8;
                cp.Height     = 8;
                cp.MouseDown += Point_MouseDown;
                cp.MouseUp   += Point_MouseUp;
                cp.MouseMove += Point_MouseMove;
                cp.Normalized = pt;

                Points[3].Add(cp);
            }

            inited = true;

            UpdatePath();

            Channels.SelectedIndex = 0;
            ValueRange.SetButtonPositions();
        }
コード例 #12
0
 public Sec1702Mapping(CurvePoint generator)
     : base(generator)
 {
 }
コード例 #13
0
ファイル: Curve.cs プロジェクト: schani/bwprocessor
    public void SetPoint(uint index, float x, float y)
    {
        CurvePoint p = new CurvePoint (x, y);

        points [(int)index] = p;

        needRecalc = true;
    }
コード例 #14
0
        // GENERATE FREE_CURVE
        public override GameObject generate(bool makeGameObjects, AXParametricObject initiator_po, bool isReplica)
        {
            parametricObject.transMatrix = Matrix4x4.TRS(new Vector3(transX, transY, 0), Quaternion.Euler(0, 0, rotZ), new Vector3(1, 1, 1));


            //Debug.Log ("IntPoint = " + parametricObject.ip.X + " --- " + parametricObject.TestInt);

            if (P_Output != null && parametricObject.curve != null)
            {
                //Curve transformedCurve = parametricObject.getTransformedCurve();

                //Output.spline = Archimatix.curve2Spline (transformedCurve);

                // ControlPaths
                P_Output.controlPaths = new Paths();                    // not to be altered in base postprocessing for offset and wallthick

                // use the "curve" to generate the source path

                // bezier experiment

                // EACH SEGMENT
                Path path = new Path();



                for (int i = 0; i <= parametricObject.curve.Count - 1; i++)
                {
                    if (i == parametricObject.curve.Count - 1 && P_Output.shapeState == ShapeState.Open)
                    {
                        break;
                    }

                    CurvePoint a = parametricObject.curve[i];

                    int next_i = (i == parametricObject.curve.Count - 1) ? 0 : i + 1;

                    CurvePoint b = parametricObject.curve[next_i];

                    if (a.isPoint() && b.isPoint())
                    {
                        if (i == 0)
                        {
                            path.Add(AXGeometryTools.Utilities.Vec2_2_IntPt(a.position));
                        }

                        path.Add(AXGeometryTools.Utilities.Vec2_2_IntPt(b.position));
                    }
                    else
                    {
                        int governor = 0;
                        for (float t = 0; t <= (1 + .9f * timetick); t = t + timetick)
                        {
                            if (governor++ > 50)
                            {
                                Debug.Log("governor hit)");
                                break;
                            }

                            if (i == 0 || t > 0)
                            {
                                Vector2 pt = bezierValue(parametricObject.curve[i], parametricObject.curve[next_i], t);
                                path.Add(AXGeometryTools.Utilities.Vec2_2_IntPt(pt));
                            }
                        }
                    }
                }

                /*
                 * if (P_Output.shapeState == ShapeState.Closed && (parametricObject.curve[0] || parametricObject.curve[parametricObject.curve.Count-1].isBezierPoint()))
                 * {
                 *      // draw last Bezier curve
                 *
                 *
                 * }
                 */

                //	path = Clipper.CleanPolygon(path, .01f);

//				if (path != null)
//				{
//					if (! Clipper.Orientation(path))
//						path.Reverse();
//
//				}



                P_Output.controlPaths.Add(path);

                P_Output.transformedControlPaths = P_Output.getTransformedControlPaths();
                P_Output.paths    = P_Output.getTransformedControlPaths();                                                       // may be altered before generate is over...
                P_Output.polyTree = null;


                base.generate(false, initiator_po, isReplica);
            }
            else
            {
                Debug.Log("no path");
            }



            base.generate(false, initiator_po, isReplica);

            calculateBounds();



            return(null);
        }
コード例 #15
0
ファイル: Bezier.cs プロジェクト: FredZvt/BezierStudy
    public static void DrawPath(
        Curve[] curves,
        CurvePoint[] path,
        bool drawCurve = true, Color? curveColor = null,
        bool drawHandles = true, float handlesRadius = .2f, Color? handlesColor = null, 
        bool drawPoints = true, float pointRadius = .2f, Color? pointsColor = null,
        bool drawTangents = true, float tangentsSize = .2f, Color? tangentsColor = null,
        bool drawNormals = true, float normalsSize = .2f, Color? normalsColor = null,
        bool drawBinormals = true, float binormalsSize = .2f, Color? binormalsColor = null
        )
    {
        var oldGizmosColor = Gizmos.color;

        handlesColor = handlesColor ?? Color.gray;
        curveColor = curveColor ?? Color.white;
        pointsColor = pointsColor ?? Color.gray;
        tangentsColor = tangentsColor ?? Color.blue;
        normalsColor = normalsColor ?? Color.green;
        binormalsColor = binormalsColor ?? Color.red;

        if (curves != null && drawHandles)
        {
            for (var i = 0; i < curves.Length; i++)
            {
                Gizmos.color = handlesColor.Value;
                Gizmos.DrawLine(curves[i].start, curves[i].startControlPoint);
                Gizmos.DrawLine(curves[i].end, curves[i].endControlPoint);
                Gizmos.DrawWireSphere(curves[i].startControlPoint, handlesRadius);
                Gizmos.DrawWireSphere(curves[i].endControlPoint, handlesRadius);
                Gizmos.DrawWireSphere(curves[i].start, handlesRadius);
                Gizmos.DrawWireSphere(curves[i].end, handlesRadius);
            }
        }

        if (path != null)
        {
            if (drawCurve || drawPoints || drawTangents || drawNormals || drawBinormals)
            {
                var lastPoint = path[0];

                for (var i = 0; i < path.Length; i++)
                {
                    Gizmos.color = curveColor.Value;
                    if (i > 0 && drawCurve)
                        Gizmos.DrawLine(lastPoint.position, path[i].position);

                    Gizmos.color = pointsColor.Value;
                    if (drawPoints)
                        Gizmos.DrawWireSphere(path[i].position, pointRadius);

                    Gizmos.color = tangentsColor.Value;
                    if (drawTangents)
                        Gizmos.DrawLine(path[i].position, path[i].position + (path[i].tangent * tangentsSize));

                    Gizmos.color = normalsColor.Value;
                    if (drawNormals)
                        Gizmos.DrawLine(path[i].position, path[i].position + (path[i].normal * normalsSize));

                    var distBetweenThisPointAndLastTangent = (path[i].position - (lastPoint.position + (lastPoint.tangent * tangentsSize))).magnitude;

                    Gizmos.color = binormalsColor.Value;
                    if (drawBinormals)
                    {

                        Gizmos.DrawLine(path[i].position, path[i].position + (path[i].binormal * binormalsSize * distBetweenThisPointAndLastTangent));
                    }

                    lastPoint = path[i];
                }
            }
        }

        Gizmos.color = oldGizmosColor;
    }
コード例 #16
0
ファイル: Bezier.cs プロジェクト: FredZvt/BezierStudy
    public static CurvePoint[] GetPointsInPath(Curve[] curves, byte resolutionPerSegment)
    {
        var pathPoints = new CurvePoint[(resolutionPerSegment * curves.Length) + 1];
        for (var i = 0; i < curves.Length; i++)
        {
            var points = GetPointsInCurve(curves[i], resolutionPerSegment);
            var pointsToGetInThisSegment = resolutionPerSegment;

            if (i == curves.Length - 1)
                pointsToGetInThisSegment++;

            var offset = resolutionPerSegment * i;
            for (var j = 0; j < pointsToGetInThisSegment; j++)
                pathPoints[offset + j] = points[j];
        }
        return pathPoints;
    }
コード例 #17
0
ファイル: Bezier.cs プロジェクト: FredZvt/BezierStudy
    public static CurvePoint[] GetPointsInCurve(
        Vector3 start,
        Vector3 startControlPoint,
        Vector3 end,
        Vector3 endControlPoint,
        byte resolution)
    {
        if (resolution < 2)
            throw new ArgumentException("Resolution must be greater than two.");

        var path = new CurvePoint[resolution + 1];
        var increment = 1f / resolution;

        for (var i = 0; i < resolution + 1; i++)
            path[i] = GetPointInCurve(start, startControlPoint, end, endControlPoint, i * increment);

        return path;
    }
コード例 #18
0
ファイル: Bezier.cs プロジェクト: FredZvt/BezierStudy
    public static CurvePoint GetPointInCurve(
        Vector3 start,
        Vector3 startControlPoint,
        Vector3 end,
        Vector3 endControlPoint,
        float time)
    {
        float omt = 1f - time;
        float omt2 = omt * omt;
        float t2 = time * time;

        var point = new CurvePoint();

        point.position =
            start * (omt2 * omt) +
            startControlPoint * (3f * omt2 * time) +
            endControlPoint * (3f * omt * t2) +
            end * (t2 * time);

        point.tangent =
            (start * (-omt2) +
            startControlPoint * (3f * omt2 - 2 * omt) +
            endControlPoint * (-3f * t2 + 2 * time) +
            end * (t2)).normalized;

        point.binormal = Vector3.Cross(Vector3.up, point.tangent).normalized;
        point.normal = Vector3.Cross(point.tangent, point.binormal).normalized;
        point.rotation = Quaternion.LookRotation(point.tangent, point.normal);

        return point;
    }
コード例 #19
0
        public CurvePoint NewCurvePoint()
        {
            CurvePoint point = points[points.Length - 1];

            return(new CurvePoint(point.curvePoint + point.curveTangent * 0.5f, point.curveTangent));
        }
コード例 #20
0
ファイル: Party.cs プロジェクト: ThreePointSquare/ecc-sharp
 public CurvePoint Multiply(CurvePoint point)
 {
     return(point.Multiply(PrivateKey));
 }
コード例 #21
0
ファイル: Party.cs プロジェクト: ThreePointSquare/ecc-sharp
 public bool VerifySignature(string message, Point signature, CurvePoint publicKey)
 {
     return(Generator.VerifySignature(message, signature, publicKey));
 }
コード例 #22
0
    public void OnSceneGUI()
    {
        bool changed = false;

//		foreach(CurvePoint point in cubicBezierSpline.points) {
        if (cubicBezierSpline.points != null)
        {
            for (int i = 0; i < cubicBezierSpline.points.Count; i++)
            {
                CurvePoint point = cubicBezierSpline.points[i];
                Handles.color = Color.red;
                Vector3 oldPosition = point.Position;
                Vector3 newPosition = Handles.FreeMoveHandle(point.Position, Quaternion.identity, 1f, Vector3.zero, Handles.SphereCap);
                if (newPosition != oldPosition)
                {
                    point.Position = newPosition;
                    changed        = true;
                }

                Handles.color = Color.green;
                oldPosition   = point.StartTangentPosition;
                newPosition   = Handles.FreeMoveHandle(point.StartTangentPosition, Quaternion.identity, 0.5f, Vector3.zero, Handles.SphereCap);
                if (newPosition != oldPosition)
                {
                    point.StartTangentPosition = newPosition;
                    changed = true;
                }

                Handles.color = Color.blue;
                oldPosition   = point.EndTangentPosition;
                newPosition   = Handles.FreeMoveHandle(point.EndTangentPosition, Quaternion.identity, 0.5f, Vector3.zero, Handles.SphereCap);
                if (newPosition != oldPosition)
                {
                    point.EndTangentPosition = newPosition;
                    changed = true;
                }

                Handles.color = Color.yellow;
                Handles.DrawLine(point.Position, point.StartTangentPosition);
                Handles.DrawLine(point.Position, point.EndTangentPosition);
                Handles.Label(point.Position + Vector3.one, "P" + i);
            }

            if (changed)
            {
                cubicBezierSpline.RecalculateCurve();
            }
        }


//		Vector3 worldPoint = GetXZPlaneCollisionInEditor(currentEvent);
//
//			Handles.color = Color.green;
//			Handles.DrawLine(node.transform.position, worldPoint);
//
//			if(currentEvent.type == EventType.MouseDown) {
//
//				GameObject newNode = Instantiate(node.gameObject) as GameObject;
//				newNode.transform.position = worldPoint;
//				newNode.name = "newNode";
//
//				Selection.activeGameObject = newNode;
//			}


        if (GUI.changed)
        {
            EditorUtility.SetDirty(cubicBezierSpline);
        }
    }
コード例 #23
0
ファイル: Party.cs プロジェクト: ThreePointSquare/ecc-sharp
 public Party(CurvePoint generator, CurvePoint publicKey)
 {
     Generator = generator;
     PublicKey = publicKey;
 }
コード例 #24
0
 public static Vector2  bezierValue(CurvePoint a, CurvePoint b, float t)
 {
     return(Mathf.Pow((1 - t), 3) * a.position + 3 * Mathf.Pow((1 - t), 2) * t * (a.position + a.localHandleB) + 3 * (1 - t) * t * t * (b.position + b.localHandleA) + Mathf.Pow(t, 3) * b.position);
 }
コード例 #25
0
ファイル: Party.cs プロジェクト: ThreePointSquare/ecc-sharp
 public Party(CurvePoint generator)
 {
     Generator  = generator;
     PrivateKey = BigInteger.Remainder(Core.RandomService.Generate(Configurations.MathConfiguration.KeyBitLength), generator.Order);
     PublicKey  = generator.Multiply(PrivateKey);
 }
コード例 #26
0
 public MessageMapping(CurvePoint generator)
 {
     Generator = generator;
 }
コード例 #27
0
        static void Main(string[] args)
        {
            var extents = MeasureGCode(GetTemplateReader());

            Console.WriteLine("Template extents:");

            Console.WriteLine("    From     Centre   To");
            Console.WriteLine("X   {0,5:##0.0}    {1,5:##0.0}    {2,5:##0.0}", extents.X.From, extents.X.Middle, extents.X.To);
            Console.WriteLine("Y   {0,5:##0.0}    {1,5:##0.0}    {2,5:##0.0}", extents.Y.From, extents.Y.Middle, extents.Y.To);
            Console.WriteLine("Z   {0,5:##0.0}    {1,5:##0.0}    {2,5:##0.0}", extents.Z.From, extents.Z.Middle, extents.Z.To);

            List <CurvePoint> curvePoints = new List <CurvePoint>();

            decimal deltaX = 0.0m;
            decimal deltaY = 0.0m;

            string outputFileName = "RetractionTest.gcode";

            if (args.Length == 0)
            {
                curvePoints.Add(
                    new CurvePoint()
                {
                    PointType  = CurvePointType.SameValueUntil,
                    Z          = FirstTowerZ,
                    Retraction = 2m,
                });

                curvePoints.Add(
                    new CurvePoint()
                {
                    PointType  = CurvePointType.InterpolateUpTo,
                    Z          = extents.Z.To,
                    Retraction = 3m,
                });
            }
            else
            {
                int index = 0;

                while (index < args.Length)
                {
                    CurvePoint curvePoint = new CurvePoint();

                    string argName = args[index].ToLowerInvariant();

                    switch (argName)
                    {
                    case "/output":
                    {
                        outputFileName = args[index + 1];
                        index++;

                        continue;
                    }

                    case "/center":
                    {
                        deltaX = decimal.Parse(args[index + 1]) - extents.X.Middle;
                        deltaY = decimal.Parse(args[index + 2]) - extents.Y.Middle;

                        index += 3;

                        continue;
                    }

                    case "/startwith":
                    {
                        var initialPoint = new CurvePoint();

                        initialPoint.PointType  = CurvePointType.SameValueUntil;
                        initialPoint.Z          = FirstTowerZ;
                        initialPoint.Retraction = decimal.Parse(args[index + 1]);

                        curvePoints.Add(initialPoint);

                        index += 2;

                        continue;
                    }

                    case "/setat":
                    case "/interpolateto":
                    {
                        switch (argName)
                        {
                        case "/setat": curvePoint.PointType = CurvePointType.SameValueUntil; break;

                        case "/interpolateto": curvePoint.PointType = CurvePointType.InterpolateUpTo; break;
                        }

                        curvePoint.Z          = decimal.Parse(args[index + 1]);
                        curvePoint.Retraction = decimal.Parse(args[index + 2]);

                        curvePoints.Add(curvePoint);

                        index += 3;

                        continue;
                    }

                    case "/checkfile":
                    {
                        AnalyzeFile(args[index + 1]);

                        return;
                    }
                    }

                    throw new Exception("Invalid command-line format");
                }
            }

            Console.WriteLine();

            if ((deltaX != 0) || (deltaY != 0))
            {
                Console.WriteLine(
                    "Will translate test print to be centred at ({0:##0.0}, {1:##0.0})",
                    extents.X.Middle + deltaX,
                    extents.Y.Middle + deltaY);
                Console.WriteLine();
            }

            Console.WriteLine("Z    ? Retraction");

            int lastCurvePointsPassed = 0;

            const decimal GraphRowHeight = 0.5m;

            for (decimal z = 17.0m; z >= FirstTowerZ - GraphRowHeight; z -= GraphRowHeight)
            {
                bool lastExtraRow = false;

                if (z < FirstTowerZ)
                {
                    lastExtraRow = true;
                    z            = FirstTowerZ;
                }

                Console.Write(z.ToString("#0.0").PadLeft(4));
                Console.Write(' ');

                int curvePointsPassed = curvePoints.Count(point => point.Z >= z);

                if (curvePointsPassed == lastCurvePointsPassed)
                {
                    Console.Write("  ");
                }
                else
                {
                    Console.Write("+ ");
                    lastCurvePointsPassed = curvePointsPassed;
                }

                var retraction = GetRetractionForZ(z, curvePoints);

                Console.Write(retraction.ToString("#0.0000 ").PadLeft(8));

                int barWidth = (int)Math.Round(retraction * 5m);

                for (int i = 0; i < barWidth; i++)
                {
                    Console.Write('*');
                }

                Console.WriteLine();

                if (lastExtraRow)
                {
                    break;
                }
            }

            Console.WriteLine();
            Console.WriteLine("Will write output to: {0}", outputFileName);

            using (var writer = new StreamWriter(outputFileName))
            {
                Console.WriteLine();
                Console.WriteLine("Generating G code...");

                TranslateGCode(
                    GetTemplateReader(),
                    writer,
                    FirstTowerZ,
                    deltaX,
                    deltaY,
                    curvePoints);
            }

            Console.WriteLine();
            Console.WriteLine(Path.GetFullPath(outputFileName));
        }
コード例 #28
0
    public static List <CurvePoint> EvalBspline(List <Vector3> P, int steps, bool averageBNT, float3 initNormal)
    {
        // Check
        if (P.Count < 4)
        {
            Debug.LogError("evalBspline must be called with 4 or more control points.");
            return(null);
        }

        // Change of basis from
        // B-spline to Bezier.
        Matrix4x4 Bbs = new Matrix4x4();

        Bbs.SetRow(0, new Vector4(1, -3, 3, -1) / 6);
        Bbs.SetRow(1, new Vector4(4, 0, -6, 3) / 6);
        Bbs.SetRow(2, new Vector4(1, 3, 3, -3) / 6);
        Bbs.SetRow(3, new Vector4(0, 0, 0, 1) / 6);

        Matrix4x4 Bbz = new Matrix4x4();

        Bbz.SetRow(0, new Vector4(1, -3, 3, -1));
        Bbz.SetRow(1, new Vector4(0, 3, -6, 3));
        Bbz.SetRow(2, new Vector4(0, 0, 3, -3));
        Bbz.SetRow(3, new Vector4(0, 0, 0, 1));

        Matrix4x4 transMat = Bbs * Bbz.inverse;

        List <CurvePoint> result = new List <CurvePoint>(P.Count * steps);

        for (int i = 0; i < P.Count - 3; ++i)
        {
            Matrix4x4 cps = new Matrix4x4(), transformedCps = new Matrix4x4();
            cps.SetColumn(0, P[i].ToVector4(1));
            cps.SetColumn(1, P[i + 1].ToVector4(1));
            cps.SetColumn(2, P[i + 2].ToVector4(1));
            cps.SetColumn(3, P[i + 3].ToVector4(1));
            transformedCps = cps * transMat;

            List <CurvePoint> tmp;
            if (i == 0)
            {
                tmp = CoreBezier(new Vector3(transformedCps.m00, transformedCps.m10, transformedCps.m20),
                                 new Vector3(transformedCps.m01, transformedCps.m11, transformedCps.m21),
                                 new Vector3(transformedCps.m02, transformedCps.m12, transformedCps.m22),
                                 new Vector3(transformedCps.m03, transformedCps.m13, transformedCps.m23), initNormal, steps);
            }
            else
            {
                tmp = CoreBezier(new Vector3(transformedCps.m00, transformedCps.m10, transformedCps.m20),
                                 new Vector3(transformedCps.m01, transformedCps.m11, transformedCps.m21),
                                 new Vector3(transformedCps.m02, transformedCps.m12, transformedCps.m22),
                                 new Vector3(transformedCps.m03, transformedCps.m13, transformedCps.m23), result[result.Count - 1].N, steps);
            }

            if (i == 0)
            {
                result.AddRange(tmp);
            }
            else
            {
                tmp.RemoveAt(0);
                result.AddRange(tmp);
            }
        }

        if (averageBNT)
        {
            result.RemoveAt(result.Count - 1);
            for (int n = 0; n < 10; ++n)
            {
                for (int i = 0; i < result.Count; ++i)
                {
                    Matrix4x4 beforeRot = new Matrix4x4(), afterRot = new Matrix4x4();
                    if (i == 0)
                    {
                        beforeRot.SetColumn(0, result[result.Count - 1].N);
                        beforeRot.SetColumn(1, result[result.Count - 1].B);
                        beforeRot.SetColumn(2, result[result.Count - 1].T);
                        beforeRot.SetColumn(3, new Vector4(0, 0, 0, 1));

                        afterRot.SetColumn(0, result[i + 1].N);
                        afterRot.SetColumn(1, result[i + 1].B);
                        afterRot.SetColumn(2, result[i + 1].T);
                        afterRot.SetColumn(3, new Vector4(0, 0, 0, 1));
                    }
                    else if (i == result.Count - 1)
                    {
                        beforeRot.SetColumn(0, result[i - 1].N);
                        beforeRot.SetColumn(1, result[i - 1].B);
                        beforeRot.SetColumn(2, result[i - 1].T);
                        beforeRot.SetColumn(3, new Vector4(0, 0, 0, 1));
                        afterRot.SetColumn(0, result[0].N);
                        afterRot.SetColumn(1, result[0].B);
                        afterRot.SetColumn(2, result[0].T);
                        afterRot.SetColumn(3, new Vector4(0, 0, 0, 1));
                    }
                    else
                    {
                        beforeRot.SetColumn(0, result[i - 1].N);
                        beforeRot.SetColumn(1, result[i - 1].B);
                        beforeRot.SetColumn(2, result[i - 1].T);
                        beforeRot.SetColumn(3, new Vector4(0, 0, 0, 1));
                        afterRot.SetColumn(0, result[i + 1].N);
                        afterRot.SetColumn(1, result[i + 1].B);
                        afterRot.SetColumn(2, result[i + 1].T);
                        afterRot.SetColumn(3, new Vector4(0, 0, 0, 1));
                    }
                    Quaternion beforeQ  = beforeRot.ToQuaternion();
                    Quaternion afterQ   = afterRot.ToQuaternion();
                    Quaternion avQ      = Quaternion.Slerp(afterQ, beforeQ, 0.5f);
                    Matrix4x4  avMatrix = Matrix4x4.TRS(Vector3.zero, avQ, Vector3.one);
                    CurvePoint p        = result[i];
                    p.N       = avMatrix.GetColumn(0).normalized;
                    p.B       = avMatrix.GetColumn(1).normalized;
                    p.T       = avMatrix.GetColumn(2).normalized;
                    result[i] = p;
                }
            }
        }

        // Return an empty curve right now.
        return(result);
    }
コード例 #29
0
 public IActionResult UpdateCurvePoint(int id, [FromBody] CurvePoint curvePoint)
 {
     // TODO: check required fields, if valid call service to update Curve and return Curve list
     return(Redirect("/curvepoint/list"));
 }
コード例 #30
0
ファイル: Spline.cs プロジェクト: burkewm/Unigine-Spline
    public QuadraticBezierCurveSegment(int index, SplinePosition startPoint, SplinePosition endPoint, CurvePoint curvePoint, float speed)
    {
        _index        = index;
        start_point   = startPoint;
        end_point     = endPoint;
        curve_point   = curvePoint;
        _useMainSpeed = false;
        startSpeed    = speed;
        endSpeed      = speed;

        CalcLength();
    }
コード例 #31
0
ファイル: CurveWidget.cs プロジェクト: schani/bwprocessor
 void CurvePointAdded(CurvePoint p)
 {
     curve.AddPoint((float)p.X, (float)p.Y);
     points.Add(p);
     ProcessCurveChange();
 }
コード例 #32
0
ファイル: Spline.cs プロジェクト: burkewm/Unigine-Spline
    public CubicBezierCurveSegment(int index, SplinePosition startPoint, SplinePosition endPoint, CurvePoint curvePoint_1, CurvePoint curvePoint_2, float start_speed, float end_speed)
    {
        _index        = index;
        start_point   = startPoint;
        end_point     = endPoint;
        curve_point_1 = curvePoint_1;
        curve_point_2 = curvePoint_2;
        _useMainSpeed = false;
        startSpeed    = start_speed;
        endSpeed      = end_speed;

        CalcLength();
    }
コード例 #33
0
ファイル: CurveWidget.cs プロジェクト: schani/bwprocessor
    void CurvePointRemoved(CurvePoint p)
    {
        int index = IndexOfPoint(p);

        curve.RemovePointIndex((uint)index);
        points.RemoveAt(index);
        ProcessCurveChange();
    }
コード例 #34
0
 bool IsPointWithinSegment(CurvePoint p1, CurvePoint p2, float x)
 {
     return(p1.x < x && p2.x >= x);
 }
コード例 #35
0
    public List <CurvePoint> GetPointsWithTangentAdjustment(bool includeLastPoint = true, bool createDoublePointsOnSharpEdges = false)
    {
        List <CurvePoint> curvePoints = new List <CurvePoint> ();

        if (points.Count == 1)
        {
            curvePoints.Add(new CurvePoint(points [0].GetPosition(), Vector3.zero, Vector3.zero));
            return(curvePoints);
        }

        int loopCount = points.Count - 1;

        if (connectedCurve && points.Count > 1)
        {
            loopCount++;
        }

        for (int i = 0; i < loopCount; i++)
        {
            int  i0 = i;
            int  i1 = (i + 1) % points.Count;
            int  lc = loopCount - 1;
            bool isLastAnchorPoint = i == lc;

            BezierPoint p0 = points [i0];
            BezierPoint p1 = points [i1];

            float   accumulatedDistance = 0.0f;
            float   tangentDot          = 1.0f;
            Vector3 lastTangent         = Vector3.zero;
            Vector3 lastPosition        = Vector3.zero;

            for (int j = 0; j <= sampleRate; j++)
            {
                bool isLastPointOnCurvePart = j == sampleRate;
                bool c1          = isLastPointOnCurvePart && !isLastAnchorPoint;
                bool isLastPoint = isLastPointOnCurvePart && isLastAnchorPoint;
                bool c2          = c1 && p1.pointType != BezierPointType.Connected && createDoublePointsOnSharpEdges;

                if (!c2)
                {
                    if (c1 || isLastPoint && connectedCurve && !includeLastPoint)
                    {
                        continue;
                    }
                }

                float stepC = (float)j / (float)sampleRate;
                float stepF = stepC + 0.005f;
                float stepB = stepC - 0.005f;

                Vector3 posC = GetPoint(p0, p1, stepC);
                Vector3 posF = GetPoint(p0, p1, stepF);
                Vector3 posB = GetPoint(p0, p1, stepB);

                Vector3 tangent = (posF - posB);
                Vector3 normal  = Vector3.Cross(tangent, Vector3.forward);

                CurvePoint curvePoint = new CurvePoint(posC, normal, tangent, i1);

                if (isLastPointOnCurvePart)
                {
                    curvePoints.Add(curvePoint);
                    continue;
                }

                if (j > 0)
                {
                    tangentDot           = Vector3.Dot(tangent.normalized, lastTangent.normalized);
                    accumulatedDistance += Vector3.Distance(posC, lastPosition);

                    if (tangentDot < 1.0f - tangentLimit || accumulatedDistance >= minDistance)
                    {
                        lastPosition = posC;
                        lastTangent  = tangent;
                        curvePoints.Add(curvePoint);
                        accumulatedDistance = 0.0f;
                    }
                }
                else
                {
                    lastPosition = posC;
                    lastTangent  = tangent;
                    curvePoints.Add(curvePoint);
                }
            }
        }

        return(curvePoints);
    }
コード例 #36
0
 public void Awake()
 {
     curvePoint = target as CurvePoint;
 }
コード例 #37
0
ファイル: Party.cs プロジェクト: ThreePointSquare/ecc-sharp
 internal CurvePoint GenerateKey(CurvePoint generator)
 {
     return(new CurvePoint(generator, PrivateKey));
 }
コード例 #38
0
ファイル: CurveWidget.cs プロジェクト: schani/bwprocessor
    void CurvePointChanged(CurvePoint p)
    {
        int index = IndexOfPoint(p);

        curve.SetPoint((uint)index, (float)p.X, (float)p.Y);
        ProcessCurveChange();
    }
コード例 #39
0
ファイル: Testing.cs プロジェクト: ravitle/Smart-Album
        /// <summary>
        /// creates learning curve after learning+deciding about given precentage of pictures according to percent[]
        /// </summary>
        /// <param name="folderAll">folder of all images</param>
        /// <param name="folderTrue">folder of true images</param>
        /// <param name="learn">data learning object for learning</param>
        /// <param name="decide">decision making object for deciding</param>
        /// <param name="percent">percentages to use for learning (percent.length is number of points in learning curve)</param>
        /// <returns>true if succeeded creating the curve</returns>
        public static CurvePoint[] LearningCurve(string folderAll, string folderTrue, DataLearning learning, DecisionMaking deciding, int[] percent, out double[] simpleAlgo,
            Testing.HandleIdenticalMethod identical, bool excludeTrainingSet)
        {
            _progress = 0;
            int itrCount=0;
            simpleAlgo = new double[3];
            //randomLearningCurve = null;
            const int ITERATIONS_PER_POINT = 5;

            // Make All, True & False files lists
            List<string> allFiles, falseFiles, trueFiles;
            try
            {
                allFiles = LoadImages(folderAll).ToList();
                trueFiles = LoadImages(folderTrue).ToList();
                falseFiles = SubstractListsByFileName(allFiles, trueFiles);
                trueFiles = SubstractListsByFileName(allFiles, falseFiles);  // In order for the path to be via 'allFiles' folder
            }
            catch (Exception exc)
            {
                MessageBox.Show(exc.Message);
                return null;
            }

            // Handle duplicates
            ProgressString = "Checking for identicals with different choise";
            HandleIdenticalVectorWithDifferentChoise(ref allFiles, ref trueFiles, ref falseFiles, learning.Repository, identical);

            //create curve of percent.length number of points
            ProgressString = "Calculating Curves";
            CurvePoint[] learningCurve = new CurvePoint[percent.Length];            //for main graph
            //randomLearningCurve = new CurvePoint[percent.Length];      //for random algorithm graph
            for (int k = 0; k < percent.Length; k++)
            {
                learningCurve[k] = new CurvePoint(percent[k]);
               // randomLearningCurve[k] = new CurvePoint(percent[k]);
                for (int itr = 0; itr < ITERATIONS_PER_POINT; itr++)
                {
                    //get wanted amount of randome images
                    List<string> chosenFiles;
                    do chosenFiles = getRandomImages(allFiles, percent[k]);
                    while (SubstractListsByFileName(chosenFiles, trueFiles).Count == 0 || SubstractListsByFileName(chosenFiles, falseFiles).Count == 0); // incase only true or only false was chosen

                    //get new lists of true and false files (Used for learning in current curve point)
                    List<string> subsetTrueFiles = SubstractListsByFileName(chosenFiles, falseFiles);
                    List<string> subsetFalseFiles = SubstractListsByFileName(chosenFiles, trueFiles);

                    //-------------------------------------
                    //learn from subsets
                    learning.LearnForTesting(chosenFiles, subsetTrueFiles);

                    //-------------------------------------
                    //decide for all files
                    double[] results;
                    deciding.DecideForTesting(allFiles, learning.Repository, out results);

                    //-------------------------------------
                    //make true and false lists according to results
                    List<string> resultsTrue = new List<string>();
                    List<string> resultsFalse = new List<string>();
                    for (int i = 0; i < results.Length; i++)
                        if (results[i]>0) //*******here deside for testing*******/
                            resultsTrue.Add(allFiles[i]);
                        else
                            resultsFalse.Add(allFiles[i]);

                    //-------------------------------------
                    //calculate success precentage
                    CurvePoint.SingleCurvePointCalc currentIteration = new CurvePoint.SingleCurvePointCalc(trueFiles, falseFiles, subsetTrueFiles, subsetFalseFiles, resultsTrue, resultsFalse, excludeTrainingSet);
                    learningCurve[k].AddSingleCurvePointCalc(currentIteration);

                    //-------------------------------------
                    //get simple algorithms calculations
                     double simpleFalseNegative,
                           simpleFalsePositive,
                           simpleSuccess;
                     Testing.SimpleAlgorithm.CalcStatisticalAlgorithm(allFiles.Count, trueFiles.Count, out simpleSuccess, out simpleFalseNegative, out simpleFalsePositive);
                    simpleAlgo[0] = simpleSuccess*100;
                    simpleAlgo[1] = simpleFalseNegative * 100;
                    simpleAlgo[2] = simpleFalsePositive * 100;

                    // Update progress indicators
                    itrCount++;
                    _progress = (int)((itrCount * 100)/(ITERATIONS_PER_POINT * percent.Length));
                }
            }

            ProgressString = "Done Calculating Curves";
            return learningCurve;
        }
コード例 #40
0
ファイル: CurveWidget.cs プロジェクト: schani/bwprocessor
 int IndexOfPoint(CurvePoint p)
 {
     for (int i = 0; i < points.Count; ++i)
         if (points[i] == p)
             return i;
     return -1;
 }
コード例 #41
0
ファイル: Wallet.cs プロジェクト: SpotLabsNET/BitcoinTool
 public string PrivateKeyDER(bool compressed)
 {
     return(Encoders.BytesToHex(CurvePoint.GetDER(compressed)));
 }