示例#1
0
		Scene createScene ()
		{
			int x = 0;
			int y = 0;

			Scene scene = new Scene ();

			Primitive p;
			int nx = 4;
			int ny = 4;
			int nz = 4;
			for (int i = 0; i < nx; i++) {
				for (int j = 0; j < ny; j++) {
					for (int k = 0; k < nz; k++) {
						double xx = 20.0 / (nx - 1) * i - 10.0;
						double yy = 20.0 / (ny - 1) * j - 10.0;
						double zz = 20.0 / (nz - 1) * k - 10.0;

						p = new Sphere (new Vec (xx, yy, zz), 3);
						p.setColor (0, 0, (i + j) / (double)(nx + ny - 2));
						p.surf.shine = 15.0;
						p.surf.ks = 1.5 - 1.0;
						p.surf.kt = 1.5 - 1.0;
						scene.Objects.Add (p);
					}
				}
			}

			scene.Lights.Add (new Light (100, 100, -50, 1.0));
			scene.Lights.Add (new Light (-100, 100, -50, 1.0));
			scene.Lights.Add (new Light (100, -100, -50, 1.0));
			scene.Lights.Add (new Light (-100, -100, -50, 1.0));
			scene.Lights.Add (new Light (200, 200, 0, 1.0));

			View v = new View (new Vec (x, 20, -30), new Vec (x, y, 0), new Vec (0, 1, 0), 1.0, 35.0 * 3.14159265 / 180.0, 1.0);

			scene.RTView = v;

			return scene;
		}
示例#2
0
		public void setScene (Scene scene)
		{
			// Get the objects count
			int nLights = scene.Lights.Count;
			int nObjects = scene.Objects.Count;

			lights = new Light[nLights];
			prim = new Primitive[nObjects];

			// Get the lights
			for (int l = 0; l < nLights; l++) {
				lights [l] = scene.Lights [l];
			}

			// Get the primitives
			for (int o = 0; o < nObjects; o++) {
				prim [o] = scene.Objects [o];
			}

			// Set the view
			view = scene.RTView;
		}