Lagrange
Material.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
14#include <lagrange/ui/api.h>
15#include <lagrange/ui/Entity.h>
16#include <lagrange/ui/types/ShaderLoader.h>
17
18namespace lagrange {
19namespace ui {
20
21
22class LA_UI_API Material
23{
24public:
25 Material(Registry& r, StringID shader_id, const ShaderDefines& shader_defines = {});
26
27 StringID shader_id() const;
28
29 std::unordered_map<StringID, int> int_values;
30 std::unordered_map<StringID, float> float_values;
31 std::unordered_map<StringID, bool> bool_values;
32 std::unordered_map<StringID, Color> color_values;
33 std::unordered_map<StringID, ShaderTextureValue> texture_values;
34 std::unordered_map<StringID, Eigen::Matrix4f> mat4_values;
35 std::unordered_map<StringID, std::vector<Eigen::Matrix4f>> mat4_array_values;
36 std::unordered_map<StringID, Eigen::Vector4f> vec4_values;
37 std::unordered_map<StringID, std::vector<Eigen::Vector4f>> vec4_array_values;
38
39 void set_vec4(const std::string& name, const Eigen::Vector4f& vec);
40 void set_vec4(StringID id, const Eigen::Vector4f& vec);
41 void set_vec4_array(const std::string& name, const Eigen::Vector4f* vectors, size_t N);
42 void set_vec4_array(StringID id, const Eigen::Vector4f* vectors, size_t N);
43
44 void set_mat4(const std::string& name, const Eigen::Matrix4f& matrix);
45 void set_mat4(StringID id, const Eigen::Matrix4f& matrix);
46 void set_mat4_array(const std::string& name, const Eigen::Matrix4f* matrices, size_t N);
47 void set_mat4_array(StringID id, const Eigen::Matrix4f* matrices, size_t N);
48
49 void set_color(const std::string& name, Color color);
50 void set_color(StringID id, Color color);
51 const Color get_color(StringID id);
52 const Color get_color(const std::string& name);
53 void set_texture(const std::string& name, std::shared_ptr<Texture> texture);
54 void set_texture(StringID id, std::shared_ptr<Texture> texture);
55 std::shared_ptr<Texture> get_texture(StringID id);
56 std::shared_ptr<Texture> get_texture(const std::string& name);
57
58 void set_float(const std::string& name, float value);
59 void set_float(StringID id, float value);
60 float get_float(StringID id);
61 float get_float(const std::string& name);
62
63 void set_int(const std::string& name, int value);
64 void set_int(StringID id, int value);
65
66 void set_bool(const std::string& name, bool value);
67 void set_bool(StringID id, bool value);
68
69
70private:
71 StringID m_shader_id;
72};
73
74} // namespace ui
75} // namespace lagrange
Definition: Color.h:24
Definition: Material.h:23
Lagrange UI Viewer and mini 3D engine.
Definition: AcceleratedPicking.h:22
Main namespace for Lagrange.
Definition: AABBIGL.h:30