601
python/cornell_box_output.json
Normal file
601
python/cornell_box_output.json
Normal file
@@ -0,0 +1,601 @@
|
|||||||
|
{
|
||||||
|
"shapes": {
|
||||||
|
"ceiling": {
|
||||||
|
"texcoords": [],
|
||||||
|
"positions": [
|
||||||
|
556.0,
|
||||||
|
548.7999877929688,
|
||||||
|
0.0,
|
||||||
|
556.0,
|
||||||
|
548.7999877929688,
|
||||||
|
559.2000122070312,
|
||||||
|
0.0,
|
||||||
|
548.7999877929688,
|
||||||
|
559.2000122070312,
|
||||||
|
0.0,
|
||||||
|
548.7999877929688,
|
||||||
|
0.0
|
||||||
|
],
|
||||||
|
"indicies": [
|
||||||
|
0.0,
|
||||||
|
1.0,
|
||||||
|
2.0,
|
||||||
|
0.0,
|
||||||
|
2.0,
|
||||||
|
3.0
|
||||||
|
],
|
||||||
|
"material_ids": [
|
||||||
|
0.0,
|
||||||
|
0.0
|
||||||
|
],
|
||||||
|
"normals": []
|
||||||
|
},
|
||||||
|
"floor": {
|
||||||
|
"texcoords": [],
|
||||||
|
"positions": [
|
||||||
|
552.7999877929688,
|
||||||
|
0.0,
|
||||||
|
0.0,
|
||||||
|
0.0,
|
||||||
|
0.0,
|
||||||
|
0.0,
|
||||||
|
0.0,
|
||||||
|
0.0,
|
||||||
|
559.2000122070312,
|
||||||
|
549.5999755859375,
|
||||||
|
0.0,
|
||||||
|
559.2000122070312,
|
||||||
|
290.0,
|
||||||
|
0.0,
|
||||||
|
114.0,
|
||||||
|
240.0,
|
||||||
|
0.0,
|
||||||
|
272.0,
|
||||||
|
82.0,
|
||||||
|
0.0,
|
||||||
|
225.0,
|
||||||
|
130.0,
|
||||||
|
0.0,
|
||||||
|
65.0,
|
||||||
|
472.0,
|
||||||
|
0.0,
|
||||||
|
406.0,
|
||||||
|
314.0,
|
||||||
|
0.0,
|
||||||
|
456.0,
|
||||||
|
265.0,
|
||||||
|
0.0,
|
||||||
|
296.0,
|
||||||
|
423.0,
|
||||||
|
0.0,
|
||||||
|
247.0
|
||||||
|
],
|
||||||
|
"indicies": [
|
||||||
|
0.0,
|
||||||
|
1.0,
|
||||||
|
2.0,
|
||||||
|
0.0,
|
||||||
|
2.0,
|
||||||
|
3.0,
|
||||||
|
4.0,
|
||||||
|
5.0,
|
||||||
|
6.0,
|
||||||
|
4.0,
|
||||||
|
6.0,
|
||||||
|
7.0,
|
||||||
|
8.0,
|
||||||
|
9.0,
|
||||||
|
10.0,
|
||||||
|
8.0,
|
||||||
|
10.0,
|
||||||
|
11.0
|
||||||
|
],
|
||||||
|
"material_ids": [
|
||||||
|
0.0,
|
||||||
|
0.0,
|
||||||
|
0.0,
|
||||||
|
0.0,
|
||||||
|
0.0,
|
||||||
|
0.0
|
||||||
|
],
|
||||||
|
"normals": []
|
||||||
|
},
|
||||||
|
"light": {
|
||||||
|
"texcoords": [],
|
||||||
|
"positions": [
|
||||||
|
343.0,
|
||||||
|
548.0,
|
||||||
|
227.0,
|
||||||
|
343.0,
|
||||||
|
548.0,
|
||||||
|
332.0,
|
||||||
|
213.0,
|
||||||
|
548.0,
|
||||||
|
332.0,
|
||||||
|
213.0,
|
||||||
|
548.0,
|
||||||
|
227.0
|
||||||
|
],
|
||||||
|
"indicies": [
|
||||||
|
0.0,
|
||||||
|
1.0,
|
||||||
|
2.0,
|
||||||
|
0.0,
|
||||||
|
2.0,
|
||||||
|
3.0
|
||||||
|
],
|
||||||
|
"material_ids": [
|
||||||
|
4.0,
|
||||||
|
4.0
|
||||||
|
],
|
||||||
|
"normals": []
|
||||||
|
},
|
||||||
|
"green_wall": {
|
||||||
|
"texcoords": [],
|
||||||
|
"positions": [
|
||||||
|
0.0,
|
||||||
|
0.0,
|
||||||
|
559.2000122070312,
|
||||||
|
0.0,
|
||||||
|
0.0,
|
||||||
|
0.0,
|
||||||
|
0.0,
|
||||||
|
548.7999877929688,
|
||||||
|
0.0,
|
||||||
|
0.0,
|
||||||
|
548.7999877929688,
|
||||||
|
559.2000122070312
|
||||||
|
],
|
||||||
|
"indicies": [
|
||||||
|
0.0,
|
||||||
|
1.0,
|
||||||
|
2.0,
|
||||||
|
0.0,
|
||||||
|
2.0,
|
||||||
|
3.0
|
||||||
|
],
|
||||||
|
"material_ids": [
|
||||||
|
2.0,
|
||||||
|
2.0
|
||||||
|
],
|
||||||
|
"normals": []
|
||||||
|
},
|
||||||
|
"back_wall": {
|
||||||
|
"texcoords": [],
|
||||||
|
"positions": [
|
||||||
|
549.5999755859375,
|
||||||
|
0.0,
|
||||||
|
559.2000122070312,
|
||||||
|
0.0,
|
||||||
|
0.0,
|
||||||
|
559.2000122070312,
|
||||||
|
0.0,
|
||||||
|
548.7999877929688,
|
||||||
|
559.2000122070312,
|
||||||
|
556.0,
|
||||||
|
548.7999877929688,
|
||||||
|
559.2000122070312
|
||||||
|
],
|
||||||
|
"indicies": [
|
||||||
|
0.0,
|
||||||
|
1.0,
|
||||||
|
2.0,
|
||||||
|
0.0,
|
||||||
|
2.0,
|
||||||
|
3.0
|
||||||
|
],
|
||||||
|
"material_ids": [
|
||||||
|
0.0,
|
||||||
|
0.0
|
||||||
|
],
|
||||||
|
"normals": []
|
||||||
|
},
|
||||||
|
"short_block": {
|
||||||
|
"texcoords": [],
|
||||||
|
"positions": [
|
||||||
|
130.0,
|
||||||
|
165.0,
|
||||||
|
65.0,
|
||||||
|
82.0,
|
||||||
|
165.0,
|
||||||
|
225.0,
|
||||||
|
240.0,
|
||||||
|
165.0,
|
||||||
|
272.0,
|
||||||
|
290.0,
|
||||||
|
165.0,
|
||||||
|
114.0,
|
||||||
|
290.0,
|
||||||
|
0.0,
|
||||||
|
114.0,
|
||||||
|
290.0,
|
||||||
|
165.0,
|
||||||
|
114.0,
|
||||||
|
240.0,
|
||||||
|
165.0,
|
||||||
|
272.0,
|
||||||
|
240.0,
|
||||||
|
0.0,
|
||||||
|
272.0,
|
||||||
|
130.0,
|
||||||
|
0.0,
|
||||||
|
65.0,
|
||||||
|
130.0,
|
||||||
|
165.0,
|
||||||
|
65.0,
|
||||||
|
290.0,
|
||||||
|
165.0,
|
||||||
|
114.0,
|
||||||
|
290.0,
|
||||||
|
0.0,
|
||||||
|
114.0,
|
||||||
|
82.0,
|
||||||
|
0.0,
|
||||||
|
225.0,
|
||||||
|
82.0,
|
||||||
|
165.0,
|
||||||
|
225.0,
|
||||||
|
130.0,
|
||||||
|
165.0,
|
||||||
|
65.0,
|
||||||
|
130.0,
|
||||||
|
0.0,
|
||||||
|
65.0,
|
||||||
|
240.0,
|
||||||
|
0.0,
|
||||||
|
272.0,
|
||||||
|
240.0,
|
||||||
|
165.0,
|
||||||
|
272.0,
|
||||||
|
82.0,
|
||||||
|
165.0,
|
||||||
|
225.0,
|
||||||
|
82.0,
|
||||||
|
0.0,
|
||||||
|
225.0
|
||||||
|
],
|
||||||
|
"indicies": [
|
||||||
|
0.0,
|
||||||
|
1.0,
|
||||||
|
2.0,
|
||||||
|
0.0,
|
||||||
|
2.0,
|
||||||
|
3.0,
|
||||||
|
4.0,
|
||||||
|
5.0,
|
||||||
|
6.0,
|
||||||
|
4.0,
|
||||||
|
6.0,
|
||||||
|
7.0,
|
||||||
|
8.0,
|
||||||
|
9.0,
|
||||||
|
10.0,
|
||||||
|
8.0,
|
||||||
|
10.0,
|
||||||
|
11.0,
|
||||||
|
12.0,
|
||||||
|
13.0,
|
||||||
|
14.0,
|
||||||
|
12.0,
|
||||||
|
14.0,
|
||||||
|
15.0,
|
||||||
|
16.0,
|
||||||
|
17.0,
|
||||||
|
18.0,
|
||||||
|
16.0,
|
||||||
|
18.0,
|
||||||
|
19.0
|
||||||
|
],
|
||||||
|
"material_ids": [
|
||||||
|
0.0,
|
||||||
|
0.0,
|
||||||
|
0.0,
|
||||||
|
0.0,
|
||||||
|
0.0,
|
||||||
|
0.0,
|
||||||
|
0.0,
|
||||||
|
0.0,
|
||||||
|
0.0,
|
||||||
|
0.0
|
||||||
|
],
|
||||||
|
"normals": []
|
||||||
|
},
|
||||||
|
"tall_block": {
|
||||||
|
"texcoords": [],
|
||||||
|
"positions": [
|
||||||
|
423.0,
|
||||||
|
0.0,
|
||||||
|
247.0,
|
||||||
|
423.0,
|
||||||
|
330.0,
|
||||||
|
247.0,
|
||||||
|
472.0,
|
||||||
|
330.0,
|
||||||
|
406.0,
|
||||||
|
472.0,
|
||||||
|
0.0,
|
||||||
|
406.0,
|
||||||
|
472.0,
|
||||||
|
0.0,
|
||||||
|
406.0,
|
||||||
|
472.0,
|
||||||
|
330.0,
|
||||||
|
406.0,
|
||||||
|
314.0,
|
||||||
|
330.0,
|
||||||
|
456.0,
|
||||||
|
314.0,
|
||||||
|
0.0,
|
||||||
|
456.0,
|
||||||
|
314.0,
|
||||||
|
0.0,
|
||||||
|
456.0,
|
||||||
|
314.0,
|
||||||
|
330.0,
|
||||||
|
456.0,
|
||||||
|
265.0,
|
||||||
|
330.0,
|
||||||
|
296.0,
|
||||||
|
265.0,
|
||||||
|
0.0,
|
||||||
|
296.0,
|
||||||
|
265.0,
|
||||||
|
0.0,
|
||||||
|
296.0,
|
||||||
|
265.0,
|
||||||
|
330.0,
|
||||||
|
296.0,
|
||||||
|
423.0,
|
||||||
|
330.0,
|
||||||
|
247.0,
|
||||||
|
423.0,
|
||||||
|
0.0,
|
||||||
|
247.0
|
||||||
|
],
|
||||||
|
"indicies": [
|
||||||
|
0.0,
|
||||||
|
1.0,
|
||||||
|
2.0,
|
||||||
|
0.0,
|
||||||
|
2.0,
|
||||||
|
3.0,
|
||||||
|
4.0,
|
||||||
|
5.0,
|
||||||
|
6.0,
|
||||||
|
4.0,
|
||||||
|
6.0,
|
||||||
|
7.0,
|
||||||
|
8.0,
|
||||||
|
9.0,
|
||||||
|
10.0,
|
||||||
|
8.0,
|
||||||
|
10.0,
|
||||||
|
11.0,
|
||||||
|
12.0,
|
||||||
|
13.0,
|
||||||
|
14.0,
|
||||||
|
12.0,
|
||||||
|
14.0,
|
||||||
|
15.0
|
||||||
|
],
|
||||||
|
"material_ids": [
|
||||||
|
0.0,
|
||||||
|
0.0,
|
||||||
|
0.0,
|
||||||
|
0.0,
|
||||||
|
0.0,
|
||||||
|
0.0,
|
||||||
|
0.0,
|
||||||
|
0.0
|
||||||
|
],
|
||||||
|
"normals": []
|
||||||
|
},
|
||||||
|
"red_wall": {
|
||||||
|
"texcoords": [],
|
||||||
|
"positions": [
|
||||||
|
552.7999877929688,
|
||||||
|
0.0,
|
||||||
|
0.0,
|
||||||
|
549.5999755859375,
|
||||||
|
0.0,
|
||||||
|
559.2000122070312,
|
||||||
|
556.0,
|
||||||
|
548.7999877929688,
|
||||||
|
559.2000122070312,
|
||||||
|
556.0,
|
||||||
|
548.7999877929688,
|
||||||
|
0.0
|
||||||
|
],
|
||||||
|
"indicies": [
|
||||||
|
0.0,
|
||||||
|
1.0,
|
||||||
|
2.0,
|
||||||
|
0.0,
|
||||||
|
2.0,
|
||||||
|
3.0
|
||||||
|
],
|
||||||
|
"material_ids": [
|
||||||
|
1.0,
|
||||||
|
1.0
|
||||||
|
],
|
||||||
|
"normals": []
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"materials": {
|
||||||
|
"blue": {
|
||||||
|
"transmittance": [
|
||||||
|
0.0,
|
||||||
|
0.0,
|
||||||
|
0.0
|
||||||
|
],
|
||||||
|
"illum": 0,
|
||||||
|
"emission": [
|
||||||
|
0.0,
|
||||||
|
0.0,
|
||||||
|
0.0
|
||||||
|
],
|
||||||
|
"diffuse_texname": "",
|
||||||
|
"ambient_texname": "",
|
||||||
|
"normal_texname": "",
|
||||||
|
"shininess": 1.0,
|
||||||
|
"ior": 1.0,
|
||||||
|
"specular": [
|
||||||
|
0.0,
|
||||||
|
0.0,
|
||||||
|
0.0
|
||||||
|
],
|
||||||
|
"specular_texname": "",
|
||||||
|
"diffuse": [
|
||||||
|
0.0,
|
||||||
|
0.0,
|
||||||
|
1.0
|
||||||
|
],
|
||||||
|
"ambient": [
|
||||||
|
0.0,
|
||||||
|
0.0,
|
||||||
|
0.0
|
||||||
|
],
|
||||||
|
"dissolve": 1.0
|
||||||
|
},
|
||||||
|
"light": {
|
||||||
|
"transmittance": [
|
||||||
|
0.0,
|
||||||
|
0.0,
|
||||||
|
0.0
|
||||||
|
],
|
||||||
|
"illum": 0,
|
||||||
|
"emission": [
|
||||||
|
0.0,
|
||||||
|
0.0,
|
||||||
|
0.0
|
||||||
|
],
|
||||||
|
"diffuse_texname": "",
|
||||||
|
"ambient_texname": "",
|
||||||
|
"normal_texname": "",
|
||||||
|
"shininess": 1.0,
|
||||||
|
"ior": 1.0,
|
||||||
|
"specular": [
|
||||||
|
0.0,
|
||||||
|
0.0,
|
||||||
|
0.0
|
||||||
|
],
|
||||||
|
"specular_texname": "",
|
||||||
|
"diffuse": [
|
||||||
|
1.0,
|
||||||
|
1.0,
|
||||||
|
1.0
|
||||||
|
],
|
||||||
|
"ambient": [
|
||||||
|
20.0,
|
||||||
|
20.0,
|
||||||
|
20.0
|
||||||
|
],
|
||||||
|
"dissolve": 1.0
|
||||||
|
},
|
||||||
|
"white": {
|
||||||
|
"transmittance": [
|
||||||
|
0.0,
|
||||||
|
0.0,
|
||||||
|
0.0
|
||||||
|
],
|
||||||
|
"illum": 0,
|
||||||
|
"emission": [
|
||||||
|
0.0,
|
||||||
|
0.0,
|
||||||
|
0.0
|
||||||
|
],
|
||||||
|
"diffuse_texname": "",
|
||||||
|
"ambient_texname": "",
|
||||||
|
"normal_texname": "",
|
||||||
|
"shininess": 1.0,
|
||||||
|
"ior": 1.0,
|
||||||
|
"specular": [
|
||||||
|
0.0,
|
||||||
|
0.0,
|
||||||
|
0.0
|
||||||
|
],
|
||||||
|
"specular_texname": "",
|
||||||
|
"diffuse": [
|
||||||
|
1.0,
|
||||||
|
1.0,
|
||||||
|
1.0
|
||||||
|
],
|
||||||
|
"ambient": [
|
||||||
|
0.0,
|
||||||
|
0.0,
|
||||||
|
0.0
|
||||||
|
],
|
||||||
|
"dissolve": 1.0
|
||||||
|
},
|
||||||
|
"green": {
|
||||||
|
"transmittance": [
|
||||||
|
0.0,
|
||||||
|
0.0,
|
||||||
|
0.0
|
||||||
|
],
|
||||||
|
"illum": 0,
|
||||||
|
"emission": [
|
||||||
|
0.0,
|
||||||
|
0.0,
|
||||||
|
0.0
|
||||||
|
],
|
||||||
|
"diffuse_texname": "",
|
||||||
|
"ambient_texname": "",
|
||||||
|
"normal_texname": "",
|
||||||
|
"shininess": 1.0,
|
||||||
|
"ior": 1.0,
|
||||||
|
"specular": [
|
||||||
|
0.0,
|
||||||
|
0.0,
|
||||||
|
0.0
|
||||||
|
],
|
||||||
|
"specular_texname": "",
|
||||||
|
"diffuse": [
|
||||||
|
0.0,
|
||||||
|
1.0,
|
||||||
|
0.0
|
||||||
|
],
|
||||||
|
"ambient": [
|
||||||
|
0.0,
|
||||||
|
0.0,
|
||||||
|
0.0
|
||||||
|
],
|
||||||
|
"dissolve": 1.0
|
||||||
|
},
|
||||||
|
"red": {
|
||||||
|
"transmittance": [
|
||||||
|
0.0,
|
||||||
|
0.0,
|
||||||
|
0.0
|
||||||
|
],
|
||||||
|
"illum": 0,
|
||||||
|
"emission": [
|
||||||
|
0.0,
|
||||||
|
0.0,
|
||||||
|
0.0
|
||||||
|
],
|
||||||
|
"diffuse_texname": "",
|
||||||
|
"ambient_texname": "",
|
||||||
|
"normal_texname": "",
|
||||||
|
"shininess": 1.0,
|
||||||
|
"ior": 1.0,
|
||||||
|
"specular": [
|
||||||
|
0.0,
|
||||||
|
0.0,
|
||||||
|
0.0
|
||||||
|
],
|
||||||
|
"specular_texname": "",
|
||||||
|
"diffuse": [
|
||||||
|
1.0,
|
||||||
|
0.0,
|
||||||
|
0.0
|
||||||
|
],
|
||||||
|
"ambient": [
|
||||||
|
0.0,
|
||||||
|
0.0,
|
||||||
|
0.0
|
||||||
|
],
|
||||||
|
"dissolve": 1.0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,5 +1,11 @@
|
|||||||
import tinyobjloader as tol
|
import tinyobjloader as tol
|
||||||
|
import json
|
||||||
|
|
||||||
|
model = tol.LoadObj("cornell_box.obj")
|
||||||
|
|
||||||
|
#print(model["shapes"], model["materials"])
|
||||||
|
print( json.dumps(model, indent=4) )
|
||||||
|
|
||||||
|
#see cornell_box_output.json
|
||||||
|
|
||||||
model = tol.LoadObj("cube.obj")
|
|
||||||
|
|
||||||
print(model["shapes"], model["materials"])
|
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
// model = tol.LoadObj(name)
|
// model = tol.LoadObj(name)
|
||||||
// print(model["shapes"])
|
// print(model["shapes"])
|
||||||
// print(model["materials"]
|
// print(model["materials"]
|
||||||
|
|
||||||
#include <Python.h>
|
#include <Python.h>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include "../tiny_obj_loader.h"
|
#include "../tiny_obj_loader.h"
|
||||||
@@ -30,8 +31,13 @@ extern "C"
|
|||||||
static PyObject*
|
static PyObject*
|
||||||
pyLoadObj(PyObject* self, PyObject* args)
|
pyLoadObj(PyObject* self, PyObject* args)
|
||||||
{
|
{
|
||||||
PyObject *rtntpl, *pyshapes, *pymaterials;
|
PyObject *rtndict, *pyshapes, *pymaterials,
|
||||||
|
*current, *meshobj;
|
||||||
|
|
||||||
char const* filename;
|
char const* filename;
|
||||||
|
char *current_name;
|
||||||
|
vectd vect;
|
||||||
|
|
||||||
std::vector<tinyobj::shape_t> shapes;
|
std::vector<tinyobj::shape_t> shapes;
|
||||||
std::vector<tinyobj::material_t> materials;
|
std::vector<tinyobj::material_t> materials;
|
||||||
|
|
||||||
@@ -42,48 +48,46 @@ pyLoadObj(PyObject* self, PyObject* args)
|
|||||||
|
|
||||||
pyshapes = PyDict_New();
|
pyshapes = PyDict_New();
|
||||||
pymaterials = PyDict_New();
|
pymaterials = PyDict_New();
|
||||||
rtntpl = PyDict_New();
|
rtndict = PyDict_New();
|
||||||
|
|
||||||
for (std::vector<tinyobj::shape_t>::iterator shape = shapes.begin() ;
|
for (std::vector<tinyobj::shape_t>::iterator shape = shapes.begin() ;
|
||||||
shape != shapes.end(); shape++)
|
shape != shapes.end(); shape++)
|
||||||
{
|
{
|
||||||
PyObject *meshobj;
|
meshobj = PyDict_New();
|
||||||
PyObject *positions, *normals, *texcoords, *indices, *material_ids;
|
|
||||||
|
|
||||||
meshobj = PyTuple_New(5);
|
|
||||||
positions = PyList_New(0);
|
|
||||||
normals = PyList_New(0);
|
|
||||||
texcoords = PyList_New(0);
|
|
||||||
indices = PyList_New(0);
|
|
||||||
material_ids = PyList_New(0);
|
|
||||||
|
|
||||||
tinyobj::mesh_t cm = (*shape).mesh;
|
tinyobj::mesh_t cm = (*shape).mesh;
|
||||||
for (int i = 0; i <= 4 ; i++ )
|
|
||||||
|
for (int i = 0; i <= 4; i++ )
|
||||||
{
|
{
|
||||||
PyObject *current;
|
current = PyList_New(0);
|
||||||
vectd vect;
|
|
||||||
|
|
||||||
switch (i)
|
switch(i) {
|
||||||
{
|
|
||||||
case 0: current = positions;
|
case 0:
|
||||||
vect = vectd(cm.positions.begin(), cm.positions.end());
|
current_name = "positions";
|
||||||
case 1: current = normals;
|
vect = vectd(cm.positions.begin(), cm.positions.end()); break;
|
||||||
vect = vectd(cm.normals.begin(), cm.normals.end());
|
case 1:
|
||||||
case 2: current = texcoords;
|
current_name = "normals";
|
||||||
vect = vectd(cm.texcoords.begin(), cm.texcoords.end());
|
vect = vectd(cm.normals.begin(), cm.normals.end()); break;
|
||||||
case 3: current = indices;
|
case 2:
|
||||||
vect = vectd(cm.indices.begin(), cm.indices.end());
|
current_name = "texcoords";
|
||||||
case 4: current = material_ids;
|
vect = vectd(cm.texcoords.begin(), cm.texcoords.end()); break;
|
||||||
vect = vectd(cm.material_ids.begin(), cm.material_ids.end());
|
case 3:
|
||||||
|
current_name = "indicies";
|
||||||
|
vect = vectd(cm.indices.begin(), cm.indices.end()); break;
|
||||||
|
case 4:
|
||||||
|
current_name = "material_ids";
|
||||||
|
vect = vectd(cm.material_ids.begin(), cm.material_ids.end()); break;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for (std::vector<double>::iterator it = vect.begin() ;
|
for (vectd::iterator it = vect.begin() ;
|
||||||
it != vect.end(); it++)
|
it != vect.end(); it++)
|
||||||
{
|
{
|
||||||
PyList_Insert(current, it - vect.begin(), PyFloat_FromDouble(*it));
|
PyList_Insert(current, it - vect.begin(), PyFloat_FromDouble(*it));
|
||||||
}
|
}
|
||||||
|
|
||||||
PyTuple_SetItem(meshobj, i, current);
|
PyDict_SetItemString(meshobj, current_name, current);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
PyDict_SetItemString(pyshapes, (*shape).name.c_str(), meshobj);
|
PyDict_SetItemString(pyshapes, (*shape).name.c_str(), meshobj);
|
||||||
@@ -111,10 +115,10 @@ pyLoadObj(PyObject* self, PyObject* args)
|
|||||||
PyDict_SetItemString(pymaterials, (*mat).name.c_str(), matobj);
|
PyDict_SetItemString(pymaterials, (*mat).name.c_str(), matobj);
|
||||||
}
|
}
|
||||||
|
|
||||||
PyDict_SetItemString(rtntpl, "shapes", pyshapes);
|
PyDict_SetItemString(rtndict, "shapes", pyshapes);
|
||||||
PyDict_SetItemString(rtntpl, "materials", pymaterials);
|
PyDict_SetItemString(rtndict, "materials", pymaterials);
|
||||||
|
|
||||||
return rtntpl;
|
return rtndict;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
13
python/setup.py
Normal file
13
python/setup.py
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
from distutils.core import setup, Extension
|
||||||
|
|
||||||
|
|
||||||
|
m = Extension('tinyobjloader',
|
||||||
|
sources = ['main.cpp', '../tiny_obj_loader.cc'])
|
||||||
|
|
||||||
|
|
||||||
|
setup (name = 'tinyobjloader',
|
||||||
|
version = '0.1',
|
||||||
|
description = 'Python module for tinyobjloader',
|
||||||
|
ext_modules = [m])
|
||||||
|
|
||||||
|
|
||||||
Reference in New Issue
Block a user