Lagrange
GLMesh.h
1/*
2 * Copyright 2021 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#include <lagrange/ui/Entity.h>
14#include <lagrange/ui/types/VertexBuffer.h>
15#include <memory>
16
17namespace lagrange {
18namespace ui {
19
21{
22 constexpr static const entt::id_type Position = entt::hashed_string{"in_pos"};
23 constexpr static const entt::id_type Normal = entt::hashed_string{"in_normal"};
24 constexpr static const entt::id_type UV = entt::hashed_string{"in_uv"};
25 constexpr static const entt::id_type Color = entt::hashed_string{"in_color"};
26 constexpr static const entt::id_type Tangent = entt::hashed_string{"in_tangent"};
27 constexpr static const entt::id_type Bitangent = entt::hashed_string{"in_bitangent"};
28 constexpr static const entt::id_type Value =
29 entt::hashed_string{"in_value"}; // For attribute value
30 constexpr static const entt::id_type BoneIDs = entt::hashed_string{"in_bone_ids"};
31 constexpr static const entt::id_type BoneWeights = entt::hashed_string{"in_bone_weights"};
32};
33
35{
36 constexpr static const entt::id_type VertexIndices = entt::hashed_string{"_vertex_indices"};
37 constexpr static const entt::id_type EdgeIndices = entt::hashed_string{"_edge_indices"};
38 constexpr static const entt::id_type TriangleIndices = entt::hashed_string{"_triangle_indices"};
39};
40
41struct GLMesh
42{
43 std::shared_ptr<GPUBuffer> get_attribute_buffer(entt::id_type id) const
44 {
45 auto it = attribute_buffers.find(id);
46 if (it == attribute_buffers.end()) return nullptr;
47 return it->second;
48 }
49
50 std::shared_ptr<GPUBuffer> get_index_buffer(entt::id_type id) const
51 {
52 auto it = index_buffers.find(id);
53 if (it == index_buffers.end()) return nullptr;
54 return it->second;
55 }
56
57 std::shared_ptr<GPUBuffer> get_submesh_buffer(entt::id_type id) const
58 {
59 auto it = submesh_indices.find(id);
60 if (it == submesh_indices.end()) return nullptr;
61 return it->second;
62 }
63
64 // Use DefaultShaderAtrribNames or custom ids
65 std::unordered_map<entt::id_type, std::shared_ptr<GPUBuffer>> attribute_buffers;
66
67 // Use DefaultShaderIndicesNames or custom ids
68 std::unordered_map<entt::id_type, std::shared_ptr<GPUBuffer>> index_buffers;
69
70 std::unordered_map<entt::id_type, std::shared_ptr<GPUBuffer>> submesh_indices;
71};
72
73} // namespace ui
74} // namespace lagrange
Definition: Color.h:24
Lagrange UI Viewer and mini 3D engine.
Definition: AcceleratedPicking.h:22
Main namespace for Lagrange.
Definition: AABBIGL.h:30
Definition: GLMesh.h:42