Add Mesh class
This commit is contained in:
parent
dfa3132759
commit
0149af3ba2
40
TrueCraft.Client.Linux/Rendering/Mesh.cs
Normal file
40
TrueCraft.Client.Linux/Rendering/Mesh.cs
Normal file
@ -0,0 +1,40 @@
|
||||
using System;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
|
||||
namespace TrueCraft.Client.Linux.Rendering
|
||||
{
|
||||
public class Mesh
|
||||
{
|
||||
public VertexBuffer Verticies { get; set; }
|
||||
public IndexBuffer Indicies { get; set; }
|
||||
|
||||
public Mesh(GraphicsDevice device, VertexPositionNormalTexture[] verticies, int[] indicies)
|
||||
{
|
||||
Verticies = new VertexBuffer(device, VertexPositionNormalTexture.VertexDeclaration,
|
||||
verticies.Length, BufferUsage.None);
|
||||
Verticies.SetData(verticies);
|
||||
Indicies = new IndexBuffer(device, IndexElementSize.ThirtyTwoBits, indicies.Length, BufferUsage.None);
|
||||
Indicies.SetData(indicies);
|
||||
}
|
||||
|
||||
~Mesh()
|
||||
{
|
||||
if (Verticies != null)
|
||||
Verticies.Dispose();
|
||||
if (Indicies != null)
|
||||
Indicies.Dispose();
|
||||
}
|
||||
|
||||
public void Draw(Effect effect)
|
||||
{
|
||||
effect.GraphicsDevice.SetVertexBuffer(Verticies);
|
||||
effect.GraphicsDevice.Indices = Indicies;
|
||||
foreach (var pass in effect.CurrentTechnique.Passes)
|
||||
{
|
||||
pass.Apply();
|
||||
effect.GraphicsDevice.DrawIndexedPrimitives(PrimitiveType.TriangleList,
|
||||
0, 0, Indicies.IndexCount, 0, Indicies.IndexCount / 3);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -73,6 +73,7 @@
|
||||
<Compile Include="Events\ChunkEventArgs.cs" />
|
||||
<Compile Include="ChunkConverter.cs" />
|
||||
<Compile Include="PhysicsEngine.cs" />
|
||||
<Compile Include="Rendering\Mesh.cs" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||
<ItemGroup>
|
||||
@ -105,6 +106,7 @@
|
||||
<Folder Include="Interface\" />
|
||||
<Folder Include="Events\" />
|
||||
<Folder Include="Content\" />
|
||||
<Folder Include="Rendering\" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="OpenTK.dll.config" />
|
||||
|
Loading…
x
Reference in New Issue
Block a user