Пример #1
0
 public FrameObjectModel(FrameObjectModel other) : base(other)
 {
     blendInfoIndex        = other.blendInfoIndex;
     skeletonIndex         = other.skeletonIndex;
     skeletonHierachyIndex = other.skeletonHierachyIndex;
     skeleton  = other.skeleton;
     blendInfo = other.blendInfo;
     restPose  = new TransformMatrix[skeleton.NumBones[0]];
     for (int i = 0; i != restPose.Length; i++)
     {
         restPose[i] = new TransformMatrix(other.restPose[i]);
     }
     unkTrasform          = other.unkTrasform;
     attachmentReferences = new AttachmentReference[other.attachmentReferences.Length];
     for (int i = 0; i != attachmentReferences.Length; i++)
     {
         attachmentReferences[i] = new AttachmentReference(other.attachmentReferences[i]);
     }
     unkFlags        = other.unkFlags;
     physSplitSize   = other.physSplitSize;
     hitBoxSize      = other.hitBoxSize;
     nPhysSplits     = other.nPhysSplits;
     blendMeshSplits = new WeightedByMeshSplit[nPhysSplits];
     for (int i = 0; i != blendMeshSplits.Length; i++)
     {
         blendMeshSplits[i] = new WeightedByMeshSplit(other.blendMeshSplits[i]);
     }
     hitBoxInfo = new HitBoxInfo[other.hitBoxInfo.Length];
     for (int i = 0; i != hitBoxInfo.Length; i++)
     {
         hitBoxInfo[i] = new HitBoxInfo(hitBoxInfo[i]);
     }
 }
Пример #2
0
        public void ReadFromFilePart2(BinaryReader reader, FrameSkeleton skeleton, FrameBlendInfo blendInfo)
        {
            this.skeleton  = skeleton;
            this.blendInfo = blendInfo;

            //do rest matrices.
            restPose = new TransformMatrix[skeleton.NumBones[0]];
            for (int i = 0; i != restPose.Length; i++)
            {
                restPose[i] = new TransformMatrix(reader);
            }

            //unknown transform.
            unkTrasform = new TransformMatrix(reader);

            //attachments.
            int length1 = reader.ReadInt32();

            attachmentReferences = new AttachmentReference[length1];

            for (int i = 0; i != length1; i++)
            {
                attachmentReferences[i] = new AttachmentReference(reader);
            }

            //unknwon.
            unkFlags      = reader.ReadUInt32();
            physSplitSize = reader.ReadInt32();
            hitBoxSize    = reader.ReadInt32();

            if (physSplitSize > 0)
            {
                nPhysSplits = reader.ReadInt16();
            }
            else
            {
                nPhysSplits = 0;
            }

            int totalSplits = 0;

            blendMeshSplits = new WeightedByMeshSplit[nPhysSplits];
            for (int i = 0; i != nPhysSplits; i++)
            {
                blendMeshSplits[i] = new WeightedByMeshSplit(reader);
                totalSplits       += blendMeshSplits[i].Data.Length;
            }

            hitBoxInfo = new HitBoxInfo[totalSplits];
            for (int i = 0; i != hitBoxInfo.Length; i++)
            {
                hitBoxInfo[i] = new HitBoxInfo(reader);
            }
        }
        public void ReadFromFilePart2(MemoryStream stream, bool isBigEndian)
        {
            //do rest matrices.
            restTransform = new Matrix[skeleton.NumBones[0]];
            for (int i = 0; i != restTransform.Length; i++)
            {
                restTransform[i] = MatrixExtensions.ReadFromFile(stream, isBigEndian);
            }


            //unknown transform.
            unkTransform = MatrixExtensions.ReadFromFile(stream, isBigEndian);

            //attachments.
            int length1 = stream.ReadInt32(isBigEndian);

            attachmentReferences = new AttachmentReference[length1];

            for (int i = 0; i != length1; i++)
            {
                attachmentReferences[i] = new AttachmentReference(stream, isBigEndian);
            }

            //unknwon.
            unkFlags      = stream.ReadUInt32(isBigEndian);
            physSplitSize = stream.ReadInt32(isBigEndian);
            hitBoxSize    = stream.ReadInt32(isBigEndian);

            if (physSplitSize > 0)
            {
                nPhysSplits = stream.ReadInt16(isBigEndian);
            }
            else
            {
                nPhysSplits = 0;
            }

            int totalSplits = 0;

            blendMeshSplits = new WeightedByMeshSplit[nPhysSplits];
            for (int i = 0; i != nPhysSplits; i++)
            {
                blendMeshSplits[i] = new WeightedByMeshSplit(stream, isBigEndian);
                int index = blendInfo.BoneIndexInfos[0].IDs[blendMeshSplits[i].BlendIndex];
                blendMeshSplits[i].JointName = skeleton.BoneNames[index].ToString();
                totalSplits += blendMeshSplits[i].Data.Length;
            }

            hitBoxInfo = new HitBoxInfo[totalSplits];
            for (int i = 0; i != hitBoxInfo.Length; i++)
            {
                hitBoxInfo[i] = new HitBoxInfo(stream, isBigEndian);
            }
        }
Пример #4
0
        public CollisionBox(HitBoxInfo info)
            : base(info.Box.X, info.Box.Y, info.Box.Width, info.Box.Height)
        {
            ID = nextID;
            nextID++;

            Name          = info.Name;
            ContactDamage = info.ContactDamage;
            Environment   = info.Environment;
            PushAway      = info.PushAway;

            Hits       = new List <string>(info.Hits);
            Groups     = new List <string>(info.Groups);
            resistance = new Dictionary <string, float>(info.Resistance);
            Properties = Game.CurrentGame.TileProperties.GetProperties(info.PropertiesName);
        }
Пример #5
0
        private void WriteHitbox(HitBoxInfo box, XmlWriter writer)
        {
            writer.WriteStartElement("Hitbox");

            if (box.Name != null)
            {
                writer.WriteAttributeString("name", box.Name);
            }

            writer.WriteAttributeString("x", box.Box.X.ToString());
            writer.WriteAttributeString("y", box.Box.Y.ToString());
            writer.WriteAttributeString("width", box.Box.Width.ToString());
            writer.WriteAttributeString("height", box.Box.Height.ToString());

            if (box.PropertiesName != null)
            {
                writer.WriteAttributeString("properties", box.PropertiesName);
            }

            if (box.ContactDamage != 0)
            {
                writer.WriteAttributeString("damage", box.ContactDamage.ToString());
            }

            writer.WriteAttributeString("environment", box.Environment.ToString());
            writer.WriteAttributeString("pushaway", box.PushAway.ToString());

            foreach (var hit in box.Hits)
            {
                writer.WriteElementString("Hits", hit);
            }

            foreach (var group in box.Groups)
            {
                writer.WriteElementString("Group", group);
            }

            foreach (var resist in box.Resistance)
            {
                writer.WriteStartElement("Resist");
                writer.WriteAttributeString("name", resist.Key);
                writer.WriteAttributeString("multiply", resist.Value.ToString());
                writer.WriteEndElement();
            }

            writer.WriteEndElement();
        }
        private static HitBoxInfo GetHitbox(XElement boxnode)
        {
            var width  = boxnode.GetAttribute <int>("width");
            var height = boxnode.GetAttribute <int>("height");
            var x      = boxnode.GetAttribute <int>("x");
            var y      = boxnode.GetAttribute <int>("y");

            var box = new HitBoxInfo()
            {
                Name           = boxnode.TryAttribute <string>("name"),
                Box            = new Common.Geometry.Rectangle(x, y, width, height),
                ContactDamage  = boxnode.TryAttribute <float>("damage"),
                Environment    = boxnode.TryAttribute <bool>("environment", true),
                PushAway       = boxnode.TryAttribute <bool>("pushaway", true),
                PropertiesName = boxnode.TryAttribute <string>("properties", "Default")
            };

            return(box);
        }
Пример #7
0
        public IEffectPartInfo Load(XElement partNode)
        {
            var info = new CollisionEffectPartInfo();

            var rects = new List <HitBoxInfo>();
            HashSet <string> enables = new HashSet <string>();

            info.ClearEnabled = partNode.Element("Clear") != null;

            var enable = partNode.Element("Enabled");

            if (enable != null)
            {
                info.Enabled = enable.GetValue <bool>();
            }

            foreach (var box in partNode.Elements("Hitbox"))
            {
                var boxinfo = new HitBoxInfo()
                {
                    Box = new Rectangle()
                    {
                        X      = box.GetAttribute <int>("x"),
                        Y      = box.GetAttribute <int>("y"),
                        Width  = box.GetAttribute <int>("width"),
                        Height = box.GetAttribute <int>("height")
                    },
                    ContactDamage  = box.TryAttribute <float>("damage"),
                    Environment    = box.TryAttribute <bool>("environment", true),
                    PushAway       = box.TryAttribute <bool>("pushaway", true),
                    PropertiesName = box.TryAttribute <string>("properties", "Default")
                };

                foreach (var groupnode in box.Elements("Hits"))
                {
                    boxinfo.Hits.Add(groupnode.Value);
                }

                foreach (var groupnode in box.Elements("Group"))
                {
                    boxinfo.Groups.Add(groupnode.Value);
                }

                foreach (var resistNode in box.Elements("Resist"))
                {
                    var   resistName = resistNode.GetAttribute <string>("name");
                    float mult       = resistNode.GetAttribute <float>("multiply");
                    boxinfo.Resistance.Add(resistName, mult);
                }

                rects.Add(boxinfo);
            }

            foreach (var enableBox in partNode.Elements("EnableBox"))
            {
                enables.Add(enableBox.GetAttribute <string>("name"));
            }

            info.HitBoxes     = rects;
            info.EnabledBoxes = enables;

            return(info);
        }
Пример #8
0
 public HitBoxInfo(HitBoxInfo other)
 {
     unk  = other.unk;
     pos  = new Short3(other.pos);
     size = new Short3(other.size);
 }