Vertex[] GenerateSlicePlane(int su, int sv, Func <int, int, VxlElement> first, Func <int, int, VxlElement> second, Func <int, int, float[]> coord) { var colors = new byte[su * sv]; var normals = new byte[su * sv]; var c = 0; for (var v = 0; v < sv; v++) { for (var u = 0; u < su; u++) { var voxel = first(u, v) ?? second(u, v); colors[c] = voxel == null ? (byte)0 : voxel.Color; normals[c] = voxel == null ? (byte)0 : voxel.Normal; c++; } } Sprite s = sheetBuilder.Allocate(new Size(su, sv)); Util.FastCopyIntoChannel(s, 0, colors); Util.FastCopyIntoChannel(s, 1, normals); s.sheet.CommitData(); var channels = new float2(channelSelect[(int)s.channel], channelSelect[(int)s.channel + 1]); return(new Vertex[4] { new Vertex(coord(0, 0), s.FastMapTextureCoords(0), channels), new Vertex(coord(su, 0), s.FastMapTextureCoords(1), channels), new Vertex(coord(su, sv), s.FastMapTextureCoords(3), channels), new Vertex(coord(0, sv), s.FastMapTextureCoords(2), channels) }); }
public static void FastCreateQuad(Vertex[] vertices, float2 a, float2 b, float2 c, float2 d, Sprite r, int palette, int nv) { var attrib = new float2(palette / (float)HardwarePalette.MaxPalettes, channelSelect[(int)r.channel]); vertices[nv] = new Vertex(a, r.FastMapTextureCoords(0), attrib); vertices[nv + 1] = new Vertex(b, r.FastMapTextureCoords(1), attrib); vertices[nv + 2] = new Vertex(c, r.FastMapTextureCoords(3), attrib); vertices[nv + 3] = new Vertex(d, r.FastMapTextureCoords(2), attrib); }
public static void FastCreateQuad(Vertex[] vertices, float2 o, Sprite r, int palette, int nv, float2 size) { var attrib = new float2(palette / (float)HardwarePalette.MaxPalettes, channelSelect[(int)r.channel]); vertices[nv] = new Vertex(o, r.FastMapTextureCoords(0), attrib); vertices[nv + 1] = new Vertex(new float2(o.X + size.X, o.Y), r.FastMapTextureCoords(1), attrib); vertices[nv + 2] = new Vertex(new float2(o.X + size.X, o.Y + size.Y), r.FastMapTextureCoords(3), attrib); vertices[nv + 3] = new Vertex(new float2(o.X, o.Y + size.Y), r.FastMapTextureCoords(2), attrib); }