A builtin Program that offers basic rendering capabilities like lighting and texture support.
Inheritance: System.Program
Exemplo n.º 1
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);
     }
 }
Exemplo n.º 2
0
        /// <summary>
        /// Bind the vertex declaration to the program.
        /// </summary>
        /// <param name="program"></param>
        /// <param name="mesh"></param>
        /// <param name="stride"></param>
        public void Bind(ModelProgram program, ModelMesh mesh, int stride)
        {
            GraphicsBuffer buffer = Model.Buffer;

            foreach (ModelVertexAttribute attribute in Attributes)
            {
                int offset = attribute.Offset + mesh.BufferDataOffset;
                ProgramAttribute programAttribute = attribute.MatchAttribute(program);

                if (programAttribute != null)
                {
                    programAttribute.Bind(buffer, offset, attribute.GraphicsFormat, stride);
                }
            }
        }
Exemplo n.º 3
0
        /// <summary>Get the <see cref="ProgramAttribute"/> this should bind to, or <c>null</c> if there is none.</summary>
        /// <param name="program"></param>
        /// <returns></returns>
        public ProgramAttribute MatchAttribute(ModelProgram program)
        {
            switch (Usage)
            {
            case ModelVertexUsage.BlendIndices: return(program.BoneIndices);

            case ModelVertexUsage.BlendWeight: return(program.BoneWeights);

            case ModelVertexUsage.Normal: return(program.Normal);

            case ModelVertexUsage.Position: return(program.Position);

            case ModelVertexUsage.TextureCoordinate: return(program.Texel);

            default: return(null);
            }
        }
Exemplo n.º 4
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;
            }
        }
Exemplo n.º 5
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;
            }
        }
Exemplo n.º 6
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);
 }
Exemplo n.º 7
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;
            }
        }
        /// <summary>
        /// Bind the vertex declaration to the program.
        /// </summary>
        /// <param name="program"></param>
        /// <param name="mesh"></param>
        /// <param name="stride"></param>
        public void Bind(ModelProgram program, ModelMesh mesh, int stride)
        {
            GraphicsBuffer buffer = Model.Buffer;

            foreach (ModelVertexAttribute attribute in Attributes) {
                int offset = attribute.Offset + mesh.BufferDataOffset;
                ProgramAttribute programAttribute = attribute.MatchAttribute(program);

                if (programAttribute != null)
                    programAttribute.Bind(buffer, offset, attribute.GraphicsFormat, stride);
            }
        }
 /// <summary>Get the <see cref="ProgramAttribute"/> this should bind to, or <c>null</c> if there is none.</summary>
 /// <param name="program"></param>
 /// <returns></returns>
 public ProgramAttribute MatchAttribute(ModelProgram program)
 {
     switch (Usage) {
         case ModelVertexUsage.BlendIndices: return program.BoneIndices;
         case ModelVertexUsage.BlendWeight: return program.BoneWeights;
         case ModelVertexUsage.Normal: return program.Normal;
         case ModelVertexUsage.Position: return program.Position;
         case ModelVertexUsage.TextureCoordinate: return program.Texel;
         default: return null;
     }
 }
Exemplo n.º 10
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;
            }
        }