-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMesh.cs
68 lines (57 loc) · 1.68 KB
/
Mesh.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
using System;
using System.Collections.Generic;
using System.Linq;
using OpenTK;
namespace GLTerrain {
public interface IMeshLoader {
void LoadMesh(string filename);
Geometry GetGeometry();
IEnumerable<Shader> GetEffects();
IEnumerable<Texture> GetTextures();
bool IsLoaded { get; }
}
public class Mesh : IDisposable {
public Geometry MeshBuffer { get; private set; }
public Shader ShaderEffect { get; private set; }
private List<Texture> textures = new List<Texture>();
public IEnumerable<Texture> Textures {
get {
foreach (Texture tex in textures) {
yield return tex;
}
}
}
public Vector3 Position {
get {
return MeshBuffer.Position;
}
set {
MeshBuffer.Position = value;
}
}
public Quaternion Orientation {
get {
return MeshBuffer.Orientation;
}
set {
MeshBuffer.Orientation = value;
}
}
public Mesh(IMeshLoader loader, string filename) {
if (!loader.IsLoaded) {
loader.LoadMesh(filename);
}
MeshBuffer = loader.GetGeometry();
textures.AddRange(loader.GetTextures());
if (loader.GetEffects().Count() > 0) {
ShaderEffect = loader.GetEffects().First();
}
}
public void Draw() {
MeshBuffer.Draw();
}
public void Dispose() {
throw new NotImplementedException();
}
}
}