Ejemplo n.º 1
0
 public Model(Mesh m) : this(
         new IndexBuffer(m.IndexData),
         new Vbuffer[] {
     Vbuffer.PositionAttrib(m.PositionData),
     m.NormalData != null ? Vbuffer.NormalAttrib(m.NormalData) : null,
     m.UVData != null ? Vbuffer.UVAttrib(m.UVData) : null,
     m.ColorData != null ? Vbuffer.ColorAttrib(m.ColorData) : null
 },
         new Texture[] { })
 {
 }
Ejemplo n.º 2
0
 public void Unbind()
 {
     Vbuffer.GlobalUnbind();
 }
Ejemplo n.º 3
0
        private Model(IndexBuffer indices, Vbuffer[] buffers, Texture[] textures)
        {
            this.indices = indices;

            List <Vbuffer> otherBuffers = new List <Vbuffer>();

            for (int i = 0; i < buffers.Length; i++)
            {
                Vbuffer buf = buffers[i];
                if (buf != null)  //this makes life easier elsewhere
                {
                    if (buf.IsPositionAttrib)
                    {
                        positions = buf;
                    }
                    else if (buf.IsNormalAttrib)
                    {
                        normals = buf;
                    }
                    else if (buf.IsUVAttrib)
                    {
                        uvs = buf;
                    }
                    else if (buf.IsColorAttrib)
                    {
                        colors = buf;
                    }
                    else
                    {
                        otherBuffers.Add(buf);
                    }
                }
            }
            if (positions == null)
            {
                throw new Exception("No position buffer");
            }
            this.genericBuffers = otherBuffers.ToArray();

            List <Texture> otherTextures = new List <Texture>();

            for (int i = 0; i < textures.Length; i++)
            {
                Texture tx = textures[i];
                if (tx != null)
                {
                    if (tx.isAlbedo)
                    {
                        albedo = tx;
                    }
                    else if (tx.isBump)
                    {
                        bump = tx;
                    }
                    else
                    {
                        otherTextures.Add(tx);
                    }
                }
            }
            this.genericTextures = otherTextures.ToArray();
        }