Blender  V3.3
obj_export_mtl.hh
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2 
7 #pragma once
8 
9 #include "BLI_map.hh"
10 #include "BLI_math_vec_types.hh"
11 
12 #include "DNA_node_types.h"
13 #include "obj_export_io.hh"
14 
15 namespace blender {
16 template<> struct DefaultHash<io::obj::eMTLSyntaxElement> {
18  {
19  return static_cast<uint64_t>(value);
20  }
21 };
22 
23 } // namespace blender
24 
25 namespace blender::io::obj {
26 
30 struct tex_map_XX {
31  tex_map_XX(StringRef to_socket_id) : dest_socket_id(to_socket_id){};
32  bool is_valid() const
33  {
34  return !image_path.empty();
35  }
36 
37  /* Target socket which this texture node connects to. */
38  const std::string dest_socket_id;
40  float3 scale{1.0f};
41  /* Only Flat and Sphere projections are supported. */
43  std::string image_path;
44  std::string mtl_dir_path;
45 };
46 
50 struct MTLMaterial {
52  {
60  }
61 
63  {
64  BLI_assert(texture_maps.contains(key));
65  return texture_maps.lookup(key);
66  }
68  {
69  BLI_assert(texture_maps.contains(key));
70  return texture_maps.lookup(key);
71  }
72 
73  std::string name;
74  /* Always check for negative values while importing or exporting. Use defaults if
75  * any value is negative. */
76  float Ns{-1.0f};
77  float3 Ka{-1.0f};
78  float3 Kd{-1.0f};
79  float3 Ks{-1.0f};
80  float3 Ke{-1.0f};
81  float Ni{-1.0f};
82  float d{-1.0f};
83  int illum{-1};
86  float map_Bump_strength{-1.0f};
87 };
88 
89 MTLMaterial mtlmaterial_for_material(const Material *material);
90 } // namespace blender::io::obj
#define BLI_assert(a)
Definition: BLI_assert.h:46
#define SHD_PROJ_FLAT
Material material
MTLMaterial mtlmaterial_for_material(const Material *material)
unsigned __int64 uint64_t
Definition: stdint.h:90
uint64_t operator()(const io::obj::eMTLSyntaxElement value) const
Map< const eMTLSyntaxElement, tex_map_XX > texture_maps
const tex_map_XX & tex_map_of_type(const eMTLSyntaxElement key) const
tex_map_XX & tex_map_of_type(const eMTLSyntaxElement key)
tex_map_XX(StringRef to_socket_id)
const std::string dest_socket_id