public void RenderChildren(GraphicsDevice gd) { JadeEffect shader = JadeShaderManager.GetShader(ShaderLabel); shader.SetParameters(this); foreach (ModelMesh mesh in Model.Meshes) { gd.Indices = mesh.IndexBuffer; shader.Effect.Begin(); foreach (EffectPass pass in shader.Effect.CurrentTechnique.Passes) { pass.Begin(); foreach (ModelMeshPart part in mesh.MeshParts) { gd.VertexDeclaration = part.VertexDeclaration; gd.Vertices[0].SetSource(mesh.VertexBuffer, part.StreamOffset, part.VertexStride); gd.Textures[0] = ((BasicEffect)part.Effect).Texture; gd.DrawIndexedPrimitives(PrimitiveType.TriangleList, part.BaseVertex, 0, part.NumVertices, part.StartIndex, part.PrimitiveCount); } pass.End(); } shader.Effect.End(); } }
public void Draw(GraphicsDevice gd) { if (this is IJadeHasMaterial) { ((IJadeHasMaterial)this).SetMaterialProperties(); } if (this is IJadeRenderable) { JadeEffect shader = JadeShaderManager.GetShader(ShaderLabel); shader.SetParameters(this); shader.Effect.Begin(); foreach (EffectPass pass in shader.Effect.CurrentTechnique.Passes) { pass.Begin(); ((IJadeRenderable)this).Render(gd); pass.End(); } shader.Effect.End(); } if (this is IJadeChildRenderer) { ((IJadeChildRenderer)this).RenderChildren(gd); } }
public void SetMaterialProperties() { Effect effect = JadeShaderManager.GetShader(ShaderLabel).Effect; if (effect.Parameters["MaterialDiffuseColor"] != null) { effect.Parameters["MaterialDiffuseColor"].SetValue(MaterialDiffuseColor); } if (effect.Parameters["MaterialSpecularColor"] != null) { effect.Parameters["MaterialSpecularColor"].SetValue(MaterialSpecularColor); } if (effect.Parameters["MaterialSpecularPower"] != null) { effect.Parameters["MaterialSpecularPower"].SetValue(MaterialSpecularPower); } }
public void RenderChildren(GraphicsDevice gd) { JadeEffect shader = JadeShaderManager.GetShader(ShaderLabel); shader.Effect.Begin(); foreach (EffectPass pass in shader.Effect.CurrentTechnique.Passes) { for (int i = 0; i < 6; i++) { Sides[i].SetPosition(JadeCameraManager.ActiveCamera.Position + Offsets[i]); shader.SetParameters(Sides[i]); pass.Begin(); Sides[i].Render(gd); pass.End(); } } shader.Effect.End(); }