public static void Render(Model model) { var transforms = model.Bones.Select(x => x.Transform).ToList(); GL.Color4(1f, 1f, 1f, 1f); TextureHelper.EnableTexturing(); foreach (var group in model.Meshes.GroupBy(x => x.SkinRef)) { var texture = model.Textures[group.Key].TextureObject; if (texture != null) texture.Bind(); foreach (var mesh in group) { GL.Begin(BeginMode.Triangles); foreach (var v in mesh.Vertices) { var transform = transforms[v.BoneWeightings.First().Bone.BoneIndex]; var c = v.Location * transform; if (texture != null) { GL.TexCoord2(v.TextureU, v.TextureV); } GL.Vertex3(c.X, c.Y, c.Z); } GL.End(); } if (texture != null) texture.Unbind(); } TextureHelper.DisableTexturing(); }
public static void Render(Model model) { var transforms = model.GetTransforms(); GL.Color4(1f, 1f, 1f, 1f); foreach (var group in model.GetActiveMeshes().GroupBy(x => x.SkinRef)) { var texture = model.Textures[group.Key].TextureObject; if (texture != null) texture.Bind(); foreach (var mesh in group) { GL.Begin(PrimitiveType.Triangles); foreach (var v in mesh.Vertices) { var transform = transforms[v.BoneWeightings.First().Bone.BoneIndex]; var c = v.Location * transform; if (texture != null) { GL.TexCoord2(v.TextureU, v.TextureV); } GL.Vertex3(c.X, c.Y, c.Z); } GL.End(); } if (texture != null) texture.Unbind(); } }
public ModelVertexArray(Model model) { _arrays = new Dictionary<object, VertexArray<float>>(); float[] array; uint[] indices; int count; TextureSubsets = new List<VertexArraySubset<int>>(); GetArrayData(model, out count, out array, out indices, TextureSubsets); Array = new VertexBuffer<float>(Specification, Modes, count, sizeof (float), array, new[] {indices}); }
private static void GetArrayData(Model model, out int count, out float[] array, out uint[] indices, List<VertexArraySubset<int>> textureSubsets) { var transforms = model.Bones.Select(x => x.Transform).ToList(); var data = new List<float>(); var indexList = new List<uint>(); count = 0; foreach (var g in model.Meshes.GroupBy(x => x.SkinRef)) { var sr = g.Key; var start = count; foreach (var mesh in g) { foreach (var vertex in mesh.Vertices) { var transform = transforms[vertex.BoneWeightings.First().Bone.BoneIndex]; var c = vertex.Location * transform; data.Add(c.X); data.Add(c.Y); data.Add(c.Z); data.Add(vertex.TextureU); data.Add(vertex.TextureV); indexList.Add((uint) count); count++; } } textureSubsets.Add(new VertexArraySubset<int>(sr, start, count - start)); } array = data.ToArray(); indices = indexList.ToArray(); }
public IRenderable CreateRenderable(Model model) { throw new NotImplementedException(); }
public ModelRenderable(Model model) { Model = model; CurrentAnimation = 1; CurrentFrame = 0; }