GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — pybind11 experiment. · ObjOne/tinyobjloader@88f0fa3

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • python
    • bindings.cc
    • cornell_box_multimaterial_output.json
    • howto.py
    • setup.py
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎python/bindings.cc‎

Copy file name to clipboard
+45Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
#include "pybind11/pybind11.h"
2+
#include "pybind11/stl.h"
3+
4+
#include "tiny_obj_loader.h"
5+
6+
7+
namespace py = pybind11;
8+
9+
using namespace tinyobj;
10+
11+
// Simple wrapper for LoadObj.
12+
// TODO(syoyo): Make it more pythonic.
13+
bool load_obj(attrib_t *attrib, std::vector<shape_t> *shapes,
14+
std::vector<material_t> *materials,
15+
std::string *warn, std::string *err,
16+
const std::string &filename,
17+
const std::string &mtl_basedir = "./",
18+
bool triangulate = true,
19+
bool default_vcols_fallback = true)
20+
{
21+
return LoadObj(attrib, shapes, materials, warn, err, filename.c_str(), mtl_basedir.c_str(), triangulate, default_vcols_fallback);
22+
}
23+
24+
// Simple wrapper for LoadMtl.
25+
// TODO(syoyo): Make it more pythonic.
26+
void load_mtl(std::map<std::string, int> *material_map,
27+
std::vector<material_t> *materials, std::istream *inStream,
28+
std::string *warning, std::string *err) {
29+
LoadMtl(material_map, materials, inStream, warning, err);
30+
}
31+
32+
33+
PYBIND11_MODULE(tinyobjloader, tobj_module)
34+
{
35+
tobj_module.doc() = "Python bindings for TinyObjLoader.";
36+
37+
// register struct
38+
py::class_<attrib_t>(tobj_module, "Attrib");
39+
py::class_<shape_t>(tobj_module, "Shape");
40+
py::class_<material_t>(tobj_module, "Material");
41+
42+
tobj_module.def("load_obj", &load_obj, "Load wavefront .obj file.");
43+
tobj_module.def("load_mtl", &load_mtl, "Load wavefront material file.");
44+
}
45+

0 commit comments

Comments
0 (0)
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.