/// <summary> /// Returns a texture layout using liquid textures. The layout itself is similar to /// <see cref="TextureLayout.Column(string, string)" />. /// </summary> public static TextureLayout Liquid(string sides, string ends) { int sideIndex = liquidTextureIndexProvider.GetTextureIndex(sides); int endIndex = liquidTextureIndexProvider.GetTextureIndex(ends); return(new TextureLayout(sideIndex, sideIndex, sideIndex, sideIndex, endIndex, endIndex)); }
/// <inheritdoc /> protected override void Setup(ITextureIndexProvider indexProvider) { int baseIndex = indexProvider.GetTextureIndex(texture); if (baseIndex == 0) { second = third = fourth = fifth = sixth = final = dead = 0; } stageTextureIndices = new[] { baseIndex, baseIndex + second, baseIndex + third, baseIndex + fourth, baseIndex + fifth, baseIndex + sixth, baseIndex + final, baseIndex + dead }; }
/// <summary> /// Returns a texture layout where every side has the same texture. /// </summary> public static TextureLayout Uniform(string texture) { int i = blockTextureIndexProvider.GetTextureIndex(texture); return(new TextureLayout(i, i, i, i, i, i)); }
/// <summary> /// Get this model as data that can be used for rendering. /// </summary> public void ToData(out float[] vertices, out int[] textureIndices, out uint[] indices) { if (isLocked) { vertices = lockedVertices; textureIndices = lockedTextureIndices; indices = lockedIndices; return; } int[] texIndexLookup = new int[TextureNames.Length]; for (var i = 0; i < TextureNames.Length; i++) { texIndexLookup[i] = blockTextureIndexProvider.GetTextureIndex(TextureNames[i]); } vertices = new float[Quads.Length * 32]; textureIndices = new int[Quads.Length * 4]; for (var q = 0; q < Quads.Length; q++) { Quad quad = Quads[q]; // Vertex 0. vertices[q * 32 + 0] = quad.Vert0.X; vertices[q * 32 + 1] = quad.Vert0.Y; vertices[q * 32 + 2] = quad.Vert0.Z; vertices[q * 32 + 3] = MathHelper.Clamp(quad.Vert0.U, min: 0f, max: 1f); vertices[q * 32 + 4] = MathHelper.Clamp(quad.Vert0.V, min: 0f, max: 1f); vertices[q * 32 + 5] = MathHelper.Clamp(quad.Vert0.N, min: -1f, max: 1f); vertices[q * 32 + 6] = MathHelper.Clamp(quad.Vert0.O, min: -1f, max: 1f); vertices[q * 32 + 7] = MathHelper.Clamp(quad.Vert0.P, min: -1f, max: 1f); textureIndices[q * 4 + 0] = texIndexLookup[quad.TextureId]; // Vertex 1. vertices[q * 32 + 8] = quad.Vert1.X; vertices[q * 32 + 9] = quad.Vert1.Y; vertices[q * 32 + 10] = quad.Vert1.Z; vertices[q * 32 + 11] = MathHelper.Clamp(quad.Vert1.U, min: 0f, max: 1f); vertices[q * 32 + 12] = MathHelper.Clamp(quad.Vert1.V, min: 0f, max: 1f); vertices[q * 32 + 13] = MathHelper.Clamp(quad.Vert1.N, min: -1f, max: 1f); vertices[q * 32 + 14] = MathHelper.Clamp(quad.Vert1.O, min: -1f, max: 1f); vertices[q * 32 + 15] = MathHelper.Clamp(quad.Vert1.P, min: -1f, max: 1f); textureIndices[q * 4 + 1] = texIndexLookup[quad.TextureId]; // Vertex 2. vertices[q * 32 + 16] = quad.Vert2.X; vertices[q * 32 + 17] = quad.Vert2.Y; vertices[q * 32 + 18] = quad.Vert2.Z; vertices[q * 32 + 19] = MathHelper.Clamp(quad.Vert2.U, min: 0f, max: 1f); vertices[q * 32 + 20] = MathHelper.Clamp(quad.Vert2.V, min: 0f, max: 1f); vertices[q * 32 + 21] = MathHelper.Clamp(quad.Vert2.N, min: -1f, max: 1f); vertices[q * 32 + 22] = MathHelper.Clamp(quad.Vert2.O, min: -1f, max: 1f); vertices[q * 32 + 23] = MathHelper.Clamp(quad.Vert2.P, min: -1f, max: 1f); textureIndices[q * 4 + 2] = texIndexLookup[quad.TextureId]; // Vertex 3. vertices[q * 32 + 24] = quad.Vert3.X; vertices[q * 32 + 25] = quad.Vert3.Y; vertices[q * 32 + 26] = quad.Vert3.Z; vertices[q * 32 + 27] = MathHelper.Clamp(quad.Vert3.U, min: 0f, max: 1f); vertices[q * 32 + 28] = MathHelper.Clamp(quad.Vert3.V, min: 0f, max: 1f); vertices[q * 32 + 29] = MathHelper.Clamp(quad.Vert3.N, min: -1f, max: 1f); vertices[q * 32 + 30] = MathHelper.Clamp(quad.Vert3.O, min: -1f, max: 1f); vertices[q * 32 + 31] = MathHelper.Clamp(quad.Vert3.P, min: -1f, max: 1f); textureIndices[q * 4 + 3] = texIndexLookup[quad.TextureId]; } indices = new uint[Quads.Length * 6]; for (var i = 0; i < Quads.Length; i++) { var offset = (uint)(i * 4); indices[i * 6 + 0] = 0 + offset; indices[i * 6 + 1] = 2 + offset; indices[i * 6 + 2] = 1 + offset; indices[i * 6 + 3] = 0 + offset; indices[i * 6 + 4] = 3 + offset; indices[i * 6 + 5] = 2 + offset; } }
/// <inheritdoc /> protected override void Setup(ITextureIndexProvider indexProvider) { indices = BlockModels.GenerateIndexDataArray(faces: 2); textureIndices = BlockModels.GenerateTextureDataArray(indexProvider.GetTextureIndex(texture), length: 8); }
/// <inheritdoc /> protected override void Setup(ITextureIndexProvider indexProvider) { bottomTextureIndex = indexProvider.GetTextureIndex(bottomTexture); topTextureIndex = bottomTextureIndex + topTexOffset; }