📄 wzwindow.c
字号:
return GL_FALSE;}*/static int wzwKeyAction_l(wzWindow win, int mask){ win->level_surf=1; win->list_valid=0; wzwShowState(win); return GL_TRUE;}static int wzwKeyAction_inc_mouse(wzWindow win, int mask){ win->sensitivity*=SQRT_2; return GL_FALSE;}static int wzwKeyAction_dec_mouse(wzWindow win, int mask){ win->sensitivity/=SQRT_2; return GL_FALSE;}static int wzwKeyAction_x(wzWindow win, int mask){ win->slice[0]=1.0; win->slice[1]=0.0; win->slice[2]=0.0; win->p_min=win->boxMin[0]+p_eps; win->p_boxMax=win->boxMax[0]-p_eps; win->sliceDir='x'; win->level_surf=0; win->list_valid=0; return GL_TRUE;}static int wzwKeyAction_y(wzWindow win, int mask){ win->slice[0]=0.0; win->slice[1]=1.0; win->slice[2]=0.0; win->p_min=win->boxMin[1]+p_eps; win->p_boxMax=win->boxMax[1]-p_eps; win->sliceDir='y'; win->level_surf=0; win->list_valid=0; return GL_TRUE;}static int wzwKeyAction_z(wzWindow win, int mask){ win->slice[0]=0.0; win->slice[1]=0.0; win->slice[2]=1.0; win->p_min=win->boxMin[2]+p_eps; win->p_boxMax=win->boxMax[2]-p_eps; win->sliceDir='z'; win->level_surf=0; win->list_valid=0; return GL_TRUE;}static int wzwKeyAction_SC_in(wzWindow win, int mask){double xm,ym,zm,xd,yd,zd; if(!win->object_move){ win->cameraSC/=SQRT_2; return GL_TRUE; } xm = (win->boxMin[0] + win->boxMax[0])/2; xd = (win->boxMax[0] - win->boxMin[0])/2; ym = (win->boxMin[1] + win->boxMax[1])/2; yd = (win->boxMax[1] - win->boxMin[1])/2; zm = (win->boxMin[2] + win->boxMax[2])/2; zd = (win->boxMax[2] - win->boxMin[2])/2; wzwSetVolume(win, xm-xd/SQRT_2,xm+xd/SQRT_2, ym-yd/SQRT_2,ym+yd/SQRT_2, zm-zd/SQRT_2,zm+zd/SQRT_2); win->list_valid=0; return GL_TRUE;}static int wzwKeyAction_SC_out(wzWindow win, int mask){double xm,ym,zm,xd,yd,zd; if(!win->object_move){ win->cameraSC*=SQRT_2; return GL_TRUE; } xm = (win->boxMin[0] + win->boxMax[0])/2; xd = (win->boxMax[0] - win->boxMin[0])/2; ym = (win->boxMin[1] + win->boxMax[1])/2; yd = (win->boxMax[1] - win->boxMin[1])/2; zm = (win->boxMin[2] + win->boxMax[2])/2; zd = (win->boxMax[2] - win->boxMin[2])/2; wzwSetVolume(win, xm-xd*SQRT_2,xm+xd*SQRT_2, ym-yd*SQRT_2,ym+yd*SQRT_2, zm-zd*SQRT_2,zm+zd*SQRT_2); win->list_valid=0; return GL_TRUE;}static int wzwKeyAction_r(wzWindow win, int mask){ wzwReset(win); wzwShowState(win); return GL_TRUE;}static int wzwKeyAction_help(wzWindow win, int mask){ int i; fprintf(stderr,"-------------------------------------\n"); fprintf(stderr,"--- WZWender Key Table ---\n"); for (i=0;i<256;i++) { if (win->key_help_table[i]) fprintf(stderr,"%s\n",win->key_help_table[i]); } fprintf(stderr,"-------------------------------------\n"); return GL_FALSE;}/****************************************************************************/static int wzwKeyAction_left(wzWindow win, int mask){ if (mask & GLW_SHIFT && mask & GLW_CONTROL) { if (win->level_surf) { win->level-= 0.1*win->sensitivity; /* decrease level */ } else { /* shift slice */ win->slice[4]-= 0.1*win->sensitivity*(win->p_boxMax-win->p_min); if ( -win->slice[4] < win->p_min) win->slice[4]= -win->p_min; if ( -win->slice[4] > win->p_boxMax) win->slice[4]= -win->p_boxMax; } win->list_valid=0; } else if (mask & GLW_CONTROL) win->lightTX-=win->sensitivity; /* rotate light */ else if (mask & GLW_SHIFT) if (win->object_move){ double xs; xs= -0.1*win->sensitivity; switch(win->sliceDir){ case 'x': xs *= win->boxMax[1]-win->boxMin[1]; wzwSetVolume(win, win->boxMin[0],win->boxMax[0], win->boxMin[1]-xs,win->boxMax[1]-xs, win->boxMin[2],win->boxMax[2]); break; case 'y': xs *= win->boxMax[0]-win->boxMin[0]; wzwSetVolume(win, win->boxMin[0]-xs,win->boxMax[0]-xs, win->boxMin[1],win->boxMax[1], win->boxMin[2],win->boxMax[2]); break; case 'z': xs *= win->boxMax[0]-win->boxMin[0]; wzwSetVolume(win, win->boxMin[0]-xs,win->boxMax[0]-xs, win->boxMin[1],win->boxMax[1], win->boxMin[2],win->boxMax[2]); break; } win->list_valid=0; }else{ win->cameraTX-=0.1*win->sensitivity; /* translate object */ } else win->cameraRY-=10*win->sensitivity; /* rotate object */ wzwShowState(win); return GL_TRUE;}static int wzwKeyAction_right(wzWindow win, int mask){ if (mask & GLW_SHIFT && mask & GLW_CONTROL) { if (win->level_surf) { win->level+= 0.1*win->sensitivity; /* increase level */ } else { /* shift slice */ win->slice[4]+= 0.1*win->sensitivity*(win->p_boxMax-win->p_min); if ( -win->slice[4] < win->p_min) win->slice[4]= -win->p_min; if ( -win->slice[4] > win->p_boxMax) win->slice[4]= -win->p_boxMax; } win->list_valid=0; } else if (mask & GLW_CONTROL) win->lightTX+=win->sensitivity; /* rotate light */ else if (mask & GLW_SHIFT) if (win->object_move){ double xs; xs= 0.1*win->sensitivity; switch(win->sliceDir){ case 'x': xs *= win->boxMax[1]-win->boxMin[1]; wzwSetVolume(win, win->boxMin[0],win->boxMax[0], win->boxMin[1]-xs,win->boxMax[1]-xs, win->boxMin[2],win->boxMax[2]); break; case 'y': xs *= win->boxMax[0]-win->boxMin[0]; wzwSetVolume(win, win->boxMin[0]-xs,win->boxMax[0]-xs, win->boxMin[1],win->boxMax[1], win->boxMin[2],win->boxMax[2]); break; case 'z': xs *= win->boxMax[0]-win->boxMin[0]; wzwSetVolume(win, win->boxMin[0]-xs,win->boxMax[0]-xs, win->boxMin[1],win->boxMax[1], win->boxMin[2],win->boxMax[2]); break; } win->list_valid=0; }else{ win->cameraTX+=0.1*win->sensitivity; /* translate object */ } else win->cameraRY+=10*win->sensitivity; /* rotate object */ wzwShowState(win); return GL_TRUE;}static int wzwKeyAction_up(wzWindow win, int mask){ if (mask & GLW_SHIFT && mask & GLW_CONTROL) { /* scale values */ win->vscale += win->sensitivity; win->list_valid=0; } else if (mask & GLW_CONTROL) win->lightTY+=win->sensitivity; /* rotate light */ else if (mask & GLW_SHIFT) if (win->object_move){ double xs; xs= 0.1*win->sensitivity; switch(win->sliceDir){ case 'x': xs *= win->boxMax[2]-win->boxMin[2]; wzwSetVolume(win, win->boxMin[0],win->boxMax[0], win->boxMin[1],win->boxMax[1], win->boxMin[2]-xs,win->boxMax[2]-xs); break; case 'y': xs *= win->boxMax[2]-win->boxMin[2]; wzwSetVolume(win, win->boxMin[0],win->boxMax[0], win->boxMin[1],win->boxMax[1], win->boxMin[2]-xs,win->boxMax[2]-xs); break; case 'z': xs *= win->boxMax[1]-win->boxMin[1]; wzwSetVolume(win, win->boxMin[0],win->boxMax[0], win->boxMin[1]-xs,win->boxMax[1]-xs, win->boxMin[2],win->boxMax[2]); break; } win->list_valid=0; }else{ win->cameraTY+=0.1*win->sensitivity; /* translate object */ } else win->cameraRX-=10*win->sensitivity; /* rotate object */ wzwShowState(win); return GL_TRUE;}static int wzwKeyAction_down(wzWindow win, int mask){ if (mask & GLW_SHIFT && mask & GLW_CONTROL) { /* scale values */ win->vscale -= win->sensitivity; win->list_valid=0; } else if (mask & GLW_CONTROL) win->lightTY-=win->sensitivity; /* rotate light */ else if (mask & GLW_SHIFT) if (win->object_move){ double xs; xs= -0.1*win->sensitivity; switch(win->sliceDir){ case 'x': xs *= win->boxMax[2]-win->boxMin[2]; wzwSetVolume(win, win->boxMin[0],win->boxMax[0], win->boxMin[1],win->boxMax[1], win->boxMin[2]-xs,win->boxMax[2]-xs); break; case 'y': xs *= win->boxMax[2]-win->boxMin[2]; wzwSetVolume(win, win->boxMin[0],win->boxMax[0], win->boxMin[1],win->boxMax[1], win->boxMin[2]-xs,win->boxMax[2]-xs); break; case 'z': xs *= win->boxMax[1]-win->boxMin[1]; wzwSetVolume(win, win->boxMin[0],win->boxMax[0], win->boxMin[1]-xs,win->boxMax[1]-xs, win->boxMin[2],win->boxMax[2]); break; } win->list_valid=0; }else{ win->cameraTY-=0.1*win->sensitivity; /* translate object */ } else win->cameraRX+=10*win->sensitivity; /* rotate object */ wzwShowState(win); return GL_TRUE;}static int wzwKeyAction_s(wzWindow win, int mask){ /* scale values */ if(win->vscale==0) win->vscale= win->sensitivity; win->vscale/= SQRT_2; win->list_valid=0; return GL_TRUE;}static int wzwKeyAction_S(wzWindow win, int mask){ /* scale values */ if(win->vscale==0) win->vscale= 1; win->vscale*= SQRT_2; win->list_valid=0; return GL_TRUE;}static int wzwKeyAction_wireframe(wzWindow win, int mask){ if(win->wireframe){ glEnable(GL_LIGHTING); glEnable(GL_COLOR_MATERIAL); glEnable(GL_DEPTH_TEST); glPolygonMode(GL_FRONT_AND_BACK,GL_FILL); win->wireframe=0; } else { win->wireframe=1; win->move_wireframe=1; win->move_frame=0; win->move_model=0; glDisable(GL_LIGHTING); glDisable(GL_COLOR_MATERIAL); glDisable(GL_DEPTH_TEST); glPolygonMode(GL_FRONT_AND_BACK,GL_LINE); } win->list_valid=0; wzwShowState(win); return GL_TRUE;}static int wzwKeyAction_info(wzWindow win, int mask){ fprintf(stderr,"-------------------------------------\n"); fprintf(stderr,"--- GL State information ---\n"); fprintf(stderr,"-------------------------------------\n"); if (win->dialog) fprintf(stderr,"state control: user controlled\n"); else fprintf(stderr,"state control: application controlled\n"); fprintf(stderr,"box:\n"); fprintf(stderr," xmin= %+8.2e, xboxMax= %+8.2e\n",win->boxMin[0],win->boxMax[0]); fprintf(stderr," ymin= %+8.2e, yboxMax= %+8.2e\n",win->boxMin[1],win->boxMax[1]); fprintf(stderr," zmin= %+8.2e, zboxMax= %+8.2e\n",win->boxMin[2],win->boxMax[2]); fprintf(stderr,"object rotation: rotx= %+8.2e, rotz= %+8.2e\n", win->cameraRX, win->cameraRY); fprintf(stderr,"object translation: x= %+8.2e, y= %+8.2e, z= %+8.2e\n", win->cameraTX, win->cameraTY, win->cameraTZ); fprintf(stderr,"object distance: %+8.2e\n", win->cameraSC); fprintf(stderr,"aspect ratio: %+8.2e\n", win->asp); fprintf(stderr,"light position: x= %+8.2e, y= %+8.2e, z= %+8.2e\n", win->lightTX, win->lightTY, win->lightTZ); fprintf(stderr,"sensitivity: %+8.2e\n", win->sensitivity); if(win->show_volume) fprintf(stderr,"show volume\n"); if (win->level_surf) fprintf(stderr,"show isosurface: level= %+8.2e\n",win->level); else { fprintf(stderr,"show values on a slice:\n"); fprintf(stderr," orthogonal with respect to the axis:\n"); fprintf(stderr," a= %+8.2e, b= %+8.2e, c= %+8.2e\n", win->slice[0],win->slice[1], win->slice[2]); fprintf(stderr," shift= %+8.2e\n", -win->slice[4]); fprintf(stderr," pmin= %+8.2e, pboxMax= %+8.2e\n",win->p_min, win->p_boxMax); fprintf(stderr,"scale factor for values: %+8.2e\n",win->vscale); } fprintf(stderr,"---\n"); if (win->wireframe) fprintf(stderr,"show edges, wireframe\n"); else { if (win->gouraud_shading) fprintf(stderr,"show faces, gouraud shading\n"); else fprintf(stderr,"show faces, flat shading\n"); } if (win->frame) fprintf(stderr,"show bounding box(frame)\n"); if (win->dialog) { if (win->move_model) fprintf(stderr,"show the object while moving\n"); else if (win->move_frame) fprintf(stderr,"show the bounding box (frame) while moving\n"); else if (win->move_wireframe) fprintf(stderr,"show the wireframe while moving\n"); } fprintf(stderr,"-------------------------------------\n"); glwShowState(win->glwin,state); return GL_FALSE;}/****************************************************************************/void wzwReset(wzWindow win){ win->button_hold = 0; win->object_move = 0; win->cameraRX=0.0; win->cameraRY=0.0; win->cameraTX=0.0; win->cameraTY=0.0; win->vscale=0.0; win->cameraSC=2.0; win->wireframe=0; win->move_wireframe=1; win->move_frame=0;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -