diff --git a/TrueCraft.Client.Linux/Content/terrain.png b/TrueCraft.Client.Linux/Content/terrain.png index 8beba3e..67efe47 100644 Binary files a/TrueCraft.Client.Linux/Content/terrain.png and b/TrueCraft.Client.Linux/Content/terrain.png differ diff --git a/TrueCraft.Client.Linux/Rendering/Blocks/SnowRenderer.cs b/TrueCraft.Client.Linux/Rendering/Blocks/SnowRenderer.cs index 04bead5..74ddbc3 100644 --- a/TrueCraft.Client.Linux/Rendering/Blocks/SnowRenderer.cs +++ b/TrueCraft.Client.Linux/Rendering/Blocks/SnowRenderer.cs @@ -25,7 +25,7 @@ namespace TrueCraft.Client.Linux.Rendering.Blocks }; public override VertexPositionNormalTexture[] Render(BlockDescriptor descriptor, Vector3 offset, - Tuple textureMap, int indiciesOffset, out int[] indicies) + Tuple textureMap, int indiciesOffset, out int[] indicies) { var overhead = new Vector3(0.5f, 0.5f, 0.5f); var cube = CreateUniformCube(overhead, Texture, indiciesOffset, out indicies); diff --git a/TrueCraft.Client.Linux/Rendering/Blocks/TorchRenderer.cs b/TrueCraft.Client.Linux/Rendering/Blocks/TorchRenderer.cs new file mode 100644 index 0000000..b38f28d --- /dev/null +++ b/TrueCraft.Client.Linux/Rendering/Blocks/TorchRenderer.cs @@ -0,0 +1,108 @@ +using System; +using Microsoft.Xna.Framework.Graphics; +using Microsoft.Xna.Framework; +using TrueCraft.Core.Logic.Blocks; +using TrueCraft.API.Logic; + +namespace TrueCraft.Client.Linux.Rendering.Blocks +{ + public class TorchRenderer : BlockRenderer + { + static TorchRenderer() + { + BlockRenderer.RegisterRenderer(TorchBlock.BlockID, new TorchRenderer()); + for (int i = 0; i < Texture.Length; i++) + Texture[i] /= 256f; + } + + private static Vector2 TextureMap = new Vector2(7, 85); // Note: this is in pixels (torch texture is not a full block) + private static Vector2[] Texture = + { + // Positive Z + TextureMap + new Vector2(2, 10), + TextureMap + new Vector2(0, 10), + TextureMap, + TextureMap + new Vector2(2, 0), + // Negative Z + TextureMap + new Vector2(2, 10), + TextureMap + new Vector2(0, 10), + TextureMap, + TextureMap + new Vector2(2, 0), + // Positive X + TextureMap + new Vector2(2, 10), + TextureMap + new Vector2(0, 10), + TextureMap, + TextureMap + new Vector2(2, 0), + // Negative X + TextureMap + new Vector2(2, 10), + TextureMap + new Vector2(0, 10), + TextureMap, + TextureMap + new Vector2(2, 0), + // Positive Y + TextureMap + new Vector2(2, 2), + TextureMap + new Vector2(0, 2), + TextureMap, + TextureMap + new Vector2(2, 0), + // Negative Y + TextureMap + new Vector2(0, 10), + TextureMap + new Vector2(0, 10), + TextureMap, + TextureMap + new Vector2(2, 0), + }; + + public override VertexPositionNormalTexture[] Render(BlockDescriptor descriptor, Vector3 offset, + Tuple textureMap, int indiciesOffset, out int[] indicies) + { + var overhead = new Vector3(0.5f, 0.5f, 0.5f); + var centerized = new Vector3(7f / 16f, 0, 7f / 16f); + var cube = CreateUniformCube(overhead, Texture, indiciesOffset, out indicies); + for (int i = 0; i < cube.Length; i++) + { + cube[i].Position.X *= 1f / 8f; + cube[i].Position.Z *= 1f / 8f; + if (cube[i].Position.Y > 0) + cube[i].Position.Y *= 5f / 8f; + switch ((TorchBlock.TorchDirection)descriptor.Metadata) + { + case TorchBlock.TorchDirection.West: + if (cube[i].Position.Y == 0) + cube[i].Position.X += 8f / 16f; + else + cube[i].Position.X += 3f / 16f; + cube[i].Position.Y += 5f / 16f; + break; + case TorchBlock.TorchDirection.East: + if (cube[i].Position.Y == 0) + cube[i].Position.X -= 8f / 16f; + else + cube[i].Position.X -= 3f / 16f; + cube[i].Position.Y += 5f / 16f; + break; + case TorchBlock.TorchDirection.North: + if (cube[i].Position.Y == 0) + cube[i].Position.Z += 8f / 16f; + else + cube[i].Position.Z += 3f / 16f; + cube[i].Position.Y += 5f / 16f; + break; + case TorchBlock.TorchDirection.South: + if (cube[i].Position.Y == 0) + cube[i].Position.Z -= 8f / 16f; + else + cube[i].Position.Z -= 3f / 16f; + cube[i].Position.Y += 5f / 16f; + break; + case TorchBlock.TorchDirection.Ground: + default: + // nop + break; + } + + cube[i].Position += offset; + cube[i].Position += centerized; + cube[i].Position -= overhead; + } + return cube; + } + } +} \ No newline at end of file diff --git a/TrueCraft.Client.Linux/TrueCraft.Client.Linux.csproj b/TrueCraft.Client.Linux/TrueCraft.Client.Linux.csproj index 0de8b30..a444170 100644 --- a/TrueCraft.Client.Linux/TrueCraft.Client.Linux.csproj +++ b/TrueCraft.Client.Linux/TrueCraft.Client.Linux.csproj @@ -86,6 +86,7 @@ + diff --git a/TrueCraft.Core/Logic/Blocks/TorchBlock.cs b/TrueCraft.Core/Logic/Blocks/TorchBlock.cs index 2e5c9bb..a0d1423 100644 --- a/TrueCraft.Core/Logic/Blocks/TorchBlock.cs +++ b/TrueCraft.Core/Logic/Blocks/TorchBlock.cs @@ -30,6 +30,8 @@ namespace TrueCraft.Core.Logic.Blocks public override byte Luminance { get { return 13; } } public override bool Opaque { get { return false; } } + + public override bool RenderOpaque { get { return true; } } public override string DisplayName { get { return "Torch"; } }