Blender  V3.3
obj_import_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 <array>
10 
11 #include "BLI_map.hh"
12 #include "BLI_math_vec_types.hh"
13 #include "BLI_string_ref.hh"
14 #include "BLI_vector.hh"
15 
16 #include "DNA_node_types.h"
17 
18 #include "MEM_guardedalloc.h"
19 
20 #include "obj_export_mtl.hh"
21 
22 namespace blender::io::obj {
23 
25  void operator()(bNodeTree *node);
26 };
27 
28 using unique_nodetree_ptr = std::unique_ptr<bNodeTree, UniqueNodetreeDeleter>;
29 
31  private:
32  /* Node arrangement:
33  * Texture Coordinates -> Mapping -> Image Texture -> (optional) Normal Map -> p-BSDF -> Material
34  * Output. */
35  unique_nodetree_ptr nodetree_;
36  bNode *bsdf_;
37  bNode *shader_output_;
38  const MTLMaterial &mtl_mat_;
39 
40  /* List of all locations occupied by nodes. */
41  Vector<std::array<int, 2>> node_locations;
42  const float node_size_{300.f};
43 
44  public:
49  ShaderNodetreeWrap(Main *bmain, const MTLMaterial &mtl_mat, Material *mat, bool relative_paths);
51 
57 
58  private:
63  bNode *add_node_to_tree(const int node_type);
68  std::pair<float, float> set_node_locations(const int pos_x);
74  void link_sockets(bNode *from_node,
75  StringRef from_node_id,
76  bNode *to_node,
77  StringRef to_node_id,
78  const int from_node_pos_x);
82  void set_bsdf_socket_values(Material *mat);
87  void add_image_textures(Main *bmain, Material *mat, bool relative_paths);
88 };
89 
90 } // namespace blender::io::obj
Read Guarded memory(de)allocation.
ShaderNodetreeWrap(Main *bmain, const MTLMaterial &mtl_mat, Material *mat, bool relative_paths)
OperationNode * node
std::unique_ptr< bNodeTree, UniqueNodetreeDeleter > unique_nodetree_ptr
Definition: BKE_main.h:121