Change the test demo

This commit is contained in:
Théophile Bastian 2018-02-13 16:19:44 +01:00
parent b404c2301f
commit a0db41689c
2 changed files with 7 additions and 10 deletions

View File

@ -12,14 +12,13 @@ int main(int argc, char** argv) {
GlutRender& render = GlutRender::get_instance();
render.init(&argc, argv, 640, 480, "Bouncing stuff");
Ball ball(Point(0, 10, 0), 0.25, 0.25, 0, 1, 1);
Ball ball(Point(0, 5, 0), 0.75, -.5, -1, 1, 1);
Cuboid bbox = ball.get_surface()->max_bounding_box();
printf("%.2lf %.2lf %.2lf | %.2lf %.2lf %.2lf\n",
bbox.low(0), bbox.low(1), bbox.low(2),
bbox.high(0), bbox.high(1), bbox.high(2));
render.add_surface(ball.get_surface(),
ball.get_surface()->max_bounding_box());
render.add_surface(ball.get_surface(), bbox);
render.set_idle_func(periodic_update);
init_periodic_static(&ball);

View File

@ -31,10 +31,10 @@ void GlutRender::init(int* argc, char** argv,
glutReshapeFunc(reshape_handle);
// ==== Lighting ====
GLfloat light0_pos[] = {2., 10., 2.};
GLfloat light0_pos[] = {10., 15., 10.};
GLfloat light0_ambient[] = {0., 0., 0., 1.};
GLfloat light0_diffuse[] = {1., 1., 1., 1.};
GLfloat light0_specular[] = {1., 1., 1., 1.};
GLfloat light0_diffuse[] = {1., 1., .65, 1.};
GLfloat light0_specular[] = {1., 1., .65, 1.};
glLightfv(GL_LIGHT0, GL_POSITION, light0_pos);
glLightfv(GL_LIGHT0, GL_AMBIENT, light0_ambient);
glLightfv(GL_LIGHT0, GL_DIFFUSE, light0_diffuse);
@ -159,8 +159,6 @@ void GlutRender::display_mesh(Mesh& mesh) const {
n1 = mesh.get_normal(face[1]),
n2 = mesh.get_normal(face[2]);
glColor3f(rand_color(), rand_color(), rand_color());
glNormal3f(n0[0], n0[1], n0[2]); glVertex3f(p0[0], p0[1], p0[2]);
glNormal3f(n1[0], n1[1], n1[2]); glVertex3f(p1[0], p1[1], p1[2]);
glNormal3f(n2[0], n2[1], n2[2]); glVertex3f(p2[0], p2[1], p2[2]);
@ -175,8 +173,8 @@ void GlutRender::display() {
// Camera position and orientation
glLoadIdentity();
//glTranslatef(1., 2., -10.);
gluLookAt(0, 5, -20,
0, 5, 0,
gluLookAt(0, 2.5, -10,
0, 2.5, 0,
0, 1, 0);
for(Mesh* mesh: meshes) {