public RocketModel(IVertexCoder <Vertex> coder) { SimpleMesh mesh = new SimpleMesh(); mesh.AddRange(Compose(new Triangle( new Vector3(0, 0, 1), new Vector3(1f / 3, -1f / 3, 1f / 3), new Vector3(1f / 3, 1f / 3, 1f / 3) ))); mesh.AddRange(Compose(Mesh.Quad( new Vector3(1f / 3, -1f / 3, 1f / 3), new Vector3(1f / 3, -1f / 3, -1), new Vector3(1f / 3, 1f / 3, -1), new Vector3(1f / 3, 1f / 3, 1f / 3) ))); mesh.AddRange(Compose(new Triangle( new Vector3(1f / 3, 0, -1f / 3), new Vector3(1f / 3, 0, -1f), new Vector3(2f / 3, 0, -1f) ))); mesh.AddRange(Mesh.Quad( new Vector3(1f / 3, -1f / 3, -1f), new Vector3(-1f / 3, -1f / 3, -1f), new Vector3(-1f / 3, 1f / 3, -1f), new Vector3(1f / 3, 1f / 3, -1f) )); _bfr = mesh.ToBuffer(coder); }
public SphereModel(IVertexCoder <Vertex> coder, int bups) { List <Triangle> triangles = new List <Triangle> { new Triangle(new Vector3(1, 0, 0), new Vector3(0, 1, 0), new Vector3(0, 0, 1)) }; for (int i = 0; i < bups; i++) { for (int j = triangles.Count - 1; j >= 0; j--) { triangles.AddRange(triangles[j].BreakUp()); triangles.RemoveAt(j); } } int octant = triangles.Count; for (int i = 1; i <= 3; i++) { float sin = (float)Math.Sin(i * (float)Math.PI / 2); float cos = (float)Math.Cos(i * (float)Math.PI / 2); for (int j = octant - 1; j >= 0; j--) { Triangle self = triangles[j]; Triangle rot = self.RotateZ(sin, cos); triangles.Add(rot); if (i == 1) { triangles.Add(self.FlipZ()); } triangles.Add(rot.FlipZ()); } } SimpleMesh mesh = new SimpleMesh(); mesh.AddRange(triangles.Select(i => new Engine.Geometry.Triangle(i.A, i.B, i.C))); _indices = mesh.ToBuffer(coder); }