Skip to content

Commit

Permalink
Add missing file.
Browse files Browse the repository at this point in the history
  • Loading branch information
kwokcb committed Sep 9, 2023
1 parent 722466e commit 74c00a9
Showing 1 changed file with 67 additions and 0 deletions.
67 changes: 67 additions & 0 deletions source/PyMaterialX/PyMaterialXRender/PyGltfMaterialHandler.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
//
// Copyright Bernard Kwok
// SPDX-License-Identifier: Apache-2.0
//

#include <PyMaterialX/PyMaterialX.h>
#include <MaterialXRender/GltfMaterialHandler.h>

namespace py = pybind11;
namespace mx = MaterialX;


class PyMaterialHandler : public mx::MaterialHandler
{
public:
PyMaterialHandler() :
mx::MaterialHandler()
{
}

bool load(const mx::FilePath& filePath, mx::StringVec& log) override
{
PYBIND11_OVERLOAD_PURE(
bool,
mx::MaterialHandler,
load,
filePath,
log
);
}

bool save(const mx::FilePath& filePath, mx::StringVec& log) override
{
PYBIND11_OVERLOAD_PURE(
bool,
mx::MaterialHandler,
save,
filePath,
log
);
}
};

void bindPyGltfMaterialHandler(py::module& mod)
{
py::class_<mx::MaterialHandler, PyMaterialHandler, mx::MaterialHandlerPtr>(mod, "MaterialHandler")
.def(py::init<>())
.def("load", &mx::MaterialHandler::load)
.def("save", &mx::MaterialHandler::save)
.def("extensionsSupported", &mx::MaterialHandler::extensionsSupported)
.def("setDefinitions", &mx::MaterialHandler::setDefinitions)
.def("getMaterials", &mx::MaterialHandler::getMaterials)
.def("setMaterials", &mx::MaterialHandler::setMaterials)
.def("setGenerateAssignments", &mx::MaterialHandler::setGenerateAssignments)
.def("getGenerateAssignments", &mx::MaterialHandler::getGenerateAssignments)
.def("setGenerateFullDefinitions", &mx::MaterialHandler::setGenerateFullDefinitions)
.def("getGenerateFullDefinitions", &mx::MaterialHandler::getGenerateFullDefinitions)
;

py::class_<mx::GltfMaterialHandler, mx::GltfMaterialHandlerPtr, mx::MaterialHandler>(mod, "GltfMaterialHandler")
.def_static("create", &mx::GltfMaterialHandler::create)
.def(py::init<>())
.def("load", &mx::GltfMaterialHandler::load)
.def("save", &mx::GltfMaterialHandler::save)
.def("translateShaders", &mx::GltfMaterialHandler::translateShaders)
;
}

0 comments on commit 74c00a9

Please sign in to comment.