Smooth triangles! And support for them in the OBJ File parser.
Also add an interesting tea party scene!
This commit is contained in:
@@ -28,9 +28,9 @@ int main()
|
||||
World w = World();
|
||||
|
||||
/* Add lights */
|
||||
Light light1 = Light(POINT_LIGHT, Point(0, 20, 2), Colour(1, 1, 1));
|
||||
Light light1 = Light(POINT_LIGHT, Point(50, 100, 20), Colour(.5, .5, .5));
|
||||
w.addLight(&light1);
|
||||
Light light2 = Light(POINT_LIGHT, Point(0, 2, 20), Colour(1, 1, 1));
|
||||
Light light2 = Light(POINT_LIGHT, Point(2, 50, 100), Colour(.5, .5, .5));
|
||||
w.addLight(&light2);
|
||||
|
||||
/* ----------------------------- */
|
||||
@@ -42,6 +42,7 @@ int main()
|
||||
p.material.ambient = 1;
|
||||
p.material.diffuse = 0;
|
||||
p.material.specular = 0;
|
||||
p.material.reflective = 0.1;
|
||||
w.addObject(&p);
|
||||
|
||||
Plane p2 = Plane();
|
||||
@@ -53,26 +54,31 @@ int main()
|
||||
w.addObject(&p2);
|
||||
|
||||
OBJFile teapot = OBJFile("teapot-low.obj");
|
||||
teapot.setTransform(rotationY(M_PI) * rotationX(-M_PI/2) * scaling(0.4, 0.4, 0.4));
|
||||
teapot.material.colour = Colour(1, 0.2, 0.1);
|
||||
teapot.material.ambient = 0.2;
|
||||
teapot.material.specular = 0.2;
|
||||
teapot.material.diffuse = 20;
|
||||
teapot.setTransform(translation(7, 0, 3) * rotationY(M_PI*23/22) * rotationX(-M_PI/2) * scaling(0.3, 0.3, 0.3));
|
||||
teapot.material.colour = Colour(1, 0.3, 0.2);
|
||||
teapot.material.shininess = 5;
|
||||
teapot.material.specular = 0.4;
|
||||
w.addObject(&teapot);
|
||||
|
||||
/* ----------------------------- */
|
||||
OBJFile teapot2 = OBJFile("teapot-lowtri.obj");
|
||||
teapot2.setTransform(translation(-7, 0, 3) * rotationY(-M_PI*46/22) * rotationX(-M_PI/2) * scaling(0.3, 0.3, 0.3));
|
||||
teapot2.material.colour = Colour(1, 0.3, 0.2);
|
||||
teapot2.material.shininess = 5;
|
||||
teapot2.material.specular = 0.4;
|
||||
w.addObject(&teapot2);
|
||||
|
||||
FILE *fpOut = fopen("teapot_worlddump.json", "wt");
|
||||
if (fpOut)
|
||||
{
|
||||
w.dumpMe(fpOut);
|
||||
fclose(fpOut);
|
||||
}
|
||||
OBJFile teapot3= OBJFile("teapot.obj");
|
||||
teapot3.setTransform(translation(0, 0, -5) * rotationY(-M_PI) * rotationX(-M_PI/2) * scaling(0.4, 0.4, 0.4));
|
||||
teapot3.material.colour = Colour(0.3, 1, 0.2);
|
||||
teapot3.material.shininess = 5;
|
||||
teapot3.material.specular = 0.4;
|
||||
teapot3.material.reflective = 0.5;
|
||||
w.addObject(&teapot3);
|
||||
|
||||
/* ----------------------------- */
|
||||
|
||||
/* Set the camera */
|
||||
Camera camera = Camera(800, 400, M_PI/2);
|
||||
Camera camera = Camera(80, 40, M_PI/2);
|
||||
camera.setTransform(viewTransform(Point(0, 7, 13),
|
||||
Point(0, 1, 0),
|
||||
Vector(0, 1, 0)));
|
||||
|
||||
Reference in New Issue
Block a user