Esempio n. 1
0
 void build11()
 {
     int ns = 100;
     world.ViewPlane.HRes = 600;
     world.ViewPlane.VRes = 600;
     world.ViewPlane.SetSampler(new Regular(ns));
     world.ViewPlane.MaxDepth = 10;
     world.Tracer = new Whitted(world);
     AmbientOccluder occ = new AmbientOccluder();
     occ.RadianceScale = 1.0f;
     occ.MinAmount = 0f;
     occ.Shadows = true;
     occ.Color = Vector3.One;
     occ.SetSampler(new Regular(ns));
     world.AmbientLight = occ;
     Pinhole cam = new Pinhole();
     cam.Position = new Vector3(-6, 6, 45);
     cam.Target = new Vector3(0, 0, 0);
     cam.Distance = 5000;
     cam.Zoom = 1.7f;
     world.Camera = cam;
     Matte plane_material = new Matte(0.9f, 0.9f, Vector3.One);
     XRectangle pl = new XRectangle(new Vector3(-2.5f, 0, -2.5f), new Vector3(0, 0, 5), new Vector3(5, 0, 0), Vector3.Up);
     //Plane pl = new Plane(new Vector3(0), Vector3.Up);
     pl.SetMaterial(plane_material);
     world.Objects.Add(pl);
     PointLight light = new PointLight();
     light.Color = Vector3.One;
     light.Position = new Vector3(-3, 3, 0);
     light.RadianceScale = 2.0f;
     float refl = 0.18f;
     float spec = 0.8f;
     float amb = 0.5f;
     float diff = 1f;
     float exp = 100;
     Group tree = new Group();
     world.Lights.Add(light);
     {
         ImageTexture im = new ImageTexture();
         Disque.Raytracer.Textures.Image imm = Extensions.CreateFromBitmap(@"C:\Users\Belal\Downloads\Earth_Diffuse_2.jpg");
         im.SetImage(imm);
         im.SetMapping(new SphericalMap());
         SV_Phong sphere_m = new SV_Phong();
         sphere_m.SetCD(im);
         sphere_m.SetSpecularColor(im);
         sphere_m.SetExp(40);
         sphere_m.SetSpecularRC(0.2f);
         sphere_m.SetDiffuseRC(0.6f);
         sphere_m.SetAmbientRC(0.25f);
         Sphere sphere = new Sphere(new Vector3(0, 0f, 0), 1f);
         Instance ins = new Instance(sphere);
         ins.SetMaterial(sphere_m);
         ins.RotateY(MathHelper.ToRadians(90));
         ins.Scale(new Vector3(0.4f));
         ins.Translate(new Vector3(0, 0.4f, 0.5f));
         world.Objects.Add(ins);
     }
     {
         Reflective smatte2 = new Reflective();
         smatte2.SetAmbientRC(amb);
         smatte2.SetDiffuseRC(diff);
         smatte2.SetCD(new Vector3(1, 0.77f, 0.77f));
         smatte2.SetRColor(new Vector3(1, 0.77f, 0.77f));
         smatte2.SetSpecularRC(spec);
         smatte2.SetExp(exp);
         smatte2.SetReflectiveRC(refl);
         Sphere s = new Sphere(new Vector3(-0.8f, 0.45f, 0.1f), 0.45f);
         s.SetMaterial(smatte2);
         tree.AddObject(s);
         //world.Objects.Add(s);
     }
     {
         Reflective smatte2 = new Reflective();
         smatte2.SetAmbientRC(amb);
         smatte2.SetDiffuseRC(diff);
         smatte2.SetCD(new Vector3(0.92f, 0.74f, 1));
         smatte2.SetRColor(new Vector3(0.92f, 0.74f, 1));
         smatte2.SetSpecularRC(spec);
         smatte2.SetExp(exp);
         smatte2.SetReflectiveRC(refl);
         Sphere s = new Sphere(new Vector3(0.7f, 0.4f, 1.5f), 0.4f);
         s.SetMaterial(smatte2);
         tree.AddObject(s);
         //world.Objects.Add(s);
     }
     {
         Reflective smatte2 = new Reflective();
         smatte2.SetAmbientRC(amb);
         smatte2.SetDiffuseRC(diff);
         smatte2.SetCD(new Vector3(0.62f, 0f, 0.7f));
         smatte2.SetRColor(new Vector3(0.62f, 0f, 0.7f));
         smatte2.SetSpecularRC(spec);
         smatte2.SetExp(exp);
         smatte2.SetReflectiveRC(refl);
         Sphere s = new Sphere(new Vector3(-0.7f, 0.2f, 1.5f), 0.2f);
         s.SetMaterial(smatte2);
         tree.AddObject(s);
         //world.Objects.Add(s);
     }
     world.Objects.Add(tree);
 }
Esempio n. 2
0
 static GeometricObject getCObject(XElement ele)
 {
     string typ = ele.Name.LocalName;
     if (typ == "Group")
     {
         bool va = false;
         Group group = new Group(getAttribute("Name", ele));
         foreach (XElement xele in ele.Elements())
             group.AddObject(getPObject(ele, ref va));
         group.SetShadows(bool.Parse(getAttribute("Shadows", ele)));
         return group;
     }
     else if (typ == "SolidCone")
     {
         SolidCone oc = new SolidCone(float.Parse(getAttribute("Radius", ele)), float.Parse(getAttribute("Height", ele)), getAttribute("Name", ele));
         oc.SetShadows(bool.Parse(getAttribute("Shadows", ele)));
         oc.SetMaterial(getMaterial(ele));
         return oc;
     }
     else if (typ == "SolidCylinder")
     {
         SolidCylinder oc = new SolidCylinder(float.Parse(getAttribute("Bottom", ele)), float.Parse(getAttribute("Top", ele)), float.Parse(getAttribute("Radius", ele)), getAttribute("Name", ele));
         oc.SetShadows(bool.Parse(getAttribute("Shadows", ele)));
         oc.SetMaterial(getMaterial(ele));
         return oc;
     }
     else if (typ == "ThickAnnulus")
     {
         ThickAnnulus oc = new ThickAnnulus(float.Parse(getAttribute("Bottom", ele)), float.Parse(getAttribute("Top", ele)), float.Parse(getAttribute("InnerRadius", ele)), float.Parse(getAttribute("OuterRadius", ele)), getAttribute("Name", ele));
         oc.SetShadows(bool.Parse(getAttribute("Shadows", ele)));
         oc.SetMaterial(getMaterial(ele));
         return oc;
     }
     throw new Exception("No recognized elements");
 }