Loading...
Searching...
No Matches
SceneFromMeshes.hpp
1#pragma once
2#include <Threedim/TinyObj.hpp>
3
4#include <ossia/dataflow/geometry_port.hpp>
5
6#include <memory>
7#include <string_view>
8
9namespace Threedim
10{
11
12// Convert a vector of Threedim::mesh (produced by TinyObjFromFile,
13// PlyFromFile, or the vcglib-STL / vcglib-OFF bridges) into a
14// scene_state containing one scene_node per mesh part, each with a
15// mesh_component backing onto a single shared CPU buffer.
16//
17// All mesh parts share the same `float_vec` — the scene's mesh_primitives
18// reference it via buffer_resource_ptr with per-attribute byte offsets
19// into the same vertex buffer. This matches the layout tinyobj / miniply
20// already produce: attributes are non-interleaved, each one a contiguous
21// span in the parent buffer, with pos_offset / texcoord_offset / …
22// in *elements* (floats), not bytes.
23//
24// `source_label` is used as the scene_node name; it should be the source
25// filename (or `.` when unknown), purely for inspector readability.
26//
27// On empty input returns a null pointer; caller keeps the previous state.
28std::shared_ptr<ossia::scene_state> sceneStateFromMeshes(
29 std::vector<Threedim::mesh> meshes,
30 Threedim::float_vec buffer,
31 std::string_view source_label = {});
32
33}