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

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
Loading
Loading
Loading
Loading
+18 −12
Original line number Diff line number Diff line
@@ -567,28 +567,34 @@ void EDA_3D_CANVAS::InitGL()
/* Initialize OpenGL light sources. */
void EDA_3D_CANVAS::SetLights()
{
    double  light;
    GLfloat light_color[4];

    /* set viewing projection */
    light_color[3] = 1.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 };

    /* activate light */
    light = 1.0;
    light_color[0] = light_color[1] = light_color[2] = light;
    // activate lights. 2 lights are used:
    // One is above the xy plane, the other is below the xy plane
    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 );
    light_color[0] = light_color[1] = light_color[2] = 1.0;
    glLightfv( GL_LIGHT0, GL_DIFFUSE, light_color );

    light_color[0] = 0.3;
    light_color[1] = 0.3;
    light_color[2] = 0.4;
    light_color[0] = light_color[1] = light_color[2] = 0.2;
    glLightfv( GL_LIGHT0, GL_SPECULAR, light_color );

    // Light below the xy plane
    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 );
    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 );
}

+7 −4
Original line number Diff line number Diff line
@@ -85,14 +85,17 @@ INFO3D_VISU::~INFO3D_VISU()
 */
void INFO3D_VISU::InitSettings( BOARD* aBoard )
{
    // Calculates the board bounding box
    // First, use only the board outlines
    EDA_RECT bbbox = aBoard->ComputeBoundingBox( true );

    // If no outlines, use the board with items
    if( bbbox.GetWidth() == 0 && bbbox.GetHeight() == 0 )
    {
        bbbox.SetWidth( Millimeter2iu( 100 ) );
        bbbox.SetHeight( Millimeter2iu( 100 ) );
    }
       bbbox = aBoard->ComputeBoundingBox( false );

    // 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();

+2 −1
Original line number Diff line number Diff line
@@ -1436,7 +1436,8 @@ void VRML_LAYER::glEnd( void )

            double firstX = 0.0;
            double firstY = 0.0;
            double lastX, lastY;
            double lastX = 0.0;
            double lastY = 0.0;
            double curX, curY;
            double area = 0.0;