public override void Parse(ParserContext context, Scene scene, string[] words) { // "s" center.x center.y center.z radius Point3D center; center.X = float.Parse(words[1]); center.Y = float.Parse(words[2]); center.Z = float.Parse(words[3]); float radius = float.Parse(words[4]); SphereTessellator tessellator = new SphereTessellator(radius, context.CurrentTessellationLevel); Mesh mesh = CreateFromPrimitive(context, tessellator, center); scene.Meshes.Add(mesh); }
public static void MakeSphere(List <Vector3> vertices, List <int> indices, List <Vector3> normals, int depth) { // Start with a unit sphere so we have normals precalculated. // Use a fine subdivision to ensure we need multiple data packets to transfer vertices. SphereTessellator.SphereSubdivision(vertices, indices, 1.0f, Vector3.Zero, depth); // Normals as vertices. Scale and offset. if (normals != null) { normals.Clear(); for (int i = 0; i < vertices.Count; ++i) { normals.Add(vertices[i]); } } const float radius = 5.5f; Vector3 sphereCentre = new Vector3(0.5f, 0, -0.25f); for (int i = 0; i < vertices.Count; ++i) { vertices[i] = sphereCentre + vertices[i] * radius; } }