Smuggler/Model.cs

37 lines
906 B
C#

using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
namespace Smuggler
{
public class Model
{
public Mesh[] Meshes { get; }
public Texture2D[] Textures { get; }
public Model(Mesh[] meshes)
{
Meshes = meshes;
}
public void SetTexture(Texture2D texture)
{
foreach (var mesh in Meshes)
{
foreach (var meshPart in mesh.MeshParts)
{
meshPart.Effect.TextureEnabled = true;
meshPart.Effect.Texture = texture;
}
}
}
public void Draw(GraphicsDevice graphicsDevice, Matrix world, Matrix view, Matrix projection)
{
foreach (var mesh in Meshes)
{
mesh.Draw(graphicsDevice, world, view, projection);
}
}
}
}