Loading...
Searching...
No Matches
GeometryLoader.hpp
1#pragma once
2#include "TransformHelper.hpp"
3
4#include <Threedim/TinyObj.hpp>
5#include <halp/controls.hpp>
6#include <halp/file_port.hpp>
7#include <halp/geometry.hpp>
8#include <halp/meta.hpp>
9#include <ossia/detail/mutex.hpp>
10
11namespace Threedim
12{
13
14// Geometry-only file loader. Dispatches by extension to the right parser
15// and emits a halp::dynamic_geometry output — one draw-ready mesh per
16// file part, no scene graph, no materials, no lights. Use AssetLoader
17// for the full-scene variant (FBX / glTF also go through a
18// geometry+materials+hierarchy scene_spec pipeline there).
19//
20// Supported extensions: .obj, .ply, .stl, .off. STL + OFF go through
21// the vcglib importers; OBJ + PLY through tinyobj / miniply. All four
22// funnel into the same `Threedim::mesh` + `float_vec` representation
23// so `rebuild_geometry` sees one uniform input format.
25{
26public:
27 halp_meta(name, "Geometry Loader")
28 halp_meta(category, "Visuals/Meshes")
29 halp_meta(c_name, "geometry_loader")
30 halp_meta(description, "Load OBJ, PLY, STL or OFF geometry without scene hierarchy or materials.")
31 halp_meta(
32 authors,
33 "Jean-Michaël Celerier, TinyOBJ authors, miniPLY authors, vcglib authors, Eigen authors")
34 halp_meta(manual_url, "https://ossia.io/score-docs/processes/meshes.html#geometry-loader")
35 halp_meta(uuid, "5df71765-505f-4ab7-98c1-f305d10a01ef")
36
37 struct ins
38 {
39 struct geom_t : halp::file_port<"3D file">
40 {
41 halp_meta(extensions, "3D files (*.obj *.ply *.stl *.off)");
42 static std::function<void(GeometryLoader&)> process(file_type data);
43 } geom;
44 PositionControl position;
45 RotationControl rotation;
46 ScaleControl scale;
47 } inputs;
48
49 struct
50 {
51 struct : halp::mesh
52 {
53 halp_meta(name, "Geometry");
54 std::vector<halp::dynamic_geometry> mesh;
55 } geometry;
56 } outputs;
57
58 void rebuild_geometry();
59 void operator()();
60
61 std::vector<mesh> meshinfo{};
62 float_vec complete;
63
64 // Per-frame TRS matrix cache (see TransformHelper.hpp).
65 CachedTRS m_cachedTRS{};
66};
67
68}
Definition GeometryLoader.hpp:25
Definition GeometryLoader.hpp:40
Definition GeometryLoader.hpp:38
Definition TinyObj.hpp:98
Definition TinyObj.hpp:103
Definition TinyObj.hpp:107
Definition TinyObj.hpp:27