static void CreateFace(JsonObjects.BlockModel blockModel, KeyValuePair <string, JsonObjects.BlockModelFace> pair, Dictionary <string, int> directions, ref List <string> definedDirections, ref Vector3[] faceChecks, ref Vector2[,] voxelUvs, ref List <int> tintedFaces) { definedDirections.Add(pair.Key); JsonObjects.BlockModelFace face = pair.Value; string realTexturePath = GetRealTexturePath(blockModel, face.texture); if (face.cullface != null && face.cullface != "all") { faceChecks[directions[pair.Key]] = VoxelData.faceChecks[directions[face.cullface]]; } else if (face.cullface == "all") { faceChecks[directions[pair.Key]] = Vector3.zero; } else { faceChecks[directions[pair.Key]] = new Vector3(2, 2, 2); } int[] uv = face.uv != null ? face.uv : new int[4] { 0, 0, 16, 16 }; Vector2[] uvs = VoxelData.voxelUvs; for (int i = 0; i < uvs.Length; i++) { voxelUvs[directions[pair.Key], i].x = uvs[i].x == 0 ? textureUvs[realTexturePath][0].x + uv[0] / 16 : textureUvs[realTexturePath][1].x + (uv[2] / 16) - 1; voxelUvs[directions[pair.Key], i].y = uvs[i].y == 0 ? textureUvs[realTexturePath][0].y + uv[1] / 16 : textureUvs[realTexturePath][1].y + (uv[3] / 16) - 1; } if (face.tintindex != null) { tintedFaces.Add(directions[pair.Key]); } }
static void RegisterFaceTexture(JsonObjects.BlockModel blockModel, JsonObjects.BlockModelElement element) { foreach (KeyValuePair <string, JsonObjects.BlockModelFace> pair in element.faces) { JsonObjects.BlockModelFace face = pair.Value; string realTexturePath = GetRealTexturePath(blockModel, face.texture); if (!textureUvs.ContainsKey(realTexturePath)) { textureUvs.Add(realTexturePath, TextureManager.RegisterBlockTexture(realTexturePath)); } } }