World class for a number of spheres

World class other are the same, just modify the build function on the line, after testing all the code is based on two or more balls are not repeated elaborate.

void World::build() {
	vp.set_hres(200);
	vp.set_vres(100);
	tracer_ptr = new MultiSphere(this);//这里变成MultiSphere
	Geometrics* obj = new Sphere(0, 0.5);
	obj->set_color(RGBColor(1, 0, 0));
	add_object(obj);
	obj = new Sphere(Point3(0, -100.5, 0), 100);
	obj->set_color(RGBColor(0, 0, 1));
	add_object(obj);
}

 

After running the test results look:

Okay, if the World according to the book :: Render code, you will find that this image is reversed. Ha ha ha ha. Because the default is rendered from upper left to lower right.

Guess you like

Origin www.cnblogs.com/dalgleish/p/12602741.html