KiCad PCB EDA Suite
|
#include <3d_model.h>
Classes | |
struct | MATERIAL |
struct | VERTEX |
Public Member Functions | |
MODEL_3D (const S3DMODEL &a3DModel, MATERIAL_MODE aMaterialMode) | |
Load a 3D model. | |
~MODEL_3D () | |
void | DrawOpaque (bool aUseSelectedMaterial, SFVEC3F aSelectionColor=SFVEC3F(0.0f)) const |
Render the model into the current context. | |
void | DrawTransparent (float aOpacity, bool aUseSelectedMaterial, SFVEC3F aSelectionColor=SFVEC3F(0.0f)) const |
Render the model into the current context. | |
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. | |
bool | HasOpaqueMeshes () const |
Return true if have opaque meshes to render. | |
bool | HasTransparentMeshes () const |
Return true if have transparent mesh's to render. | |
void | DrawBbox () const |
Draw main bounding box of the model. | |
void | DrawBboxes () const |
Draw individual bounding boxes of each mesh. | |
const BBOX_3D & | GetBBox () const |
Get the main bounding box. | |
Static Public Member Functions | |
static void | BeginDrawMulti (bool aUseColorInformation) |
Set some basic render states before drawing multiple models. | |
static void | EndDrawMulti () |
Cleanup render states after drawing multiple models. | |
Static Private Member Functions | |
static void | MakeBbox (const BBOX_3D &aBox, unsigned int aIdxOffset, VERTEX *aVtxOut, GLuint *aIdxOut, const glm::vec4 &aColor) |
Private Attributes | |
MATERIAL_MODE | m_materialMode |
BBOX_3D | m_model_bbox |
global bounding box for this model | |
std::vector< BBOX_3D > | m_meshes_bbox |
individual bbox for each mesh | |
GLuint | m_vertex_buffer = 0 |
GLuint | m_index_buffer = 0 |
GLenum | m_index_buffer_type = GL_INVALID_ENUM |
std::vector< MATERIAL > | m_materials |
bool | m_have_opaque_meshes = false |
bool | m_have_transparent_meshes = false |
GLuint | m_bbox_vertex_buffer = 0 |
GLuint | m_bbox_index_buffer = 0 |
GLenum | m_bbox_index_buffer_type = GL_INVALID_ENUM |
Static Private Attributes | |
static const wxChar * | m_logTrace = wxT( "KI_TRACE_EDA_OGL_3DMODEL" ) |
static constexpr unsigned int | bbox_vtx_count = 8 |
static constexpr unsigned int | bbox_idx_count = 24 |
Definition at line 37 of file 3d_model.h.
MODEL_3D::MODEL_3D | ( | const S3DMODEL & | a3DModel, |
MATERIAL_MODE | aMaterialMode | ||
) |
Load a 3D model.
a3DModel | a 3d model data to load. |
aMaterialMode | a mode to render the materials of the model. |
WARNING: Horrible hack here! Somehow, buffer values are being shared between pcbnew and the 3d viewer, which then frees the buffer, resulting in errors in pcbnew. To resolve this temporarily, we generate extra buffers in 3dviewer and use the higher numbers. These are freed on close. todo: Correctly separate the OpenGL contexts to prevent overlapping buffer vals
Definition at line 90 of file 3d_model.cpp.
References bbox_idx_count, bbox_vtx_count, BBOX_3D::IsInitialized(), MODEL_3D::MATERIAL::IsTransparent(), MODEL_3D::MATERIAL::m_bbox, m_bbox_index_buffer, m_bbox_index_buffer_type, m_bbox_vertex_buffer, MODEL_3D::VERTEX::m_cad_color, MODEL_3D::VERTEX::m_color, SMESH::m_Color, SMATERIAL::m_Diffuse, SMESH::m_FaceIdx, SMESH::m_FaceIdxSize, m_have_opaque_meshes, m_have_transparent_meshes, m_index_buffer, m_index_buffer_type, m_logTrace, SMESH::m_MaterialIdx, m_materialMode, m_materials, S3DMODEL::m_Materials, S3DMODEL::m_MaterialsSize, S3DMODEL::m_Meshes, m_meshes_bbox, S3DMODEL::m_MeshesSize, m_model_bbox, SMESH::m_Normals, MODEL_3D::VERTEX::m_nrm, MODEL_3D::VERTEX::m_pos, SMESH::m_Positions, MODEL_3D::MATERIAL::m_render_idx_buffer_offset, MODEL_3D::MATERIAL::m_render_idx_count, MODEL_3D::VERTEX::m_tex_uv, SMESH::m_Texcoords, SMATERIAL::m_Transparency, m_vertex_buffer, SMESH::m_VertexSize, MakeBbox(), MaterialDiffuseToColorCAD(), and BBOX_3D::Union().
MODEL_3D::~MODEL_3D | ( | ) |
Definition at line 557 of file 3d_model.cpp.
References m_bbox_index_buffer, m_bbox_vertex_buffer, m_index_buffer, and m_vertex_buffer.
|
static |
Set some basic render states before drawing multiple models.
Definition at line 388 of file 3d_model.cpp.
Referenced by EDA_3D_MODEL_VIEWER::OnPaint(), RENDER_3D_OPENGL::renderOpaqueModels(), and RENDER_3D_OPENGL::renderTransparentModels().
void MODEL_3D::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.
if aModelWorldMatrix and aCameraWorldPos is provided, it renders the material groups sorted.
Definition at line 417 of file 3d_model.cpp.
References BBOX_3D::GetCenter(), m_index_buffer, m_index_buffer_type, m_materialMode, m_materials, m_vertex_buffer, MaterialDiffuseToColorCAD(), OglSetDiffuseMaterial(), and OglSetMaterial().
Referenced by DrawOpaque(), DrawTransparent(), and RENDER_3D_OPENGL::renderModel().
void MODEL_3D::DrawBbox | ( | ) | const |
Draw main bounding box of the model.
Definition at line 569 of file 3d_model.cpp.
References bbox_idx_count, m_bbox_index_buffer, m_bbox_index_buffer_type, and m_bbox_vertex_buffer.
Referenced by RENDER_3D_OPENGL::renderModel().
void MODEL_3D::DrawBboxes | ( | ) | const |
Draw individual bounding boxes of each mesh.
Definition at line 588 of file 3d_model.cpp.
References bbox_idx_count, m_bbox_index_buffer, m_bbox_index_buffer_type, m_bbox_vertex_buffer, and m_meshes_bbox.
Referenced by RENDER_3D_OPENGL::renderModel().
|
inline |
Render the model into the current context.
Definition at line 55 of file 3d_model.h.
References Draw().
Referenced by EDA_3D_MODEL_VIEWER::OnPaint().
|
inline |
Render the model into the current context.
Definition at line 63 of file 3d_model.h.
References Draw().
Referenced by EDA_3D_MODEL_VIEWER::OnPaint().
|
static |
Cleanup render states after drawing multiple models.
Definition at line 404 of file 3d_model.cpp.
Referenced by EDA_3D_MODEL_VIEWER::OnPaint(), RENDER_3D_OPENGL::renderOpaqueModels(), and RENDER_3D_OPENGL::renderTransparentModels().
|
inline |
Get the main bounding box.
Definition at line 103 of file 3d_model.h.
References m_model_bbox.
Referenced by EDA_3D_MODEL_VIEWER::OnPaint().
|
inline |
Return true if have opaque meshes to render.
Definition at line 82 of file 3d_model.h.
References m_have_opaque_meshes.
|
inline |
Return true if have transparent mesh's to render.
Definition at line 87 of file 3d_model.h.
References m_have_transparent_meshes.
|
staticprivate |
Definition at line 51 of file 3d_model.cpp.
References bbox_line, MODEL_3D::VERTEX::m_pos, BBOX_3D::Max(), and BBOX_3D::Min().
Referenced by MODEL_3D().
|
staticconstexprprivate |
Definition at line 166 of file 3d_model.h.
Referenced by DrawBbox(), DrawBboxes(), and MODEL_3D().
|
staticconstexprprivate |
Definition at line 165 of file 3d_model.h.
Referenced by MODEL_3D().
|
private |
Definition at line 169 of file 3d_model.h.
Referenced by DrawBbox(), DrawBboxes(), MODEL_3D(), and ~MODEL_3D().
|
private |
Definition at line 170 of file 3d_model.h.
Referenced by DrawBbox(), DrawBboxes(), and MODEL_3D().
|
private |
Definition at line 168 of file 3d_model.h.
Referenced by DrawBbox(), DrawBboxes(), MODEL_3D(), and ~MODEL_3D().
|
private |
Definition at line 160 of file 3d_model.h.
Referenced by HasOpaqueMeshes(), and MODEL_3D().
|
private |
Definition at line 161 of file 3d_model.h.
Referenced by HasTransparentMeshes(), and MODEL_3D().
|
private |
Definition at line 139 of file 3d_model.h.
Referenced by Draw(), MODEL_3D(), and ~MODEL_3D().
|
private |
Definition at line 140 of file 3d_model.h.
Referenced by Draw(), and MODEL_3D().
|
staticprivate |
Definition at line 116 of file 3d_model.h.
Referenced by MODEL_3D().
|
private |
Definition at line 121 of file 3d_model.h.
Referenced by Draw(), and MODEL_3D().
|
private |
Definition at line 155 of file 3d_model.h.
Referenced by Draw(), and MODEL_3D().
|
private |
individual bbox for each mesh
Definition at line 124 of file 3d_model.h.
Referenced by DrawBboxes(), and MODEL_3D().
|
private |
global bounding box for this model
Definition at line 123 of file 3d_model.h.
Referenced by GetBBox(), and MODEL_3D().
|
private |
Definition at line 138 of file 3d_model.h.
Referenced by Draw(), MODEL_3D(), and ~MODEL_3D().