1
1
Fork 0

Parsing Improvements #14

Merged
Bogdan Nagirniak merged 5 commits from matx-parsing-improvements into matx-export-material 2023-09-07 15:10:17 +02:00
4 changed files with 13 additions and 6 deletions
Showing only changes of commit 32369e5093 - Show all commits

View File

@ -32,7 +32,7 @@ MaterialX::DocumentPtr export_to_materialx(Depsgraph *depsgraph, Material *mater
}
CLOG_INFO(LOG_MATERIALX_SHADER,
2,
1,
"Material: %s\n%s",
material->id.name,
MaterialX::writeToXmlString(doc).c_str());

View File

@ -617,6 +617,14 @@ NodeItem::Type NodeItem::type() const
return Type::Empty;
}
NodeItem NodeItem::create_node(const std::string &mx_category, NodeItem::Type type)
{
std::string mx_type = this->type(type);
CLOG_INFO(LOG_MATERIALX_SHADER, 2, "%s, %s", mx_category.c_str(), mx_type.c_str());
node = graph_->addNode(mx_category, MaterialX::EMPTY_STRING, mx_type);
return *this;
}
void NodeItem::set_input(const std::string &in_name, const NodeItem &item)
{
if (item.value) {

View File

@ -97,14 +97,15 @@ class NodeItem {
NodeItem empty() const;
template<class T> NodeItem val(const T &data) const;
Type type() const;
NodeItem create_node(const std::string &mx_category, NodeItem::Type type);
/* Functions to set input and output */
template<class T>
void set_input(const std::string &in_name, const T &value, const std::string &in_type);
void set_input(const std::string &in_name, const NodeItem &item);
void set_input_output(const std::string &in_name,
const NodeItem &item,
const std::string &out_name);
const NodeItem &item,
const std::string &out_name);
void add_output(const std::string &in_name, Type out_type);
private:

View File

@ -41,9 +41,7 @@ std::string NodeParser::node_name()
NodeItem NodeParser::create_node(const std::string &mx_category, NodeItem::Type type)
{
NodeItem res = empty();
res.node = graph_->addNode(mx_category, MaterialX::EMPTY_STRING, NodeItem::type(type));
return res;
return empty().create_node(mx_category, type);
}
NodeItem NodeParser::get_input_default(const std::string &name, NodeItem::Type to_type)