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