Example #1
0
        public static void ReadModel(FMDL model, Model mdl)
        {
            if (model == null)
            {
                model = new FMDL();
            }
            model.Text     = mdl.Name;
            model.Skeleton = new FSKL(mdl.Skeleton);

            model.Nodes.RemoveAt(2);
            model.Nodes.Add(model.Skeleton.node);

            model.ModelU = mdl;
            foreach (Material mat in mdl.Materials.Values)
            {
                FMAT FMAT = new FMAT();
                FMAT.Text = mat.Name;
                FMAT.ReadMaterial(mat);
                model.Nodes["FmatFolder"].Nodes.Add(FMAT);
                model.materials.Add(FMAT.Text, FMAT);
            }
            foreach (Shape shp in mdl.Shapes.Values)
            {
                VertexBuffer vertexBuffer = mdl.VertexBuffers[shp.VertexBufferIndex];
                Material     material     = mdl.Materials[shp.MaterialIndex];
                FSHP         mesh         = new FSHP();
                ReadShapesVertices(mesh, shp, vertexBuffer, model);
                mesh.MaterialIndex = shp.MaterialIndex;

                model.Nodes["FshpFolder"].Nodes.Add(mesh);
                model.shapes.Add(mesh);
            }
        }
Example #2
0
        private static void ReadMeshes(FSHP fshp, Shape shp)
        {
            fshp.lodMeshes.Clear();

            foreach (Mesh msh in shp.Meshes)
            {
                uint   FaceCount    = msh.IndexCount;
                uint[] indicesArray = msh.GetIndices().ToArray();

                FSHP.LOD_Mesh lod = new FSHP.LOD_Mesh();
                foreach (SubMesh subMsh in msh.SubMeshes)
                {
                    FSHP.LOD_Mesh.SubMesh sub = new FSHP.LOD_Mesh.SubMesh();
                    sub.size   = subMsh.Count;
                    sub.offset = subMsh.Offset;
                    lod.subMeshes.Add(sub);
                }
                lod.IndexFormat   = (STIndexFormat)msh.IndexFormat;
                lod.PrimitiveType = (STPolygonType)msh.PrimitiveType;
                lod.FirstVertex   = msh.FirstVertex;

                for (int face = 0; face < FaceCount; face++)
                {
                    lod.faces.Add((int)indicesArray[face] + (int)msh.FirstVertex);
                }

                fshp.lodMeshes.Add(lod);
            }
        }
Example #3
0
        private static void SetUniforms(FMAT mat, Shader shader, FSHP m, int id)
        {
            shader.SetVector4("gsys_bake_st0", new Vector4(1, 1, 0, 0));
            shader.SetVector4("gsys_bake_st1", new Vector4(1, 1, 0, 0));
            shader.SetVector4("tev_color0", new Vector4(1, 1, 0, 0));
            shader.SetVector4("tev_color1", new Vector4(1, 1, 0, 0));
            shader.SetVector4("mat_color0", new Vector4(1, 1, 0, 0));
            shader.SetVector4("mat_color1", new Vector4(1, 1, 0, 0));

            shader.SetVector4("const_color0", new Vector4(1, 1, 1, 1));
            shader.SetVector4("base_color_mul_color", new Vector4(1, 1, 1, 1));

            shader.SetInt("enableCellShading", 0);
            bool HasTans = m.vertexAttributes.Any(x => x.Name == "_t0");

            shader.SetBoolToInt("hasTangents", HasTans);

            SetUniformData(mat, shader, "gsys_bake_st0");
            SetUniformData(mat, shader, "gsys_bake_st1");
            SetUniformData(mat, shader, "const_color0");
            SetUniformData(mat, shader, "tev_color0");
            SetUniformData(mat, shader, "tev_color1");
            SetUniformData(mat, shader, "mat_color0");
            SetUniformData(mat, shader, "mat_color1");
        }
Example #4
0
        public static void ReadShapesVertices(FSHP fshp, Shape shp, VertexBuffer vertexBuffer, FMDL model)
        {
            fshp.boundingBoxes.Clear();

            foreach (Bounding bnd in shp.SubMeshBoundings)
            {
                FSHP.BoundingBox box = new FSHP.BoundingBox();
                box.Center = new Vector3(bnd.Center.X, bnd.Center.Y, bnd.Center.Z);
                box.Extend = new Vector3(bnd.Extent.X, bnd.Extent.Y, bnd.Extent.Z);
                fshp.boundingBoxes.Add(box);
            }

            fshp.boundingRadius    = shp.RadiusArray.ToList();
            fshp.VertexBufferIndex = shp.VertexBufferIndex;
            fshp.Shape             = shp;
            fshp.VertexBuffer      = vertexBuffer;
            fshp.VertexSkinCount   = shp.VertexSkinCount;
            fshp.BoneIndex         = shp.BoneIndex;
            fshp.Text = shp.Name;
            fshp.TargetAttribCount = shp.TargetAttribCount;
            fshp.MaterialIndex     = shp.MaterialIndex;

            if (shp.SkinBoneIndices == null)
            {
                shp.SkinBoneIndices = new List <ushort>();
            }

            fshp.BoneIndices = shp.SkinBoneIndices.ToList();

            ReadMeshes(fshp, shp);
            ReadVertexBuffer(fshp, vertexBuffer, model);
        }
Example #5
0
        public static void CheckMissingTextures(FSHP shape)
        {
            bool ImportMissingTextures = false;

            foreach (BinaryTextureContainer bntx in PluginRuntime.bntxContainers)
            {
                foreach (MatTexture tex in shape.GetMaterial().textures)
                {
                    if (!bntx.Textures.ContainsKey(tex.Name))
                    {
                        if (!ImportMissingTextures)
                        {
                            DialogResult result = MessageBox.Show("Missing textures found! Would you like to use placeholders?", "", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

                            if (result == DialogResult.Yes)
                            {
                                ImportMissingTextures = true;
                            }
                            else
                            {
                                return;
                            }
                        }

                        if (ImportMissingTextures)
                        {
                            bntx.ImportPlaceholderTexture(tex.Name);
                        }
                    }
                }
            }
        }
Example #6
0
        private static void ApplyTransformFix(FMDL fmdl, FSHP m, SF.Shader shader)
        {
            Matrix4 idenity = Matrix4.Identity;

            shader.SetInt("NoSkinning", 0);
            shader.SetInt("RigidSkinning", 0);
            shader.SetInt("SingleBoneIndex", m.BoneIndex);

            shader.SetMatrix4x4("SingleBoneBindTransform", ref idenity);
            //Some objects will have no weights or indices. These will weigh to the bone index in the shape section.

            if (m.VertexSkinCount == 1)
            {
                shader.SetInt("RigidSkinning", 1);
            }
            if (m.VertexSkinCount == 0)
            {
                if (fmdl.Skeleton.bones.Count > 0)
                {
                    Matrix4 transform = fmdl.Skeleton.bones[m.BoneIndex].invert * fmdl.Skeleton.bones[m.BoneIndex].Transform;

                    shader.SetMatrix4x4("SingleBoneBindTransform", ref transform);
                    shader.SetInt("NoSkinning", 1);
                }
            }
        }
Example #7
0
 private static void SetTextureUniforms(FMAT mat, FSHP m, SHShaderProgram shader)
 {
     for (int t = 0; t < mat.TextureMaps.Count; t++)
     {
         MatTexture matex = (MatTexture)mat.TextureMaps[t];
         mat.HasDiffuseMap = TextureUniform(shader, mat, $"tex_map{t}", matex);
     }
 }
Example #8
0
        private static void SetBoneUniforms(SF.Shader shader, FMDL fmdl, FSHP fshp)
        {
            for (int i = 0; i < fmdl.Skeleton.Node_Array.Length; i++)
            {
                GL.Uniform1(GL.GetUniformLocation(shader.Id, String.Format("boneIds[{0}]", i)), fmdl.Skeleton.Node_Array[i]);

                Matrix4 transform = fmdl.Skeleton.bones[fmdl.Skeleton.Node_Array[i]].invert * fmdl.Skeleton.bones[fmdl.Skeleton.Node_Array[i]].Transform;
                GL.UniformMatrix4(GL.GetUniformLocation(shader.Id, String.Format("bones[{0}]", i)), false, ref transform);
            }
        }
Example #9
0
        private static void ReadMeshes(FSHP fshp, Shape shp)
        {
            fshp.lodMeshes.Clear();

            foreach (Mesh msh in shp.Meshes)
            {
                uint   FaceCount    = msh.IndexCount;
                uint[] indicesArray = msh.GetIndices().ToArray();

                FSHP.LOD_Mesh lod = new FSHP.LOD_Mesh();
                foreach (SubMesh subMsh in msh.SubMeshes)
                {
                    FSHP.LOD_Mesh.SubMesh sub = new FSHP.LOD_Mesh.SubMesh();
                    sub.size   = subMsh.Count;
                    sub.offset = subMsh.Offset;
                    lod.subMeshes.Add(sub);
                }
                lod.IndexFormat = (STIndexFormat)msh.IndexFormat;
                switch (msh.PrimitiveType)
                {
                case GX2PrimitiveType.Triangles:
                    lod.PrimativeType = STPrimitiveType.Triangles;
                    break;

                case GX2PrimitiveType.TriangleStrip:
                    lod.PrimativeType = STPrimitiveType.TrangleStrips;
                    break;

                case GX2PrimitiveType.Quads:
                    lod.PrimativeType = STPrimitiveType.Quads;
                    break;

                case GX2PrimitiveType.Lines:
                    lod.PrimativeType = STPrimitiveType.Lines;
                    break;

                case GX2PrimitiveType.LineStrip:
                    lod.PrimativeType = STPrimitiveType.LineStrips;
                    break;

                case GX2PrimitiveType.Points:
                    lod.PrimativeType = STPrimitiveType.Points;
                    break;
                }

                lod.FirstVertex = msh.FirstVertex;

                for (int face = 0; face < FaceCount; face++)
                {
                    lod.faces.Add((int)indicesArray[face] + (int)msh.FirstVertex);
                }

                fshp.lodMeshes.Add(lod);
            }
        }
Example #10
0
        public void LoadMesh(FSHP.LOD_Mesh mesh, FSHP fshp)
        {
            activeShape = fshp;
            activeMesh  = mesh;

            int index = 0;

            foreach (var subMesh in mesh.subMeshes)
            {
                listViewCustom1.Items.Add($"Sub Mesh{index}");
            }
        }
Example #11
0
        private void DrawModel(FSHP m, FMDL mdl, Shader shader, bool drawSelection = false)
        {
            if (m.lodMeshes[m.DisplayLODIndex].faces.Count <= 3)
            {
                return;
            }

            SetUniforms(m.GetMaterial(), shader, m, m.DisplayId);
            SetTextureUniforms(m.GetMaterial(), m, shader);
            SetBoneUniforms(shader, mdl);
            SetVertexAttributes(m, shader);
            ApplyTransformFix(mdl, m, shader);

            if (m.Checked && m.Parent.Parent.Checked)
            {
                if ((m.IsSelected))
                {
                    DrawModelSelection(m, shader);
                }
                else
                {
                    if (Runtime.RenderModelWireframe)
                    {
                        DrawModelWireframe(m, shader);
                    }
                    if (Runtime.RenderModels)
                    {
                        PrimitiveType primitiveType = PrimitiveType.Triangles;

                        switch (m.lodMeshes[m.DisplayLODIndex].PrimitiveType)
                        {
                        case STPolygonType.Line:
                            primitiveType = PrimitiveType.Lines;
                            break;

                        case STPolygonType.LineStrip:
                            primitiveType = PrimitiveType.LineStrip;
                            break;

                        case STPolygonType.Point:
                            primitiveType = PrimitiveType.Points;
                            break;

                        case STPolygonType.Triangle:
                            primitiveType = PrimitiveType.Triangles;
                            break;
                        }

                        GL.DrawElements(primitiveType, m.lodMeshes[m.DisplayLODIndex].displayFaceSize, DrawElementsType.UnsignedInt, m.Offset);
                    }
                }
            }
        }
Example #12
0
        private void SetDuplicateShapeName(FSHP shape)
        {
            DialogResult dialogResult = MessageBox.Show($"A shape {shape.Text} already exists with that name", "", MessageBoxButtons.OK);

            if (dialogResult == DialogResult.OK)
            {
                RenameDialog renameDialog = new RenameDialog();
                renameDialog.Text = "Rename Texture";
                if (renameDialog.ShowDialog() == DialogResult.OK)
                {
                    shape.Text = renameDialog.textBox1.Text;
                }
            }
        }
Example #13
0
        private static void SetBoneUniforms(ShaderProgram shader, FMDL fmdl, FSHP fshp)
        {
            for (int i = 0; i < fmdl.Skeleton.Node_Array.Length; i++)
            {
                //   if (!fmdl.Skeleton.bones[fmdl.Skeleton.Node_Array[i]].Visible)
                //    fshp.Checked = false;


                GL.Uniform1(GL.GetUniformLocation(shader.program, String.Format("boneIds[{0}]", i)), fmdl.Skeleton.Node_Array[i]);

                Matrix4 transform = fmdl.Skeleton.bones[fmdl.Skeleton.Node_Array[i]].invert * fmdl.Skeleton.bones[fmdl.Skeleton.Node_Array[i]].Transform;
                GL.UniformMatrix4(GL.GetUniformLocation(shader.program, String.Format("bones[{0}]", i)), false, ref transform);
            }
        }
        public void LoadLODS(FSHP fshp)
        {
            meshListView.Items.Clear();
            subMeshListView.Items.Clear();
            subMeshListView.FullRowSelect = true;
            meshListView.FullRowSelect    = true;

            ActiveShape = fshp;

            for (int i = 0; i < fshp.lodMeshes.Count; i++)
            {
                meshListView.Items.Add($"mesh {i}");
            }
        }
Example #15
0
        private static void SetRenderPass(FMAT mat, ShaderProgram shader, FSHP m, int id)
        {
            if (mat.shaderassign.ShaderArchive == "Turbo_UBER")
            {
                AglShaderTurbo aglShader = new AglShaderTurbo();

                foreach (var renderInfo in mat.renderinfo)
                {
                    aglShader.LoadRenderInfo(renderInfo);
                }

                aglShader.LoadRenderPass(mat, shader);
            }
        }
Example #16
0
        public void LoadVertexBuffers(FSHP fshp, ResU.VertexBuffer vertexBuffer)
        {
            activeShape = fshp;

            attributeListView.Items.Clear();

            foreach (var att in vertexBuffer.Attributes.Values)
            {
                ListViewItem item = new ListViewItem();
                item.Text = att.Name;
                item.SubItems.Add(GetAttributeHint(att.Name));
                item.SubItems.Add(att.Format.ToString());
                attributeListView.Items.Add(item);
            }
        }
Example #17
0
 public static void SetShaderAssignAttributes(FMAT.ShaderAssign shd, FSHP shape)
 {
     foreach (var att in shape.vertexAttributes)
     {
         if (!shd.attributes.ContainsValue(att.Name) && !shd.attributes.ContainsKey(att.Name))
         {
             shd.attributes.Add(att.Name, att.Name);
         }
     }
     foreach (var tex in shape.GetMaterial().textures)
     {
         if (!shd.samplers.ContainsValue(tex.SamplerName))
         {
             shd.samplers.Add(tex.SamplerName, tex.SamplerName);
         }
     }
 }
        private void listView1_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (objectList.SelectedItems.Count > 0)
            {
                ActiveFSHP = ActiveFMDL.shapes[objectList.SelectedIndices[0]];

                attributeCB.Items.Clear();
                foreach (var attribute in ActiveFSHP.vertexAttributes)
                {
                    attributeCB.Items.Add(attribute.Name);
                }
                if (attributeCB.Items.Count > 0)
                {
                    attributeCB.SelectedIndex = 0;
                }
            }
        }
Example #19
0
 private void SetVertexAttributes(FSHP m, SF.Shader shader)
 {
     GL.BindBuffer(BufferTarget.ArrayBuffer, vbo_position);
     GL.VertexAttribPointer(shader.GetAttribLocation("vPosition"), 3, VertexAttribPointerType.Float, false, DisplayVertex.Size, 0);
     GL.VertexAttribPointer(shader.GetAttribLocation("vNormal"), 3, VertexAttribPointerType.Float, false, DisplayVertex.Size, 12);
     GL.VertexAttribPointer(shader.GetAttribLocation("vTangent"), 3, VertexAttribPointerType.Float, false, DisplayVertex.Size, 24);
     GL.VertexAttribPointer(shader.GetAttribLocation("vBitangent"), 3, VertexAttribPointerType.Float, false, DisplayVertex.Size, 36);
     GL.VertexAttribPointer(shader.GetAttribLocation("vUV0"), 2, VertexAttribPointerType.Float, false, DisplayVertex.Size, 48);
     GL.VertexAttribPointer(shader.GetAttribLocation("vColor"), 4, VertexAttribPointerType.Float, false, DisplayVertex.Size, 56);
     GL.VertexAttribIPointer(shader.GetAttribLocation("vBone"), 4, VertexAttribIntegerType.Int, DisplayVertex.Size, new IntPtr(72));
     GL.VertexAttribPointer(shader.GetAttribLocation("vWeight"), 4, VertexAttribPointerType.Float, false, DisplayVertex.Size, 88);
     GL.VertexAttribPointer(shader.GetAttribLocation("vUV1"), 2, VertexAttribPointerType.Float, false, DisplayVertex.Size, 104);
     GL.VertexAttribPointer(shader.GetAttribLocation("vUV2"), 2, VertexAttribPointerType.Float, false, DisplayVertex.Size, 112);
     GL.VertexAttribPointer(shader.GetAttribLocation("vPosition2"), 3, VertexAttribPointerType.Float, false, DisplayVertex.Size, 124);
     GL.VertexAttribPointer(shader.GetAttribLocation("vPosition3"), 3, VertexAttribPointerType.Float, false, DisplayVertex.Size, 136);
     GL.BindBuffer(BufferTarget.ElementArrayBuffer, ibo_elements);
 }
Example #20
0
        public static void SetShape(this FSHP s, Shape shp)
        {
            shp.Name          = s.Text;
            shp.MaterialIndex = (ushort)s.MaterialIndex;
            shp.BoneIndex     = (ushort)s.BoneIndex;

            if (shp.SubMeshBoundingNodes == null)
            {
                shp.SubMeshBoundingNodes = new List <BoundingNode>();
            }
            if (shp.SubMeshBoundingIndices == null)
            {
                shp.SubMeshBoundingIndices = new List <ushort>();
            }
            if (shp.SkinBoneIndices == null)
            {
                shp.SkinBoneIndices = new List <ushort>();
            }

            int indx = 0;

            foreach (var mesh in shp.Meshes)
            {
                switch (s.lodMeshes[indx].PrimativeType)
                {
                case STPrimitiveType.Triangles:
                    mesh.PrimitiveType = GX2PrimitiveType.Triangles;
                    break;

                case STPrimitiveType.Lines:
                    mesh.PrimitiveType = GX2PrimitiveType.Lines;
                    break;

                case STPrimitiveType.LineStrips:
                    mesh.PrimitiveType = GX2PrimitiveType.LineStrip;
                    break;

                case STPrimitiveType.Points:
                    mesh.PrimitiveType = GX2PrimitiveType.Points;
                    break;
                }
                indx++;
            }
        }
Example #21
0
        static List <DisplayVertex> CreateDisplayVertices(FMDL model, FSHP mesh)
        {
            // rearrange faces
            mesh.display = mesh.lodMeshes[mesh.DisplayLODIndex].getDisplayFace().ToArray();

            List <DisplayVertex> displayVertList = new List <DisplayVertex>();

            if (mesh.lodMeshes[mesh.DisplayLODIndex].faces.Count <= 3)
            {
                return(displayVertList);
            }

            foreach (Vertex v in mesh.vertices)
            {
                model.MaxPosition = OpenGLUtils.GetMax(model.MaxPosition, v.pos);
                model.MinPosition = OpenGLUtils.GetMin(model.MinPosition, v.pos);

                DisplayVertex displayVert = new DisplayVertex()
                {
                    Position   = v.pos,
                    Normal     = v.nrm,
                    Color0     = v.col,
                    Color1     = v.col2,
                    TexCoord0  = v.uv0,
                    TexCoord1  = v.uv1,
                    TexCoord2  = v.uv2,
                    BlendIndex = new Vector4(
                        v.boneIds.Count > 0 ? v.boneIds[0] : -1,
                        v.boneIds.Count > 1 ? v.boneIds[1] : -1,
                        v.boneIds.Count > 2 ? v.boneIds[2] : -1,
                        v.boneIds.Count > 3 ? v.boneIds[3] : -1),
                    BlendWeight = new Vector4(
                        v.boneWeights.Count > 0 ? v.boneWeights[0] : 0,
                        v.boneWeights.Count > 1 ? v.boneWeights[1] : 0,
                        v.boneWeights.Count > 2 ? v.boneWeights[2] : 0,
                        v.boneWeights.Count > 3 ? v.boneWeights[3] : 0),
                };

                displayVertList.Add(displayVert);
            }

            return(displayVertList);
        }
Example #22
0
 private void SetVertexAttributes(FSHP m, SHShaderProgram shader)
 {
     GL.BindBuffer(BufferTarget.ArrayBuffer, vbo_position);
     GL.VertexAttribPointer(shader.GetAttribute("aPosition"), 3, VertexAttribPointerType.Float, false, DisplayVertex.Size, 0);
     GL.VertexAttribPointer(shader.GetAttribute("aNormal"), 3, VertexAttribPointerType.Float, false, DisplayVertex.Size, 12);
     GL.VertexAttribPointer(shader.GetAttribute("aBlendWeight"), 4, VertexAttribPointerType.Float, false, DisplayVertex.Size, 24);
     GL.VertexAttribIPointer(shader.GetAttribute("aBlendIndex"), 4, VertexAttribIntegerType.Int, DisplayVertex.Size, new IntPtr(40));
     GL.VertexAttribPointer(shader.GetAttribute("aTexCoord0"), 2, VertexAttribPointerType.Float, false, DisplayVertex.Size, 56);
     GL.VertexAttribPointer(shader.GetAttribute("aTexCoord1"), 2, VertexAttribPointerType.Float, false, DisplayVertex.Size, 64);
     GL.VertexAttribPointer(shader.GetAttribute("aTexCoord2"), 2, VertexAttribPointerType.Float, false, DisplayVertex.Size, 72);
     GL.VertexAttribPointer(shader.GetAttribute("aTexCoord3"), 2, VertexAttribPointerType.Float, false, DisplayVertex.Size, 80);
     GL.VertexAttribPointer(shader.GetAttribute("aTexCoord4"), 2, VertexAttribPointerType.Float, false, DisplayVertex.Size, 88);
     GL.VertexAttribPointer(shader.GetAttribute("aTexCoord5"), 2, VertexAttribPointerType.Float, false, DisplayVertex.Size, 96);
     GL.VertexAttribPointer(shader.GetAttribute("aTexCoord6"), 2, VertexAttribPointerType.Float, false, DisplayVertex.Size, 104);
     GL.VertexAttribPointer(shader.GetAttribute("aTexCoord7"), 2, VertexAttribPointerType.Float, false, DisplayVertex.Size, 112);
     GL.VertexAttribPointer(shader.GetAttribute("aColor0"), 4, VertexAttribPointerType.Float, false, DisplayVertex.Size, 120);
     GL.VertexAttribPointer(shader.GetAttribute("aColor1"), 4, VertexAttribPointerType.Float, false, DisplayVertex.Size, 136);
     GL.BindBuffer(BufferTarget.ElementArrayBuffer, ibo_elements);
 }
Example #23
0
        public static void Read(BFRESRender renderer, ResFile resFile, TreeNode ResFileNode)
        {
            int CurMdl = 0;

            foreach (Model mdl in resFile.Models.Values)
            {
                FMDL model = new FMDL();
                model.Text     = mdl.Name;
                model.Skeleton = new FSKL(mdl.Skeleton);
                model.Nodes.Add(model.Skeleton.node);
                model.Skeleton.reset();
                model.Skeleton.update();
                model.BFRESRender = renderer;
                model.Skeleton.node.BFRESRender = renderer;
                model.ModelU = mdl;
                foreach (Material mat in mdl.Materials.Values)
                {
                    FMAT FMAT = new FMAT();
                    FMAT.BFRESRender = renderer;
                    FMAT.Text        = mat.Name;
                    FMAT.ReadMaterial(mat);
                    model.Nodes[1].Nodes.Add(FMAT);
                    model.materials.Add(FMAT.Text, FMAT);
                }
                foreach (Shape shp in mdl.Shapes.Values)
                {
                    VertexBuffer vertexBuffer = mdl.VertexBuffers[shp.VertexBufferIndex];
                    Material     material     = mdl.Materials[shp.MaterialIndex];
                    FSHP         mesh         = new FSHP();
                    mesh.BFRESRender = renderer;
                    mesh.ModelIndex  = CurMdl;
                    ReadShapesVertices(mesh, shp, vertexBuffer, model);
                    mesh.MaterialIndex = shp.MaterialIndex;

                    model.Nodes[0].Nodes.Add(mesh);
                    model.shapes.Add(mesh);
                }
                ResFileNode.Nodes[0].Nodes.Add(model);
                renderer.models.Add(model);

                CurMdl++;
            }
        }
Example #24
0
        public static void LoadShapeEditor(FSHP fshp)
        {
            foreach (Control control in FirstPlugin.MainF.Controls)
            {
                if (control is DockPanel)
                {
                    if (FirstPlugin.DockedEditorS == null)
                    {
                        FirstPlugin.DockedEditorS = new DockContent();
                        FirstPlugin.DockedEditorS.Show((DockPanel)control, PluginRuntime.FSHPDockState);
                    }
                }
            }

            if (!EditorIsActive(FirstPlugin.DockedEditorS))
            {
                FirstPlugin.DockedEditorS.Controls.Clear();
                FSHPEditor BfresProperties = new FSHPEditor();
                BfresProperties.Text = fshp.Text;
                BfresProperties.Dock = DockStyle.Fill;
                BfresProperties.LoadObject((FMDL)fshp.Parent.Parent, fshp);
                FirstPlugin.DockedEditorS.Controls.Add(BfresProperties);
            }
            bool EditorIsActive(DockContent dock)
            {
                foreach (Control ctrl in dock.Controls)
                {
                    if (ctrl is FSHPEditor)
                    {
                        ((FSHPEditor)ctrl).LoadObject((FMDL)fshp.Parent.Parent, fshp);
                        return(true);
                    }
                }
                return(false);
            }
        }
Example #25
0
        public static Shape SaveShape(FSHP fshp)
        {
            Shape ShapeU = new Shape();

            ShapeU.VertexSkinCount   = (byte)fshp.VertexSkinCount;
            ShapeU.Flags             = ShapeFlags.HasVertexBuffer;
            ShapeU.BoneIndex         = (ushort)fshp.BoneIndex;
            ShapeU.MaterialIndex     = (ushort)fshp.MaterialIndex;
            ShapeU.VertexBufferIndex = (ushort)fshp.VertexBufferIndex;
            ShapeU.KeyShapes         = new ResDict <KeyShape>();
            ShapeU.Name = fshp.Text;
            ShapeU.TargetAttribCount = (byte)fshp.TargetAttribCount;
            ShapeU.SkinBoneIndices   = fshp.BoneIndices;
            ShapeU.SubMeshBoundings  = new List <Bounding>();
            ShapeU.RadiusArray       = new List <float>();
            ShapeU.RadiusArray       = fshp.boundingRadius;
            ShapeU.Meshes            = new List <Mesh>();

            foreach (FSHP.BoundingBox box in fshp.boundingBoxes)
            {
                Bounding bnd = new Bounding();
                bnd.Center = new Syroot.Maths.Vector3F(box.Center.X, box.Center.Y, box.Center.Z);
                bnd.Extent = new Syroot.Maths.Vector3F(box.Extend.X, box.Extend.Y, box.Extend.Z);
                ShapeU.SubMeshBoundings.Add(bnd);
            }

            foreach (FSHP.LOD_Mesh mesh in fshp.lodMeshes)
            {
                Mesh msh = new Mesh();
                msh.SubMeshes     = new List <SubMesh>();
                msh.PrimitiveType = (GX2PrimitiveType)mesh.PrimitiveType;
                msh.FirstVertex   = mesh.FirstVertex;

                foreach (FSHP.LOD_Mesh.SubMesh sub in mesh.subMeshes)
                {
                    SubMesh subMesh = new SubMesh();
                    subMesh.Offset = sub.offset;
                    subMesh.Count  = (uint)mesh.faces.Count;
                    msh.SubMeshes.Add(subMesh);
                }

                IList <uint> faceList = new List <uint>();
                msh.IndexBuffer = new Syroot.NintenTools.Bfres.Buffer();
                foreach (int f in mesh.faces)
                {
                    faceList.Add((uint)f);
                }
                if (faceList.Count > 65000)
                {
                    MessageBox.Show($"Warning! Your poly count for a single mesh {fshp.Text} is pretty high! ({faceList.Count})." +
                                    $" You may want to split this!");
                    msh.SetIndices(faceList, GX2IndexFormat.UInt32);
                }
                else
                {
                    msh.SetIndices(faceList, GX2IndexFormat.UInt16);
                }

                ShapeU.Meshes.Add(msh);
                break;
            }
            return(ShapeU);
        }
Example #26
0
        private static void ReadVertexBuffer(FSHP fshp, VertexBuffer vtx, FMDL model)
        {
            fshp.vertices.Clear();
            fshp.vertexAttributes.Clear();

            //Create a buffer instance which stores all the buffer data
            VertexBufferHelper helper = new VertexBufferHelper(vtx, Syroot.BinaryData.ByteOrder.BigEndian);

            //Set each array first from the lib if exist. Then add the data all in one loop
            Syroot.Maths.Vector4F[] vec4Positions = new Syroot.Maths.Vector4F[0];
            Syroot.Maths.Vector4F[] vec4Normals   = new Syroot.Maths.Vector4F[0];
            Syroot.Maths.Vector4F[] vec4uv0       = new Syroot.Maths.Vector4F[0];
            Syroot.Maths.Vector4F[] vec4uv1       = new Syroot.Maths.Vector4F[0];
            Syroot.Maths.Vector4F[] vec4uv2       = new Syroot.Maths.Vector4F[0];
            Syroot.Maths.Vector4F[] vec4c0        = new Syroot.Maths.Vector4F[0];
            Syroot.Maths.Vector4F[] vec4t0        = new Syroot.Maths.Vector4F[0];
            Syroot.Maths.Vector4F[] vec4b0        = new Syroot.Maths.Vector4F[0];
            Syroot.Maths.Vector4F[] vec4w0        = new Syroot.Maths.Vector4F[0];
            Syroot.Maths.Vector4F[] vec4i0        = new Syroot.Maths.Vector4F[0];

            //For shape morphing
            Syroot.Maths.Vector4F[] vec4Positions1 = new Syroot.Maths.Vector4F[0];
            Syroot.Maths.Vector4F[] vec4Positions2 = new Syroot.Maths.Vector4F[0];

            foreach (VertexAttrib att in vtx.Attributes.Values)
            {
                FSHP.VertexAttribute attr = new FSHP.VertexAttribute();
                attr.Name   = att.Name;
                attr.Format = attr.GetTypeWiiU(att.Format);

                if (att.Name == "_p0")
                {
                    vec4Positions = AttributeData(att, helper, "_p0");
                }
                if (att.Name == "_n0")
                {
                    vec4Normals = AttributeData(att, helper, "_n0");
                }
                if (att.Name == "_u0")
                {
                    vec4uv0 = AttributeData(att, helper, "_u0");
                }
                if (att.Name == "_u1")
                {
                    vec4uv1 = AttributeData(att, helper, "_u1");
                }
                if (att.Name == "_u2")
                {
                    vec4uv2 = AttributeData(att, helper, "_u2");
                }
                if (att.Name == "_c0")
                {
                    vec4c0 = AttributeData(att, helper, "_c0");
                }
                if (att.Name == "_t0")
                {
                    vec4t0 = AttributeData(att, helper, "_t0");
                }
                if (att.Name == "_b0")
                {
                    vec4b0 = AttributeData(att, helper, "_b0");
                }
                if (att.Name == "_w0")
                {
                    vec4w0 = AttributeData(att, helper, "_w0");
                }
                if (att.Name == "_i0")
                {
                    vec4i0 = AttributeData(att, helper, "_i0");
                }

                if (att.Name == "_p1")
                {
                    vec4Positions1 = AttributeData(att, helper, "_p1");
                }
                if (att.Name == "_p2")
                {
                    vec4Positions2 = AttributeData(att, helper, "_p2");
                }

                fshp.vertexAttributes.Add(attr);
            }
            for (int i = 0; i < vec4Positions.Length; i++)
            {
                Vertex v = new Vertex();
                if (vec4Positions.Length > 0)
                {
                    v.pos = new Vector3(vec4Positions[i].X, vec4Positions[i].Y, vec4Positions[i].Z);
                }
                if (vec4Positions1.Length > 0)
                {
                    v.pos1 = new Vector3(vec4Positions1[i].X, vec4Positions1[i].Y, vec4Positions1[i].Z);
                }
                if (vec4Positions2.Length > 0)
                {
                    v.pos2 = new Vector3(vec4Positions2[i].X, vec4Positions2[i].Y, vec4Positions2[i].Z);
                }
                if (vec4Normals.Length > 0)
                {
                    v.nrm = new Vector3(vec4Normals[i].X, vec4Normals[i].Y, vec4Normals[i].Z);
                }
                if (vec4uv0.Length > 0)
                {
                    v.uv0 = new Vector2(vec4uv0[i].X, vec4uv0[i].Y);
                }
                if (vec4uv1.Length > 0)
                {
                    v.uv1 = new Vector2(vec4uv1[i].X, vec4uv1[i].Y);
                }
                if (vec4uv2.Length > 0)
                {
                    v.uv2 = new Vector2(vec4uv2[i].X, vec4uv2[i].Y);
                }
                if (vec4w0.Length > 0)
                {
                    v.boneWeights.Add(vec4w0[i].X);
                    v.boneWeights.Add(vec4w0[i].Y);
                    v.boneWeights.Add(vec4w0[i].Z);
                    v.boneWeights.Add(vec4w0[i].W);
                }
                if (vec4i0.Length > 0)
                {
                    v.boneIds.Add((int)vec4i0[i].X);
                    v.boneIds.Add((int)vec4i0[i].Y);
                    v.boneIds.Add((int)vec4i0[i].Z);
                    v.boneIds.Add((int)vec4i0[i].W);
                }

                if (vec4t0.Length > 0)
                {
                    v.tan = new Vector4(vec4t0[i].X, vec4t0[i].Y, vec4t0[i].Z, vec4t0[i].W);
                }
                if (vec4b0.Length > 0)
                {
                    v.bitan = new Vector4(vec4b0[i].X, vec4b0[i].Y, vec4b0[i].Z, vec4b0[i].W);
                }
                if (vec4c0.Length > 0)
                {
                    v.col = new Vector4(vec4c0[i].X, vec4c0[i].Y, vec4c0[i].Z, vec4c0[i].W);
                }

                if (fshp.VertexSkinCount == 1)
                {
                    Matrix4 sb = model.Skeleton.bones[model.Skeleton.Node_Array[v.boneIds[0]]].Transform;
                    v.pos = Vector3.TransformPosition(v.pos, sb);
                    v.nrm = Vector3.TransformNormal(v.nrm, sb);
                }
                if (fshp.VertexSkinCount == 0)
                {
                    Matrix4 NoBindFix = model.Skeleton.bones[fshp.BoneIndex].Transform;
                    v.pos = Vector3.TransformPosition(v.pos, NoBindFix);
                    v.nrm = Vector3.TransformNormal(v.nrm, NoBindFix);
                }
                fshp.vertices.Add(v);
            }
        }
Example #27
0
        private static void ReadVertexBuffer(FSHP fshp, VertexBuffer vtx, FMDL model)
        {
            fshp.vertices.Clear();
            fshp.vertexAttributes.Clear();

            //Create a buffer instance which stores all the buffer data
            VertexBufferHelper helper = new VertexBufferHelper(vtx, Syroot.BinaryData.ByteOrder.BigEndian);

            //Set each array first from the lib if exist. Then add the data all in one loop
            Syroot.Maths.Vector4F[] vec4Positions = new Syroot.Maths.Vector4F[0];
            Syroot.Maths.Vector4F[] vec4Normals   = new Syroot.Maths.Vector4F[0];
            Syroot.Maths.Vector4F[] vec4uv0       = new Syroot.Maths.Vector4F[0];
            Syroot.Maths.Vector4F[] vec4uv1       = new Syroot.Maths.Vector4F[0];
            Syroot.Maths.Vector4F[] vec4uv2       = new Syroot.Maths.Vector4F[0];
            Syroot.Maths.Vector4F[] vec4c0        = new Syroot.Maths.Vector4F[0];
            Syroot.Maths.Vector4F[] vec4t0        = new Syroot.Maths.Vector4F[0];
            Syroot.Maths.Vector4F[] vec4b0        = new Syroot.Maths.Vector4F[0];
            Syroot.Maths.Vector4F[] vec4w0        = new Syroot.Maths.Vector4F[0];
            Syroot.Maths.Vector4F[] vec4i0        = new Syroot.Maths.Vector4F[0];

            //For shape morphing
            Syroot.Maths.Vector4F[] vec4Positions1 = new Syroot.Maths.Vector4F[0];
            Syroot.Maths.Vector4F[] vec4Positions2 = new Syroot.Maths.Vector4F[0];

            List <VertexAttrib> SortedList = vtx.Attributes.Values.OrderBy(o => o.BufferIndex).ToList();

            foreach (VertexAttrib att in SortedList)
            {
                Console.WriteLine($"{att.Name} {att.BufferIndex} {att.Offset} {att.Format} ");
            }

            foreach (VertexAttrib att in vtx.Attributes.Values)
            {
                FSHP.VertexAttribute attr = new FSHP.VertexAttribute();
                attr.Name        = att.Name;
                attr.Format      = attr.GetTypeWiiU(att.Format);
                attr.BufferIndex = att.BufferIndex;

                if (att.Name == "_p0")
                {
                    vec4Positions = AttributeData(att, helper, "_p0");
                }
                if (att.Name == "_n0")
                {
                    vec4Normals = AttributeData(att, helper, "_n0");
                }
                if (att.Name == "_u0")
                {
                    vec4uv0 = AttributeData(att, helper, "_u0");
                }
                if (att.Name == "_u1")
                {
                    vec4uv1 = AttributeData(att, helper, "_u1");
                }
                if (att.Name == "_u2")
                {
                    vec4uv2 = AttributeData(att, helper, "_u2");
                }
                if (att.Name == "_c0")
                {
                    vec4c0 = AttributeData(att, helper, "_c0");
                }
                if (att.Name == "_t0")
                {
                    vec4t0 = AttributeData(att, helper, "_t0");
                }
                if (att.Name == "_b0")
                {
                    vec4b0 = AttributeData(att, helper, "_b0");
                }
                if (att.Name == "_w0")
                {
                    vec4w0 = AttributeData(att, helper, "_w0");
                }
                if (att.Name == "_i0")
                {
                    vec4i0 = AttributeData(att, helper, "_i0");
                }

                if (att.Name == "_p1")
                {
                    vec4Positions1 = AttributeData(att, helper, "_p1");
                }
                if (att.Name == "_p2")
                {
                    vec4Positions2 = AttributeData(att, helper, "_p2");
                }

                fshp.vertexAttributes.Add(attr);
            }
            for (int i = 0; i < vec4Positions.Length; i++)
            {
                Vertex v = new Vertex();
                if (vec4Positions.Length > 0)
                {
                    v.pos = new Vector3(vec4Positions[i].X, vec4Positions[i].Y, vec4Positions[i].Z);
                }
                if (vec4Positions1.Length > 0)
                {
                    v.pos1 = new Vector3(vec4Positions1[i].X, vec4Positions1[i].Y, vec4Positions1[i].Z);
                }
                if (vec4Positions2.Length > 0)
                {
                    v.pos2 = new Vector3(vec4Positions2[i].X, vec4Positions2[i].Y, vec4Positions2[i].Z);
                }
                if (vec4Normals.Length > 0)
                {
                    v.nrm = new Vector3(vec4Normals[i].X, vec4Normals[i].Y, vec4Normals[i].Z);
                }
                if (vec4uv0.Length > 0)
                {
                    v.uv0 = new Vector2(vec4uv0[i].X, vec4uv0[i].Y);
                }
                if (vec4uv1.Length > 0)
                {
                    v.uv1 = new Vector2(vec4uv1[i].X, vec4uv1[i].Y);
                }
                if (vec4uv2.Length > 0)
                {
                    v.uv2 = new Vector2(vec4uv2[i].X, vec4uv2[i].Y);
                }
                if (vec4w0.Length > 0)
                {
                    v.boneWeights.Add(vec4w0[i].X);
                    v.boneWeights.Add(vec4w0[i].Y);
                    v.boneWeights.Add(vec4w0[i].Z);
                    v.boneWeights.Add(vec4w0[i].W);
                }
                if (vec4i0.Length > 0)
                {
                    v.boneIds.Add((int)vec4i0[i].X);
                    v.boneIds.Add((int)vec4i0[i].Y);
                    v.boneIds.Add((int)vec4i0[i].Z);
                    v.boneIds.Add((int)vec4i0[i].W);
                }

                if (vec4t0.Length > 0)
                {
                    v.tan = new Vector4(vec4t0[i].X, vec4t0[i].Y, vec4t0[i].Z, vec4t0[i].W);
                }
                if (vec4b0.Length > 0)
                {
                    v.bitan = new Vector4(vec4b0[i].X, vec4b0[i].Y, vec4b0[i].Z, vec4b0[i].W);
                }
                if (vec4c0.Length > 0)
                {
                    v.col = new Vector4(vec4c0[i].X, vec4c0[i].Y, vec4c0[i].Z, vec4c0[i].W);
                }

                if (fshp.VertexSkinCount == 1)
                {
                    int boneIndex = fshp.BoneIndex;
                    if (v.boneIds.Count > 0)
                    {
                        boneIndex = model.Skeleton.Node_Array[v.boneIds[0]];
                    }

                    //Check if the bones are a rigid type
                    //In game it seems to not transform if they are not rigid
                    if (model.Skeleton.bones[boneIndex].RigidMatrixIndex != -1)
                    {
                        Matrix4 sb = model.Skeleton.bones[boneIndex].Transform;
                        v.pos = Vector3.TransformPosition(v.pos, sb);
                        v.nrm = Vector3.TransformNormal(v.nrm, sb);
                    }
                }
                if (fshp.VertexSkinCount == 0)
                {
                    try
                    {
                        if (model.Skeleton.bones.Count > 0)
                        {
                            int boneIndex = fshp.BoneIndex;

                            Matrix4 NoBindFix = model.Skeleton.bones[boneIndex].Transform;
                            v.pos = Vector3.TransformPosition(v.pos, NoBindFix);
                            v.nrm = Vector3.TransformNormal(v.nrm, NoBindFix);
                        }
                    }
                    catch //Matrix failed. Print the coordinate data of the bone
                    {
                        Console.WriteLine(model.Skeleton.bones[fshp.BoneIndex].Text);
                        Console.WriteLine(model.Skeleton.bones[fshp.BoneIndex].GetPosition());
                        Console.WriteLine(model.Skeleton.bones[fshp.BoneIndex].GetRotation());
                        Console.WriteLine(model.Skeleton.bones[fshp.BoneIndex].GetScale());
                    }
                }
                fshp.vertices.Add(v);
            }
        }
Example #28
0
 public void LoadUniforms(FMDL fmdl, FSHP shp, STSkeleton skeleton, GL_EditorFramework.GL_Core.GL_ControlBase control)
 {
 }
Example #29
0
        public static void SaveVertexBuffer(FSHP fshp)
        {
            VertexBuffer buffer = new VertexBuffer();

            buffer.Attributes = new ResDict <VertexAttrib>();

            VertexBufferHelper helper             = new VertexBufferHelper(buffer, Syroot.BinaryData.ByteOrder.BigEndian);
            List <VertexBufferHelperAttrib> atrib = new List <VertexBufferHelperAttrib>();

            fshp.UpdateVertices();

            foreach (FSHP.VertexAttribute att in fshp.vertexAttributes)
            {
                if (att.Name == "_p0")
                {
                    VertexBufferHelperAttrib vert = new VertexBufferHelperAttrib();
                    vert.Name   = att.Name;
                    vert.Data   = fshp.verts.ToArray();
                    vert.Format = att.SetTypeWiiU(att.Format);
                    atrib.Add(vert);
                }
                if (att.Name == "_n0")
                {
                    VertexBufferHelperAttrib vert = new VertexBufferHelperAttrib();
                    vert.Name   = att.Name;
                    vert.Data   = fshp.norms.ToArray();
                    vert.Format = att.SetTypeWiiU(att.Format);
                    atrib.Add(vert);
                }
                if (att.Name == "_u0")
                {
                    VertexBufferHelperAttrib vert = new VertexBufferHelperAttrib();
                    vert.Name   = att.Name;
                    vert.Data   = fshp.uv0.ToArray();
                    vert.Format = att.SetTypeWiiU(att.Format);
                    atrib.Add(vert);
                }
                if (att.Name == "_u1")
                {
                    VertexBufferHelperAttrib vert = new VertexBufferHelperAttrib();
                    vert.Name   = att.Name;
                    vert.Data   = fshp.uv1.ToArray();
                    vert.Format = att.SetTypeWiiU(att.Format);
                    atrib.Add(vert);
                }
                if (att.Name == "_u2")
                {
                    VertexBufferHelperAttrib vert = new VertexBufferHelperAttrib();
                    vert.Name   = att.Name;
                    vert.Data   = fshp.uv2.ToArray();
                    vert.Format = att.SetTypeWiiU(att.Format);
                    atrib.Add(vert);
                }
                if (att.Name == "_w0")
                {
                    VertexBufferHelperAttrib vert = new VertexBufferHelperAttrib();
                    vert.Name   = att.Name;
                    vert.Data   = fshp.weights.ToArray();
                    vert.Format = att.SetTypeWiiU(att.Format);
                    atrib.Add(vert);
                }
                if (att.Name == "_i0")
                {
                    VertexBufferHelperAttrib vert = new VertexBufferHelperAttrib();
                    vert.Name   = att.Name;
                    vert.Data   = fshp.boneInd.ToArray();
                    vert.Format = att.SetTypeWiiU(att.Format);
                    atrib.Add(vert);
                }
                if (att.Name == "_b0")
                {
                    VertexBufferHelperAttrib vert = new VertexBufferHelperAttrib();
                    vert.Name   = att.Name;
                    vert.Data   = fshp.bitans.ToArray();
                    vert.Format = att.SetTypeWiiU(att.Format);
                    atrib.Add(vert);
                }
                if (att.Name == "_t0")
                {
                    VertexBufferHelperAttrib vert = new VertexBufferHelperAttrib();
                    vert.Name   = att.Name;
                    vert.Data   = fshp.tans.ToArray();
                    vert.Format = att.SetTypeWiiU(att.Format);
                    atrib.Add(vert);
                }
                if (att.Name == "_c0")
                {
                    VertexBufferHelperAttrib vert = new VertexBufferHelperAttrib();
                    vert.Name   = att.Name;
                    vert.Data   = fshp.colors.ToArray();
                    vert.Format = att.SetTypeWiiU(att.Format);
                    atrib.Add(vert);
                }
            }
            if (atrib.Count == 0)
            {
                MessageBox.Show("Attributes are empty?");
                return;
            }
            helper.Attributes  = atrib;
            fshp.VertexBufferU = helper.ToVertexBuffer();
            fshp.VertexBufferU.VertexSkinCount = fshp.VertexSkinCount;
        }
        public void LoadShape(FSHP fshp)
        {
            InitializeControls();

            activeShape = fshp;

            shapeVertexSkinCountUD.Value = (decimal)fshp.VertexSkinCount;

            FMDL fmdl = fshp.GetParentModel();

            //Load info
            nameTB.Bind(fshp, "Text");
            shapeIndexUD.Value = fmdl.shapes.IndexOf(fshp);

            //Load meshes to toggle LOD display
            for (int i = 0; i < fshp.lodMeshes.Count; i++)
            {
                lodDisplayCB.Items.Add($"mesh {i}");
            }
            lodDisplayCB.SelectedIndex = activeShape.DisplayLODIndex;

            //Load material (all materials will load when activated)
            materialComboBox1.Items.Add(fshp.GetMaterial().Text);
            materialComboBox1.SelectedIndex = 0;

            //Load bone binded (all bones will load when activated)
            bonesCB.Items.Add(fmdl.Skeleton.bones[fshp.BoneIndex].Text);
            bonesCB.SelectedIndex = 0;

            //Load transform
            GetShapeTransform();

            if (fshp.VertexBufferU != null)
            {
                vertexBufferSkinCountUD.Maximum = (decimal)fshp.VertexBufferU.VertexSkinCount;
                vertexBufferSkinCountUD.Value   = (decimal)fshp.VertexBufferU.VertexSkinCount;
                vertexBufferList1.LoadVertexBuffers(fshp, fshp.VertexBufferU);
            }
            else
            {
                vertexBufferSkinCountUD.Maximum = (decimal)fshp.VertexBuffer.VertexSkinCount;
                vertexBufferSkinCountUD.Value   = (decimal)fshp.VertexBuffer.VertexSkinCount;
                vertexBufferList1.LoadVertexBuffers(fshp, fshp.VertexBuffer);
            }

            vtxCountUD.Maximum = fshp.vertices.Count;
            vtxCountUD.Value   = fshp.vertices.Count;


            if (fshp.ShapeU != null)
            {
                keyShapeList1.LoadKeyShapes(fshp.ShapeU.KeyShapes);
            }
            else
            {
                keyShapeList1.LoadKeyShapes(fshp.Shape.KeyShapes, fshp.Shape.KeyShapeDict);
            }

            int lodIndx = 0;

            foreach (var mesh in fshp.lodMeshes)
            {
                lodListView.Items.Add($"Detail Level {lodIndx++}");
            }

            IsLoaded = true;
        }