/* Auteur: Nicolas JANEY */ /* nicolas.janey@univ-fcomte.fr */ /* Octobre 2005 */ /* Classe de gestion de surfaces */ /* spheriques */ #include #include #include #include "ModuleFont.h" #include "Droite.h" Droite::Droite(void) { p = new Position(); d = new Direction(); } Droite::Droite(float x,float y,float z, float dx,float dy,float dz) { p = new Position(x,y,z); d = new Direction(dx,dy,dz); } Droite::Droite(Position *p,Direction *d) { this->p = new Position(p); this->d = new Direction(d); } Droite::~Droite(void) { delete(p); delete(d); } Position *Droite::position(float t) { Position *np = new Position(); np->x = p->x + t*d->x; np->y = p->y + t*d->y; np->z = p->z + t*d->z; return(np); } void Droite::dessine(void) { glPushMatrix(); glTranslatef(p->x,p->y,p->z); glutSolidSphere(0.1,36,36); glBegin(GL_LINES); glVertex3f(d->x*100.0F,d->y*100.0F,d->z*100.0F); glVertex3f(-d->x*100.0F,-d->y*100.0F,-d->z*100.0F); glEnd(); glPopMatrix(); } void Droite::dessine(float *c) { int l = glIsEnabled(GL_LIGHTING); glPushAttrib(GL_ALL_ATTRIB_BITS); glPushMatrix(); glTranslatef(p->x,p->y,p->z); glEnable(GL_LIGHTING); glMaterialfv(GL_FRONT_AND_BACK,GL_DIFFUSE,c); glutSolidSphere(0.1,36,36); glDisable(GL_LIGHTING); glColor3fv(c); glBegin(GL_LINES); glVertex3f(d->x*100.0F,d->y*100.0F,d->z*100.0F); glVertex3f(-d->x*100.0F,-d->y*100.0F,-d->z*100.0F); glEnd(); glPopMatrix(); if ( l ) glEnable(GL_LIGHTING); else glDisable(GL_LIGHTING); glPopAttrib(); } void Droite::print(char *format) { simpleBitmapOutput(1,REGULAR8x13,format, p->x,p->y,p->z,d->x,d->y,d->z); }