#include #include #include #include #include #define MAXPTS 55 #define EPS 0.000001 #define STEP 0.01 #define WIREFRAME 1 #define SOLID 2 #define PTMOVEMUL 5 int mousex, mousey; int sirka=800, vyska=600; int M=0,N=0; double V[MAXPTS][MAXPTS][3]; int sel_pt_i=0,sel_pt_j=0,color=0,mode=0; int is_ctrl,is_alt,is_shift; double ZOOM=2.0,XOFFSET=-1.0,YOFFSET=0.0,ROTATEX=15.0,ROTATEY=0.0; GLuint wlist,slist; double Comb[100][100]; int SHOW_PTS=1; void PreCompute(void){ int i,j; for (i=0;i<100;i++) for (j=0;j<=i;j++) if ((!j)||(j==i)) Comb[i][j]=1; else Comb[i][j]=Comb[i-1][j-1]+Comb[i-1][j]; } void PisBitmapovyText(int x, int y, char *string, void *font) { int len, i; glRasterPos2f(x, y); len = (int) strlen(string); for (i = 0; i < len; i++) glutBitmapCharacter(font, string[i]); } void PisVektorovyText(GLfloat x, GLfloat y, char *format,...) { va_list args; char buffer[200], *p; va_start(args, format); vsprintf(buffer, format, args); va_end(args); glPushMatrix(); glLoadIdentity(); glTranslatef(-1.0,0.0,-6.0f); // move into the screen 6.0 glRotatef(15,1.0,0.0,0.0); glRotatef(0,0.0,1.0,0.0); glScalef(2,2,-2); glTranslatef(x, y, 0); glScalef(0.0005,0.0005,0.0005); for (p = buffer; *p; p++) glutStrokeCharacter(GLUT_STROKE_ROMAN, *p); glPopMatrix(); } void SetVertexColor(double u, double v) { if (u+v<=1.0) glColor3d(1.0,u+v,0.0); else glColor3d(2.0-u-v,1.0,0.0); } void GenerateBezierWireframe(void){ double u,v,P[3],MSTEP,NSTEP; int i,j,k; glNewList(wlist,GL_COMPILE); MSTEP=1.0/(M-1); NSTEP=1.0/(N-1); glLineWidth(2.0); glColor3d(0.0,0.0,1.0); for (u=0.0;u<1.0+MSTEP-EPS;u+=MSTEP) { glBegin(GL_LINE_STRIP); for (v=0.0;v<1.0+STEP-EPS;v+=STEP) { for (k=0;k<3;k++) { P[k]=0.0; for (i=0;i0) sel_pt_j--; break; case GLUT_KEY_LEFT: if (sel_pt_i>0) sel_pt_i--; break; case GLUT_KEY_RIGHT: if (sel_pt_i