Exemplo n.º 1
0
        private void DrawModel(GLControl control, SOBJWrapper m, CMDLWrapper mdl, ShaderProgram shader, bool drawSelection)
        {
            if (m.lodMeshes[m.DisplayLODIndex].faces.Count <= 3)
            {
                return;
            }

            SetUniforms(m.MaterialWrapper, shader, m, m.DisplayId);
            SetUniformBlocks(m.MaterialWrapper, shader, m, m.DisplayId);
            SetBoneUniforms(control, shader, mdl, m);
            SetVertexAttributes(m, shader);
            SetTextureUniforms(m.MaterialWrapper, m, shader);

            if ((m.IsSelected))
            {
                DrawModelSelection(m, shader);
            }
            else
            {
                if (Runtime.RenderModels)
                {
                    GL.DrawElements(PrimitiveType.Triangles, m.lodMeshes[m.DisplayLODIndex].displayFaceSize, DrawElementsType.UnsignedInt, m.Offset);
                }
            }
        }
Exemplo n.º 2
0
        private void AddNodeGroup <T>(ResDict <T> SubSections, BCRESGroupNode Folder)
            where T : CtrObject, new()
        {
            if (SubSections == null || SubSections.Count == 0)
            {
                return;
            }

            Nodes.Add(Folder);

            foreach (CtrObject section in SubSections.Values)
            {
                switch (Folder.Type)
                {
                case BCRESGroupType.Models:
                    var CMDLWrapper = new CMDLWrapper((Model)section, this);
                    Folder.AddNode(CMDLWrapper);
                    RenderedBcres.Models.Add(CMDLWrapper);
                    break;

                case BCRESGroupType.Textures:
                    Folder.AddNode(new TXOBWrapper((Texture)section, this));
                    PluginRuntime.bcresTexContainers.Add(Folder);
                    break;
                }
            }
        }
Exemplo n.º 3
0
        private static void SetBoneUniforms(GLControl control, ShaderProgram shader, CMDLWrapper fmdl, SOBJWrapper fshp)
        {
            foreach (var FaceGroup in fshp.Shape.FaceGroups)
            {
                if (FaceGroup.BoneIndexList == null)
                {
                    continue;
                }

                for (int i = 0; i < FaceGroup.BoneIndexList.Length; i++)
                {
                    GL.Uniform1(GL.GetUniformLocation(shader.programs[control], String.Format("boneIds[{0}]", i)), FaceGroup.BoneIndexList[i]);

                    Matrix4 transform = fmdl.Skeleton.Renderable.bones[(int)FaceGroup.BoneIndexList[i]].invert * fmdl.Skeleton.Renderable.bones[(int)FaceGroup.BoneIndexList[i]].Transform;
                    GL.UniformMatrix4(GL.GetUniformLocation(shader.programs[control], String.Format("bones[{0}]", i)), false, ref transform);
                }
            }
        }
Exemplo n.º 4
0
 public SOBJWrapper(CMDLWrapper model, Mesh mesh) : base()
 {
     ParentModelWrapper = model;
     Load(mesh);
 }