/// <summary> /// Draw the <see cref="Model"/>. /// </summary> /// <param name="drawContext"></param> public void Draw(ModelDrawContext drawContext) { foreach (var mesh in meshes) { mesh.Draw(drawContext); } }
/// <summary> /// Bind the material to the program. /// </summary> /// <param name="context"></param> /// <param name="program"></param> public void Bind(ModelDrawContext context, ModelProgram program) { foreach (ModelMaterialParameter parameter in Parameters) { parameter.Bind(context, program); } }
/// <summary> /// Render the model. /// </summary> protected override void Render() { base.Render(); var context = new ModelDrawContext() { Projection = Projection, View = View, World =World, DisplayMode = Program.DisplayMode, }; Model.Draw(context); }
/// <summary> /// Render the model. /// </summary> protected override void Render() { base.Render(); var context = new ModelDrawContext() { Projection = Projection, View = View, World = World, DisplayMode = Program.DisplayMode, }; Model.Draw(context); }
/// <summary> /// Draw the <see cref="ModelMesh"/>. /// </summary> /// <param name="context"></param> public void Draw(ModelDrawContext context) { try { if (Program == null) { Program = new ModelProgram(); VertexDeclaration.Bind(Program, this, VertexSize); Material.Bind(context, Program); } Program.Projection = context.Projection; Program.View = context.View; Program.World = context.World; Program.DisplayMode = context.DisplayMode; DetailLevels[0].Draw(context, Program); } catch (Exception exception) { throw exception; } }
/// <summary> /// Bind the material parameter to the program. /// </summary> /// <param name="context"></param> /// <param name="program"></param> public void Bind(ModelDrawContext context, ModelProgram program) { Texture2D texture = TextureSource != null?TextureSource.GetResourceValue() : null; switch (Name) { case DiffuseMapName: program.DiffuseMap = texture; break; case SpecularMapName: case NormalMapName: case LightMapName: case DetailNormalMapName: break; default: break; } }
/// <summary> /// Draw the detail level. /// </summary> /// <param name="context"></param> /// <param name="program"></param> public void Draw(ModelDrawContext context, ModelProgram program) { program.Draw(Primitive.TriangleStrip, IndexCount, Model.Buffer, ElementType.UInt16, BufferIndexOffset); }
/// <summary> /// Bind the material parameter to the program. /// </summary> /// <param name="context"></param> /// <param name="program"></param> public void Bind(ModelDrawContext context, ModelProgram program) { Texture2D texture = TextureSource != null ? TextureSource.GetResourceValue() : null; switch (Name) { case DiffuseMapName: program.DiffuseMap = texture; break; case SpecularMapName: case NormalMapName: case LightMapName: case DetailNormalMapName: break; default: break; } }
/// <summary> /// Draw the <see cref="Model"/>. /// </summary> /// <param name="drawContext"></param> public void Draw(ModelDrawContext drawContext) { foreach (var mesh in meshes) mesh.Draw(drawContext); }