Exemplo n.º 1
0
        public static void ReadSkeleton(this TreeNodeCustom skl, Skeleton skeleton, FSKL RenderableSkeleton)
        {
            if (skeleton.MatrixToBoneList == null)
            {
                skeleton.MatrixToBoneList = new List <ushort>();
            }

            RenderableSkeleton.Node_Array = new int[skeleton.MatrixToBoneList.Count];
            int nodes = 0;

            foreach (ushort node in skeleton.MatrixToBoneList)
            {
                RenderableSkeleton.Node_Array[nodes] = node;
                nodes++;
            }

            foreach (Bone bone in skeleton.Bones.Values)
            {
                BfresBone STBone = new BfresBone(RenderableSkeleton);
                ReadBone(STBone, bone);
                RenderableSkeleton.bones.Add(STBone);
            }
            RenderableSkeleton.update();
            RenderableSkeleton.reset();

            foreach (var bone in RenderableSkeleton.bones)
            {
                if (bone.Parent == null)
                {
                    skl.Nodes.Add(bone);
                }
            }
        }
Exemplo n.º 2
0
        public static void SetSkeleton(this TreeNodeCustom skl, Skeleton skeleton, FSKL RenderableSkeleton)
        {
            if (skeleton.MatrixToBoneList == null)
            {
                skeleton.MatrixToBoneList = new List <ushort>();
            }

            RenderableSkeleton.Node_Array = new int[skeleton.MatrixToBoneList.Count];
            int nodes = 0;

            foreach (ushort node in skeleton.MatrixToBoneList)
            {
                RenderableSkeleton.Node_Array[nodes] = node;
                nodes++;
            }
            for (int i = 0; i < skeleton.Bones.Count; i++)
            {
                if (skeleton.InverseModelMatrices == null)
                {
                    break;
                }

                if (i < skeleton.InverseModelMatrices.Count)
                {
                    RenderableSkeleton.matrices.Add(Utils.ToMat3x4(skeleton.InverseModelMatrices[i]));
                }
                else
                {
                    RenderableSkeleton.matrices.Add(Matrix3x4.Zero);
                }
            }
            foreach (Bone bone in skeleton.Bones.Values)
            {
                BfresBone STBone = new BfresBone(RenderableSkeleton);
                SetBone(STBone, bone);
                STBone.BFRESRender = RenderableSkeleton.node.BFRESRender; //to update viewport on bone edits
                RenderableSkeleton.bones.Add(STBone);

                if (bone.InverseMatrix != null)
                {
                    RenderableSkeleton.matrices.Add(Utils.ToMat3x4(bone.InverseMatrix));
                }
            }
            RenderableSkeleton.update();
            RenderableSkeleton.reset();

            //     foreach (var bone in RenderableSkeleton.bones)
            //     if (bone.Parent == null)
            //      skl.Nodes.Add(bone);

            Runtime.abstractGlDrawables.Add(RenderableSkeleton);
        }
Exemplo n.º 3
0
            public void Read(FileReader reader, TreeNodeCustom node)
            {
                reader.ByteOrder = Syroot.BinaryData.ByteOrder.LittleEndian;

                reader.ReadSignature(4, "BNSH");
                uint padding = reader.ReadUInt32();
                uint Version = reader.ReadUInt32();

                SetVersionInfo(Version);
                ushort ByteOrderMark = reader.ReadUInt16();
                byte   Alignment     = reader.ReadByte();
                byte   Target        = reader.ReadByte();

                FileName = reader.LoadString(0, DataType.uint32);
                uint PathOffset            = reader.ReadUInt32();
                uint RelocationTableOffset = reader.ReadUInt32();
                uint FileSize = reader.ReadUInt32();

                reader.Seek(0x40); //padding
                reader.ReadSignature(4, "grsc");

                uint  BlockOffset = reader.ReadUInt32();
                ulong BlockSize   = reader.ReadUInt64();

                reader.Seek(0x0C);
                uint VariationCount  = reader.ReadUInt32();
                long VariationOffset = reader.ReadUInt32();

                reader.Seek(VariationOffset, SeekOrigin.Begin);
                for (int i = 0; i < VariationCount; i++)
                {
                    ShaderVariation var = new ShaderVariation();
                    var.Text = "Shader Variation" + i;
                    var.Read(reader);
                    ShaderVariations.Add(var);
                    node.Nodes.Add(var);
                }

                reader.Close();
                reader.Dispose();
            }
Exemplo n.º 4
0
        public static void SetSkeleton(this TreeNodeCustom skl, Skeleton skeleton, FSKL RenderableSkeleton)
        {
            if (skeleton.MatrixToBoneList == null)
            {
                skeleton.MatrixToBoneList = new List <ushort>();
            }

            RenderableSkeleton.Node_Array = new int[skeleton.MatrixToBoneList.Count];
            int nodes = 0;

            foreach (ushort node in skeleton.MatrixToBoneList)
            {
                RenderableSkeleton.Node_Array[nodes] = node;
                nodes++;
            }

            foreach (Bone bone in skeleton.Bones.Values)
            {
                BfresBone STBone = new BfresBone(RenderableSkeleton);
                SetBone(STBone, bone);
                STBone.BFRESRender = RenderableSkeleton.node.BFRESRender; //to update viewport on bone edits
                RenderableSkeleton.bones.Add(STBone);
            }
            RenderableSkeleton.update();
            RenderableSkeleton.reset();

            foreach (var bone in RenderableSkeleton.bones)
            {
                if (bone.Parent == null)
                {
                    skl.Nodes.Add(bone);
                }
            }

            Runtime.abstractGlDrawables.Add(RenderableSkeleton);
        }