Render snow variation of grass blocks

This also increases the average rainfall everywhere so that fucking
deserts are less common
This commit is contained in:
Drew DeVault 2015-06-20 11:01:07 -04:00
parent f3fc43fbf9
commit 939a6dc79c
6 changed files with 59 additions and 5 deletions

View File

@ -1,4 +1,5 @@
using System; using System;
using TrueCraft.API.World;
namespace TrueCraft.API.Logic namespace TrueCraft.API.Logic
{ {
@ -8,6 +9,9 @@ namespace TrueCraft.API.Logic
public byte Metadata; public byte Metadata;
public byte BlockLight; public byte BlockLight;
public byte SkyLight; public byte SkyLight;
// Optional
public Coordinates3D Coordinates; public Coordinates3D Coordinates;
// Optional
public IChunk Chunk;
} }
} }

View File

@ -3,6 +3,8 @@ using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework; using Microsoft.Xna.Framework;
using TrueCraft.Core.Logic.Blocks; using TrueCraft.Core.Logic.Blocks;
using TrueCraft.API.Logic; using TrueCraft.API.Logic;
using TrueCraft.Core.World;
using TrueCraft.API;
namespace TrueCraft.Client.Rendering.Blocks namespace TrueCraft.Client.Rendering.Blocks
{ {
@ -13,11 +15,14 @@ namespace TrueCraft.Client.Rendering.Blocks
BlockRenderer.RegisterRenderer(GrassBlock.BlockID, new GrassRenderer()); BlockRenderer.RegisterRenderer(GrassBlock.BlockID, new GrassRenderer());
for (int i = 0; i < Texture.Length; i++) for (int i = 0; i < Texture.Length; i++)
Texture[i] *= new Vector2(16f / 256f); Texture[i] *= new Vector2(16f / 256f);
for (int i = 0; i < Texture.Length; i++)
SnowTexture[i] *= new Vector2(16f / 256f);
} }
private static Vector2 TextureMap = new Vector2(0, 0); private static Vector2 TextureMap = new Vector2(0, 0);
private static Vector2 EndsTexture = new Vector2(2, 0); private static Vector2 EndsTexture = new Vector2(2, 0);
private static Vector2 SideTexture = new Vector2(3, 0); private static Vector2 SideTexture = new Vector2(3, 0);
private static Vector2 SideTextureSnow = new Vector2(4, 4);
private static Vector2[] Texture = private static Vector2[] Texture =
{ {
// Positive Z // Positive Z
@ -51,13 +56,54 @@ namespace TrueCraft.Client.Rendering.Blocks
EndsTexture, EndsTexture,
EndsTexture + Vector2.UnitX, EndsTexture + Vector2.UnitX,
}; };
private static Vector2[] SnowTexture =
{
// Positive Z
SideTextureSnow + Vector2.UnitX + Vector2.UnitY,
SideTextureSnow + Vector2.UnitY,
SideTextureSnow,
SideTextureSnow + Vector2.UnitX,
// Negative Z
SideTextureSnow + Vector2.UnitX + Vector2.UnitY,
SideTextureSnow + Vector2.UnitY,
SideTextureSnow,
SideTextureSnow + Vector2.UnitX,
// Positive X
SideTextureSnow + Vector2.UnitX + Vector2.UnitY,
SideTextureSnow + Vector2.UnitY,
SideTextureSnow,
SideTextureSnow + Vector2.UnitX,
// Negative X
SideTextureSnow + Vector2.UnitX + Vector2.UnitY,
SideTextureSnow + Vector2.UnitY,
SideTextureSnow,
SideTextureSnow + Vector2.UnitX,
// Positive Y
TextureMap + Vector2.UnitX + Vector2.UnitY,
TextureMap + Vector2.UnitY,
TextureMap,
TextureMap + Vector2.UnitX,
// Negative Y
EndsTexture + Vector2.UnitX + Vector2.UnitY,
EndsTexture + Vector2.UnitY,
EndsTexture,
EndsTexture + Vector2.UnitX,
};
public static readonly Color BiomeColor = new Color(105, 169, 63); public static readonly Color BiomeColor = new Color(105, 169, 63);
public override VertexPositionNormalColorTexture[] Render(BlockDescriptor descriptor, Vector3 offset, public override VertexPositionNormalColorTexture[] Render(BlockDescriptor descriptor, Microsoft.Xna.Framework.Vector3 offset,
Tuple<int, int> textureMap, int indiciesOffset, out int[] indicies) Tuple<int, int> textureMap, int indiciesOffset, out int[] indicies)
{ {
var cube = CreateUniformCube(offset, Texture, indiciesOffset, out indicies, Color.White); var texture = Texture;
if (descriptor.Coordinates.Y < World.Height)
{
if (descriptor.Chunk.GetBlockID(descriptor.Coordinates + Coordinates3D.Up) == SnowfallBlock.BlockID)
{
texture = SnowTexture;
}
}
var cube = CreateUniformCube(offset, texture, indiciesOffset, out indicies, Color.White);
// Apply biome colors to top of cube // Apply biome colors to top of cube
for (int i = (int)(CubeFace.PositiveY) * 4; i < (int)(CubeFace.PositiveY) * 4 + 4; i++) for (int i = (int)(CubeFace.PositiveY) * 4; i < (int)(CubeFace.PositiveY) * 4 + 4; i++)
{ {

View File

@ -131,7 +131,8 @@ namespace TrueCraft.Client.Rendering
Metadata = chunk.GetMetadata(coords), Metadata = chunk.GetMetadata(coords),
BlockLight = chunk.GetBlockLight(coords), BlockLight = chunk.GetBlockLight(coords),
SkyLight = chunk.GetSkyLight(coords), SkyLight = chunk.GetSkyLight(coords),
Coordinates = coords Coordinates = coords,
Chunk = chunk.Chunk
}; };
var provider = BlockRepository.GetBlockProvider(descriptor.ID); var provider = BlockRepository.GetBlockProvider(descriptor.ID);
if (provider.RenderOpaque) if (provider.RenderOpaque)

View File

@ -101,6 +101,7 @@
<Compile Include="Rendering\Blocks\SugarcaneRenderer.cs" /> <Compile Include="Rendering\Blocks\SugarcaneRenderer.cs" />
<Compile Include="Rendering\Blocks\VegitationRenderer.cs" /> <Compile Include="Rendering\Blocks\VegitationRenderer.cs" />
<Compile Include="Rendering\VertexPositionNormalColorTexture.cs" /> <Compile Include="Rendering\VertexPositionNormalColorTexture.cs" />
<Compile Include="Rendering\Blocks\WheatRenderer.cs" />
</ItemGroup> </ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" /> <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<ItemGroup> <ItemGroup>

View File

@ -71,6 +71,8 @@ namespace TrueCraft.Core.Logic.Blocks
public override string DisplayName { get { return "Snow"; } } public override string DisplayName { get { return "Snow"; } }
public override TrueCraft.API.BoundingBox? BoundingBox { get { return null; } }
public override Tuple<int, int> GetTextureMap(byte metadata) public override Tuple<int, int> GetTextureMap(byte metadata)
{ {
return new Tuple<int, int>(2, 4); return new Tuple<int, int>(2, 4);

View File

@ -24,7 +24,7 @@ namespace TrueCraft.Core.World
TempNoise.Octaves = 2; TempNoise.Octaves = 2;
TempNoise.Lacunarity = 1.3; TempNoise.Lacunarity = 1.3;
RainNoise.Frequency = 0.03; RainNoise.Frequency = 0.03;
RainNoise.Octaves = 2; RainNoise.Octaves = 3;
RainNoise.Amplitude = 5; RainNoise.Amplitude = 5;
RainNoise.Lacunarity = 1.7; RainNoise.Lacunarity = 1.7;
TempNoise.Seed = seed; TempNoise.Seed = seed;