Context for drawing a Model.
Ejemplo n.º 1
0
 /// <summary>
 /// Draw the <see cref="Model"/>.
 /// </summary>
 /// <param name="drawContext"></param>
 public void Draw(ModelDrawContext drawContext)
 {
     foreach (var mesh in meshes)
     {
         mesh.Draw(drawContext);
     }
 }
Ejemplo n.º 2
0
 /// <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);
     }
 }
Ejemplo n.º 3
0
        /// <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);
        }
Ejemplo n.º 4
0
        /// <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);
        }
Ejemplo n.º 5
0
        /// <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;
            }
        }
Ejemplo n.º 6
0
        /// <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;
            }
        }
Ejemplo n.º 7
0
 /// <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);
 }
Ejemplo n.º 8
0
        /// <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;
            }
        }
Ejemplo n.º 9
0
 /// <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;
            }
        }
Ejemplo n.º 11
0
 /// <summary>
 /// Draw the <see cref="Model"/>.
 /// </summary>
 /// <param name="drawContext"></param>
 public void Draw(ModelDrawContext drawContext)
 {
     foreach (var mesh in meshes)
         mesh.Draw(drawContext);
 }