Smuggler/Model.cs

37 lines
906 B
C#
Raw Normal View History

2020-07-28 09:08:13 +00:00
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
namespace Smuggler
{
public class Model
{
public Mesh[] Meshes { get; }
2020-07-29 08:35:11 +00:00
public Texture2D[] Textures { get; }
2020-07-28 09:08:13 +00:00
public Model(Mesh[] meshes)
{
Meshes = meshes;
}
2020-07-29 08:35:11 +00:00
public void SetTexture(Texture2D texture)
{
foreach (var mesh in Meshes)
{
foreach (var meshPart in mesh.MeshParts)
{
meshPart.Effect.TextureEnabled = true;
meshPart.Effect.Texture = texture;
}
}
}
2020-07-28 09:08:13 +00:00
public void Draw(GraphicsDevice graphicsDevice, Matrix world, Matrix view, Matrix projection)
{
foreach (var mesh in Meshes)
{
mesh.Draw(graphicsDevice, world, view, projection);
}
}
}
}