#include #include class triangle { public: //Costruttore vuoto triangle(){ scale=1.0; rotationX=0.0; rotationY=0.0; r=1.0; g=0.0; b=0.0; } triangle(GLfloat *x, GLfloat *y,GLfloat*z){ r=1.0; g=0.0; b=0.0; for (int i=0;i<3;i++) { ptsX[i]=x[i]; ptsY[i]=y[i]; ptsZ[i]=z[i]; } scale=1.0; rotationX=0.0; rotationY=0.0; } public: GLfloat X(int i) { assert(i<3); return(ptsX[i]); } GLfloat Y(int i) { assert(i<3); return(ptsY[i]); } GLfloat Z(int i) { assert(i<3); return(ptsZ[i]); } void Draw(void){ printf("R: %f, G: %f, B: %f\n",r,g,b); glRotatef(rotationX,1.0,0.0,0.0); glRotatef(rotationY,0.0,1.0,0.0); glScalef(scale,scale,scale); glBegin(GL_TRIANGLES);//Disegno Un triangolo glColor3f(r,g,b); glVertex3f(ptsX[0], ptsY[0], ptsZ[0]); glVertex3f(ptsX[1], ptsY[1], ptsZ[1]); glVertex3f(ptsX[2], ptsY[2], ptsZ[2]); glEnd(); glFlush(); } void setColorRGB(float red, float green, float blue){ r = red; g = green; b = blue; } public: //Dati Pubblici int last_x, last_y; float rotationX, rotationY; float scale, last_scale; private: GLfloat ptsX[3]; GLfloat ptsY[3]; GLfloat ptsZ[3]; float r,g,b; };