Commit 3a62a595 authored by jean-pierre charras's avatar jean-pierre charras

3d viewer: fix a (minor) bug when run from cvpcb or modedit: the footprint is...

3d viewer: fix a (minor) bug when run from cvpcb or modedit: the footprint is now centered on Z axis
Better setup for lights, which gives a better rendering
parent afd89c35
...@@ -567,28 +567,34 @@ void EDA_3D_CANVAS::InitGL() ...@@ -567,28 +567,34 @@ void EDA_3D_CANVAS::InitGL()
/* Initialize OpenGL light sources. */ /* Initialize OpenGL light sources. */
void EDA_3D_CANVAS::SetLights() void EDA_3D_CANVAS::SetLights()
{ {
double light;
GLfloat light_color[4];
/* set viewing projection */ /* set viewing projection */
light_color[3] = 1.0;
GLfloat Z_axis_pos[4] = { 0.0, 0.0, 30.0, 0.0 }; GLfloat Z_axis_pos[4] = { 0.0, 0.0, 30.0, 0.0 };
GLfloat lowZ_axis_pos[4] = { 0.0, 0.0, -30.0, 0.5 }; GLfloat lowZ_axis_pos[4] = { 0.0, 0.0, -30.0, 0.5 };
/* activate light */ // activate lights. 2 lights are used:
light = 1.0; // One is above the xy plane, the other is below the xy plane
light_color[0] = light_color[1] = light_color[2] = light; GLfloat light_color[4]; // color of lights (RGBA values)
light_color[3] = 1.0;
// Light above the xy plane
// The default setting for GL_AMBIENT light intensity is (0.0, 0.0, 0.0, 1.0)
glLightfv( GL_LIGHT0, GL_POSITION, Z_axis_pos ); glLightfv( GL_LIGHT0, GL_POSITION, Z_axis_pos );
light_color[0] = light_color[1] = light_color[2] = 1.0;
glLightfv( GL_LIGHT0, GL_DIFFUSE, light_color ); glLightfv( GL_LIGHT0, GL_DIFFUSE, light_color );
light_color[0] = 0.3; light_color[0] = light_color[1] = light_color[2] = 0.2;
light_color[1] = 0.3; glLightfv( GL_LIGHT0, GL_SPECULAR, light_color );
light_color[2] = 0.4;
// Light below the xy plane
glLightfv( GL_LIGHT1, GL_POSITION, lowZ_axis_pos ); glLightfv( GL_LIGHT1, GL_POSITION, lowZ_axis_pos );
light_color[0] = light_color[1] = light_color[2] = 0.4;
glLightfv( GL_LIGHT1, GL_DIFFUSE, light_color ); glLightfv( GL_LIGHT1, GL_DIFFUSE, light_color );
glEnable( GL_LIGHT0 ); // White spot on Z axis
glEnable( GL_LIGHT1 ); // White spot on Z axis ( bottom) light_color[0] = light_color[1] = light_color[2] = 0.1;
glLightfv( GL_LIGHT1, GL_SPECULAR, light_color );
glEnable( GL_LIGHT0 ); // White spot on Z axis ( top )
// glEnable( GL_LIGHT1 ); // White spot on Z axis ( bottom )
glEnable( GL_LIGHTING ); glEnable( GL_LIGHTING );
} }
......
...@@ -85,14 +85,17 @@ INFO3D_VISU::~INFO3D_VISU() ...@@ -85,14 +85,17 @@ INFO3D_VISU::~INFO3D_VISU()
*/ */
void INFO3D_VISU::InitSettings( BOARD* aBoard ) void INFO3D_VISU::InitSettings( BOARD* aBoard )
{ {
// Calculates the board bounding box
// First, use only the board outlines
EDA_RECT bbbox = aBoard->ComputeBoundingBox( true ); EDA_RECT bbbox = aBoard->ComputeBoundingBox( true );
// If no outlines, use the board with items
if( bbbox.GetWidth() == 0 && bbbox.GetHeight() == 0 ) if( bbbox.GetWidth() == 0 && bbbox.GetHeight() == 0 )
{ bbbox = aBoard->ComputeBoundingBox( false );
bbbox.SetWidth( Millimeter2iu( 100 ) );
bbbox.SetHeight( Millimeter2iu( 100 ) );
}
// Gives a non null size to avoid issues in zoom / scale calculations
if( bbbox.GetWidth() == 0 && bbbox.GetHeight() == 0 )
bbbox.Inflate( Millimeter2iu( 10 ) );
m_BoardSettings = &aBoard->GetDesignSettings(); m_BoardSettings = &aBoard->GetDesignSettings();
......
...@@ -1436,7 +1436,8 @@ void VRML_LAYER::glEnd( void ) ...@@ -1436,7 +1436,8 @@ void VRML_LAYER::glEnd( void )
double firstX = 0.0; double firstX = 0.0;
double firstY = 0.0; double firstY = 0.0;
double lastX, lastY; double lastX = 0.0;
double lastY = 0.0;
double curX, curY; double curX, curY;
double area = 0.0; double area = 0.0;
......
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