diff --git a/Common/Context.h b/Common/Context.h index f4a2f671ff65cc766df25c13346cf8b2bab5508a..1000908320e79c3a98bf0177588e752eb8e7d462 100644 --- a/Common/Context.h +++ b/Common/Context.h @@ -157,7 +157,7 @@ public : int points_num, lines_num, surfaces_num, volumes_num; double point_size, line_width, point_sel_size, line_sel_width; int point_type, line_type, surface_type; - int draw, light; + int draw, light, light_two_side; int old_circle, circle_points; int extrude_spline_points, extrude_return_lateral, old_newreg; double normals, tangents; diff --git a/Common/DefaultOptions.h b/Common/DefaultOptions.h index e9ff6f6ef1cf98c767280516269ed248204bf708..a2b8c497b35d4bd3d902c890ba023b10a4b8d5e1 100644 --- a/Common/DefaultOptions.h +++ b/Common/DefaultOptions.h @@ -813,6 +813,8 @@ StringXNumber GeometryOptions_Number[] = { { F|O, "Light" , opt_geometry_light , 1. , "Enable lighting for the geometry" }, + { F|O, "LightTwoSide" , opt_geometry_light_two_side , 1. , + "Light both sides of surfaces (leads to slower rendering)" }, { F|O, "Lines" , opt_geometry_lines , 1. , "Display geometry curves?" }, { F|O, "LineNumbers" , opt_geometry_lines_num , 0. , @@ -951,7 +953,7 @@ StringXNumber MeshOptions_Number[] = { { F|O, "LightLines" , opt_mesh_light_lines , 1. , "Enable lighting for mesh lines (element edges)" }, { F|O, "LightTwoSide" , opt_mesh_light_two_side , 1. , - "Light both sides of mesh elements (leads to slower rendering)" }, + "Light both sides of surfaces (leads to slower rendering)" }, { F|O, "Lines" , opt_mesh_lines , 0. , "Display mesh lines (1D elements)?" }, { F|O, "LineNumbers" , opt_mesh_lines_num , 0. , @@ -1269,7 +1271,7 @@ StringXNumber ViewOptions_Number[] = { { F|O, "LightLines" , opt_view_light_lines , 1. , "Light element edges" }, { F|O, "LightTwoSide" , opt_view_light_two_side , 1. , - "Light both sides of view elements (leads to slower rendering)" }, + "Light both sides of surfaces (leads to slower rendering)" }, { F|O, "LineType" , opt_view_line_type , 0. , "Display lines as solid color segments (0) or 3D cylinders (1)" }, { F|O, "LineWidth" , opt_view_line_width , 1.0 , diff --git a/Common/Options.cpp b/Common/Options.cpp index f2d0f19ac03cc18e0fb90f57cd5f55a97aaf7f31..881c66edb1afa33e9197cebe4b739a39fc5c727f 100644 --- a/Common/Options.cpp +++ b/Common/Options.cpp @@ -1,4 +1,4 @@ -// $Id: Options.cpp,v 1.383 2008-02-22 07:59:00 geuzaine Exp $ +// $Id: Options.cpp,v 1.384 2008-02-23 10:43:44 geuzaine Exp $ // // Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle // @@ -4101,6 +4101,17 @@ double opt_geometry_light(OPT_ARGS_NUM) return CTX.geom.light; } +double opt_geometry_light_two_side(OPT_ARGS_NUM) +{ + if(action & GMSH_SET) + CTX.geom.light_two_side = (int)val; +#if defined(HAVE_FLTK) + if(WID && (action & GMSH_GUI)) + WID->geo_butt[14]->value(CTX.geom.light_two_side); +#endif + return CTX.geom.light_two_side; +} + double opt_geometry_occ_fix_small_edges(OPT_ARGS_NUM) { if(action & GMSH_SET) diff --git a/Common/Options.h b/Common/Options.h index ac4288de75fc76349e77405dae300a9596fd1f4a..1bb71c169ca261fae0b0a0dfb99af53aaead5658 100644 --- a/Common/Options.h +++ b/Common/Options.h @@ -413,6 +413,7 @@ double opt_geometry_line_sel_width(OPT_ARGS_NUM); double opt_geometry_line_type(OPT_ARGS_NUM); double opt_geometry_surface_type(OPT_ARGS_NUM); double opt_geometry_light(OPT_ARGS_NUM); +double opt_geometry_light_two_side(OPT_ARGS_NUM); double opt_geometry_occ_fix_small_edges(OPT_ARGS_NUM); double opt_geometry_occ_fix_small_faces(OPT_ARGS_NUM); double opt_geometry_occ_sew_faces(OPT_ARGS_NUM); diff --git a/Fltk/Callbacks.cpp b/Fltk/Callbacks.cpp index a7d41741007b29e6545a2f4b05a31281fdcf4886..afa75829ff2f9c679a8dca8978d6bda8ec6580fd 100644 --- a/Fltk/Callbacks.cpp +++ b/Fltk/Callbacks.cpp @@ -1,4 +1,4 @@ -// $Id: Callbacks.cpp,v 1.563 2008-02-22 07:59:00 geuzaine Exp $ +// $Id: Callbacks.cpp,v 1.564 2008-02-23 10:43:44 geuzaine Exp $ // // Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle // @@ -1059,6 +1059,7 @@ void geometry_options_ok_cb(CALLBACK_ARGS) opt_geometry_occ_fix_small_edges(0, GMSH_SET, WID->geo_butt[11]->value()); opt_geometry_occ_fix_small_faces(0, GMSH_SET, WID->geo_butt[12]->value()); opt_geometry_occ_sew_faces(0, GMSH_SET, WID->geo_butt[13]->value()); + opt_geometry_light_two_side(0, GMSH_SET, WID->geo_butt[14]->value()); opt_geometry_normals(0, GMSH_SET, WID->geo_value[0]->value()); opt_geometry_tangents(0, GMSH_SET, WID->geo_value[1]->value()); diff --git a/Fltk/GUI.cpp b/Fltk/GUI.cpp index 228bb9689360750bbf7bb8f7bbff86853f46aacc..3ded65eb3a729f8d3265265784ebfeff413376df 100644 --- a/Fltk/GUI.cpp +++ b/Fltk/GUI.cpp @@ -1,4 +1,4 @@ -// $Id: GUI.cpp,v 1.656 2008-02-22 07:59:00 geuzaine Exp $ +// $Id: GUI.cpp,v 1.657 2008-02-23 10:43:44 geuzaine Exp $ // // Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle // @@ -2351,6 +2351,10 @@ void GUI::create_option_window() geo_butt[9]->tooltip("(Alt+w)"); geo_butt[9]->callback(geometry_options_ok_cb); + geo_butt[14] = new Fl_Check_Button(L + 2 * WB, 2 * WB + 2 * BH, BW, BH, "Use two-side lighting"); + geo_butt[14]->type(FL_TOGGLE_BUTTON); + geo_butt[14]->callback(geometry_options_ok_cb); + o->end(); } { diff --git a/Graphics/Geom.cpp b/Graphics/Geom.cpp index 64fb031d4122a8c1d922e30037fd33564fd52310..16c1c733ae02038ed277584b71e37a89d6d538a9 100644 --- a/Graphics/Geom.cpp +++ b/Graphics/Geom.cpp @@ -1,4 +1,4 @@ -// $Id: Geom.cpp,v 1.154 2008-02-23 08:24:42 geuzaine Exp $ +// $Id: Geom.cpp,v 1.155 2008-02-23 10:43:44 geuzaine Exp $ // // Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle // @@ -442,7 +442,10 @@ void Draw_Geom() { if(!CTX.geom.draw) return; - glLightModelf(GL_LIGHT_MODEL_TWO_SIDE, GL_TRUE); + if(CTX.geom.light_two_side) + glLightModelf(GL_LIGHT_MODEL_TWO_SIDE, GL_TRUE); + else + glLightModelf(GL_LIGHT_MODEL_TWO_SIDE, GL_FALSE); for(int i = 0; i < 6; i++) if(CTX.clip[i] & 1)