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, CLOG_INFO(LOG_MATERIALX_SHADER,
2, 1,
"Material: %s\n%s", "Material: %s\n%s",
material->id.name, material->id.name,
MaterialX::writeToXmlString(doc).c_str()); MaterialX::writeToXmlString(doc).c_str());

View File

@ -617,6 +617,14 @@ NodeItem::Type NodeItem::type() const
return Type::Empty; 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) void NodeItem::set_input(const std::string &in_name, const NodeItem &item)
{ {
if (item.value) { if (item.value) {

View File

@ -97,6 +97,7 @@ class NodeItem {
NodeItem empty() const; NodeItem empty() const;
template<class T> NodeItem val(const T &data) const; template<class T> NodeItem val(const T &data) const;
Type type() const; Type type() const;
NodeItem create_node(const std::string &mx_category, NodeItem::Type type);
/* Functions to set input and output */ /* Functions to set input and output */
template<class T> template<class T>

View File

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