Beispiel #1
0
        private void DrawModel(FSHP m, FMDL mdl, SF.Shader shader, bool ModelSelected)
        {
            if (m.lodMeshes[m.DisplayLODIndex].faces.Count <= 3)
            {
                return;
            }

            var mat = m.GetFMAT();

            if (shader != OpenTKSharedResources.shaders["BFRES_Normals"])
            {
                bool useVertexColors = true;
                if (mat.shaderassign.ShaderArchive == "Park_UBER")
                {
                    useVertexColors = false;
                }

                SetRenderSettings(shader, useVertexColors);
                SetRenderPass(mat);
                SetUniforms(mat, shader, m, m.DisplayId);
                SetTextureUniforms(mat, m, shader);
            }
            SetBoneUniforms(shader, mdl, m);
            ApplyTransformFix(mdl, m, shader);
            SetVertexAttributes(m, shader);

            //Check the binded bone if it's visible from bone visual anims
            //     if (!mdl.Skeleton.bones[m.boneIndx].Visible)
            //         m.Checked = false;

            if (m.Checked && mdl.Skeleton.bones.Count > 0 && mdl.Skeleton.bones[m.BoneIndex].Visible && mat.Enabled)
            {
                shader.SetVector3("materialSelectColor", new Vector3(0));
                if (m.GetMaterial().IsSelected)
                {
                    shader.SetVector3("materialSelectColor", ColorUtility.ToVector3(Color.FromArgb(0, 163, 204)));
                    DrawModelSelection(m, shader);
                }
                else if (m.IsSelected || ModelSelected)
                {
                    DrawModelSelection(m, shader);
                }
                else
                {
                    if (Runtime.RenderModelWireframe)
                    {
                        DrawModelWireframe(m, shader);
                    }
                    if (Runtime.RenderModels)
                    {
                        DrawMdoelHoverSelection(m, shader, IsSelected(), Hovered);

                        PrimitiveType primitiveType = PrimitiveType.Triangles;

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

                        case STPrimitiveType.LineStrips:
                            primitiveType = PrimitiveType.LineStrip;
                            break;

                        case STPrimitiveType.Points:
                            primitiveType = PrimitiveType.Points;
                            break;

                        case STPrimitiveType.Triangles:
                            primitiveType = PrimitiveType.Triangles;
                            break;
                        }

                        GL.DrawElements(primitiveType, m.lodMeshes[m.DisplayLODIndex].displayFaceSize, DrawElementsType.UnsignedInt, m.Offset);
                    }
                }
            }
        }
Beispiel #2
0
        private void DrawModel(GL_ControlBase control, FSHP m, FMDL mdl, bool ModelSelected)
        {
            if (m.lodMeshes[m.DisplayLODIndex].faces.Count <= 3)
            {
                return;
            }

            var mat = m.GetFMAT();

            SHShaderProgram shader = SearchProgram(
                mat.shaderassign.ShaderArchive,
                mat.shaderassign.ShaderModel);

            if (shader == null)
            {
                return;
            }

            shader.Enable();
            shader.EnableVertexAttributes();

            GL.Enable(EnableCap.AlphaTest);
            GL.AlphaFunc(AlphaFunction.Gequal, 0.1f);

            //   SetRenderPass(mat);
            //    SetUniforms(mat, shader, m, m.DisplayId);
            //   SetTextureUniforms(mat, m, shader);

            shader.LoadUniforms(mdl, m, mdl.Skeleton, control);

            SetVertexAttributes(m, shader);

            if (m.Checked && mdl.Skeleton.bones.Count > 0 && mdl.Skeleton.bones[m.BoneIndex].Visible && mat.Enabled)
            {
                PrimitiveType primitiveType = PrimitiveType.Triangles;

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

                case STPrimitiveType.LineStrips:
                    primitiveType = PrimitiveType.LineStrip;
                    break;

                case STPrimitiveType.Points:
                    primitiveType = PrimitiveType.Points;
                    break;

                case STPrimitiveType.Triangles:
                    primitiveType = PrimitiveType.Triangles;
                    break;
                }

                GL.DrawElements(primitiveType, m.lodMeshes[m.DisplayLODIndex].displayFaceSize, DrawElementsType.UnsignedInt, m.Offset);
            }

            shader.DisableVertexAttributes();
            shader.Disable();
        }