Blender  V3.3
Materials.h
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2 
3 #pragma once
4 
5 #include <map>
6 #include <string>
7 
8 #include "BKE_context.h"
9 #include "BKE_node.h"
10 #include "BLI_listbase.h"
11 #include "DNA_material_types.h"
12 #include "DNA_node_types.h"
13 
14 #include "COLLADAFWEffectCommon.h"
15 #include "collada_utils.h"
16 
17 typedef std::map<std::string, bNode *> NodeMap;
18 
19 class MaterialNode {
20 
21  private:
22  bContext *mContext;
23  Material *material;
24  COLLADAFW::EffectCommon *effect;
25  UidImageMap *uid_image_map = nullptr;
26  KeyImageMap *key_image_map = nullptr;
27 
28  NodeMap node_map;
29  bNodeTree *ntree;
30 
31  bNode *shader_node;
32  bNode *output_node;
33 
35  bNodeTree *prepare_material_nodetree();
36  bNode *add_node(int node_type, int locx, int locy, std::string label);
37  void add_link(bNode *from_node, int from_index, bNode *to_node, int to_index);
38  void add_link(bNode *from_node, const char *from_label, bNode *to_node, const char *to_label);
39  bNode *add_texture_node(COLLADAFW::ColorOrTexture &cot, int locx, int locy, std::string label);
40  void setShaderType();
41 
42  public:
43  MaterialNode(bContext *C, COLLADAFW::EffectCommon *ef, Material *ma, UidImageMap &uid_image_map);
44  MaterialNode(bContext *C, Material *ma, KeyImageMap &key_image_map);
46 
47  void set_diffuse(COLLADAFW::ColorOrTexture &cot);
48  void set_specular(COLLADAFW::ColorOrTexture &cot);
49  void set_ambient(COLLADAFW::ColorOrTexture &cot);
50  void set_reflective(COLLADAFW::ColorOrTexture &cot);
51  void set_emission(COLLADAFW::ColorOrTexture &cot);
52  void set_opacity(COLLADAFW::ColorOrTexture &cot);
53  void set_reflectivity(COLLADAFW::FloatOrParam &val);
54  void set_shininess(COLLADAFW::FloatOrParam &val);
55  void set_ior(COLLADAFW::FloatOrParam &val);
56  void set_alpha(COLLADAFW::EffectCommon::OpaqueMode mode,
57  COLLADAFW::ColorOrTexture &cot,
58  COLLADAFW::FloatOrParam &val);
59 
61 };
std::map< std::string, bNode * > NodeMap
Definition: Materials.h:17
#define C
Definition: RandGen.cpp:25
void set_reflectivity(COLLADAFW::FloatOrParam &val)
Definition: Materials.cpp:136
void set_shininess(COLLADAFW::FloatOrParam &val)
void set_specular(COLLADAFW::ColorOrTexture &cot)
Definition: Materials.cpp:374
void update_material_nodetree()
Definition: Materials.cpp:95
void set_ior(COLLADAFW::FloatOrParam &val)
Definition: Materials.cpp:158
void set_reflective(COLLADAFW::ColorOrTexture &cot)
Definition: Materials.cpp:306
void set_emission(COLLADAFW::ColorOrTexture &cot)
Definition: Materials.cpp:322
Image * get_diffuse_image()
Definition: Materials.cpp:249
MaterialNode(bContext *C, COLLADAFW::EffectCommon *ef, Material *ma, UidImageMap &uid_image_map)
Definition: Materials.cpp:19
void set_opacity(COLLADAFW::ColorOrTexture &cot)
Definition: Materials.cpp:349
void set_alpha(COLLADAFW::EffectCommon::OpaqueMode mode, COLLADAFW::ColorOrTexture &cot, COLLADAFW::FloatOrParam &val)
Definition: Materials.cpp:172
void set_diffuse(COLLADAFW::ColorOrTexture &cot)
Definition: Materials.cpp:218
void set_ambient(COLLADAFW::ColorOrTexture &cot)
Definition: Materials.cpp:290
std::map< std::string, Image * > KeyImageMap
Definition: collada_utils.h:56
std::map< COLLADAFW::UniqueId, Image * > UidImageMap
Definition: collada_utils.h:55
const char * label