35#include <glm/geometric.hpp>
46#define UNITS3D_TO_UNITSPCB ( pcbIUScale.IU_PER_MM )
52 wxLogTrace(
m_logTrace, wxT(
"RENDER_3D_OPENGL::RENDER_3D_OPENGL" ) );
82 wxLogTrace(
m_logTrace, wxT(
"RENDER_3D_OPENGL::RENDER_3D_OPENGL" ) );
111 glEnable( GL_LIGHT0 );
113 glDisable( GL_LIGHT0 );
120 glEnable( GL_LIGHT1 );
122 glDisable( GL_LIGHT1 );
129 glEnable( GL_LIGHT2 );
131 glDisable( GL_LIGHT2 );
139 glDisable( GL_CULL_FACE );
143 glClear( GL_DEPTH_BUFFER_BIT );
145 glMatrixMode( GL_PROJECTION );
149 glMatrixMode( GL_MODELVIEW );
152 const glm::mat4 TranslationMatrix =
153 glm::translate( glm::mat4( 1.0f ),
SFVEC3F( 0.0f, 0.0f, -( arrow_size * 2.75f ) ) );
157 glLoadMatrixf( glm::value_ptr( ViewMatrix ) );
161 glColor3f( 0.9f, 0.0f, 0.0f );
164 glColor3f( 0.0f, 0.9f, 0.0f );
167 glColor3f( 0.0f, 0.0f, 0.9f );
170 glEnable( GL_CULL_FACE );
197 m_materials.m_Copper.m_Shininess = shininessfactor * 128.0f;
206 m_materials.m_NonPlatedCopper.m_Shininess = 0.1f * 128.0f;
234 m_materials.m_SilkSTop.m_Shininess = 0.078125f * 128.0f;
247 m_materials.m_SilkSBot.m_Shininess = 0.078125f * 128.0f;
250 m_materials.m_SolderMask.m_Shininess = 0.8f * 128.0f;
260 m_materials.m_EpoxyBoard.m_Shininess = 0.1f * 128.0f;
278 m_materials.m_SolderMask.m_Transparency = 1.0f - layerColor.a;
338 m_materials.m_Plastic.m_Shininess = 0.078125f * 128.0f;
355 const GLfloat ambient[] = { 0.084f, 0.084f, 0.084f, 1.0f };
356 const GLfloat diffuse0[] = { 0.3f, 0.3f, 0.3f, 1.0f };
357 const GLfloat specular0[] = { 0.5f, 0.5f, 0.5f, 1.0f };
359 glLightfv( GL_LIGHT0, GL_AMBIENT, ambient );
360 glLightfv( GL_LIGHT0, GL_DIFFUSE, diffuse0 );
361 glLightfv( GL_LIGHT0, GL_SPECULAR, specular0 );
363 const GLfloat diffuse12[] = { 0.7f, 0.7f, 0.7f, 1.0f };
364 const GLfloat specular12[] = { 0.7f, 0.7f, 0.7f, 1.0f };
367 GLfloat position[4] = { 0.0f, 0.0f, 1.0f, 0.0f };
371 glm::pi<float>() * 0.25f );
373 position[0] = vectorLight.x;
374 position[1] = vectorLight.y;
375 position[2] = vectorLight.z;
377 glLightfv( GL_LIGHT1, GL_AMBIENT, ambient );
378 glLightfv( GL_LIGHT1, GL_DIFFUSE, diffuse12 );
379 glLightfv( GL_LIGHT1, GL_SPECULAR, specular12 );
380 glLightfv( GL_LIGHT1, GL_POSITION, position );
383 position[2] = -position[2];
385 glLightfv( GL_LIGHT2, GL_AMBIENT, ambient );
386 glLightfv( GL_LIGHT2, GL_DIFFUSE, diffuse12 );
387 glLightfv( GL_LIGHT2, GL_SPECULAR, specular12 );
388 glLightfv( GL_LIGHT2, GL_POSITION, position );
390 const GLfloat lmodel_ambient[] = { 0.0f, 0.0f, 0.0f, 1.0f };
392 glLightModelfv( GL_LIGHT_MODEL_AMBIENT, lmodel_ambient );
394 glLightModeli( GL_LIGHT_MODEL_TWO_SIDE, GL_FALSE );
406 glEnable( GL_POLYGON_OFFSET_FILL );
407 glPolygonOffset( -0.1f, -2.0f );
414 glDisable( GL_POLYGON_OFFSET_FILL );
429 if( aSkipRenderHoles )
460 if( aStatusReporter )
461 aStatusReporter->
Report(
_(
"Loading..." ) );
463 reload( aStatusReporter, aWarningReporter );
483 glDepthFunc( GL_LESS );
484 glEnable( GL_CULL_FACE );
485 glFrontFace( GL_CCW );
486 glEnable( GL_NORMALIZE );
490 glDisable( GL_MULTISAMPLE );
492 glEnable( GL_MULTISAMPLE );
495 glClearColor( 0.0f, 0.0f, 0.0f, 1.0f );
496 glClearDepth( 1.0f );
497 glClearStencil( 0x00 );
498 glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT );
506 glEnable( GL_DEPTH_TEST );
509 glMatrixMode( GL_PROJECTION );
511 glMatrixMode( GL_MODELVIEW );
520 glEnable( GL_LIGHTING );
529 if( cameraPos.z > 0.0f )
530 zpos = glm::max( cameraPos.z, 0.5f ) + cameraPos.z * cameraPos.z;
532 zpos = glm::min( cameraPos.z,-0.5f ) - cameraPos.z * cameraPos.z;
535 const GLfloat headlight_pos[] = { cameraPos.x, cameraPos.y, zpos, 1.0f };
537 glLightfv( GL_LIGHT0, GL_POSITION, headlight_pos );
544 bool drawMiddleSegments = !skipThickness;
550 if( !( skipRenderVias || skipRenderHoles ) &&
m_vias )
557 for( MAP_OGL_DISP_LISTS::const_iterator ii =
m_layers.begin(); ii !=
m_layers.end(); ++ii )
568 const double opacity_min = 0.8;
572 if( ( layer_id >
F_Cu ) && ( layer_id <
B_Cu ) )
580 if( ( layer_id >=
F_Cu ) && ( layer_id <=
B_Cu ) )
587 if( skipRenderHoles )
596 drawMiddleSegments );
602 drawMiddleSegments );
627 wxASSERT( viasHolesLayer !=
nullptr );
629 if( viasHolesLayer !=
nullptr )
688 if( throughHolesOuter )
700 anti_board =
nullptr;
714 if( skipRenderHoles )
731 throughHolesOuter, anti_board );
733 else if( throughHolesOuter )
747 glm::mat4 cameraViewMatrix;
749 glGetFloatv( GL_MODELVIEW_MATRIX, glm::value_ptr( cameraViewMatrix ) );
763 glEnable( GL_POLYGON_OFFSET_FILL );
764 glPolygonOffset( 0.0f, -2.0f );
771 drawMiddleSegments, skipRenderHoles );
777 drawMiddleSegments, skipRenderHoles );
785 drawMiddleSegments, skipRenderHoles );
791 drawMiddleSegments, skipRenderHoles );
795 glDisable( GL_POLYGON_OFFSET_FILL );
796 glPolygonOffset( 0.0f, 0.0f );
802 glDepthMask( GL_FALSE );
803 glEnable( GL_BLEND );
804 glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
807 glEnable( GL_TEXTURE_2D );
808 glActiveTexture( GL_TEXTURE0 );
811 glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE );
812 glTexEnvf( GL_TEXTURE_ENV, GL_COMBINE_RGB, GL_INTERPOLATE );
813 glTexEnvf( GL_TEXTURE_ENV, GL_COMBINE_ALPHA, GL_MODULATE );
815 glTexEnvi( GL_TEXTURE_ENV, GL_SRC0_RGB, GL_PRIMARY_COLOR );
816 glTexEnvi( GL_TEXTURE_ENV, GL_OPERAND0_RGB, GL_SRC_COLOR );
818 glTexEnvi( GL_TEXTURE_ENV, GL_SRC1_RGB, GL_PREVIOUS );
819 glTexEnvi( GL_TEXTURE_ENV, GL_OPERAND1_RGB, GL_SRC_COLOR );
821 glTexEnvi( GL_TEXTURE_ENV, GL_SRC0_ALPHA, GL_PRIMARY_COLOR );
822 glTexEnvi( GL_TEXTURE_ENV, GL_OPERAND0_ALPHA, GL_SRC_ALPHA );
823 glTexEnvi( GL_TEXTURE_ENV, GL_SRC1_ALPHA, GL_CONSTANT );
824 glTexEnvi( GL_TEXTURE_ENV, GL_OPERAND1_ALPHA, GL_SRC_ALPHA );
828 glDisable( GL_BLEND );
831 glDepthMask( GL_TRUE );
836 glDisable( GL_LIGHTING );
841 glEnable( GL_LIGHTING );
858 glEnable( GL_LINE_SMOOTH );
859 glShadeModel( GL_SMOOTH );
862 glPixelStorei( GL_UNPACK_ALIGNMENT, 4 );
879 circleImageBlured->
EfxFilter_SkipCenter( circleImage, IMAGE_FILTER::GAUSSIAN_BLUR, circleRadius - 8 );
883 delete circleImageBlured;
884 circleImageBlured =
nullptr;
887 circleImage =
nullptr;
901 glEnable( GL_COLOR_MATERIAL );
902 glColorMaterial( GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE );
909 glMaterialfv( GL_FRONT_AND_BACK, GL_SPECULAR, &specular.r );
910 glMaterialf( GL_FRONT_AND_BACK, GL_SHININESS, 96.0f );
912 glMaterialfv( GL_FRONT_AND_BACK, GL_AMBIENT, &ambient.r );
913 glMaterialfv( GL_FRONT_AND_BACK, GL_DIFFUSE, &diffuse.r );
914 glMaterialfv( GL_FRONT_AND_BACK, GL_EMISSION, &emissive.r );
921 glDeleteLists(
m_grid, 1 );
925 for( MAP_OGL_DISP_LISTS::const_iterator ii =
m_layers.begin(); ii !=
m_layers.end(); ++ii )
928 delete pLayerDispList;
940 for(
const std::pair<const PCB_LAYER_ID, OPENGL_RENDER_LIST*> entry :
m_outerLayerHoles )
945 for(
const std::pair<const PCB_LAYER_ID, OPENGL_RENDER_LIST*> entry :
m_innerLayerHoles )
955 for(
const std::pair<const wxString, MODEL_3D*>& entry :
m_3dModelMap )
989 bool aDrawMiddleSegments,
bool aSkipRenderHoles )
991 wxASSERT( (aLayerID ==
B_Mask) || (aLayerID ==
F_Mask) );
1010 if( aSkipRenderHoles )
1032 if( aSkipRenderHoles )
1046 bool aGetTop,
bool aGetBot,
bool aRenderTransparentOnly,
1047 bool aRenderSelectedOnly )
1049 wxASSERT( ( aGetTop ==
true ) || ( aGetBot ==
true ) );
1057 bool highlight =
false;
1061 if( fp->IsSelected() )
1070 if( aRenderSelectedOnly != highlight )
1074 if( !fp->Models().empty() )
1078 const bool isFlipped = fp->IsFlipped();
1080 if( ( aGetTop == !isFlipped ) ||
1081 ( aGetBot == isFlipped ) )
1090 const FOOTPRINT* aFootprint,
bool aRenderTransparentOnly,
1093 if( !aFootprint->
Models().empty() )
1099 glm::mat4 fpMatrix( 1.0f );
1101 fpMatrix = glm::translate( fpMatrix,
1108 fpMatrix = glm::rotate( fpMatrix,
1110 SFVEC3F( 0.0f, 0.0f, 1.0f ) );
1115 fpMatrix = glm::rotate( fpMatrix, glm::pi<float>(),
SFVEC3F( 0.0f, 1.0f, 0.0f ) );
1116 fpMatrix = glm::rotate( fpMatrix, glm::pi<float>(),
SFVEC3F( 0.0f, 0.0f, 1.0f ) );
1122 fpMatrix = glm::scale( fpMatrix,
1123 SFVEC3F( modelunit_to_3d_units_factor ) );
1128 if( !sM.m_Show || sM.m_Filename.empty() )
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, sM.m_Rotation.z );
1150 std::vector<float> key = { offset.x, offset.y, offset.z,
1151 rotation.x, rotation.y, rotation.z,
1158 modelworldMatrix *= it->second;
1162 glm::mat4 mtx( 1.0f );
1163 mtx = glm::translate( mtx, offset );
1164 mtx = glm::rotate( mtx, glm::radians( -rotation.z ), { 0.0f, 0.0f, 1.0f } );
1165 mtx = glm::rotate( mtx, glm::radians( -rotation.y ), { 0.0f, 1.0f, 0.0f } );
1166 mtx = glm::rotate( mtx, glm::radians( -rotation.x ), { 1.0f, 0.0f, 0.0f } );
1167 mtx = glm::scale( mtx,
scale );
1170 modelworldMatrix *= mtx;
1173 if( aRenderTransparentOnly )
1175 aDstRenderList.emplace_back( modelworldMatrix,
1183 aDstRenderList.emplace_back( modelworldMatrix,
1202 std::list<MODELTORENDER> renderList;
1210 if( !renderList.empty() )
1215 renderModel( aCameraViewMatrix, mtr, selColor,
nullptr );
1224 if( !renderList.empty() )
1229 renderModel( aCameraViewMatrix, mtr, selColor,
nullptr );
1242 std::list<MODELTORENDER> renderListModels;
1253 if( renderListModels.empty() )
1256 std::vector<std::pair<const MODELTORENDER *, float>> transparentModelList;
1258 transparentModelList.reserve( renderListModels.size() );
1265 const BBOX_3D& bBox = mtr.m_model->GetBBox();
1267 const SFVEC3F bBoxWorld = mtr.m_modelWorldMat * glm::vec4( bBoxCenter, 1.0f );
1269 const float distanceToCamera = glm::length( cameraPos - bBoxWorld );
1271 transparentModelList.emplace_back( &mtr, distanceToCamera );
1275 std::sort( transparentModelList.begin(), transparentModelList.end(),
1276 [&]( std::pair<const MODELTORENDER *, float>& a,
1277 std::pair<const MODELTORENDER *, float>& b )
1279 return a.second > b.second;
1285 bool isUsingColorInformation = !( transparentModelList.begin()->first->m_isSelected &&
1290 for(
const std::pair<const MODELTORENDER *, float>& mtr : transparentModelList )
1295 if( !isUsingColorInformation && !mtr.first->m_isSelected )
1297 isUsingColorInformation =
true;
1299 glEnableClientState( GL_COLOR_ARRAY );
1300 glEnableClientState( GL_TEXTURE_COORD_ARRAY );
1301 glEnable( GL_COLOR_MATERIAL );
1305 if( isUsingColorInformation && mtr.first->m_isSelected )
1307 isUsingColorInformation =
false;
1309 glDisableClientState( GL_COLOR_ARRAY );
1310 glDisableClientState( GL_TEXTURE_COORD_ARRAY );
1311 glDisable( GL_COLOR_MATERIAL );
1318 renderModel( aCameraViewMatrix, *mtr.first, selColor, &cameraPos );
1330 const SFVEC3F *aCameraWorldPos )
1332 const glm::mat4 modelviewMatrix = aCameraViewMatrix * aModelToRender.
m_modelWorldMat;
1334 glLoadMatrixf( glm::value_ptr( modelviewMatrix ) );
1342 const bool wasBlendEnabled = glIsEnabled( GL_BLEND );
1344 if( !wasBlendEnabled )
1346 glEnable( GL_BLEND );
1347 glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
1350 glDisable( GL_LIGHTING );
1358 glEnable( GL_LIGHTING );
1360 if( !wasBlendEnabled )
1361 glDisable( GL_BLEND );
1369 glDeleteLists(
m_grid, 1 );
1373 if( aGridType == GRID3D_TYPE::NONE )
1376 m_grid = glGenLists( 1 );
1378 if( !glIsList(
m_grid ) )
1381 glNewList(
m_grid, GL_COMPILE );
1383 glEnable( GL_BLEND );
1384 glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
1386 const double zpos = 0.0;
1394 const GLfloat transparency = 0.35f;
1396 double griSizeMM = 0.0;
1400 case GRID3D_TYPE::GRID_1MM: griSizeMM = 1.0;
break;
1401 case GRID3D_TYPE::GRID_2P5MM: griSizeMM = 2.5;
break;
1402 case GRID3D_TYPE::GRID_5MM: griSizeMM = 5.0;
break;
1403 case GRID3D_TYPE::GRID_10MM: griSizeMM = 10.0;
break;
1406 case GRID3D_TYPE::NONE:
return;
1409 glNormal3f( 0.0, 0.0, 1.0 );
1414 brd_center_pos.
y = -brd_center_pos.
y;
1420 double xmin = ( brd_center_pos.
x - xsize / 2 ) *
scale;
1421 double xmax = ( brd_center_pos.
x + xsize / 2 ) *
scale;
1422 double ymin = ( brd_center_pos.
y - ysize / 2 ) *
scale;
1423 double ymax = ( brd_center_pos.
y + ysize / 2 ) *
scale;
1431 for(
int ii = 0; ; ii++ )
1434 glColor4f( gridColor.r, gridColor.g, gridColor.b, transparency );
1436 glColor4f( gridColor_marker.r, gridColor_marker.g, gridColor_marker.b,
1441 if(
delta <= xsize / 2 )
1443 glBegin( GL_LINES );
1444 glVertex3f( (brd_center_pos.
x +
delta) *
scale, -ymin, zpos );
1445 glVertex3f( (brd_center_pos.
x +
delta) *
scale, -ymax, zpos );
1450 glBegin( GL_LINES );
1451 glVertex3f( (brd_center_pos.
x -
delta) *
scale, -ymin, zpos );
1452 glVertex3f( (brd_center_pos.
x -
delta) *
scale, -ymax, zpos );
1457 if(
delta <= ysize / 2 )
1459 glBegin( GL_LINES );
1460 glVertex3f( xmin, -( brd_center_pos.
y +
delta ) *
scale, zpos );
1461 glVertex3f( xmax, -( brd_center_pos.
y +
delta ) *
scale, zpos );
1466 glBegin( GL_LINES );
1467 glVertex3f( xmin, -( brd_center_pos.
y -
delta ) *
scale, zpos );
1468 glVertex3f( xmax, -( brd_center_pos.
y -
delta ) *
scale, zpos );
1473 if( (
delta > ysize / 2 ) && (
delta > xsize / 2 ) )
1478 glNormal3f( 0.0, -1.0, 0.0 );
1481 double posy = -brd_center_pos.
y *
scale;
1483 for(
int ii = 0; ; ii++ )
1486 glColor4f( gridColor.r, gridColor.g, gridColor.b, transparency );
1488 glColor4f( gridColor_marker.r, gridColor_marker.g, gridColor_marker.b,
1493 glBegin( GL_LINES );
1496 glVertex3f( xmax, posy, zmin );
1497 glVertex3f( xmax, posy, zmax );
1502 glBegin( GL_LINES );
1504 glVertex3f( xmin, posy, zmin );
1505 glVertex3f( xmin, posy, zmax );
1509 if(
delta > xsize / 2.0f )
1514 for(
int ii = 0; ; ii++ )
1517 glColor4f( gridColor.r, gridColor.g, gridColor.b, transparency );
1519 glColor4f( gridColor_marker.r, gridColor_marker.g, gridColor_marker.b, transparency );
1526 glBegin( GL_LINES );
1527 glVertex3f( xmin, posy,
delta );
1528 glVertex3f( xmax, posy,
delta );
1532 if(
delta <= -zmin && ( ii != 0 ) )
1535 glBegin( GL_LINES );
1536 glVertex3f( xmin, posy, -
delta );
1537 glVertex3f( xmax, posy, -
delta );
1545 glDisable( GL_BLEND );
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
constexpr EDA_IU_SCALE pcbIUScale
#define RANGE_SCALE_3D
This defines the range that all coord will have to be rendered.
Helper class to handle information needed to display 3D board.
double BiuTo3dUnits() const noexcept
Board integer units To 3D units.
SFVEC4F m_BgColorTop
background top color
SFVEC4F m_SolderPasteColor
in realistic mode: solder paste color
bool IsFootprintShown(FOOTPRINT_ATTR_T aFPAttributes) const
Test if footprint should be displayed in relation to attributes and the flags.
VECTOR2I GetBoardSize() const noexcept
Get the board size.
std::bitset< LAYER_3D_END > GetVisibleLayers() const
SFVEC4F m_SolderMaskColorBot
in realistic mode: solder mask color ( bot )
VECTOR2I GetBoardPos() const noexcept
Get the board center.
float GetLayerBottomZPos(PCB_LAYER_ID aLayerId) const noexcept
Get the bottom z position.
SFVEC4F m_SolderMaskColorTop
in realistic mode: solder mask color ( top )
SFVEC4F GetColor(const COLOR4D &aColor) const
SFVEC4F m_CopperColor
in realistic mode: copper color
const BOARD * GetBoard() const noexcept
float GetFootprintZPos(bool aIsFlipped) const
Get the position of the footprint in 3d integer units considering if it is flipped or not.
float GetNonCopperLayerThickness() const noexcept
Get the non copper layers thickness (in 3D units).
float GetLayerTopZPos(PCB_LAYER_ID aLayerId) const noexcept
Get the top z position.
EDA_3D_VIEWER_SETTINGS * m_Cfg
SFVEC4F m_SilkScreenColorTop
in realistic mode: SilkScreen color ( top )
SFVEC4F m_SilkScreenColorBot
in realistic mode: SilkScreen color ( bot )
float GetBoardBodyThickness() const noexcept
Get the board body thickness, including internal copper layers (in 3D units).
SFVEC4F m_BoardBodyColor
in realistic mode: FR4 board color
SFVEC4F m_UserCommentsColor
SFVEC4F GetLayerColor(PCB_LAYER_ID aLayerId) const
Get the technical color of a layer.
SFVEC4F m_UserDrawingsColor
SFVEC4F m_BgColorBot
background bottom color
FOOTPRINTS & Footprints()
A class used to derive camera objects from.
glm::mat4 GetRotationMatrix() const
Get the rotation matrix to be applied in a transformation camera.
const glm::mat4 & GetProjectionMatrix() const
const SFVEC3F & GetPos() const
const glm::mat4 & GetViewMatrix() const
Implement a canvas based on a wxGLCanvas.
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
static 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 DrawAllCameraCulled(float zCameraPos, bool aDrawMiddle=true) const
Draw all layers if they are visible by the camera if camera position is above the layer.
void ApplyScalePosition(float aZposition, float aZscale)
void SetItIsTransparent(bool aSetTransparent)
void DrawAll(bool aDrawMiddle=true) const
Call to draw all the display lists.
This is a base class to hold data and functions for render targets.
CAMERA & m_camera
Flag if the opengl specific for this render was already initialized.
std::unique_ptr< BUSY_INDICATOR > CreateBusyIndicator() const
Return a created busy indicator, if a factory has been set, else a null pointer.
bool m_reloadRequested
The window size that this camera is working.
bool m_is_opengl_initialized
BOARD_ADAPTER & m_boardAdapter
OPENGL_RENDER_LIST * m_board
OPENGL_RENDER_LIST * m_vias
OPENGL_RENDER_LIST * m_outerThroughHoleRings
GRID3D_TYPE m_lastGridType
Stores the last grid type.
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
BOARD_ITEM * m_currentRollOverItem
void renderBoardBody(bool aSkipRenderHoles)
LIST_TRIANGLES m_triangles
store pointers so can be deleted latter
OPENGL_RENDER_LIST * m_outerViaThroughHoles
OPENGL_RENDER_LIST * m_outerThroughHoles
void setLayerMaterial(PCB_LAYER_ID aLayerID)
std::map< wxString, MODEL_3D * > m_3dModelMap
OPENGL_RENDER_LIST * m_platedPadsFront
void renderSolderMaskLayer(PCB_LAYER_ID aLayerID, float aZPosition, bool aDrawMiddleSegments, bool aSkipRenderHoles)
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 renderTransparentModels(const glm::mat4 &aCameraViewMatrix)
std::map< std::vector< float >, glm::mat4 > m_3dModelMatrixMap
void get3dModelsSelected(std::list< MODELTORENDER > &aDstRenderList, bool aGetTop, bool aGetBot, bool aRenderTransparentOnly, bool aRenderSelectedOnly)
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,...
OPENGL_RENDER_LIST * m_padHoles
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)
struct RENDER_3D_OPENGL::@2 m_materials
void setLightBottom(bool enabled)
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)=0
Report a string with a given severity.
#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.
@ LAYER_3D_SOLDERMASK_TOP
@ LAYER_3D_SOLDERMASK_BOTTOM
PCB_LAYER_ID
A quick note on layer IDs:
void OglResetTextureState()
Reset to default state the texture settings.
void OglDrawBackground(const SFVEC3F &aTopColor, const SFVEC3F &aBotColor)
void OglSetMaterial(const SMATERIAL &aMaterial, float aOpacity, bool aUseSelectedMaterial, SFVEC3F aSelectionColor)
Set OpenGL materials.
GLuint OglLoadTexture(const IMAGE &aImage)
Generate a new OpenGL texture.
Define generic OpenGL functions that are common to any OpenGL target.
void DrawRoundArrow(SFVEC3F aPosition, SFVEC3F aTargetPos, float aSize)
Draw a round arrow.
#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
bool opengl_highlight_on_rollover
KIGFX::COLOR4D opengl_selection_color
bool opengl_show_model_bbox
bool subtract_mask_from_silk
bool renderPlatedPadsAsPlated
bool clip_silk_on_via_annulus
bool opengl_holes_disableOnMove
bool opengl_AA_disableOnMove
bool opengl_vias_disableOnMove
bool opengl_show_off_board_silk
constexpr int mmToIU(double mm) const
glm::mat4 m_modelWorldMat
constexpr ret_type KiROUND(fp_type v)
Round a floating point number to an integer using "round halfway cases away from zero".