#include #include #include #include #include #define MAXPTS 20 #define EPS 0.000001 int mousex, mousey; int sirka=800, vyska=600; int N,M,D1,D2; double V[MAXPTS][MAXPTS][3],w[MAXPTS][MAXPTS]; 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,STEP=0.05; GLuint wlist1,wlist2,slist1,slist2; int SHOW_PTS=1; double ALPHA=0.3, BETA1=0.3, BETA2=0.7; double MM[4][4]; double A[4][4][3],B[4][4][3],C[4][4][3]; // //double s[100],t[100],N1[50][50],N2[50][50]; 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); // glRotatef(10,1.0,0.0,0.0); glRotatef(0,0.0,1.0,0.0); glScalef(2,2,-2); glTranslatef(x, y, 0); glScalef(0.0007,0.0007,0.0007); for (p = buffer; *p; p++) glutStrokeCharacter(GLUT_STROKE_ROMAN, *p); glPopMatrix(); } void SetVertexColor(double u, double v, int I, int J) { double uu,vv; uu=u+I; u/=(N+1); vv=v+J; vv/=(M+1); glColor3d(uu,vv,1.0-uu-vv); } //int ComputeAnalyticPoint(double u, double v, double *x, double *y, double *z){ //} void DajBod(int i, int j, double *x, double *y, double *z){ double x1,y1,z1,x2,y2,z2; if ((i>=0) && (i<=N) && (j>=0) && (j<=M)) { *x=V[i][j][0]; *y=V[i][j][1]; *z=V[i][j][2]; } if ((mode==1)||(mode==2)){ if (fabs(ALPHA)0.01) STEP-=0.01; GenerujDisplayList(); break; case 'p': SHOW_PTS^=1; break; } glutPostRedisplay(); } void keypressed_special(int key, int x, int y) { is_ctrl=glutGetModifiers(); is_alt=is_ctrl&GLUT_ACTIVE_ALT; is_shift=is_ctrl&GLUT_ACTIVE_SHIFT; is_ctrl=is_ctrl&GLUT_ACTIVE_CTRL; if (is_alt) { switch (key) { case GLUT_KEY_UP: ROTATEX+=2; break; case GLUT_KEY_DOWN: ROTATEX-=2; break; case GLUT_KEY_LEFT: ROTATEY+=2; break; case GLUT_KEY_RIGHT: ROTATEY-=2; break; } } if (is_ctrl) { switch (key) { case GLUT_KEY_UP: YOFFSET-=STEP; break; case GLUT_KEY_DOWN: YOFFSET+=STEP; break; case GLUT_KEY_LEFT: XOFFSET+=STEP; break; case GLUT_KEY_RIGHT: XOFFSET-=STEP; break; } } if (is_shift) { switch (key) { case GLUT_KEY_PAGE_UP: V[sel_pt_i][sel_pt_j][1]+=0.025; break; case GLUT_KEY_PAGE_DOWN: V[sel_pt_i][sel_pt_j][1]-=0.025; break; case GLUT_KEY_UP: V[sel_pt_i][sel_pt_j][2]+=0.025; break; case GLUT_KEY_DOWN: V[sel_pt_i][sel_pt_j][2]-=0.025; break; case GLUT_KEY_LEFT: V[sel_pt_i][sel_pt_j][0]-=0.025; break; case GLUT_KEY_RIGHT: V[sel_pt_i][sel_pt_j][0]+=0.025; break; } GenerujDisplayList(); } if ((!is_alt)&&(!is_ctrl)&&(!is_shift)) { switch (key) { case GLUT_KEY_UP: if (sel_pt_j0) 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