34#include <glm/geometric.hpp>
47#define UNITS3D_TO_UNITSPCB ( pcbIUScale.IU_PER_MM )
53 wxLogTrace(
m_logTrace, wxT(
"RENDER_3D_OPENGL::RENDER_3D_OPENGL" ) );
90 wxLogTrace(
m_logTrace, wxT(
"RENDER_3D_OPENGL::RENDER_3D_OPENGL" ) );
113 int fbWidth, fbHeight;
114 glGetIntegerv( GL_VIEWPORT, viewport );
127 glEnable( GL_LIGHT0 );
129 glDisable( GL_LIGHT0 );
136 glEnable( GL_LIGHT1 );
138 glDisable( GL_LIGHT1 );
145 glEnable( GL_LIGHT2 );
147 glDisable( GL_LIGHT2 );
210 m_materials.m_Copper.m_Shininess = shininessfactor * 128.0f;
219 m_materials.m_NonPlatedCopper.m_Shininess = 0.1f * 128.0f;
247 m_materials.m_SilkSTop.m_Shininess = 0.078125f * 128.0f;
260 m_materials.m_SilkSBot.m_Shininess = 0.078125f * 128.0f;
263 m_materials.m_SolderMask.m_Shininess = 0.8f * 128.0f;
273 m_materials.m_EpoxyBoard.m_Shininess = 0.1f * 128.0f;
303 m_materials.m_SolderMask.m_Transparency = 1.0f - layerColor.a;
363 m_materials.m_Plastic.m_Shininess = 0.078125f * 128.0f;
386 m_materials.m_Plastic.m_Shininess = 0.078125f * 128.0f;
404 const GLfloat ambient[] = { 0.084f, 0.084f, 0.084f, 1.0f };
405 const GLfloat diffuse0[] = { 0.3f, 0.3f, 0.3f, 1.0f };
406 const GLfloat specular0[] = { 0.5f, 0.5f, 0.5f, 1.0f };
408 glLightfv( GL_LIGHT0, GL_AMBIENT, ambient );
409 glLightfv( GL_LIGHT0, GL_DIFFUSE, diffuse0 );
410 glLightfv( GL_LIGHT0, GL_SPECULAR, specular0 );
412 const GLfloat diffuse12[] = { 0.7f, 0.7f, 0.7f, 1.0f };
413 const GLfloat specular12[] = { 0.7f, 0.7f, 0.7f, 1.0f };
416 GLfloat position[4] = { 0.0f, 0.0f, 1.0f, 0.0f };
420 glm::pi<float>() * 0.25f );
422 position[0] = vectorLight.x;
423 position[1] = vectorLight.y;
424 position[2] = vectorLight.z;
426 glLightfv( GL_LIGHT1, GL_AMBIENT, ambient );
427 glLightfv( GL_LIGHT1, GL_DIFFUSE, diffuse12 );
428 glLightfv( GL_LIGHT1, GL_SPECULAR, specular12 );
429 glLightfv( GL_LIGHT1, GL_POSITION, position );
432 position[2] = -position[2];
434 glLightfv( GL_LIGHT2, GL_AMBIENT, ambient );
435 glLightfv( GL_LIGHT2, GL_DIFFUSE, diffuse12 );
436 glLightfv( GL_LIGHT2, GL_SPECULAR, specular12 );
437 glLightfv( GL_LIGHT2, GL_POSITION, position );
439 const GLfloat lmodel_ambient[] = { 0.0f, 0.0f, 0.0f, 1.0f };
441 glLightModelfv( GL_LIGHT_MODEL_AMBIENT, lmodel_ambient );
443 glLightModeli( GL_LIGHT_MODEL_TWO_SIDE, GL_FALSE );
455 glEnable( GL_POLYGON_OFFSET_FILL );
456 glPolygonOffset( -0.1f, -2.0f );
463 glDisable( GL_POLYGON_OFFSET_FILL );
478 if( aSkipRenderHoles )
506 return SFVEC4F( aInput.r * aInput.a, aInput.g * aInput.a, aInput.b * aInput.a, aInput.a );
526 if( aStatusReporter )
527 aStatusReporter->
Report(
_(
"Loading..." ) );
534 reload( aStatusReporter, aWarningReporter );
555 glDepthFunc( GL_LESS );
556 glEnable( GL_CULL_FACE );
557 glFrontFace( GL_CCW );
558 glEnable( GL_NORMALIZE );
562 glDisable( GL_MULTISAMPLE );
564 glEnable( GL_MULTISAMPLE );
567 glClearColor( 0.0f, 0.0f, 0.0f, 0.0f );
568 glClearDepth( 1.0f );
569 glClearStencil( 0x00 );
570 glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT );
578 glEnable( GL_DEPTH_TEST );
581 glMatrixMode( GL_PROJECTION );
582 glLoadMatrixf( glm::value_ptr(
m_camera.GetProjectionMatrix() ) );
583 glMatrixMode( GL_MODELVIEW );
585 glLoadMatrixf( glm::value_ptr(
m_camera.GetViewMatrix() ) );
592 glEnable( GL_LIGHTING );
601 if( cameraPos.z > 0.0f )
602 zpos = glm::max( cameraPos.z, 0.5f ) + cameraPos.z * cameraPos.z;
604 zpos = glm::min( cameraPos.z,-0.5f ) - cameraPos.z * cameraPos.z;
607 const GLfloat headlight_pos[] = { cameraPos.x, cameraPos.y, zpos, 1.0f };
609 glLightfv( GL_LIGHT0, GL_POSITION, headlight_pos );
615 bool showThickness = !skipThickness;
617 std::bitset<LAYER_3D_END> layerFlags =
m_boardAdapter.GetVisibleLayers();
628 for( MAP_OGL_DISP_LISTS::const_iterator ii =
m_layers.begin(); ii !=
m_layers.end(); ++ii )
642 const double opacity_min = 0.8;
667 if( !skipRenderHoles )
713 if( !skipRenderHoles )
722 anti_board =
nullptr;
729 if( throughHolesOuter )
739 glEnable( GL_POLYGON_OFFSET_FILL );
740 glPolygonOffset( 0.0f, -4.0f );
742 pLayerDispList->
DrawCulled( showThickness, solder_mask, throughHolesOuter, anti_board );
744 glDisable( GL_POLYGON_OFFSET_FILL );
745 glPolygonOffset( 0.0f, 0.0f );
751 glm::mat4 cameraViewMatrix;
753 glGetFloatv( GL_MODELVIEW_MATRIX, glm::value_ptr( cameraViewMatrix ) );
768 bool highlight =
false;
772 if( fp->IsSelected() )
786 renderList->DrawAll();
799 bool highlight =
false;
803 if( fp->IsSelected() )
828 renderList->DrawAll();
838 glEnable( GL_POLYGON_OFFSET_FILL );
839 glPolygonOffset( 0.0f, 2.0f );
843 glDisable( GL_POLYGON_OFFSET_FILL );
844 glPolygonOffset( 0.0f, 0.0f );
853 glEnable( GL_POLYGON_OFFSET_FILL );
854 glPolygonOffset( 0.0f, -2.0f );
861 showThickness, skipRenderHoles );
867 showThickness, skipRenderHoles );
875 showThickness, skipRenderHoles );
881 showThickness, skipRenderHoles );
885 glDisable( GL_POLYGON_OFFSET_FILL );
886 glPolygonOffset( 0.0f, 0.0f );
892 glDepthMask( GL_FALSE );
893 glEnable( GL_BLEND );
894 glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
897 glEnable( GL_TEXTURE_2D );
898 glActiveTexture( GL_TEXTURE0 );
903 glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE );
904 glTexEnvf( GL_TEXTURE_ENV, GL_COMBINE_RGB, GL_INTERPOLATE );
905 glTexEnvf( GL_TEXTURE_ENV, GL_COMBINE_ALPHA, GL_MODULATE );
907 glTexEnvi( GL_TEXTURE_ENV, GL_SRC0_RGB, GL_PRIMARY_COLOR );
908 glTexEnvi( GL_TEXTURE_ENV, GL_OPERAND0_RGB, GL_SRC_COLOR );
910 glTexEnvi( GL_TEXTURE_ENV, GL_SRC1_RGB, GL_PREVIOUS );
911 glTexEnvi( GL_TEXTURE_ENV, GL_OPERAND1_RGB, GL_SRC_COLOR );
913 glTexEnvi( GL_TEXTURE_ENV, GL_SRC0_ALPHA, GL_PRIMARY_COLOR );
914 glTexEnvi( GL_TEXTURE_ENV, GL_OPERAND0_ALPHA, GL_SRC_ALPHA );
915 glTexEnvi( GL_TEXTURE_ENV, GL_SRC1_ALPHA, GL_CONSTANT );
916 glTexEnvi( GL_TEXTURE_ENV, GL_OPERAND1_ALPHA, GL_SRC_ALPHA );
920 glDisable( GL_BLEND );
923 glDepthMask( GL_TRUE );
928 glDisable( GL_LIGHTING );
933 glEnable( GL_LIGHTING );
950 glEnable( GL_LINE_SMOOTH );
951 glShadeModel( GL_SMOOTH );
954 glPixelStorei( GL_UNPACK_ALIGNMENT, 4 );
975 delete circleImageBlured;
976 circleImageBlured =
nullptr;
979 circleImage =
nullptr;
993 glEnable( GL_COLOR_MATERIAL );
994 glColorMaterial( GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE );
1001 glMaterialfv( GL_FRONT_AND_BACK, GL_SPECULAR, &specular.r );
1002 glMaterialf( GL_FRONT_AND_BACK, GL_SHININESS, 96.0f );
1004 glMaterialfv( GL_FRONT_AND_BACK, GL_AMBIENT, &ambient.r );
1005 glMaterialfv( GL_FRONT_AND_BACK, GL_DIFFUSE, &diffuse.r );
1006 glMaterialfv( GL_FRONT_AND_BACK, GL_EMISSION, &emissive.r );
1012#define DELETE_AND_FREE( ptr ) \
1018#define DELETE_AND_FREE_MAP( map ) \
1020 for( auto& [ layer, ptr ] : map ) \
1027 glDeleteLists(
m_grid, 1 );
1071 bool aShowThickness,
bool aSkipRenderHoles )
1073 wxASSERT( (aLayerID ==
B_Mask) || (aLayerID ==
F_Mask) );
1086 m_board->SetItIsTransparent(
true );
1087 m_board->DrawCulled( aShowThickness, solder_mask, via_holes );
1104 bool aGetBot,
bool aRenderTransparentOnly,
1105 bool aRenderSelectedOnly )
1107 wxASSERT( ( aGetTop ==
true ) || ( aGetBot ==
true ) );
1117 bool highlight =
false;
1121 if( fp->IsSelected() )
1127 if( aRenderSelectedOnly != highlight )
1131 bool hasModels = !fp->Models().empty();
1132 bool showMissing =
m_boardAdapter.m_Cfg->m_Render.show_missing_models;
1134 if( hasModels || showMissing )
1138 const bool isFlipped = fp->IsFlipped();
1140 if( aGetTop == !isFlipped || aGetBot == isFlipped )
1151 bool aRenderTransparentOnly,
bool aIsSelected )
1153 if( !aFootprint->
Models().empty() )
1159 glm::mat4 fpMatrix( 1.0f );
1167 SFVEC3F( 0.0f, 0.0f, 1.0f ) );
1172 fpMatrix = glm::rotate( fpMatrix, glm::pi<float>(),
SFVEC3F( 0.0f, 1.0f, 0.0f ) );
1173 fpMatrix = glm::rotate( fpMatrix, glm::pi<float>(),
SFVEC3F( 0.0f, 0.0f, 1.0f ) );
1178 fpMatrix = glm::scale( fpMatrix,
SFVEC3F( modelunit_to_3d_units_factor ) );
1183 if( !sM.m_Show || sM.m_Filename.empty() )
1192 aIsSelected, aRenderTransparentOnly ? sM.m_Opacity : 1.0f );
1196 if(
const MODEL_3D* modelPtr = cache_i->second )
1198 bool opaque = sM.m_Opacity >= 1.0;
1200 if( ( !aRenderTransparentOnly && modelPtr->HasOpaqueMeshes() && opaque ) ||
1201 ( aRenderTransparentOnly && ( modelPtr->HasTransparentMeshes() || !opaque ) ) )
1203 glm::mat4 modelworldMatrix = fpMatrix;
1205 const SFVEC3F offset =
SFVEC3F( sM.m_Offset.x, sM.m_Offset.y, sM.m_Offset.z );
1206 const SFVEC3F rotation =
SFVEC3F( sM.m_Rotation.x, sM.m_Rotation.y,
1210 std::vector<float> key = { offset.x, offset.y, offset.z,
1211 rotation.x, rotation.y, rotation.z,
1218 modelworldMatrix *= it->second;
1222 glm::mat4 mtx( 1.0f );
1223 mtx = glm::translate( mtx, offset );
1224 mtx = glm::rotate( mtx, glm::radians( -rotation.z ), { 0.0f, 0.0f, 1.0f } );
1225 mtx = glm::rotate( mtx, glm::radians( -rotation.y ), { 0.0f, 1.0f, 0.0f } );
1226 mtx = glm::rotate( mtx, glm::radians( -rotation.x ), { 1.0f, 0.0f, 0.0f } );
1227 mtx = glm::scale( mtx,
scale );
1230 modelworldMatrix *= mtx;
1233 aDstRenderList.emplace_back( modelworldMatrix, modelPtr,
1234 aRenderTransparentOnly ? sM.m_Opacity : 1.0f,
1235 aRenderTransparentOnly,
1247 glm::mat4 fpMatrix( 1.0f );
1255 SFVEC3F( 0.0f, 0.0f, 1.0f ) );
1260 fpMatrix = glm::rotate( fpMatrix, glm::pi<float>(),
SFVEC3F( 0.0f, 1.0f, 0.0f ) );
1261 fpMatrix = glm::rotate( fpMatrix, glm::pi<float>(),
SFVEC3F( 0.0f, 0.0f, 1.0f ) );
1266 fpMatrix = glm::scale( fpMatrix,
SFVEC3F( modelunit_to_3d_units_factor ) );
1275 const glm::mat4& aFpMatrix,
const FOOTPRINT* aFootprint,
1276 bool aRenderTransparentOnly,
bool aIsSelected,
float aOpacity )
1290 float scaleX = bboxW;
1291 float scaleY = bboxH;
1292 float scaleZ = std::min( bboxW, bboxH ) * 0.5f;
1295 float offsetX = localCenter.
x /
pcbIUScale.IU_PER_MM;
1296 float offsetY = -localCenter.
y /
pcbIUScale.IU_PER_MM;
1297 float offsetZ = scaleZ * 0.5f;
1302 glm::mat4 mtx = aFpMatrix;
1303 mtx = glm::translate( mtx,
SFVEC3F( offsetX, offsetY, offsetZ ) );
1304 mtx = glm::scale( mtx,
SFVEC3F( scaleX, scaleY, scaleZ ) );
1306 bool placeholderOpaque = aOpacity >= 1.0;
1308 if( ( !aRenderTransparentOnly &&
m_placeholderModel->HasOpaqueMeshes() && placeholderOpaque )
1309 || ( aRenderTransparentOnly && (
m_placeholderModel->HasTransparentMeshes() || !placeholderOpaque ) ) )
1311 aDstRenderList.emplace_back( mtx,
m_placeholderModel, aOpacity, aRenderTransparentOnly,
1325 std::list<MODELTORENDER> renderList;
1333 if( !renderList.empty() )
1338 renderModel( aCameraViewMatrix, mtr, selColor,
nullptr );
1347 if( !renderList.empty() )
1352 renderModel( aCameraViewMatrix, mtr, selColor,
nullptr );
1367 std::list<MODELTORENDER> renderListModels;
1378 if( renderListModels.empty() )
1381 std::vector<std::pair<const MODELTORENDER *, float>> transparentModelList;
1383 transparentModelList.reserve( renderListModels.size() );
1390 const BBOX_3D& bBox = mtr.m_model->GetBBox();
1392 const SFVEC3F bBoxWorld = mtr.m_modelWorldMat * glm::vec4( bBoxCenter, 1.0f );
1394 const float distanceToCamera = glm::length( cameraPos - bBoxWorld );
1396 transparentModelList.emplace_back( &mtr, distanceToCamera );
1400 std::sort( transparentModelList.begin(), transparentModelList.end(),
1401 [&]( std::pair<const MODELTORENDER *, float>& a,
1402 std::pair<const MODELTORENDER *, float>& b )
1404 if( a.second != b.second )
1405 return a.second > b.second;
1407 return a.first > b.first;
1413 bool isUsingColorInformation = !( transparentModelList.begin()->first->m_isSelected &&
1418 for(
const std::pair<const MODELTORENDER *, float>& mtr : transparentModelList )
1423 if( !isUsingColorInformation && !mtr.first->m_isSelected )
1425 isUsingColorInformation =
true;
1427 glEnableClientState( GL_COLOR_ARRAY );
1428 glEnableClientState( GL_TEXTURE_COORD_ARRAY );
1429 glEnable( GL_COLOR_MATERIAL );
1431 else if( isUsingColorInformation && mtr.first->m_isSelected )
1433 isUsingColorInformation =
false;
1435 glDisableClientState( GL_COLOR_ARRAY );
1436 glDisableClientState( GL_TEXTURE_COORD_ARRAY );
1437 glDisable( GL_COLOR_MATERIAL );
1443 renderModel( aCameraViewMatrix, *mtr.first, selColor, &cameraPos );
1458 const glm::mat4 modelviewMatrix = aCameraViewMatrix * aModelToRender.
m_modelWorldMat;
1460 glLoadMatrixf( glm::value_ptr( modelviewMatrix ) );
1468 const bool wasBlendEnabled = glIsEnabled( GL_BLEND );
1470 if( !wasBlendEnabled )
1472 glEnable( GL_BLEND );
1473 glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
1476 glDisable( GL_LIGHTING );
1484 glEnable( GL_LIGHTING );
1486 if( !wasBlendEnabled )
1487 glDisable( GL_BLEND );
1495 glDeleteLists(
m_grid, 1 );
1502 m_grid = glGenLists( 1 );
1504 if( !glIsList(
m_grid ) )
1507 glNewList(
m_grid, GL_COMPILE );
1509 glEnable( GL_BLEND );
1510 glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
1512 const double zpos = 0.0;
1520 const GLfloat transparency = 0.35f;
1522 double griSizeMM = 0.0;
1535 glNormal3f( 0.0, 0.0, 1.0 );
1540 brd_center_pos.
y = -brd_center_pos.
y;
1542 const int xsize = std::max( brd_size.
x,
pcbIUScale.mmToIU( 100 ) ) * 1.2;
1543 const int ysize = std::max( brd_size.
y,
pcbIUScale.mmToIU( 100 ) ) * 1.2;
1546 double xmin = ( brd_center_pos.
x - xsize / 2 ) *
scale;
1547 double xmax = ( brd_center_pos.
x + xsize / 2 ) *
scale;
1548 double ymin = ( brd_center_pos.
y - ysize / 2 ) *
scale;
1549 double ymax = ( brd_center_pos.
y + ysize / 2 ) *
scale;
1557 for(
int ii = 0; ; ii++ )
1560 glColor4f( gridColor.r, gridColor.g, gridColor.b, transparency );
1562 glColor4f( gridColor_marker.r, gridColor_marker.g, gridColor_marker.b,
1567 if(
delta <= xsize / 2 )
1569 glBegin( GL_LINES );
1570 glVertex3f( (brd_center_pos.
x +
delta) *
scale, -ymin, zpos );
1571 glVertex3f( (brd_center_pos.
x +
delta) *
scale, -ymax, zpos );
1576 glBegin( GL_LINES );
1577 glVertex3f( (brd_center_pos.
x -
delta) *
scale, -ymin, zpos );
1578 glVertex3f( (brd_center_pos.
x -
delta) *
scale, -ymax, zpos );
1583 if(
delta <= ysize / 2 )
1585 glBegin( GL_LINES );
1586 glVertex3f( xmin, -( brd_center_pos.
y +
delta ) *
scale, zpos );
1587 glVertex3f( xmax, -( brd_center_pos.
y +
delta ) *
scale, zpos );
1592 glBegin( GL_LINES );
1593 glVertex3f( xmin, -( brd_center_pos.
y -
delta ) *
scale, zpos );
1594 glVertex3f( xmax, -( brd_center_pos.
y -
delta ) *
scale, zpos );
1599 if( (
delta > ysize / 2 ) && (
delta > xsize / 2 ) )
1604 glNormal3f( 0.0, -1.0, 0.0 );
1607 double posy = -brd_center_pos.
y *
scale;
1609 for(
int ii = 0; ; ii++ )
1612 glColor4f( gridColor.r, gridColor.g, gridColor.b, transparency );
1614 glColor4f( gridColor_marker.r, gridColor_marker.g, gridColor_marker.b,
1619 glBegin( GL_LINES );
1622 glVertex3f( xmax, posy, zmin );
1623 glVertex3f( xmax, posy, zmax );
1628 glBegin( GL_LINES );
1630 glVertex3f( xmin, posy, zmin );
1631 glVertex3f( xmin, posy, zmax );
1635 if(
delta > xsize / 2.0f )
1640 for(
int ii = 0; ; ii++ )
1643 glColor4f( gridColor.r, gridColor.g, gridColor.b, transparency );
1645 glColor4f( gridColor_marker.r, gridColor_marker.g, gridColor_marker.b, transparency );
1652 glBegin( GL_LINES );
1653 glVertex3f( xmin, posy,
delta );
1654 glVertex3f( xmax, posy,
delta );
1658 if(
delta <= -zmin && ( ii != 0 ) )
1661 glBegin( GL_LINES );
1662 glVertex3f( xmin, posy, -
delta );
1663 glVertex3f( xmax, posy, -
delta );
1671 glDisable( GL_BLEND );
1680 static SFVEC3F positions[24] = {
1681 { -0.5f, -0.5f, 0.5f },
1682 { 0.5f, -0.5f, 0.5f },
1683 { 0.5f, 0.5f, 0.5f },
1684 { -0.5f, 0.5f, 0.5f },
1687 { -0.5f, 0.5f, -0.5f },
1688 { 0.5f, 0.5f, -0.5f },
1689 { 0.5f, -0.5f, -0.5f },
1690 { -0.5f, -0.5f, -0.5f },
1693 { 0.5f, -0.5f, -0.5f },
1694 { 0.5f, 0.5f, -0.5f },
1695 { 0.5f, 0.5f, 0.5f },
1696 { 0.5f, -0.5f, 0.5f },
1699 { -0.5f, -0.5f, 0.5f },
1700 { -0.5f, 0.5f, 0.5f },
1701 { -0.5f, 0.5f, -0.5f },
1702 { -0.5f, -0.5f, -0.5f },
1705 { -0.5f, 0.5f, 0.5f },
1706 { 0.5f, 0.5f, 0.5f },
1707 { 0.5f, 0.5f, -0.5f },
1708 { -0.5f, 0.5f, -0.5f },
1711 { -0.5f, -0.5f, -0.5f },
1712 { 0.5f, -0.5f, -0.5f },
1713 { 0.5f, -0.5f, 0.5f },
1714 { -0.5f, -0.5f, 0.5f }
1717 static SFVEC3F normals[24] = {
1749 static unsigned int indices[36] = {
1752 8, 9, 10, 8, 10, 11,
1753 12, 13, 14, 12, 14, 15,
1754 16, 17, 18, 16, 18, 19,
1755 20, 21, 22, 20, 22, 23
1767 static SMESH mesh = { 24, positions, normals,
nullptr,
nullptr, 36, indices, 0 };
@ NORMAL
Use all material properties from model file.
Defines math related functions.
float mapf(float x, float in_min, float in_max, float out_min, float out_max)
SFVEC3F SphericalToCartesian(float aInclination, float aAzimuth)
https://en.wikipedia.org/wiki/Spherical_coordinate_system
EXTRUSION_MATERIAL_PROPS GetMaterialProps(EXTRUSION_MATERIAL aMaterial, const SFVEC3F &aDiffuse)
BOX2I CalcPlaceholderLocalBox(const FOOTPRINT *aFootprint)
Calculate a local space bounding box for a placeholder 3D model.
constexpr EDA_IU_SCALE pcbIUScale
constexpr BOX2I KiROUND(const BOX2D &aBoxD)
Helper class to handle information needed to display 3D board.
constexpr size_type GetWidth() const
constexpr const Vec GetCenter() const
constexpr size_type GetHeight() const
A class used to derive camera objects from.
Implement a canvas based on a wxGLCanvas.
static KIGFX::COLOR4D GetDefaultColor(EXTRUSION_MATERIAL aMaterial)
EXTRUSION_MATERIAL m_material
auto RunWithoutCtxLock(Func &&aFunction, Args &&... args)
Run the given function first releasing the GL context lock, then restoring it.
Manage an 8-bit channel image.
void CircleFilled(int aCx, int aCy, int aRadius, unsigned char aValue)
void EfxFilter_SkipCenter(IMAGE *aInImg, IMAGE_FILTER aFilterType, unsigned int aRadius)
Apply a filter to the input image and store it in the image class.
unsigned int GetHeight() const
unsigned int GetWidth() const
A color representation with 4 components: red, green, blue, alpha.
static const COLOR4D UNSPECIFIED
For legacy support; used as a value to indicate color hasn't been set yet.
static const LSET & PhysicalLayersMask()
Return a mask holding all layers which are physically realized.
void DrawBbox() const
Draw main bounding box of the model.
static void EndDrawMulti()
Cleanup render states after drawing multiple models.
void Draw(bool aTransparent, float aOpacity, bool aUseSelectedMaterial, const SFVEC3F &aSelectionColor, const glm::mat4 *aModelWorldMatrix, const SFVEC3F *aCameraWorldPos) const
Render the model into the current context.
static void BeginDrawMulti(bool aUseColorInformation)
Set some basic render states before drawing multiple models.
void DrawBboxes() const
Draw individual bounding boxes of each mesh.
Store the OpenGL display lists to related with a layer.
void ApplyScalePosition(float aZposition, float aZscale)
void SetItIsTransparent(bool aSetTransparent)
void DrawCulled(bool aDrawMiddle, const OPENGL_RENDER_LIST *aSubtractList=nullptr, const OPENGL_RENDER_LIST *bSubtractList=nullptr, const OPENGL_RENDER_LIST *cSubtractList=nullptr, const OPENGL_RENDER_LIST *dSubtractList=nullptr) const
Draw all layers if they are visible by the camera if camera position is above the layer.
void DrawAll(bool aDrawMiddle=true) const
Call to draw all the display lists.
GL_CONTEXT_MANAGER * GetGLContextManager()
std::unique_ptr< BUSY_INDICATOR > CreateBusyIndicator() const
Return a created busy indicator, if a factory has been set, else a null pointer.
RENDER_3D_BASE(BOARD_ADAPTER &aBoardAdapter, CAMERA &aCamera)
bool m_canvasInitialized
Flag if the canvas specific for this render was already initialized.
wxSize m_windowSize
The window size that this camera is working.
BOARD_ADAPTER & m_boardAdapter
Settings reference in use for this render.
OPENGL_RENDER_LIST * m_board
OPENGL_RENDER_LIST * m_outerThroughHoleRings
OPENGL_RENDER_LIST * m_offboardPadsFront
SPHERES_GIZMO::GizmoSphereSelection getSelectedGizmoSphere() const
GRID3D_TYPE m_lastGridType
Stores the last grid type.
std::tuple< int, int, int, int > getGizmoViewport() const
OPENGL_RENDER_LIST * m_microviaHoles
void renderOpaqueModels(const glm::mat4 &aCameraViewMatrix)
void generate3dGrid(GRID3D_TYPE aGridType)
Create a 3D grid to an OpenGL display list.
void setLightFront(bool enabled)
std::map< const FOOTPRINT *, OPENGL_RENDER_LIST * > m_extrudedPadLists
bool Redraw(bool aIsMoving, REPORTER *aStatusReporter, REPORTER *aWarningReporter) override
Redraw the view.
MAP_OGL_DISP_LISTS m_layers
MAP_OGL_DISP_LISTS m_innerLayerHoles
OPENGL_RENDER_LIST * m_boardWithHoles
RENDER_3D_OPENGL(EDA_3D_CANVAS *aCanvas, BOARD_ADAPTER &aAdapter, CAMERA &aCamera)
MAP_OGL_DISP_LISTS m_outerLayerHoles
OPENGL_RENDER_LIST * m_offboardPadsBack
BOARD_ITEM * m_currentRollOverItem
void renderBoardBody(bool aSkipRenderHoles)
std::map< std::vector< float >, glm::mat4 > m_3dModelMatrixMap
std::map< wxString, MODEL_3D * > m_3dModelMap
OPENGL_RENDER_LIST * m_viaBackCover
OPENGL_RENDER_LIST * m_viaFrontCover
LIST_TRIANGLES m_triangles
store pointers so can be deleted latter
OPENGL_RENDER_LIST * m_outerViaThroughHoles
MODEL_3D * m_placeholderModel
OPENGL_RENDER_LIST * m_outerThroughHoles
void setLayerMaterial(PCB_LAYER_ID aLayerID)
OPENGL_RENDER_LIST * m_platedPadsFront
void resetSelectedGizmoSphere()
struct RENDER_3D_OPENGL::@136145154067207014164113243162246125147361200233 m_materials
void createPlaceholderModel()
void renderModel(const glm::mat4 &aCameraViewMatrix, const MODELTORENDER &aModelToRender, const SFVEC3F &aSelColor, const SFVEC3F *aCameraWorldPos)
int GetWaitForEditingTimeOut() override
Give the interface the time (in ms) that it should wait for editing or movements before (this works f...
void renderSolderMaskLayer(PCB_LAYER_ID aLayerID, float aZPos, bool aShowThickness, bool aSkipRenderHoles)
void renderTransparentModels(const glm::mat4 &aCameraViewMatrix)
std::map< const FOOTPRINT *, OPENGL_RENDER_LIST * > m_extrudedBodyLists
void get3dModelsSelected(std::list< MODELTORENDER > &aDstRenderList, bool aGetTop, bool aGetBot, bool aRenderTransparentOnly, bool aRenderSelectedOnly)
OPENGL_RENDER_LIST * m_postMachinePlugs
Board material plugs for backdrill/counterbore/countersink.
void setPlatedCopperAndDepthOffset(PCB_LAYER_ID aLayer_id)
void updateGizmoSelection(glm::mat4 aCameraRotationMatrix)
OPENGL_RENDER_LIST * m_antiBoard
void SetCurWindowSize(const wxSize &aSize) override
Before each render, the canvas will tell the render what is the size of its windows,...
void renderPlaceholderForFootprint(std::list< MODELTORENDER > &aDstRenderList, const glm::mat4 &aFpMatrix, const FOOTPRINT *aFootprint, bool aRenderTransparentOnly, bool aIsSelected, float aOpacity)
OPENGL_RENDER_LIST * m_padHoles
SPHERES_GIZMO * m_spheres_gizmo
GLuint m_grid
oGL list that stores current grid
OPENGL_RENDER_LIST * m_platedPadsBack
void get3dModelsFromFootprint(std::list< MODELTORENDER > &aDstRenderList, const FOOTPRINT *aFootprint, bool aRenderTransparentOnly, bool aIsSelected)
void handleGizmoMouseInput(int mouseX, int mouseY)
void setLightBottom(bool enabled)
void setGizmoViewport(int x, int y, int width, int height)
void setLightTop(bool enabled)
A pure virtual class used to derive REPORTER objects from.
virtual REPORTER & Report(const wxString &aText, SEVERITY aSeverity=RPT_SEVERITY_UNDEFINED)
Report a string with a given severity.
Renders a set of colored spheres in 3D space that act as a directional orientation gizmo.
GizmoSphereSelection
Enum to indicate which sphere (direction) is selected.
Store arrays of triangles to be used to create display lists.
#define DELETE_AND_FREE_MAP(map)
#define DELETE_AND_FREE(ptr)
#define UNITS3D_TO_UNITSPCB
Implements a model viewer canvas.
static const wxChar * m_logTrace
Trace mask used to enable or disable the trace output of this class.
int MapPCBLayerTo3DLayer(PCB_LAYER_ID aLayer)
@ LAYER_3D_SOLDERMASK_TOP
@ LAYER_3D_SOLDERMASK_BOTTOM
bool IsCopperLayer(int aLayerId)
Test whether a layer is a copper layer.
PCB_LAYER_ID
A quick note on layer IDs:
EDA_ANGLE abs(const EDA_ANGLE &aAngle)
void OglResetTextureState()
Reset to default state the texture settings.
void OglSetMaterial(const SMATERIAL &aMaterial, float aOpacity, bool aUseSelectedMaterial, SFVEC3F aSelectionColor)
Set OpenGL materials.
GLuint OglLoadTexture(const IMAGE &aImage)
Generate a new OpenGL texture.
void OglDrawBackground(const SFVEC4F &aTopColor, const SFVEC4F &aBotColor)
Define generic OpenGL functions that are common to any OpenGL target.
PGM_BASE & Pgm()
The global program "get" accessor.
static SFVEC4F premultiplyAlpha(const SFVEC4F &aInput)
#define SIZE_OF_CIRCLE_TEXTURE
Manage a bounding box defined by two SFVEC3F min max points.
SFVEC3F GetCenter() const
Return the center point of the bounding box.
bool opengl_thickness_disableOnMove
KIGFX::COLOR4D opengl_selection_color
bool clip_silk_on_via_annuli
bool subtract_mask_from_silk
bool opengl_microvias_disableOnMove
bool highlight_on_rollover
bool DifferentiatePlatedCopper()
return true if platted copper aeras and non platted copper areas must be drawn using a different colo...
bool opengl_holes_disableOnMove
bool opengl_AA_disableOnMove
glm::mat4 m_modelWorldMat
Store the a model based on meshes and materials.
float m_Transparency
1.0 is completely transparent, 0.0 completely opaque
SFVEC3F m_Diffuse
Default diffuse color if m_Color is NULL.
Per-vertex normal/color/texcoors structure.
VECTOR2< int32_t > VECTOR2I