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(
31 authors,
32 "Jean-Michaël Celerier, TinyOBJ authors, miniPLY authors, vcglib authors, Eigen authors")
33 halp_meta(manual_url, "https://ossia.io/score-docs/processes/meshes.html#geometry-loader")
34 halp_meta(uuid, "5df71765-505f-4ab7-98c1-f305d10a01ef")
35
36 struct ins
37 {
38 struct geom_t : halp::file_port<"3D file">
39 {
40 halp_meta(extensions, "3D files (*.obj *.ply *.stl *.off)");
41 static std::function<void(GeometryLoader&)> process(file_type data);
42 } geom;
43 PositionControl position;
44 RotationControl rotation;
45 ScaleControl scale;
46 } inputs;
47
48 struct
49 {
50 struct : halp::mesh
51 {
52 halp_meta(name, "Geometry");
53 std::vector<halp::dynamic_geometry> mesh;
54 } geometry;
55 } outputs;
56
57 void rebuild_geometry();
58 void operator()();
59
60 std::vector<mesh> meshinfo{};
61 float_vec complete;
62
63 // Per-frame TRS matrix cache (see TransformHelper.hpp).
64 CachedTRS m_cachedTRS{};
65};
66
67}
Definition GeometryLoader.hpp:25
Definition GeometryLoader.hpp:39
Definition GeometryLoader.hpp:37
Definition TinyObj.hpp:98
Definition TinyObj.hpp:103
Definition TinyObj.hpp:107
Definition TinyObj.hpp:27