2015-05-29 15:46:44 -06:00
|
|
|
|
using System;
|
|
|
|
|
using Microsoft.Xna.Framework.Graphics;
|
|
|
|
|
using TrueCraft.Core.World;
|
|
|
|
|
using Microsoft.Xna.Framework;
|
|
|
|
|
|
|
|
|
|
namespace TrueCraft.Client.Rendering
|
|
|
|
|
{
|
2015-06-16 15:53:28 -04:00
|
|
|
|
/// <summary>
|
|
|
|
|
///
|
|
|
|
|
/// </summary>
|
2015-05-29 15:46:44 -06:00
|
|
|
|
public class ChunkMesh : Mesh
|
|
|
|
|
{
|
2015-06-16 15:53:28 -04:00
|
|
|
|
/// <summary>
|
|
|
|
|
///
|
|
|
|
|
/// </summary>
|
2015-05-29 15:46:44 -06:00
|
|
|
|
public ReadOnlyChunk Chunk { get; set; }
|
|
|
|
|
|
2015-06-16 15:53:28 -04:00
|
|
|
|
/// <summary>
|
|
|
|
|
///
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="chunk"></param>
|
|
|
|
|
/// <param name="device"></param>
|
|
|
|
|
/// <param name="vertices"></param>
|
|
|
|
|
/// <param name="indices"></param>
|
2015-06-19 17:36:39 -04:00
|
|
|
|
public ChunkMesh(ReadOnlyChunk chunk, TrueCraftGame game, VertexPositionNormalColorTexture[] vertices, int[] indices)
|
2015-06-19 00:55:38 -04:00
|
|
|
|
: base(game, 1, true)
|
2015-05-29 15:46:44 -06:00
|
|
|
|
{
|
|
|
|
|
Chunk = chunk;
|
2015-06-19 01:11:14 -04:00
|
|
|
|
Vertices = vertices;
|
2015-06-16 15:53:28 -04:00
|
|
|
|
SetSubmesh(0, indices);
|
|
|
|
|
}
|
2015-06-17 19:23:24 -04:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
///
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="chunk"></param>
|
|
|
|
|
/// <param name="device"></param>
|
|
|
|
|
/// <param name="vertices"></param>
|
|
|
|
|
/// <param name="opaqueIndices"></param>
|
|
|
|
|
/// <param name="transparentIndices"></param>
|
2015-06-19 17:36:39 -04:00
|
|
|
|
public ChunkMesh(ReadOnlyChunk chunk, TrueCraftGame game, VertexPositionNormalColorTexture[] vertices, int[] opaqueIndices, int[] transparentIndices)
|
2015-06-19 00:55:38 -04:00
|
|
|
|
: base(game, 2, true)
|
2015-06-17 19:23:24 -04:00
|
|
|
|
{
|
|
|
|
|
Chunk = chunk;
|
2015-06-19 01:11:14 -04:00
|
|
|
|
Vertices = vertices;
|
2015-06-17 19:23:24 -04:00
|
|
|
|
SetSubmesh(0, opaqueIndices);
|
|
|
|
|
SetSubmesh(1, transparentIndices);
|
|
|
|
|
}
|
2015-06-16 15:53:28 -04:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
///
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="vertices"></param>
|
|
|
|
|
/// <returns></returns>
|
2015-06-19 17:36:39 -04:00
|
|
|
|
protected override BoundingBox RecalculateBounds(VertexPositionNormalColorTexture[] vertices)
|
2015-06-16 15:53:28 -04:00
|
|
|
|
{
|
|
|
|
|
return new BoundingBox(
|
|
|
|
|
new Vector3(Chunk.X * TrueCraft.Core.World.Chunk.Width, 0, Chunk.Z * TrueCraft.Core.World.Chunk.Depth),
|
|
|
|
|
new Vector3(Chunk.X * TrueCraft.Core.World.Chunk.Width
|
2015-05-29 15:46:44 -06:00
|
|
|
|
+ TrueCraft.Core.World.Chunk.Width, TrueCraft.Core.World.Chunk.Height,
|
2015-06-16 15:53:28 -04:00
|
|
|
|
Chunk.Z * TrueCraft.Core.World.Chunk.Depth + TrueCraft.Core.World.Chunk.Depth));
|
2015-05-29 15:46:44 -06:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|