public static void CreateBlocks(TrueCraftGame game, IBlockRepository repository) { for (int i = 0; i < 0x100; i++) { var provider = repository.GetBlockProvider((byte)i); if (provider == null || provider.GetIconTexture(0) != null) continue; int[] indicies; var verticies = BlockRenderer.RenderBlock(provider, new BlockDescriptor { ID = provider.ID }, VisibleFaces.All, new Vector3(-0.5f), 0, out indicies); var mesh = new Mesh(game, verticies, indicies); BlockMeshes[provider.ID] = mesh; } PrepareEffects(game); }
private void GenerateProgressMesh() { int[] indicies; var texCoords = new Vector2(Progress, 15); var texture = new[] { texCoords + Vector2.UnitX + Vector2.UnitY, texCoords + Vector2.UnitY, texCoords, texCoords + Vector2.UnitX }; for (int i = 0; i < texture.Length; i++) texture[i] *= new Vector2(16f / 256f); var verticies = BlockRenderer.CreateUniformCube(XVector3.Zero, texture, VisibleFaces.All, 0, out indicies, Color.White); ProgressMesh = new Mesh(Game, verticies, indicies); }
private void InitializeHighlightedBlock() { const int size = 64; HighlightedBlock = -Coordinates3D.One; HighlightTexture = new Texture2D(GraphicsDevice, size, size); var colors = new Color[size * size]; for (int i = 0; i < colors.Length; i++) colors[i] = Color.Transparent; for (int x = 0; x < size; x++) colors[x] = Color.Black; // Top for (int x = 0; x < size; x++) colors[x + (size - 1) * size] = Color.Black; // Bottom for (int y = 0; y < size; y++) colors[y * size] = Color.Black; // Left for (int y = 0; y < size; y++) colors[y * size + (size - 1)] = Color.Black; // Right HighlightTexture.SetData<Color>(colors); var texcoords = new[] { Vector2.UnitX + Vector2.UnitY, Vector2.UnitY, Vector2.Zero, Vector2.UnitX }; int[] indicies; var verticies = BlockRenderer.CreateUniformCube(Microsoft.Xna.Framework.Vector3.Zero, texcoords, VisibleFaces.All, 0, out indicies, Color.White); HighlightMesh = new Mesh(this, verticies, indicies); }