Lagrange
Loading...
Searching...
No Matches
mesh_to_xatlas.h
1/*
2 * Copyright 2026 Adobe. All rights reserved.
3 * This file is licensed to you under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License. You may obtain a copy
5 * of the License at http://www.apache.org/licenses/LICENSE-2.0
6 *
7 * Unless required by applicable law or agreed to in writing, software distributed under
8 * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
9 * OF ANY KIND, either express or implied. See the License for the specific language
10 * governing permissions and limitations under the License.
11 */
12#pragma once
13
14#include <lagrange/SurfaceMesh.h>
15#include <lagrange/xatlas/Options.h>
16
17#include <cstdint>
18#include <string_view>
19#include <vector>
20
21#include <xatlas/xatlas.h>
22
23namespace lagrange::xatlas::internal {
24
31{
33 std::vector<float> positions;
34
36 std::vector<float> normals;
37
39 std::vector<float> uvs;
40
42 std::vector<uint32_t> indices;
43
45 uint32_t vertex_count = 0;
46
48 uint32_t face_count = 0;
49
51 ::xatlas::MeshDecl as_decl() const noexcept;
52};
53
62template <typename Scalar, typename Index>
63MeshAdapter build_mesh_adapter(
64 const SurfaceMesh<Scalar, Index>& mesh,
65 const UnwrapOptions& options);
66
72{
74 std::vector<float> uvs;
75
77 std::vector<uint32_t> indices;
78
81 std::vector<uint32_t> face_materials;
82
84 uint32_t vertex_count = 0;
85
87 uint32_t face_count = 0;
88
90 ::xatlas::UvMeshDecl as_decl() const noexcept;
91};
92
101template <typename Scalar, typename Index>
102UvMeshAdapter build_uv_mesh_adapter(
103 const SurfaceMesh<Scalar, Index>& mesh,
104 std::string_view uv_attribute_name,
105 std::string_view chart_attribute_name);
106
107} // namespace lagrange::xatlas::internal
A general purpose polygonal mesh class.
Definition SurfaceMesh.h:73
@ Scalar
Mesh attribute must have exactly 1 channel.
Definition AttributeFwd.h:56
Options controlling a full unwrap (segment + parameterize + pack).
Definition Options.h:128
Owning storage for an xatlas::MeshDecl derived from a Lagrange SurfaceMesh.
Definition mesh_to_xatlas.h:31
uint32_t vertex_count
Number of vertices (after optional unify).
Definition mesh_to_xatlas.h:45
uint32_t face_count
Number of facets.
Definition mesh_to_xatlas.h:48
std::vector< float > uvs
Optional float UV hints tightly packed (2 * vertex_count). Empty if no hints supplied.
Definition mesh_to_xatlas.h:39
std::vector< float > normals
Optional float normals tightly packed (3 * vertex_count). Empty if no normals supplied.
Definition mesh_to_xatlas.h:36
::xatlas::MeshDecl as_decl() const noexcept
Build an xatlas::MeshDecl referencing this adapter's buffers.
Definition mesh_to_xatlas.cpp:149
std::vector< uint32_t > indices
uint32 indices tightly packed (3 * facet_count for triangle-only meshes).
Definition mesh_to_xatlas.h:42
std::vector< float > positions
Float positions tightly packed (3 * vertex_count). Always copied/cast from input.
Definition mesh_to_xatlas.h:33
Owning storage for an xatlas::UvMeshDecl derived from a Lagrange SurfaceMesh whose UV attribute is to...
Definition mesh_to_xatlas.h:72
uint32_t vertex_count
Number of UV "vertices" (= number of unique indexed UV values).
Definition mesh_to_xatlas.h:84
uint32_t face_count
Number of triangles.
Definition mesh_to_xatlas.h:87
std::vector< uint32_t > face_materials
Optional per-face chart ids (size == face_count) forwarded to xatlas as faceMaterialData to pin input...
Definition mesh_to_xatlas.h:81
std::vector< float > uvs
Float UV values tightly packed (2 * vertex_count).
Definition mesh_to_xatlas.h:74
std::vector< uint32_t > indices
uint32 indices tightly packed (3 * facet_count).
Definition mesh_to_xatlas.h:77