Changeset 92
- Timestamp:
- 10/16/07 21:49:00 (1 year ago)
- Files:
-
- trunk/OpenMeshD/OpenMesh/Apps/GLViewer/GLViewer.d (modified) (4 diffs)
- trunk/OpenMeshD/OpenMesh/Apps/GLViewer/MeshDrawerT.d (modified) (14 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/OpenMeshD/OpenMesh/Apps/GLViewer/GLViewer.d
r91 r92 221 221 } 222 222 } 223 223 224 void mouse_down(ref SDL_MouseButtonEvent ev) 224 225 { … … 233 234 last_pos_[1] = ev.y; 234 235 } 236 235 237 void mouse_up(ref SDL_MouseButtonEvent ev) 236 238 { … … 245 247 last_pos_[1] = ev.y; 246 248 } 249 247 250 void mouse_move(ref SDL_MouseMotionEvent ev) 248 251 { … … 413 416 g_app.drawer.flip_normals(); 414 417 } 418 else if (key == SDLK_t) { 419 g_app.drawer.two_sided_lighting = ! 420 g_app.drawer.two_sided_lighting; 421 } 415 422 else if (key == SDLK_PLUS || 416 423 key == SDLK_EQUALS) { trunk/OpenMeshD/OpenMesh/Apps/GLViewer/MeshDrawerT.d
r88 r92 344 344 void show_fnormals(bool fnorm) { show_fnormals_ = fnorm; } 345 345 bool show_fnormals() { return show_fnormals_; } 346 void use_color(bool use_col) { use_color_ = use_color; } 347 bool use_color() { return use_color_; } 346 348 347 349 /// Set scaling for display of normal vectors … … 349 351 /// Return current scaling for display of normal vectors 350 352 float normal_scale() { return normal_scale_; } 353 354 /// Toggle two-sided lighting on and off. 355 /// Must be called when the GL context is active. 356 void two_sided_lighting(bool onOff) { 357 int ion = onOff; 358 glLightModeliv(GL_LIGHT_MODEL_TWO_SIDE, &ion); 359 } 360 361 bool two_sided_lighting() { 362 GLboolean ion; 363 glGetBooleanv(GL_LIGHT_MODEL_TWO_SIDE, &ion); 364 return ion!=0; 365 } 351 366 352 367 void multviewGL() { … … 470 485 glShadeModel(GL_SMOOTH); 471 486 draw_openmesh(_draw_mode); 487 472 488 } 473 489 … … 522 538 void setDefaultMaterial() { 523 539 GLfloat[] mat_a = [0.2, 0.2, 0.2, 1.0]; 524 GLfloat[] mat_d = [0. 7, 0.7, 0.5, 1.0];540 GLfloat[] mat_d = [0.85, 0.85, 0.7, 1.0]; 525 541 GLfloat[] mat_s = [0.6, 0.6, 0.4, 1.0]; 526 542 GLfloat[] shine = [120.0]; … … 535 551 { 536 552 static GLfloat[4] pos1 = [0.1, 0.1, 0.08, 0.0]; // main light 537 static GLfloat[4] col1 = [ 0. 9, 0.9, 0.7, 1.0]; // reddish553 static GLfloat[4] col1 = [ 0.7, 0.7, 0.5, 1.0]; // reddish 538 554 539 555 static GLfloat[4] pos2 = [-0.1, -0.1, 0.05, 0.0]; // secondary 540 static GLfloat[4] col2 = [ 0. 5, 0.6, 0.6, 1.0]; // bluish556 static GLfloat[4] col2 = [ 0.4, 0.5, 0.55, 1.0]; // bluish 541 557 542 558 static GLfloat[4] pos3 = [ 0.0, 0.03, 0.1, 0.0]; // headlight … … 595 611 view_all(); 596 612 } 613 614 // Setup which material properties will track color, 615 // but don't enable GL_COLOR_MATERIAL by default 616 glColorMaterial( GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE); 617 618 // Two sided lighting by default because lots of real 619 // models have inconsistent triangle ordering 620 int is_ON = 1; 621 glLightModeliv(GL_LIGHT_MODEL_TWO_SIDE, &is_ON); 597 622 } 598 623 … … 701 726 glNormalPointer(GL_FLOAT, 0, mesh_.vertex_normals().ptr); 702 727 728 if ( mesh_.has_vertex_colors() && use_color_) 729 { 730 glEnable(GL_COLOR_MATERIAL); 731 glEnableClientState( GL_COLOR_ARRAY ); 732 glColorPointer(3, GL_UNSIGNED_BYTE, 0,mesh_.vertex_colors().ptr); 733 } 734 703 735 if ( tex_id_ && mesh_.has_vertex_texcoords2D() ) 704 736 { … … 724 756 glDisableClientState(GL_VERTEX_ARRAY); 725 757 glDisableClientState(GL_NORMAL_ARRAY); 758 glDisableClientState(GL_COLOR_ARRAY); 759 glDisable(GL_COLOR_MATERIAL); 726 760 727 761 if ( tex_id_ && mesh_.has_vertex_texcoords2D() ) … … 740 774 glNormalPointer(GL_FLOAT, 0, mesh_.vertex_normals().ptr); 741 775 742 if ( mesh_.has_vertex_colors() ) 743 { 776 if ( mesh_.has_vertex_colors() && use_color_ ) 777 { 778 glEnable(GL_COLOR_MATERIAL); 744 779 glEnableClientState( GL_COLOR_ARRAY ); 745 780 glColorPointer(3, GL_UNSIGNED_BYTE, 0,mesh_.vertex_colors().ptr); … … 761 796 glDisableClientState(GL_NORMAL_ARRAY); 762 797 glDisableClientState(GL_COLOR_ARRAY); 798 glDisable(GL_COLOR_MATERIAL); 763 799 } 764 800 … … 826 862 glNormalPointer(GL_FLOAT, 0, mesh_.vertex_normals().ptr); 827 863 864 865 if (mesh_.has_vertex_colors() && use_color_) 866 { 867 glEnable(GL_COLOR_MATERIAL); 868 glEnableClientState(GL_COLOR_ARRAY); 869 glColorPointer(3, GL_UNSIGNED_BYTE, 0, mesh_.vertex_colors().ptr); 870 } 871 828 872 if ( tex_id_ && mesh_.has_vertex_texcoords2D() ) 829 873 { … … 848 892 glDisableClientState(GL_NORMAL_ARRAY); 849 893 glDisableClientState(GL_TEXTURE_COORD_ARRAY); 894 glDisableClientState(GL_COLOR_ARRAY); 895 glDisable(GL_COLOR_MATERIAL); 896 850 897 } 851 898 … … 892 939 if (mesh_.has_vertex_colors() && use_color_) 893 940 { 941 glEnable(GL_COLOR_MATERIAL); 894 942 glEnableClientState(GL_COLOR_ARRAY); 895 943 glColorPointer(3, GL_UNSIGNED_BYTE, 0, mesh_.vertex_colors().ptr); 944 } else { 945 glColor3f(1,1,1); 896 946 } 897 947 … … 899 949 glDisableClientState(GL_VERTEX_ARRAY); 900 950 glDisableClientState(GL_COLOR_ARRAY); 951 glDisable(GL_COLOR_MATERIAL); 901 952 } 902 953
