Point de vue souhaité
Point de vue assuré par le repère initial
Après la translation T
Après la rotation R1
Après la rotation R2
Point de vue final
Paramètres numériques de visualisation
Point de vue sur une scène constituée de cylindres verticaux
Image obtenue
Le source : TD-TransformationVisualisation.cpp
/* Auteur: Nicolas JANEY */
/* nicolas.janey@univ-fcomte.fr */
/* Mars 2003 */
/* Programmation d'une transformation */
/* geometrique de visualisation */
#include <stdio.h>
#include <math.h>
#include <GL/glut.h>
#include <GL/gl.h>
#include <GL/glu.h>
#include "ModuleMatriceVecteur.h"
#include "ModuleCouleurs.h"
#include "ModuleManipulateur.h"
#include "ModuleMenus.h"
#include "ModuleReshape.h"
#include "ModuleFont.h"
#include "ModuleAxes.h"
#include "ModuleFleche.h"
#include "ModuleDessinArc.h"
#ifndef M_PI
#define M_PI 3.1415926535897932F
#endif
static int scn = 0;
static vecteur ref = { 1.6F,1.8F,4.0F,1.0F };
static vecteur po = { 1.6F,1.8F,4.0F,1.0F };
static vecteur pv = { 2.8F,0.5F,-4.0F,1.0F };
static int f1;
static int f2;
static int f3;
static vecteur axeVisee;
static float thetay;
static matrice r1;
static vecteur axeVisee2;
static float thetax;
static matrice r2;
static vecteur axeVisee3;
static matrice m;
static vecteur axe;
static matrice t;
static vecteur p;
static matrice mc;
void calculParametresVisualisation(void) {
calculVecteur(po,pv,axeVisee);
thetay =(float) -atan2(-axeVisee[0],-axeVisee[2])*180/M_PI;
toRotationY(r1,thetay);
produitMatriceVecteur(r1,axeVisee,axeVisee2) ;
thetax =(float) atan2(-axeVisee2[1],-axeVisee2[2])*180/M_PI;
toRotationX(r2,thetax);
produitMatriceVecteur(r2,axeVisee2,axeVisee3) ;
produitMatriceMatrice(r2,r1,m);
produitMatriceVecteur(m,axeVisee,axe) ;
toTranslation(t,-po[0],-po[1],-po[2]);
produitMatriceMatrice(m,t,m) ;
produitMatriceVecteur(m,pv,p) ;
vecteur av;
calculVecteur(po,pv,av);
normalise(av);
float a = 1.0F/(float) sqrt(1-av[1]*av[1]);
mc[0][0] = -a*av[2];
mc[0][1] = 0.0F;
mc[0][2] = a*av[0];
mc[0][3] = a*(po[0]*av[2]-po[2]*av[0]);
mc[1][0] = a*av[0]*av[1];
mc[1][1] = 1/a;
mc[1][2] = -a*av[1]*av[2];
mc[1][3] = a*av[1]*(po[0]*av[0]+po[2]*av[2])-po[1]/a;
mc[2][0] = -av[0];
mc[2][1] = -av[1];
mc[2][2] = -av[2];
mc[2][3] = po[0]*av[0]+po[1]*av[1]+po[2]*av[2];
mc[3][0] = 0.0F;
mc[3][1] = 0.0F;
mc[3][2] = 0.0F;
mc[3][3] = 1.0F;
}
void myinit(float *c) {
glClearColor(c[0],c[1],c[2],1.0F);
GLfloat light_position0[] = { 1.0F,1.0F,1.0F,0.0F };
glLightfv(GL_LIGHT0,GL_AMBIENT,couleurNoir());
glLightfv(GL_LIGHT0,GL_DIFFUSE,couleurBlanc());
glLightfv(GL_LIGHT0,GL_SPECULAR,couleurBlanc());
glLightfv(GL_LIGHT0,GL_POSITION,light_position0);
glEnable(GL_LIGHTING);
glEnable(GL_LIGHT0);
glEnable(GL_AUTO_NORMAL);
glEnable(GL_NORMALIZE);
glEnable(GL_DEPTH_TEST);
glDepthFunc(GL_LESS);
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
glEnable(GL_CULL_FACE);
}
void solidCylinder(float r,float h,int n,int m) {
glPushMatrix();
glRotatef(90,1.0F,0.0F,0.0F);
glTranslatef(0.0F,0.0F,-h/2);
GLUquadricObj *qobj = gluNewQuadric();
gluQuadricDrawStyle(qobj,GLU_FILL);
gluCylinder(qobj,r,r,h,n,m);
gluDeleteQuadric(qobj);
glPopMatrix();
}
void scene(void) {
if ( scn ) {
glEnable(GL_LIGHTING);
glEnable(GL_CULL_FACE);
glPushMatrix();
glTranslatef(2.8F,0.5F,-4.0F);
glMaterialfv(GL_FRONT,GL_DIFFUSE,couleurCyan());
glutSolidSphere(0.25,36,36);
glPopMatrix();
glPushMatrix();
glTranslatef(4.8F,0.9F,-1.5F);
glMaterialfv(GL_FRONT,GL_DIFFUSE,couleurRouge(0.5));
solidCylinder(0.1,3.0,30,10);
glPopMatrix();
glPushMatrix();
glTranslatef(0.8F,0.2F,-3.5F);
glMaterialfv(GL_FRONT,GL_DIFFUSE,couleurJaune(0.5));
solidCylinder(0.1,3.0,30,10);
glPopMatrix();
glPushMatrix();
glTranslatef(1.8F,0.7F,-2.5F);
glMaterialfv(GL_FRONT,GL_DIFFUSE,couleurVert(0.5));
solidCylinder(0.1,3.0,30,10);
glPopMatrix();
glPushMatrix();
glTranslatef(3.2F,0.3F,-2.0F);
glMaterialfv(GL_FRONT,GL_DIFFUSE,couleurBleu(0.5));
solidCylinder(0.1,3.0,30,10);
glPopMatrix();
glEnable(GL_CULL_FACE); }
}
void box(float x,float y,float z) {
glVertex3f(x,y,z);
glVertex3f(x,0.0,z);
glVertex3f(x,y,z);
glVertex3f(x,y,0.0);
glVertex3f(x,y,z);
glVertex3f(0.0,y,z);
glVertex3f(0.0,0.0,z);
glVertex3f(x,0.0,z);
glVertex3f(0.0,y,0.0);
glVertex3f(x,y,0.0);
glVertex3f(0.0,0.0,z);
glVertex3f(0.0,y,z);
glVertex3f(x,0.0,0.0);
glVertex3f(x,0.0,z);
glVertex3f(x,0.0,0.0);
glVertex3f(x,y,0.0);
glVertex3f(0.0,y,0.0);
glVertex3f(0.0,y,z);
}
void display0(void) {
glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
glPushMatrix();
manipulateurSouris();
manipulateurClavier();
axes();
glEnable(GL_LIGHTING);
glPushMatrix();
glTranslatef(po[0],po[1],po[2]);
glMaterialfv(GL_FRONT,GL_DIFFUSE,couleurBlanc());
glutSolidSphere(0.25,20,20);
glPopMatrix();
glPushMatrix();
glTranslatef(pv[0],pv[1],pv[2]);
glMaterialfv(GL_FRONT,GL_DIFFUSE,couleurCyan());
glutSolidSphere(0.25,20,20);
glPopMatrix();
glPushMatrix();
glTranslatef(po[0],po[1],po[2]);
glRotatef(-thetay,0.0F,1.0F,0.0F);
glRotatef(-thetax,1.0F,0.0F,0.0F);
axes();
glPopMatrix();
glPushMatrix();
glTranslatef(po[0],po[1],po[2]);
glMaterialfv(GL_FRONT,GL_DIFFUSE,couleurBleu());
flecheEnVolume(axeVisee[0],axeVisee[1],axeVisee[2],0.2F,1.0F,0.05F);
glPopMatrix();
glPushMatrix();
glDisable(GL_LIGHTING);
glColor4fv(couleurGrisFonce(0.5));
glBegin(GL_LINES);
glVertex3f(po[0]-10*axeVisee[0],po[1]-10*axeVisee[1],po[2]-10*axeVisee[2]);
glVertex3f(po[0]+10*axeVisee[0],po[1]+10*axeVisee[1],po[2]+10*axeVisee[2]);
box(po[0],po[1],po[2]);
box(pv[0],pv[1],pv[2]);
glVertex3f(-100.0,0.0,0.0);
glVertex3f(100.0,0.0,0.0);
glVertex3f(0.0,-100.0,0.0);
glVertex3f(0.0,100.0,0.0);
glVertex3f(0.0,0.0,-100.0);
glVertex3f(0.0,0.0,100.0);
glEnd();
glPopMatrix();
scene();
glPopMatrix();
glFlush();
glutSwapBuffers() ;
}
void display1(void) {
glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
glPushMatrix();
manipulateurSouris();
manipulateurClavier();
axes();
glEnable(GL_LIGHTING);
glPushMatrix();
glTranslatef(po[0],po[1],po[2]);
glMaterialfv(GL_FRONT,GL_DIFFUSE,couleurBlanc());
glutSolidSphere(0.25,20,20);
glPopMatrix();
glPushMatrix();
glTranslatef(pv[0],pv[1],pv[2]);
glMaterialfv(GL_FRONT,GL_DIFFUSE,couleurCyan());
glutSolidSphere(0.25,20,20);
glPopMatrix();
glMaterialfv(GL_FRONT,GL_DIFFUSE,couleurMagenta());
flecheEnVolume(axeVisee3[0],axeVisee3[1],axeVisee3[2],0.2F,1.0F,0.05F);
glPushMatrix();
glTranslatef(po[0],po[1],po[2]);
glMaterialfv(GL_FRONT,GL_DIFFUSE,couleurBleu(0.25));
glEnable(GL_CULL_FACE);
flecheEnVolume(axeVisee[0],axeVisee[1],axeVisee[2],0.2F,1.0F,0.05F);
glDisable(GL_CULL_FACE);
glPopMatrix();
glDisable(GL_LIGHTING);
glColor4fv(couleurGrisFonce(0.5));
glBegin(GL_LINES);
glVertex3f(po[0]-10*axeVisee[0],po[1]-10*axeVisee[1],po[2]-10*axeVisee[2]);
glVertex3f(po[0]+10*axeVisee[0],po[1]+10*axeVisee[1],po[2]+10*axeVisee[2]);
box(po[0],po[1],po[2]);
box(pv[0],pv[1],pv[2]);
glVertex3f(-100.0,0.0,0.0);
glVertex3f(100.0,0.0,0.0);
glVertex3f(0.0,-100.0,0.0);
glVertex3f(0.0,100.0,0.0);
glVertex3f(0.0,0.0,-100.0);
glVertex3f(0.0,0.0,100.0);
glEnd();
glPopMatrix();
glFlush();
glutSwapBuffers() ;
}
void display2(void) {
glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
glPushMatrix();
manipulateurSouris();
manipulateurClavier();
axes();
glEnable(GL_LIGHTING);
glPushMatrix();
glTranslatef(po[0],po[1],po[2]);
glMaterialfv(GL_FRONT,GL_DIFFUSE,couleurBlanc());
glutSolidSphere(0.25,20,20);
glPopMatrix();
glPushMatrix();
glTranslatef(pv[0],pv[1],pv[2]);
glMaterialfv(GL_FRONT,GL_DIFFUSE,couleurCyan());
glutSolidSphere(0.25,20,20);
glPopMatrix();
glMaterialfv(GL_FRONT,GL_DIFFUSE,couleurMagenta(0.25F));
flecheEnVolume(axeVisee3[0],axeVisee3[1],axeVisee3[2],0.2F,1.0F,0.05F);
glTranslatef(po[0],po[1],po[2]);
axes();
glMaterialfv(GL_FRONT,GL_DIFFUSE,couleurMagenta());
flecheEnVolume(axeVisee3[0],axeVisee3[1],axeVisee3[2],0.2F,1.0F,0.05F);
glMaterialfv(GL_FRONT,GL_DIFFUSE,couleurBleu(0.25));
glEnable(GL_CULL_FACE);
flecheEnVolume(axeVisee[0],axeVisee[1],axeVisee[2],0.2F,1.0F,0.05F);
glDisable(GL_CULL_FACE);
glDisable(GL_LIGHTING);
glColor4fv(couleurGrisFonce(0.5));
glBegin(GL_LINES);
glVertex3f(-10*axeVisee[0],-10*axeVisee[1],-10*axeVisee[2]);
glVertex3f(10*axeVisee[0],10*axeVisee[1],10*axeVisee[2]);
box(axeVisee[0],axeVisee[1],axeVisee[2]);
glVertex3f(-100.0,0.0,0.0);
glVertex3f(100.0,0.0,0.0);
glVertex3f(0.0,-100.0,0.0);
glVertex3f(0.0,100.0,0.0);
glVertex3f(0.0,0.0,-100.0);
glVertex3f(0.0,0.0,100.0);
glEnd();
glPopMatrix();
glFlush();
glutSwapBuffers() ;
}
void display3(void) {
glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
glPushMatrix();
manipulateurSouris();
manipulateurClavier();
axes();
glEnable(GL_LIGHTING);
glPushMatrix();
glTranslatef(po[0],po[1],po[2]);
glMaterialfv(GL_FRONT,GL_DIFFUSE,couleurBlanc());
glutSolidSphere(0.25,20,20);
glPopMatrix();
glPushMatrix();
glTranslatef(pv[0],pv[1],pv[2]);
glMaterialfv(GL_FRONT,GL_DIFFUSE,couleurCyan());
glutSolidSphere(0.25,20,20);
glPopMatrix();
glPushMatrix();
glTranslatef(po[0],po[1],po[2]);
glRotatef(-thetay,0.0F,1.0F,0.0F);
axes();
glPopMatrix();
glPushMatrix();
glTranslatef(po[0],po[1],po[2]);
vecteur av2;
matrice rr;
toRotationY(rr,-thetay);
produitMatriceVecteur(rr,axeVisee3,av2);
glDisable(GL_LIGHTING);
glColor4fv(couleurRouge());
traceAngleFleche(axeVisee3,av2,30,0.7F,1,2,3.0F,0.025F) ;
glEnable(GL_LIGHTING);
glPopMatrix();
glPushMatrix();
glTranslatef(po[0],po[1],po[2]);
glMaterialfv(GL_FRONT,GL_DIFFUSE,couleurRouge(0.25F));
flecheEnVolume(axeVisee3[0],axeVisee3[1],axeVisee3[2],0.2F,1.0F,0.05F);
glPopMatrix();
glPushMatrix();
glTranslatef(po[0],po[1],po[2]);
glMaterialfv(GL_FRONT,GL_DIFFUSE,couleurRouge());
glRotatef(-thetay,0.0F,1.0F,0.0F);
flecheEnVolume(axeVisee3[0],axeVisee3[1],axeVisee3[2],0.2F,1.0F,0.05F);
glPopMatrix();
glPushMatrix();
glTranslatef(po[0],po[1],po[2]);
glMaterialfv(GL_FRONT,GL_DIFFUSE,couleurBleu(0.25));
glEnable(GL_CULL_FACE);
flecheEnVolume(axeVisee[0],axeVisee[1],axeVisee[2],0.2F,1.0F,0.05F);
glDisable(GL_CULL_FACE);
glPopMatrix();
glDisable(GL_LIGHTING);
glColor4fv(couleurGrisFonce(0.5));
glTranslatef(po[0],po[1],po[2]);
glRotatef(-thetay,0.0F,1.0F,0.0F);
glBegin(GL_LINES);
box(axeVisee2[0],axeVisee2[1],axeVisee2[2]);
glVertex3f(-100.0,0.0,0.0);
glVertex3f(100.0,0.0,0.0);
glVertex3f(0.0,-100.0,0.0);
glVertex3f(0.0,100.0,0.0);
glVertex3f(0.0,0.0,-100.0);
glVertex3f(0.0,0.0,100.0);
glEnd();
glPopMatrix();
glFlush();
glutSwapBuffers() ;
}
void display4(void) {
glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
glPushMatrix();
manipulateurSouris();
manipulateurClavier();
axes();
glEnable(GL_LIGHTING);
glPushMatrix();
glTranslatef(po[0],po[1],po[2]);
glMaterialfv(GL_FRONT,GL_DIFFUSE,couleurBlanc());
glutSolidSphere(0.25,20,20);
glPopMatrix();
glPushMatrix();
glTranslatef(pv[0],pv[1],pv[2]);
glMaterialfv(GL_FRONT,GL_DIFFUSE,couleurCyan());
glutSolidSphere(0.25,20,20);
glPopMatrix();
glPushMatrix();
glTranslatef(po[0],po[1],po[2]);
glRotatef(-thetay,0.0F,1.0F,0.0F);
glRotatef(-thetax,1.0F,0.0F,0.0F);
axes();
glPopMatrix();
glPushMatrix();
glTranslatef(po[0],po[1],po[2]);
vecteur av2;
matrice rr;
toRotationY(rr,-thetay);
produitMatriceVecteur(rr,axeVisee3,av2);
glDisable(GL_LIGHTING);
glColor4fv(couleurVert());
traceAngleFleche(av2,axeVisee,30,0.7F,1,2,3.0F,0.025F) ;
glEnable(GL_LIGHTING);
glPopMatrix();
glPushMatrix();
glTranslatef(po[0],po[1],po[2]);
glMaterialfv(GL_FRONT,GL_DIFFUSE,couleurVert(0.25F));
glRotatef(-thetay,0.0F,1.0F,0.0F);
flecheEnVolume(axeVisee3[0],axeVisee3[1],axeVisee3[2],0.2F,1.0F,0.05F);
glPopMatrix();
glPushMatrix();
glTranslatef(po[0],po[1],po[2]);
glMaterialfv(GL_FRONT,GL_DIFFUSE,couleurVert());
flecheEnVolume(axeVisee[0],axeVisee[1],axeVisee[2],0.2F,1.0F,0.05F);
glPopMatrix();
glDisable(GL_LIGHTING);
glColor4fv(couleurGrisFonce(0.5));
glTranslatef(po[0],po[1],po[2]);
glRotatef(-thetay,0.0F,1.0F,0.0F);
glRotatef(-thetax,1.0F,0.0F,0.0F);
glBegin(GL_LINES);
glVertex3f(-100.0,0.0,0.0);
glVertex3f(100.0,0.0,0.0);
glVertex3f(0.0,-100.0,0.0);
glVertex3f(0.0,100.0,0.0);
glVertex3f(0.0,0.0,-100.0);
glVertex3f(0.0,0.0,100.0);
glEnd();
glPopMatrix();
glFlush();
glutSwapBuffers() ;
}
void display5(void) {
glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
glPushMatrix();
manipulateurSouris();
manipulateurClavier();
axes();
glEnable(GL_LIGHTING);
glPushMatrix();
glTranslatef(po[0],po[1],po[2]);
glMaterialfv(GL_FRONT,GL_DIFFUSE,couleurBlanc());
glutSolidSphere(0.25,20,20);
glPopMatrix();
glPushMatrix();
glTranslatef(pv[0],pv[1],pv[2]);
glMaterialfv(GL_FRONT,GL_DIFFUSE,couleurCyan());
glutSolidSphere(0.25,20,20);
glPopMatrix();
glPushMatrix();
glTranslatef(po[0],po[1],po[2]);
glRotatef(-thetay,0.0F,1.0F,0.0F);
glRotatef(-thetax,1.0F,0.0F,0.0F);
axes();
glPopMatrix();
glPushMatrix();
glTranslatef(po[0],po[1],po[2]);
glMaterialfv(GL_FRONT,GL_DIFFUSE,couleurMagenta());
flecheEnVolume(axeVisee[0],axeVisee[1],axeVisee[2],0.2F,1.0F,0.05F);
glPopMatrix();
glPushMatrix();
glDisable(GL_LIGHTING);
glColor4fv(couleurGrisFonce(0.5));
glTranslatef(po[0],po[1],po[2]);
glRotatef(-thetay,0.0F,1.0F,0.0F);
glRotatef(-thetax,1.0F,0.0F,0.0F);
glBegin(GL_LINES);
glVertex3f(-100.0,0.0,0.0);
glVertex3f(100.0,0.0,0.0);
glVertex3f(0.0,-100.0,0.0);
glVertex3f(0.0,100.0,0.0);
glVertex3f(0.0,0.0,-100.0);
glVertex3f(0.0,0.0,100.0);
glEnd();
glPopMatrix();
scene();
glPopMatrix();
glFlush();
glutSwapBuffers() ;
}
void postRedisplay(void) {
calculParametresVisualisation();
glutPostWindowRedisplay(f1);
glutPostWindowRedisplay(f2);
glutPostWindowRedisplay(f3);
}
void key(unsigned char key,int x,int y) {
static int aff = 1;
static int disp = 0;
if ( keyManipulateur(key,x,y) )
postRedisplay();
else
switch ( key ) {
case 's' : scn = !scn;
postRedisplay();
break;
case '1' : po[0] -= 0.05F;
postRedisplay();
break;
case '4' : po[0] += 0.05F;
postRedisplay();
break;
case '2' : po[1] -= 0.05F;
postRedisplay();
break;
case '5' : po[1] += 0.05F;
postRedisplay();
break;
case '3' : po[2] -= 0.05F;
postRedisplay();
break;
case '6' : po[2] += 0.05F;
postRedisplay();
break;
case ' ' : aff = !aff;
if ( aff ) {
po[0] = pv[0];
po[1] = pv[1];
po[2] = 4.0F; }
else {
po[0] = ref[0];
po[1] = ref[1];
po[2] = ref[2]; }
postRedisplay();
break;
case 0x0D : disp = (disp+1)%6;
glutSetWindow(f1);
switch(disp) {
case 0 : glutDisplayFunc(display0);
break;
case 1 : glutDisplayFunc(display1);
break;
case 2 : glutDisplayFunc(display2);
break;
case 3 : glutDisplayFunc(display3);
break;
case 4 : glutDisplayFunc(display4);
break;
case 5 : glutDisplayFunc(display5);
break; }
postRedisplay();
break; }
}
void reshapeValeurs(int w,int h) {
glViewport(0,0,w,h);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(0,w,-h,0,-1.0,1.0);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
}
void displayValeurs() {
int i;
glClear(GL_DEPTH_BUFFER_BIT|GL_COLOR_BUFFER_BIT);
glPushMatrix();
float pos = 1.0F;
glColor4fv(couleurBlanc());
placeFontCursor(5.0F,-pos*20.0F,0.0F) ;
simpleBitmapOutput(1,REGULAR8x13,"Po=Observateur : %6.3f %6.3f %6.3f %6.3f",po[0],po[1],po[2],po[3]) ;
pos += 1.0F;
placeFontCursor(5.0F,-pos*20.0F,0.0F) ;
glColor4fv(couleurCyan());
simpleBitmapOutput(1,REGULAR8x13,"Pv=Point vise : %6.3f %6.3f %6.3f %6.3f",pv[0],pv[1],pv[2],pv[3]) ;
pos += 1.0F;
placeFontCursor(5.0F,-pos*20.0F,0.0F) ;
glColor4fv(couleurBleu());
simpleBitmapOutput(1,REGULAR8x13,"A=Axe de visee : %6.3f %-.3f %6.3f %6.3f",axeVisee[0],axeVisee[1],axeVisee[2],axeVisee[3]) ;
pos += 1.0F;
placeFontCursor(5.0F,-pos*20.0F,0.0F) ;
glColor4fv(couleurRouge());
simpleBitmapOutput(1,REGULAR8x13,"ThetaY (R1) : %8.3f degres",thetay) ;
pos += 1.0F;
placeFontCursor(5.0F,-pos*20.0F,0.0F) ;
glColor4fv(couleurBlanc());
simpleBitmapOutput(1,REGULAR8x13,"A'=R1.A : %6.3f %6.3f %6.3f %6.3f",axeVisee2[0],axeVisee2[1],axeVisee2[2],axeVisee2[3]) ;
pos += 1.0F;
placeFontCursor(5.0F,-pos*20.0F,0.0F) ;
glColor4fv(couleurVert());
simpleBitmapOutput(1,REGULAR8x13,"ThetaX (R2) : %8.3f degres",thetax) ;
pos += 1.0F;
placeFontCursor(5.0F,-pos*20.0F,0.0F) ;
glColor4fv(couleurMagenta());
simpleBitmapOutput(1,REGULAR8x13,"A\"=R2.A' : %6.3f %6.3f %6.3f %6.3f",axeVisee3[0],axeVisee3[1],axeVisee3[2],axeVisee3[3]) ;
pos += 1.0F;
placeFontCursor(5.0F,-pos*20.0F,0.0F) ;
glColor4fv(couleurJaune());
simpleBitmapOutput(1,REGULAR8x13,"Matrice M=R2.R1") ;
pos += 1.0F;
for ( i = 0 ; i < 4 ; i++ ) {
placeFontCursor(5.0F,-pos*20.0F,0.0F) ;
simpleBitmapOutput(1,REGULAR8x13," %6.3f %6.3f %6.3f %6.3f",m[i][0],m[i][1],m[i][2],m[i][3]) ;
pos += 1.0F; }
placeFontCursor(5.0F,-pos*20.0F,0.0F) ;
glColor4fv(couleurMagenta());
simpleBitmapOutput(1,REGULAR8x13,"M.Axe visee : %6.3f %6.3f %6.3f %6.3f",axe[0],axe[1],axe[2],axe[3]) ;
pos += 1.0F;
glColor4fv(couleurJaune());
placeFontCursor(5.0F,-pos*20.0F,0.0F) ;
simpleBitmapOutput(1,REGULAR8x13,"Matrice M'=M.T=R2.R1.T") ;
pos += 1.0F;
for ( i = 0 ; i < 4 ; i++ ) {
placeFontCursor(5.0F,-pos*20.0F,0.0F) ;
simpleBitmapOutput(1,REGULAR8x13," %6.3f %6.3f %6.3f %6.3f",m[i][0],m[i][1],m[i][2],m[i][3]) ;
pos += 1.0F; }
placeFontCursor(5.0F,-pos*20.0F,0.0F) ;
glColor4fv(couleurMagenta());
simpleBitmapOutput(1,REGULAR8x13,"M'.Pv : %6.3f %6.3f %6.3f %6.3f",p[0],p[1],p[2],p[3]) ;
pos += 1.0F;
placeFontCursor(5.0F,-pos*20.0F,0.0F) ;
glColor4fv(couleurJaune());
simpleBitmapOutput(1,REGULAR8x13,"Matrice calculee MC") ;
pos += 1.0F;
for ( i = 0 ; i < 4 ; i++ ) {
placeFontCursor(5.0F,-pos*20.0F,0.0F) ;
simpleBitmapOutput(1,REGULAR8x13," %6.3f %6.3f %6.3f %6.3f",mc[i][0],mc[i][1],mc[i][2],mc[i][3]) ;
pos += 1.0F; }
glPopMatrix();
glutSwapBuffers();
}
void reshapeScene(int w,int h) {
glViewport(0,0,w,h);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(w*-2.0F/h,w*2.0F/h,-2.0,2.0F,-10.0,10.0);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
gluLookAt(po[0],po[1],po[2],pv[0],pv[1],pv[2],0.0,1.0,0.0);
}
void displayScene() {
glClear(GL_DEPTH_BUFFER_BIT|GL_COLOR_BUFFER_BIT);
glPushMatrix();
scene();
glPopMatrix();
glutSwapBuffers();
}
int main(int argc,char **argv) {
calculParametresVisualisation();
glutInit(&argc,argv);
glutInitDisplayMode(GLUT_RGBA|GLUT_DEPTH|GLUT_DOUBLE);
glutInitWindowSize(470,250);
glutInitWindowPosition(40,50);
f1 = glutCreateWindow("Les parametres de visualisation");
myinit(couleurGrisMoyen());
creationMenuBasique();
setParametresOrthoBasique(-3.0,3.0,-3.0,3.0,-50.0,50.0);
setManipulateurDistance(1.0F);
setManipulateurClavierAngle(20.0,-40.0,0.0);
glutReshapeFunc(reshapeOrthoBasique);
glutKeyboardFunc(key);
glutSpecialFunc(specialBasique);
glutMotionFunc(motionBasique);
glutMouseFunc(sourisBasique);
glutDisplayFunc(display0);
glutInitWindowSize(470,490);
glutInitWindowPosition(40,340);
glutInitDisplayMode(GLUT_RGBA|GLUT_DEPTH|GLUT_DOUBLE);
f2 = glutCreateWindow("Valeurs");
creationMenuBasique();
glutDisplayFunc(displayValeurs);
glutReshapeFunc(reshapeValeurs);
glutKeyboardFunc(key);
glutSpecialFunc(specialBasique);
glutInitWindowSize(470,250);
glutInitWindowPosition(530,50);
glutInitDisplayMode(GLUT_RGBA|GLUT_DEPTH|GLUT_DOUBLE);
f3 = glutCreateWindow("Scene");
myinit(couleurNoir());
creationMenuBasique();
glutDisplayFunc(displayScene);
glutReshapeFunc(reshapeScene);
glutKeyboardFunc(key);
glutSpecialFunc(specialBasique);
glutMainLoop();
return(0);
}