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[] { }) { }
public void Unbind() { Vbuffer.GlobalUnbind(); }
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(); }