Beispiel #1
0
        public void Draw(GLShaderProgram shaderProgram, ref Matrix4 view, ref Matrix4 projection, double animationTime)
        {
            if (Animation != null)
            {
                AnimateNodes(animationTime);
            }

            shaderProgram.Use();
            shaderProgram.SetUniform("uView", view);
            shaderProgram.SetUniform("uProjection", projection);

            foreach (var glNode in Nodes)
            {
                if (!glNode.IsVisible)
                {
                    continue;
                }

                for (var i = 0; i < glNode.Meshes.Count; i++)
                {
                    var glMesh = glNode.Meshes[i];
                    if (Animation != null && glMesh.Mesh != null)
                    {
                        var oldGlMesh = glMesh;
                        glMesh = glNode.Meshes[i] = new GLMesh(oldGlMesh.Mesh, glNode.WorldTransform, ModelPack.Model.Bones, Nodes, Materials);
                        oldGlMesh.Dispose();
                    }

                    glMesh.Draw(glNode.WorldTransform.ToOpenTK(), shaderProgram);
                }
            }
        }
Beispiel #2
0
 public void Draw(Matrix4 modelMatrix, GLShaderProgram shaderProgram)
 {
     shaderProgram.SetUniform("uModel", modelMatrix);
     Material.Bind(shaderProgram);
     shaderProgram.Check();
     VertexArray.Draw();
     Material.Unbind(shaderProgram);
 }
Beispiel #3
0
        public void Bind(GLShaderProgram shaderProgram)
        {
            shaderProgram.SetUniform("uMatHasDiffuse", HasDiffuseTexture);

            if (HasDiffuseTexture)
            {
                DiffuseTexture.Bind();
            }

            shaderProgram.SetUniform("uMatAmbient", Ambient);
            shaderProgram.SetUniform("uMatDiffuse", Diffuse);
            shaderProgram.SetUniform("uMatSpecular", Specular);
            shaderProgram.SetUniform("uMatEmissive", Emissive);
            shaderProgram.SetUniform("uMatHasAlphaTransparency", HasAlphaTransparency);

            if (RenderWireframe)
            {
                GL.PolygonMode(MaterialFace.FrontAndBack, PolygonMode.Line);
            }

            if (!EnableBackfaceCulling)
            {
                GL.Disable(EnableCap.CullFace);
            }
        }
Beispiel #4
0
 public void Bind(GLShaderProgram shaderProgram)
 {
     shaderProgram.SetUniform("uView", View);
     shaderProgram.SetUniform("uProjection", Projection);
 }