コード例 #1
0
        private void ParseSkeleton(int offset)
        {
            //Init
            int unk1Offset = BitConverter.ToInt32(rawBytes, offset + 20) + offset;
            int unk2Offset = BitConverter.ToInt32(rawBytes, offset + 24) + offset;

            //Skeleton init
            eskFile.Skeleton = new ESK_Skeleton()
            {
                I_02     = BitConverter.ToInt16(rawBytes, offset + 2),
                I_28     = BitConverter_Ex.ToInt32Array(rawBytes, offset + 28, 2),
                Unk1     = ESK_Unk1.Read(rawBytes, unk1Offset),
                UseUnk2  = (unk2Offset != 0) ? true : false,
                ESKBones = new ObservableCollection <ESK_Bone>()
            };

            //Setting the offsets for the initial loop to use
            int[] offsets               = GetBoneOffset(0, offset);
            int   boneIndexOffset       = offsets[0];
            int   nameOffset            = offsets[1];
            int   skinningMatrixOffset  = offsets[2];
            int   transformMatrixOffset = offsets[3];

            while (true)
            {
                int      idx    = eskFile.Skeleton.ESKBones.Count;
                ESK_Bone parent = ESK_Bone.Read(bytes, rawBytes, offsets, _index, null);
                eskFile.Skeleton.ESKBones.Add(parent);
                _index += 1;
                if (BitConverter.ToInt16(rawBytes, boneIndexOffset + 2) != -1)
                {
                    eskFile.Skeleton.ESKBones[idx].ESK_Bones = ParseChildrenBones(BitConverter.ToInt16(rawBytes, boneIndexOffset + 2), offset, parent);
                }
                //Loop management
                if (BitConverter.ToInt16(rawBytes, boneIndexOffset + 4) != -1)
                {
                    //There is a sibling
                    offsets               = GetBoneOffset(BitConverter.ToInt16(rawBytes, boneIndexOffset + 4), offset);
                    boneIndexOffset       = offsets[0];
                    nameOffset            = offsets[1];
                    skinningMatrixOffset  = offsets[2];
                    transformMatrixOffset = offsets[3];
                }
                else
                {
                    //There is no sibling. End loop.
                    break;
                }
            }
        }
コード例 #2
0
        private ObservableCollection <ESK_Bone> ParseChildrenBones(int indexOfFirstSibling, int offset, ESK_Bone parent)
        {
            ObservableCollection <ESK_Bone> newBones = new ObservableCollection <ESK_Bone>();

            int[] offsets               = GetBoneOffset(indexOfFirstSibling, offset);
            int   boneIndexOffset       = offsets[0];
            int   nameOffset            = offsets[1];
            int   skinningMatrixOffset  = offsets[2];
            int   transformMatrixOffset = offsets[3];

            while (true)
            {
                int      idx  = newBones.Count;
                ESK_Bone bone = ESK_Bone.Read(bytes, rawBytes, offsets, _index, parent);
                newBones.Add(bone);
                _index += 1;
                if (BitConverter.ToInt16(rawBytes, boneIndexOffset + 2) != -1)
                {
                    newBones[idx].ESK_Bones = ParseChildrenBones(BitConverter.ToInt16(rawBytes, boneIndexOffset + 2), offset, bone);
                }
                //Loop management
                if (BitConverter.ToInt16(rawBytes, boneIndexOffset + 4) != -1)
                {
                    //There is a sibling
                    offsets               = GetBoneOffset(BitConverter.ToInt16(rawBytes, boneIndexOffset + 4), offset);
                    boneIndexOffset       = offsets[0];
                    nameOffset            = offsets[1];
                    skinningMatrixOffset  = offsets[2];
                    transformMatrixOffset = offsets[3];
                }
                else
                {
                    //There is no sibling. End loop.
                    break;
                }
            }

            return(newBones);
        }