Commit 8e7bc566 authored by unknown's avatar unknown Committed by jean-pierre charras

3d viewer: fix current shading issues with some models.

parent f87577ca
......@@ -563,7 +563,7 @@ void EDA_3D_CANVAS::InitGL()
void EDA_3D_CANVAS::SetLights()
{
// activate light. the source is above the xy plane, at source_pos
GLfloat source_pos[4] = { 0.0, 0.0, 30.0, 0.0 };
GLfloat source_pos[4] = { 0.0, 0.0, 1000.0, 0.0 };
GLfloat light_color[4]; // color of lights (RGBA values)
light_color[3] = 1.0;
......
......@@ -342,16 +342,9 @@ void EDA_3D_CANVAS::Redraw()
glClearStencil( 0 );
glClearDepth( 1.0 );
glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT );
if( isEnabled( FL_RENDER_SMOOTH ) )
{
glShadeModel( GL_SMOOTH );
}
else
{
glShadeModel( GL_FLAT );
}
glShadeModel( GL_SMOOTH );
// Draw background
glMatrixMode( GL_PROJECTION );
glLoadIdentity();
......
......@@ -54,7 +54,8 @@ static const wxChar keyShowRealisticMode[] = wxT( "ShowRealisticMode" );
static const wxChar keyRenderShadows[] = wxT( "Render_Shadows" );
static const wxChar keyRenderRemoveHoles[] = wxT( "Render_RemoveHoles" );
static const wxChar keyRenderTextures[] = wxT( "Render_Textures" );
static const wxChar keyRenderSmooth[] = wxT( "Render_Smooth" );
static const wxChar keyRenderSmoothNormals[] = wxT( "Render_Smooth_Normals" );
static const wxChar keyRenderUseModelNormals[] =wxT( "Render_Use_Model_Normals" );
static const wxChar keyRenderMaterial[] = wxT( "Render_Material" );
static const wxChar keyShowAxis[] = wxT( "ShowAxis" );
......@@ -247,8 +248,11 @@ void EDA_3D_FRAME::LoadSettings( wxConfigBase* aCfg )
aCfg->Read( keyRenderTextures, &tmp, false );
prms.SetFlag( FL_RENDER_TEXTURES, tmp );
aCfg->Read( keyRenderSmooth, &tmp, false );
prms.SetFlag( FL_RENDER_SMOOTH, tmp );
aCfg->Read( keyRenderSmoothNormals, &tmp, false );
prms.SetFlag( FL_RENDER_SMOOTH_NORMALS, tmp );
aCfg->Read( keyRenderUseModelNormals, &tmp, false );
prms.SetFlag( FL_RENDER_USE_MODEL_NORMALS, tmp );
aCfg->Read( keyRenderMaterial, &tmp, false );
prms.SetFlag( FL_RENDER_MATERIAL, tmp );
......@@ -312,7 +316,8 @@ void EDA_3D_FRAME::SaveSettings( wxConfigBase* aCfg )
aCfg->Write( keyRenderShadows, prms.GetFlag( FL_RENDER_SHADOWS ) );
aCfg->Write( keyRenderRemoveHoles, prms.GetFlag( FL_RENDER_SHOW_HOLES_IN_ZONES ) );
aCfg->Write( keyRenderTextures, prms.GetFlag( FL_RENDER_TEXTURES ) );
aCfg->Write( keyRenderSmooth, prms.GetFlag( FL_RENDER_SMOOTH ) );
aCfg->Write( keyRenderSmoothNormals, prms.GetFlag( FL_RENDER_SMOOTH_NORMALS ) );
aCfg->Write( keyRenderUseModelNormals, prms.GetFlag( FL_RENDER_USE_MODEL_NORMALS ) );
aCfg->Write( keyRenderMaterial, prms.GetFlag( FL_RENDER_MATERIAL ) );
aCfg->Write( keyShowAxis, prms.GetFlag( FL_AXIS ) );
......@@ -488,8 +493,13 @@ void EDA_3D_FRAME::Process_Special_Functions( wxCommandEvent& event )
NewDisplay(GL_ID_TECH_LAYERS);
return;
case ID_MENU3D_FL_RENDER_SMOOTH:
GetPrm3DVisu().SetFlag( FL_RENDER_SMOOTH, isChecked );
case ID_MENU3D_FL_RENDER_SMOOTH_NORMALS:
GetPrm3DVisu().SetFlag( FL_RENDER_SMOOTH_NORMALS, isChecked );
NewDisplay();
return;
case ID_MENU3D_FL_RENDER_USE_MODEL_NORMALS:
GetPrm3DVisu().SetFlag( FL_RENDER_USE_MODEL_NORMALS, isChecked );
NewDisplay();
return;
......
This diff is collapsed.
......@@ -95,6 +95,9 @@ private:
bool isPerPointNormalsComputed;
void calcPerPointNormals();
bool isPerVertexNormalsVerified;
void perVertexNormalsVerify_and_Repair();
};
......
......@@ -175,9 +175,13 @@ void EDA_3D_FRAME::CreateMenuBar()
_( "Apply a grid/cloud textures to Board, Solder Mask and Silkscreen" ),
KiBitmap( green_xpm ), wxITEM_CHECK );
AddMenuItem( renderOptionsMenu, ID_MENU3D_FL_RENDER_SMOOTH,
AddMenuItem( renderOptionsMenu, ID_MENU3D_FL_RENDER_SMOOTH_NORMALS,
_( "Render Smooth Normals" ),
KiBitmap( green_xpm ), wxITEM_CHECK );
AddMenuItem( renderOptionsMenu, ID_MENU3D_FL_RENDER_USE_MODEL_NORMALS,
_( "Use Model Normals" ),
KiBitmap( green_xpm ), wxITEM_CHECK );
AddMenuItem( renderOptionsMenu, ID_MENU3D_FL_RENDER_MATERIAL,
_( "Render Material Properties" ),
......@@ -287,8 +291,11 @@ void EDA_3D_FRAME::SetMenuBarOptionsState()
item = menuBar->FindItem( ID_MENU3D_FL_RENDER_TEXTURES );
item->Check( GetPrm3DVisu().GetFlag( FL_RENDER_TEXTURES ) );
item = menuBar->FindItem( ID_MENU3D_FL_RENDER_SMOOTH );
item->Check( GetPrm3DVisu().GetFlag( FL_RENDER_SMOOTH ) );
item = menuBar->FindItem( ID_MENU3D_FL_RENDER_SMOOTH_NORMALS );
item->Check( GetPrm3DVisu().GetFlag( FL_RENDER_SMOOTH_NORMALS ) );
item = menuBar->FindItem( ID_MENU3D_FL_RENDER_USE_MODEL_NORMALS );
item->Check( GetPrm3DVisu().GetFlag( FL_RENDER_USE_MODEL_NORMALS ) );
item = menuBar->FindItem( ID_MENU3D_FL_RENDER_MATERIAL );
item->Check( GetPrm3DVisu().GetFlag( FL_RENDER_MATERIAL ) );
......
......@@ -49,7 +49,8 @@ enum id_3dview_frm
ID_MENU3D_FL_RENDER_SHADOWS,
ID_MENU3D_FL_RENDER_SHOW_HOLES_IN_ZONES,
ID_MENU3D_FL_RENDER_TEXTURES,
ID_MENU3D_FL_RENDER_SMOOTH,
ID_MENU3D_FL_RENDER_SMOOTH_NORMALS,
ID_MENU3D_FL_RENDER_USE_MODEL_NORMALS,
ID_MENU3D_FL_RENDER_MATERIAL,
ID_END_COMMAND_3D,
......
......@@ -75,7 +75,8 @@ enum DISPLAY3D_FLG {
FL_RENDER_SHADOWS,
FL_RENDER_SHOW_HOLES_IN_ZONES,
FL_RENDER_TEXTURES,
FL_RENDER_SMOOTH,
FL_RENDER_SMOOTH_NORMALS,
FL_RENDER_USE_MODEL_NORMALS,
FL_RENDER_MATERIAL,
FL_LAST
};
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment