Skip to content

AI/Gen3D: Slice C — Mesh construction + scene/export integration #767

Description

@fernandotonon

Part of #764. Depends on Slice B (predictor returns vertex/index arrays).

Goal

Turn MeshGenPredictor::Result float arrays into an Ogre::Mesh, attach it to the scene, and export it — reusing the project's standard mesh-build + export paths.

Work

  • New helper (in MeshGenPredictor or a small MeshBuilder): build Ogre::Mesh from positions/indices via MeshManager::createManualVertexDeclaration (POSITION + NORMAL, +DIFFUSE if colors) → HardwareVertexBuffer/HardwareIndexBuffer (IT_16BIT if ≤65536 verts else IT_32BIT) → _setBounds/_setBoundingSphereRadiusload(). Recipe: src/TestHelpers.h createInMemoryTriangleMesh (~241–282).
  • Compute per-vertex normals by accumulating face normals (marching-cubes output may lack them).
  • Attach: create entity + child SceneNode under Manager::getSingleton()->getSceneMgr() root (headless via initOgreHeadless() in CLI; live scene in GUI).
  • Export: MeshImporterExporter::exporter(node, outputPath, format) — default .glb; honor requested extension.
  • Apply the auto-scale convention MeshImporterExporter already uses for sub-unit meshes so generated meshes frame correctly.

Tests

  • Build a mesh from a known cube SDF (Slice A) → assert vertex/triangle counts, non-degenerate bounds, normals roughly unit-length.
  • Round-trip: build → export .glb → re-import → counts match (skip if no GL/Ogre).

Acceptance

  • Float arrays → valid Ogre::Mesh with normals + correct bounds.
  • Saved .glb re-imports cleanly with matching geometry.
  • Generated mesh frames correctly in a viewport (auto-scale applied).

Metadata

Metadata

Assignees

No one assigned

    Labels

    ai-assistLocal-AI-assisted 3D workflows (epic prefix: AI:)enhancementNew feature or requestqtmesh-roadmap

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions