38#include <glm/geometric.hpp>
48#include <glm/gtc/type_ptr.hpp>
61 const float aaa = aTransparency * aTransparency * aTransparency;
64 float ca = 1.0f - aTransparency;
65 ca = 1.00f - 1.05f * ca * ca * ca;
67 return glm::clamp( aGrayColorValue * ca + aaa, 0.0f, 1.0f );
73#define UNITS3D_TO_UNITSPCB ( pcbIUScale.IU_PER_MM )
79 wxLogTrace(
m_logTrace, wxT(
"RENDER_3D_OPENGL::RENDER_3D_OPENGL" ) );
116 wxLogTrace(
m_logTrace, wxT(
"RENDER_3D_OPENGL::RENDER_3D_OPENGL" ) );
139 int fbWidth, fbHeight;
140 glGetIntegerv( GL_VIEWPORT, viewport );
153 glEnable( GL_LIGHT0 );
155 glDisable( GL_LIGHT0 );
162 glEnable( GL_LIGHT1 );
164 glDisable( GL_LIGHT1 );
171 glEnable( GL_LIGHT2 );
173 glDisable( GL_LIGHT2 );
230 m_materials.m_Copper.m_Shininess = shininessfactor * 128.0f;
239 m_materials.m_NonPlatedCopper.m_Shininess = 0.1f * 128.0f;
267 m_materials.m_SilkSTop.m_Shininess = 0.078125f * 128.0f;
280 m_materials.m_SilkSBot.m_Shininess = 0.078125f * 128.0f;
284 m_materials.m_SolderMask.m_Shininess = 0.85f * 128.0f;
294 m_materials.m_EpoxyBoard.m_Shininess = 0.1f * 128.0f;
324 const float solderMask_gray = ( layerColor.r + layerColor.g + layerColor.b ) / 3.0f;
328 const float baseTransparency = 1.0f - layerColor.a;
341 const float minSolderMaskShininess = 0.85f * 128.0f;
342 const float maxSolderMaskShininess = 512.0f;
343 m_materials.m_SolderMask.m_Shininess = minSolderMaskShininess
344 + ( maxSolderMaskShininess - minSolderMaskShininess ) * ( 1.0f - solderMask_gray );
399 m_materials.m_Plastic.m_Shininess = 0.078125f * 128.0f;
422 m_materials.m_Plastic.m_Shininess = 0.078125f * 128.0f;
440 const GLfloat ambient[] = { 0.084f, 0.084f, 0.084f, 1.0f };
441 const GLfloat diffuse0[] = { 0.3f, 0.3f, 0.3f, 1.0f };
442 const GLfloat specular0[] = { 0.5f, 0.5f, 0.5f, 1.0f };
444 glLightfv( GL_LIGHT0, GL_AMBIENT, ambient );
445 glLightfv( GL_LIGHT0, GL_DIFFUSE, diffuse0 );
446 glLightfv( GL_LIGHT0, GL_SPECULAR, specular0 );
448 const GLfloat diffuse12[] = { 0.7f, 0.7f, 0.7f, 1.0f };
449 const GLfloat specular12[] = { 0.7f, 0.7f, 0.7f, 1.0f };
452 GLfloat position[4] = { 0.0f, 0.0f, 1.0f, 0.0f };
456 glm::pi<float>() * 0.25f );
458 position[0] = vectorLight.x;
459 position[1] = vectorLight.y;
460 position[2] = vectorLight.z;
462 glLightfv( GL_LIGHT1, GL_AMBIENT, ambient );
463 glLightfv( GL_LIGHT1, GL_DIFFUSE, diffuse12 );
464 glLightfv( GL_LIGHT1, GL_SPECULAR, specular12 );
465 glLightfv( GL_LIGHT1, GL_POSITION, position );
468 position[2] = -position[2];
470 glLightfv( GL_LIGHT2, GL_AMBIENT, ambient );
471 glLightfv( GL_LIGHT2, GL_DIFFUSE, diffuse12 );
472 glLightfv( GL_LIGHT2, GL_SPECULAR, specular12 );
473 glLightfv( GL_LIGHT2, GL_POSITION, position );
475 const GLfloat lmodel_ambient[] = { 0.0f, 0.0f, 0.0f, 1.0f };
477 glLightModelfv( GL_LIGHT_MODEL_AMBIENT, lmodel_ambient );
479 glLightModeli( GL_LIGHT_MODEL_TWO_SIDE, GL_FALSE );
491 glEnable( GL_POLYGON_OFFSET_FILL );
492 glPolygonOffset( -0.1f, -2.0f );
499 glDisable( GL_POLYGON_OFFSET_FILL );
514 if( aSkipRenderHoles )
542 return SFVEC4F( aInput.r * aInput.a, aInput.g * aInput.a, aInput.b * aInput.a, aInput.a );
562 if( aStatusReporter )
563 aStatusReporter->
Report(
_(
"Loading..." ) );
570 reload( aStatusReporter, aWarningReporter );
591 glDepthFunc( GL_LESS );
592 glEnable( GL_CULL_FACE );
593 glFrontFace( GL_CCW );
594 glEnable( GL_NORMALIZE );
598 glDisable( GL_MULTISAMPLE );
600 glEnable( GL_MULTISAMPLE );
603 glClearColor( 0.0f, 0.0f, 0.0f, 0.0f );
604 glClearDepth( 1.0f );
605 glClearStencil( 0x00 );
606 glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT );
614 glEnable( GL_DEPTH_TEST );
617 glMatrixMode( GL_PROJECTION );
618 glLoadMatrixf( glm::value_ptr(
m_camera.GetProjectionMatrix() ) );
619 glMatrixMode( GL_MODELVIEW );
621 glLoadMatrixf( glm::value_ptr(
m_camera.GetViewMatrix() ) );
628 glEnable( GL_LIGHTING );
637 if( cameraPos.z > 0.0f )
638 zpos = glm::max( cameraPos.z, 0.5f ) + cameraPos.z * cameraPos.z;
640 zpos = glm::min( cameraPos.z,-0.5f ) - cameraPos.z * cameraPos.z;
643 const GLfloat headlight_pos[] = { cameraPos.x, cameraPos.y, zpos, 1.0f };
645 glLightfv( GL_LIGHT0, GL_POSITION, headlight_pos );
651 bool showThickness = !skipThickness;
653 std::bitset<LAYER_3D_END> layerFlags =
m_boardAdapter.GetVisibleLayers();
664 for( MAP_OGL_DISP_LISTS::const_iterator ii =
m_layers.begin(); ii !=
m_layers.end(); ++ii )
678 const double opacity_min = 0.8;
703 if( !skipRenderHoles )
749 if( !skipRenderHoles )
758 anti_board =
nullptr;
765 if( throughHolesOuter )
774 pLayerDispList->
DrawCulled( showThickness, solder_mask, throughHolesOuter, anti_board );
780 glm::mat4 cameraViewMatrix;
782 glGetFloatv( GL_MODELVIEW_MATRIX, glm::value_ptr( cameraViewMatrix ) );
797 glEnable( GL_POLYGON_OFFSET_FILL );
798 glPolygonOffset( 0.0f, -2.0f );
805 showThickness, skipRenderHoles );
811 showThickness, skipRenderHoles );
819 showThickness, skipRenderHoles );
825 showThickness, skipRenderHoles );
829 glDisable( GL_POLYGON_OFFSET_FILL );
830 glPolygonOffset( 0.0f, 0.0f );
836 glDepthMask( GL_FALSE );
837 glEnable( GL_BLEND );
838 glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
841 glEnable( GL_TEXTURE_2D );
842 glActiveTexture( GL_TEXTURE0 );
847 glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE );
848 glTexEnvf( GL_TEXTURE_ENV, GL_COMBINE_RGB, GL_INTERPOLATE );
849 glTexEnvf( GL_TEXTURE_ENV, GL_COMBINE_ALPHA, GL_MODULATE );
851 glTexEnvi( GL_TEXTURE_ENV, GL_SRC0_RGB, GL_PRIMARY_COLOR );
852 glTexEnvi( GL_TEXTURE_ENV, GL_OPERAND0_RGB, GL_SRC_COLOR );
854 glTexEnvi( GL_TEXTURE_ENV, GL_SRC1_RGB, GL_PREVIOUS );
855 glTexEnvi( GL_TEXTURE_ENV, GL_OPERAND1_RGB, GL_SRC_COLOR );
857 glTexEnvi( GL_TEXTURE_ENV, GL_SRC0_ALPHA, GL_PRIMARY_COLOR );
858 glTexEnvi( GL_TEXTURE_ENV, GL_OPERAND0_ALPHA, GL_SRC_ALPHA );
859 glTexEnvi( GL_TEXTURE_ENV, GL_SRC1_ALPHA, GL_CONSTANT );
860 glTexEnvi( GL_TEXTURE_ENV, GL_OPERAND1_ALPHA, GL_SRC_ALPHA );
864 glDisable( GL_BLEND );
867 glDepthMask( GL_TRUE );
872 glDisable( GL_LIGHTING );
877 glEnable( GL_LIGHTING );
894 glEnable( GL_LINE_SMOOTH );
895 glShadeModel( GL_SMOOTH );
898 glPixelStorei( GL_UNPACK_ALIGNMENT, 4 );
919 delete circleImageBlured;
920 circleImageBlured =
nullptr;
923 circleImage =
nullptr;
937 glEnable( GL_COLOR_MATERIAL );
938 glColorMaterial( GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE );
945 glMaterialfv( GL_FRONT_AND_BACK, GL_SPECULAR, &specular.r );
946 glMaterialf( GL_FRONT_AND_BACK, GL_SHININESS, 96.0f );
948 glMaterialfv( GL_FRONT_AND_BACK, GL_AMBIENT, &ambient.r );
949 glMaterialfv( GL_FRONT_AND_BACK, GL_DIFFUSE, &diffuse.r );
950 glMaterialfv( GL_FRONT_AND_BACK, GL_EMISSION, &emissive.r );
956#define DELETE_AND_FREE( ptr ) \
962#define DELETE_AND_FREE_MAP( map ) \
964 for( auto& [ layer, ptr ] : map ) \
971 glDeleteLists(
m_grid, 1 );
1012 bool aShowThickness,
bool aSkipRenderHoles )
1014 wxASSERT( (aLayerID ==
B_Mask) || (aLayerID ==
F_Mask) );
1027 m_board->SetItIsTransparent(
true );
1028 m_board->DrawCulled( aShowThickness, solder_mask, via_holes );
1045 bool aGetBot,
bool aRenderTransparentOnly,
1046 bool aRenderSelectedOnly )
1048 wxASSERT( ( aGetTop ==
true ) || ( aGetBot ==
true ) );
1058 bool highlight =
false;
1062 if( fp->IsSelected() )
1068 if( aRenderSelectedOnly != highlight )
1072 bool hasModels = !fp->Models().empty();
1073 bool showMissing =
m_boardAdapter.m_Cfg->m_Render.show_missing_models;
1075 if( hasModels || showMissing )
1079 const bool isFlipped = fp->IsFlipped();
1081 if( aGetTop == !isFlipped || aGetBot == isFlipped )
1092 bool aRenderTransparentOnly,
bool aIsSelected )
1094 if( !aFootprint->
Models().empty() )
1100 glm::mat4 fpMatrix( 1.0f );
1108 SFVEC3F( 0.0f, 0.0f, 1.0f ) );
1113 fpMatrix = glm::rotate( fpMatrix, glm::pi<float>(),
SFVEC3F( 0.0f, 1.0f, 0.0f ) );
1114 fpMatrix = glm::rotate( fpMatrix, glm::pi<float>(),
SFVEC3F( 0.0f, 0.0f, 1.0f ) );
1119 fpMatrix = glm::scale( fpMatrix,
SFVEC3F( modelunit_to_3d_units_factor ) );
1124 if( !sM.m_Show || sM.m_Filename.empty() )
1133 aIsSelected, aRenderTransparentOnly ? sM.m_Opacity : 1.0f );
1137 if(
const MODEL_3D* modelPtr = cache_i->second )
1139 bool opaque = sM.m_Opacity >= 1.0;
1141 if( ( !aRenderTransparentOnly && modelPtr->HasOpaqueMeshes() && opaque ) ||
1142 ( aRenderTransparentOnly && ( modelPtr->HasTransparentMeshes() || !opaque ) ) )
1144 glm::mat4 modelworldMatrix = fpMatrix;
1146 const SFVEC3F offset =
SFVEC3F( sM.m_Offset.x, sM.m_Offset.y, sM.m_Offset.z );
1147 const SFVEC3F rotation =
SFVEC3F( sM.m_Rotation.x, sM.m_Rotation.y,
1151 std::vector<float> key = { offset.x, offset.y, offset.z,
1152 rotation.x, rotation.y, rotation.z,
1159 modelworldMatrix *= it->second;
1163 glm::mat4 mtx( 1.0f );
1164 mtx = glm::translate( mtx, offset );
1165 mtx = glm::rotate( mtx, glm::radians( -rotation.z ), { 0.0f, 0.0f, 1.0f } );
1166 mtx = glm::rotate( mtx, glm::radians( -rotation.y ), { 0.0f, 1.0f, 0.0f } );
1167 mtx = glm::rotate( mtx, glm::radians( -rotation.x ), { 1.0f, 0.0f, 0.0f } );
1168 mtx = glm::scale( mtx,
scale );
1171 modelworldMatrix *= mtx;
1174 aDstRenderList.emplace_back( modelworldMatrix, modelPtr,
1175 aRenderTransparentOnly ? sM.m_Opacity : 1.0f,
1176 aRenderTransparentOnly,
1188 glm::mat4 fpMatrix( 1.0f );
1196 SFVEC3F( 0.0f, 0.0f, 1.0f ) );
1201 fpMatrix = glm::rotate( fpMatrix, glm::pi<float>(),
SFVEC3F( 0.0f, 1.0f, 0.0f ) );
1202 fpMatrix = glm::rotate( fpMatrix, glm::pi<float>(),
SFVEC3F( 0.0f, 0.0f, 1.0f ) );
1207 fpMatrix = glm::scale( fpMatrix,
SFVEC3F( modelunit_to_3d_units_factor ) );
1216 const glm::mat4& aFpMatrix,
const FOOTPRINT* aFootprint,
1217 bool aRenderTransparentOnly,
bool aIsSelected,
float aOpacity )
1227 float scaleX = bboxW;
1228 float scaleY = bboxH;
1229 float scaleZ = std::min( bboxW, bboxH ) * 0.5f;
1232 float offsetX = localCenter.
x /
pcbIUScale.IU_PER_MM;
1233 float offsetY = -localCenter.
y /
pcbIUScale.IU_PER_MM;
1234 float offsetZ = scaleZ * 0.5f;
1239 glm::mat4 mtx = aFpMatrix;
1240 mtx = glm::translate( mtx,
SFVEC3F( offsetX, offsetY, offsetZ ) );
1241 mtx = glm::scale( mtx,
SFVEC3F( scaleX, scaleY, scaleZ ) );
1243 bool placeholderOpaque = aOpacity >= 1.0;
1245 if( ( !aRenderTransparentOnly &&
m_placeholderModel->HasOpaqueMeshes() && placeholderOpaque )
1246 || ( aRenderTransparentOnly && (
m_placeholderModel->HasTransparentMeshes() || !placeholderOpaque ) ) )
1248 aDstRenderList.emplace_back( mtx,
m_placeholderModel, aOpacity, aRenderTransparentOnly,
1262 std::list<MODELTORENDER> renderList;
1270 if( !renderList.empty() )
1275 renderModel( aCameraViewMatrix, mtr, selColor,
nullptr );
1284 if( !renderList.empty() )
1289 renderModel( aCameraViewMatrix, mtr, selColor,
nullptr );
1304 std::list<MODELTORENDER> renderListModels;
1315 if( renderListModels.empty() )
1318 std::vector<std::pair<const MODELTORENDER *, float>> transparentModelList;
1320 transparentModelList.reserve( renderListModels.size() );
1327 const BBOX_3D& bBox = mtr.m_model->GetBBox();
1329 const SFVEC3F bBoxWorld = mtr.m_modelWorldMat * glm::vec4( bBoxCenter, 1.0f );
1331 const float distanceToCamera = glm::length( cameraPos - bBoxWorld );
1333 transparentModelList.emplace_back( &mtr, distanceToCamera );
1337 std::sort( transparentModelList.begin(), transparentModelList.end(),
1338 [&]( std::pair<const MODELTORENDER *, float>& a,
1339 std::pair<const MODELTORENDER *, float>& b )
1341 if( a.second != b.second )
1342 return a.second > b.second;
1344 return a.first > b.first;
1350 bool isUsingColorInformation = !( transparentModelList.begin()->first->m_isSelected &&
1355 for(
const std::pair<const MODELTORENDER *, float>& mtr : transparentModelList )
1360 if( !isUsingColorInformation && !mtr.first->m_isSelected )
1362 isUsingColorInformation =
true;
1364 glEnableClientState( GL_COLOR_ARRAY );
1365 glEnableClientState( GL_TEXTURE_COORD_ARRAY );
1366 glEnable( GL_COLOR_MATERIAL );
1368 else if( isUsingColorInformation && mtr.first->m_isSelected )
1370 isUsingColorInformation =
false;
1372 glDisableClientState( GL_COLOR_ARRAY );
1373 glDisableClientState( GL_TEXTURE_COORD_ARRAY );
1374 glDisable( GL_COLOR_MATERIAL );
1380 renderModel( aCameraViewMatrix, *mtr.first, selColor, &cameraPos );
1395 const glm::mat4 modelviewMatrix = aCameraViewMatrix * aModelToRender.
m_modelWorldMat;
1397 glLoadMatrixf( glm::value_ptr( modelviewMatrix ) );
1405 const bool wasBlendEnabled = glIsEnabled( GL_BLEND );
1407 if( !wasBlendEnabled )
1409 glEnable( GL_BLEND );
1410 glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
1413 glDisable( GL_LIGHTING );
1421 glEnable( GL_LIGHTING );
1423 if( !wasBlendEnabled )
1424 glDisable( GL_BLEND );
1432 glDeleteLists(
m_grid, 1 );
1439 m_grid = glGenLists( 1 );
1441 if( !glIsList(
m_grid ) )
1444 glNewList(
m_grid, GL_COMPILE );
1446 glEnable( GL_BLEND );
1447 glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
1449 const double zpos = 0.0;
1457 const GLfloat transparency = 0.35f;
1459 double griSizeMM = 0.0;
1472 glNormal3f( 0.0, 0.0, 1.0 );
1477 brd_center_pos.
y = -brd_center_pos.
y;
1479 const int xsize = std::max( brd_size.
x,
pcbIUScale.mmToIU( 100 ) ) * 1.2;
1480 const int ysize = std::max( brd_size.
y,
pcbIUScale.mmToIU( 100 ) ) * 1.2;
1483 double xmin = ( brd_center_pos.
x - xsize / 2 ) *
scale;
1484 double xmax = ( brd_center_pos.
x + xsize / 2 ) *
scale;
1485 double ymin = ( brd_center_pos.
y - ysize / 2 ) *
scale;
1486 double ymax = ( brd_center_pos.
y + ysize / 2 ) *
scale;
1494 for(
int ii = 0; ; ii++ )
1497 glColor4f( gridColor.r, gridColor.g, gridColor.b, transparency );
1499 glColor4f( gridColor_marker.r, gridColor_marker.g, gridColor_marker.b,
1504 if(
delta <= xsize / 2 )
1506 glBegin( GL_LINES );
1507 glVertex3f( (brd_center_pos.
x +
delta) *
scale, -ymin, zpos );
1508 glVertex3f( (brd_center_pos.
x +
delta) *
scale, -ymax, zpos );
1513 glBegin( GL_LINES );
1514 glVertex3f( (brd_center_pos.
x -
delta) *
scale, -ymin, zpos );
1515 glVertex3f( (brd_center_pos.
x -
delta) *
scale, -ymax, zpos );
1520 if(
delta <= ysize / 2 )
1522 glBegin( GL_LINES );
1523 glVertex3f( xmin, -( brd_center_pos.
y +
delta ) *
scale, zpos );
1524 glVertex3f( xmax, -( brd_center_pos.
y +
delta ) *
scale, zpos );
1529 glBegin( GL_LINES );
1530 glVertex3f( xmin, -( brd_center_pos.
y -
delta ) *
scale, zpos );
1531 glVertex3f( xmax, -( brd_center_pos.
y -
delta ) *
scale, zpos );
1536 if( (
delta > ysize / 2 ) && (
delta > xsize / 2 ) )
1541 glNormal3f( 0.0, -1.0, 0.0 );
1544 double posy = -brd_center_pos.
y *
scale;
1546 for(
int ii = 0; ; ii++ )
1549 glColor4f( gridColor.r, gridColor.g, gridColor.b, transparency );
1551 glColor4f( gridColor_marker.r, gridColor_marker.g, gridColor_marker.b,
1556 glBegin( GL_LINES );
1559 glVertex3f( xmax, posy, zmin );
1560 glVertex3f( xmax, posy, zmax );
1565 glBegin( GL_LINES );
1567 glVertex3f( xmin, posy, zmin );
1568 glVertex3f( xmin, posy, zmax );
1572 if(
delta > xsize / 2.0f )
1577 for(
int ii = 0; ; ii++ )
1580 glColor4f( gridColor.r, gridColor.g, gridColor.b, transparency );
1582 glColor4f( gridColor_marker.r, gridColor_marker.g, gridColor_marker.b, transparency );
1589 glBegin( GL_LINES );
1590 glVertex3f( xmin, posy,
delta );
1591 glVertex3f( xmax, posy,
delta );
1595 if(
delta <= -zmin && ( ii != 0 ) )
1598 glBegin( GL_LINES );
1599 glVertex3f( xmin, posy, -
delta );
1600 glVertex3f( xmax, posy, -
delta );
1608 glDisable( GL_BLEND );
1617 static SFVEC3F positions[24] = {
1618 { -0.5f, -0.5f, 0.5f },
1619 { 0.5f, -0.5f, 0.5f },
1620 { 0.5f, 0.5f, 0.5f },
1621 { -0.5f, 0.5f, 0.5f },
1624 { -0.5f, 0.5f, -0.5f },
1625 { 0.5f, 0.5f, -0.5f },
1626 { 0.5f, -0.5f, -0.5f },
1627 { -0.5f, -0.5f, -0.5f },
1630 { 0.5f, -0.5f, -0.5f },
1631 { 0.5f, 0.5f, -0.5f },
1632 { 0.5f, 0.5f, 0.5f },
1633 { 0.5f, -0.5f, 0.5f },
1636 { -0.5f, -0.5f, 0.5f },
1637 { -0.5f, 0.5f, 0.5f },
1638 { -0.5f, 0.5f, -0.5f },
1639 { -0.5f, -0.5f, -0.5f },
1642 { -0.5f, 0.5f, 0.5f },
1643 { 0.5f, 0.5f, 0.5f },
1644 { 0.5f, 0.5f, -0.5f },
1645 { -0.5f, 0.5f, -0.5f },
1648 { -0.5f, -0.5f, -0.5f },
1649 { 0.5f, -0.5f, -0.5f },
1650 { 0.5f, -0.5f, 0.5f },
1651 { -0.5f, -0.5f, 0.5f }
1654 static SFVEC3F normals[24] = {
1686 static unsigned int indices[36] = {
1689 8, 9, 10, 8, 10, 11,
1690 12, 13, 14, 12, 14, 15,
1691 16, 17, 18, 16, 18, 19,
1692 20, 21, 22, 20, 22, 23
1704 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
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.
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 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)
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)
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)
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)
static float TransparencyControl(float aGrayColorValue, float aTransparency)
Attempt to control the transparency based on the gray value of the color.
#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.
Per-vertex normal/color/texcoors structure.
VECTOR2< int32_t > VECTOR2I