From 24d01209cd6f3d1cf559bcdd3d26eb59dcbf5bf7 Mon Sep 17 00:00:00 2001 From: Yoann Date: Mon, 3 Oct 2011 11:26:50 +0200 Subject: [PATCH] =?UTF-8?q?Petite=20am=C3=A9lioration=20dans=20l'affichage?= =?UTF-8?q?=20mais=20c'est=20pas=20encore=20=C3=A7a.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- display.c | 36 +++++++++++++++++++----------------- display.h | 4 ++-- roam.c | 2 +- 3 files changed, 22 insertions(+), 20 deletions(-) diff --git a/display.c b/display.c index e7d103d..91a077e 100644 --- a/display.c +++ b/display.c @@ -8,31 +8,32 @@ int initWindow() { glLoadIdentity(); gluPerspective(70,(double)windowWidth/windowHeight,1,10000); glEnable(GL_DEPTH_TEST); - glEnable(GL_LIGHTING); // Active l'éclairage - glEnable(GL_LIGHT0); // Active la lumière 0; glewInit(); float MatSpec[4] = {0.0f, 0.0f, 0.0f, 1.0f}; - float MatDif[4] = {0.0f, 1.0f, 0.0f, 1.0f}; + float MatDif[4] = {1.0f, 1.0f, 1.0f, 1.0f}; float MatAmb[4] = {0.1f, 0.1f, 0.1f, 1.0f}; float Light1Pos[4] = {0.0f, 0.0f, -1.0f, 0.0f}; float Light1Dif[4] = {1.0f, 1.0f, 1.0f, 1.0f}; float Light1Spec[4] = {0.0f, 0.0f, 0.0f, 1.0f}; float Light1Amb[4] = {0.4f, 0.4f, 0.4f, 1.0f}; - float shininess = 100.0f; + //float shininess = 128.0f; glMaterialfv(GL_FRONT_AND_BACK,GL_SPECULAR,MatSpec); glMaterialfv(GL_FRONT_AND_BACK,GL_DIFFUSE,MatDif); glMaterialfv(GL_FRONT_AND_BACK,GL_AMBIENT,MatAmb); - glMaterialfv(GL_FRONT,GL_SHININESS,&shininess); + //glMaterialfv(GL_FRONT,GL_SHININESS,&shininess); glLightfv(GL_LIGHT0, GL_DIFFUSE, Light1Dif); glLightfv(GL_LIGHT0, GL_SPECULAR, Light1Spec); glLightfv(GL_LIGHT0, GL_AMBIENT, Light1Amb); glLightfv(GL_LIGHT0, GL_POSITION, Light1Pos); + glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER, GL_TRUE); - + glEnable(GL_LIGHTING); // Active l'éclairage + glEnable(GL_LIGHT0); // Active la lumière 0; + return 0; } @@ -175,17 +176,18 @@ void setNormals(Triangle *t) { int by = t->vApex->y - t->vRight->y; int bz = t->vApex->z - t->vRight->z; - int x = (ay * bz) - (az * by); - int y = (az * bx) - (ax * bz); - int z = (ax * by) - (ay * bx); - int length = sqrt((x^2) + (y^2) + (z^2)); + float x = (float)((ay * bz) - (az * by)); + float y = (float)((az * bx) - (ax * bz)); + float z = (float)((ax * by) - (ay * bx)); + float length = sqrt(((int)x^2) + ((int)y^2) + ((int)z^2)); - length = length; - x = x/1000; - y = y/1000; - z = z/1000; + length = length*100; + x = x/length; + y = y/length; + z = z/length; + - printf("%d %d %d\n",x,y,z); + printf("%f %f %f\n",x,y,z); t->vLeft->xNormal = x; t->vLeft->yNormal = y; t->vLeft->zNormal = z; @@ -204,8 +206,8 @@ void setNormals(Triangle *t) { void displayTree(Triangle *t) { if(t->tLeftChild == NULL) { - glNormal3d(t->vLeft->xNormal,t->vLeft->yNormal,t->vLeft->zNormal); - //glNormal3d(0,10000,0); + glNormal3f(t->vLeft->xNormal,t->vLeft->yNormal,t->vLeft->zNormal); + //glNormal3d(0,1,0); glBegin(GL_TRIANGLES); glVertex3d(t->vLeft->x,t->vLeft->y,t->vLeft->z); glVertex3d(t->vApex->x,t->vApex->y,t->vApex->z); diff --git a/display.h b/display.h index 67ea19d..3d8e0b6 100644 --- a/display.h +++ b/display.h @@ -17,8 +17,8 @@ int windowWidth = 1024; int nbVertex = 0; int windowHeight = 768; int xCamera = 1024; -int yCamera = -800; -int zCamera = 600; +int yCamera = -400; +int zCamera = 1500; int xSight = 1024; int ySight = 512; int zSight = 0; diff --git a/roam.c b/roam.c index ca550bc..1747e92 100644 --- a/roam.c +++ b/roam.c @@ -326,7 +326,7 @@ Triangle* initDefaultExample() { t->tRightNeighbor = NULL; t->tParent = NULL; - recursiveSplit(t, 6); + recursiveSplit(t, 13); /* triangle_split(t); */ /* triangle_split(t->tLeftChild); */ /* triangle_split(t->tLeftChild->tLeftChild); */