/// <summary> /// Parses scenes from sphere table view /// </summary> /// <param name="sphereView">sphere table view</param> /// <param name="sceneID">scene ID</param> /// <returns></returns> private List <Sphere> ParseSpheres(DataView sphereView, int sceneID) { int sphereID; Point location; float diffusion, reflection, transparency, diameter, refraction; Color color; List <Sphere> spheres = new List <Sphere>(); for (int i = 0; i < sphereView.Count; i++) { if (sceneID == Convert.ToInt32(sphereView[i]["sceneID"])) { sphereID = Convert.ToInt32(sphereView[i]["id"]); location = MakePoint((string)sphereView[i]["location"]); color = MakeColor((string)sphereView[i]["color"]); diffusion = float.Parse(sphereView[i]["diffusion"].ToString()); reflection = float.Parse(sphereView[i]["reflection"].ToString()); transparency = float.Parse(sphereView[i]["transparency"].ToString()); diameter = float.Parse(sphereView[i]["diameter"].ToString()); refraction = float.Parse(sphereView[i]["refraction"].ToString()); Sphere sphere = new Sphere(sphereID, location, diameter); sphere.SetColor(color); sphere.SetProperties(diffusion, reflection, transparency); sphere.SetRefraction(refraction); spheres.Add(sphere); } } return(spheres); }
private void CreateEllipse() { int r = rnd.Next(256); int g = rnd.Next(256); int b = rnd.Next(256); float diameter = 5; RayTracer.Sphere sphere = new RayTracer.Sphere(-1, new RayTracer.Point(2.5f, 2.5f, 2.5f), diameter); sphere.SetColor((float)(r / 256.0), (float)(g / 256.0), (float)(b / 256.0)); CreateEllipse(sphere); }