fd5787c55f
- .mcp.json - bash/functions/infra/write_mcp_jupyter_config.md - bash/functions/infra/write_mcp_jupyter_config.sh - cpp/CMakeLists.txt - cpp/apps/chart_demo - cpp/apps/shaders_lab - cpp/functions/gfx/gl_framebuffer.cpp - cpp/functions/gfx/gl_framebuffer.h - cpp/functions/gfx/gl_framebuffer.md - cpp/functions/gfx/mesh_gpu.md - ... Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
3.4 KiB
3.4 KiB
name, kind, lang, domain, version, purity, signature, description, tags, uses_functions, uses_types, returns, returns_optional, error_type, imports, tested, tests, test_file_path, file_path, framework, emits, params, output
| name | kind | lang | domain | version | purity | signature | description | tags | uses_functions | uses_types | returns | returns_optional | error_type | imports | tested | tests | test_file_path | file_path | framework | emits | params | output | |||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| mesh_viewer | component | cpp | viz | 1.1.0 | impure | void mesh_viewer(const char* id, const MeshViewerConfig& cfg) | Renderiza un MeshGpu (3D) en un FBO interno cacheado por id, con orbit camera, iluminacion Lambert headlight, depth test correcto (GL_DEPTH_COMPONENT24), opcion wireframe. Drag/wheel del mouse mueven la camara. |
|
|
false | error_go_core |
|
false | cpp/functions/viz/mesh_viewer.cpp | imgui |
|
|
Renderiza una imagen del mesh dentro del frame ImGui actual; muta cfg.cam in-place segun drag/wheel del mouse cuando el panel esta active/hovered. |
mesh_viewer
Componente de viz para inspeccionar geometria 3D dentro de cualquier panel ImGui. Internamente:
- Compila/cachea (por
id) un programa shader Lambert headlight (vertex + fragment). - Cachea un
Framebuffercon depth renderbuffer poridy lo redimensiona seguncfg.size. - Cada frame: bind FBO, clear color+depth, draw
cfg.meshcon depth test activo, mostrar la textura viaImGui::Image. - Si el panel esta active → llama
orbit_camera_handle_dragconMouseDelta. - Si el panel esta hovered y hay scroll → ajusta zoom.
Ejemplo
static fn::core::OrbitCamera cam;
fn::viz::MeshViewerConfig cfg{};
cfg.mesh = &gpu; // MeshGpu valido
cfg.cam = &cam;
cfg.size = {-1, 480};
cfg.wireframe = false;
cfg.color = IM_COL32(160, 200, 255, 255);
fn::viz::mesh_viewer("##teapot_view", cfg);
Cuando usarla
Cuando necesites inspeccionar geometria 3D (OBJ, STL, cualquier MeshGpu) dentro de un panel ImGui existente, con orbit camera interactiva y auto-oclusion correcta de caras.
Gotchas
- Cache por id: si el
idcambia dinamicamente entre frames, se acumulan FBOs y programas en memoria (leak). Usar IDs estables ("##nombre_fijo"). - Wireframe: usa
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE)— no disponible en GL ES; protegido con#ifndef __EMSCRIPTEN__. - Iluminacion: Lambert con luz fija en
+Zview-space ("headlight"), suficiente para inspeccion. Sin specular, sin sombras. - Matrices: row-major desde
orbit_camera_matrices; se suben contranspose=GL_TRUE(GL espera column-major). - Estado GL: salva y restaura
GL_FRAMEBUFFER_BINDING,GL_VIEWPORTyGL_DEPTH_TESTantes/despues del render. No contamina el estado del frame ImGui principal.
Notas
- Depth renderbuffer activo (GL_DEPTH_COMPONENT24): auto-oclusion correcta en meshes solidos.
glEnable(GL_DEPTH_TEST)+glDepthFunc(GL_LESS)dentro del render del FBO. - Usa
fb_init_depthdegl_framebuffer_cpp_gfx(v1.1.0+).
Capability growth log
v1.1.0 (2026-05-28) — depth renderbuffer via fb_init_depth, fix auto-oclusion en meshes solidos