This commit is contained in:
Olivier
2015-10-21 03:23:06 +02:00
parent 475bc83ef3
commit fcad68bf2d
5 changed files with 599 additions and 706 deletions

View File

@@ -0,0 +1,581 @@
{
"shapes": {
"back_wall": {
"material_ids": [
0.0,
0.0
],
"normals": [],
"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
],
"texcoords": []
},
"floor": {
"material_ids": [
0.0,
0.0,
0.0,
0.0,
0.0,
0.0
],
"normals": [],
"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
],
"texcoords": []
},
"red_wall": {
"material_ids": [
1.0,
1.0
],
"normals": [],
"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
],
"texcoords": []
},
"light": {
"material_ids": [
4.0,
4.0
],
"normals": [],
"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
],
"texcoords": []
},
"tall_block": {
"material_ids": [
2.0,
2.0,
2.0,
2.0
],
"normals": [],
"positions": [
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
],
"texcoords": []
},
"short_block": {
"material_ids": [
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
0.0
],
"normals": [],
"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
],
"texcoords": []
},
"green_wall": {
"material_ids": [
2.0,
2.0
],
"normals": [],
"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
],
"texcoords": []
},
"ceiling": {
"material_ids": [
0.0,
0.0
],
"normals": [],
"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
],
"texcoords": []
}
},
"materials": {
"blue": {
"diffuse_texname": "",
"ambient_texname": "",
"illum": 0,
"displacement_texname": "",
"alpha_texname": "",
"emission": [
0.0,
0.0,
0.0
],
"transmittance": [
0.0,
0.0,
0.0
],
"ambient": [
0.0,
0.0,
0.0
],
"bump_texname": "",
"diffuse": [
0.0,
0.0,
1.0
],
"shininess": 1.0,
"specular_highlight_texname": "",
"unknown_parameter": {},
"ior": 1.0,
"dissolve": 1.0,
"specular": [
0.0,
0.0,
0.0
],
"specular_texname": ""
},
"white": {
"diffuse_texname": "",
"ambient_texname": "",
"illum": 0,
"displacement_texname": "",
"alpha_texname": "",
"emission": [
0.0,
0.0,
0.0
],
"transmittance": [
0.0,
0.0,
0.0
],
"ambient": [
0.0,
0.0,
0.0
],
"bump_texname": "",
"diffuse": [
1.0,
1.0,
1.0
],
"shininess": 1.0,
"specular_highlight_texname": "",
"unknown_parameter": {},
"ior": 1.0,
"dissolve": 1.0,
"specular": [
0.0,
0.0,
0.0
],
"specular_texname": ""
},
"red": {
"diffuse_texname": "",
"ambient_texname": "",
"illum": 0,
"displacement_texname": "",
"alpha_texname": "",
"emission": [
0.0,
0.0,
0.0
],
"transmittance": [
0.0,
0.0,
0.0
],
"ambient": [
0.0,
0.0,
0.0
],
"bump_texname": "",
"diffuse": [
1.0,
0.0,
0.0
],
"shininess": 1.0,
"specular_highlight_texname": "",
"unknown_parameter": {},
"ior": 1.0,
"dissolve": 1.0,
"specular": [
0.0,
0.0,
0.0
],
"specular_texname": ""
},
"light": {
"diffuse_texname": "",
"ambient_texname": "",
"illum": 0,
"displacement_texname": "",
"alpha_texname": "",
"emission": [
0.0,
0.0,
0.0
],
"transmittance": [
0.0,
0.0,
0.0
],
"ambient": [
20.0,
20.0,
20.0
],
"bump_texname": "",
"diffuse": [
1.0,
1.0,
1.0
],
"shininess": 1.0,
"specular_highlight_texname": "",
"unknown_parameter": {},
"ior": 1.0,
"dissolve": 1.0,
"specular": [
0.0,
0.0,
0.0
],
"specular_texname": ""
},
"green": {
"diffuse_texname": "",
"ambient_texname": "",
"illum": 0,
"displacement_texname": "",
"alpha_texname": "",
"emission": [
0.0,
0.0,
0.0
],
"transmittance": [
0.0,
0.0,
0.0
],
"ambient": [
0.0,
0.0,
0.0
],
"bump_texname": "",
"diffuse": [
0.0,
1.0,
0.0
],
"shininess": 1.0,
"specular_highlight_texname": "",
"unknown_parameter": {},
"ior": 1.0,
"dissolve": 1.0,
"specular": [
0.0,
0.0,
0.0
],
"specular_texname": ""
}
}
}

View File

@@ -1,601 +0,0 @@
{
"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
}
}
}

View File

@@ -1,11 +1,9 @@
import tinyobjloader as tol
import json
model = tol.LoadObj("cornell_box.obj")
model = tol.LoadObj("cornell_box_multimaterial.obj")
#print(model["shapes"], model["materials"])
print( json.dumps(model, indent=4) )
#see cornell_box_output.json

View File

@@ -97,6 +97,13 @@ pyLoadObj(PyObject* self, PyObject* args)
mat != materials.end(); mat++)
{
PyObject *matobj = PyDict_New();
PyObject *unknown_parameter = PyDict_New();
for (std::map<std::string, std::string>::iterator p = (*mat).unknown_parameter.begin() ;
p != (*mat).unknown_parameter.end(); ++p)
{
PyDict_SetItemString(unknown_parameter, p->first.c_str(), PyUnicode_FromString(p->second.c_str()));
}
PyDict_SetItemString(matobj, "shininess", PyFloat_FromDouble((*mat).shininess));
PyDict_SetItemString(matobj, "ior", PyFloat_FromDouble((*mat).ior));
@@ -105,12 +112,16 @@ pyLoadObj(PyObject* self, PyObject* args)
PyDict_SetItemString(matobj, "ambient_texname", PyUnicode_FromString((*mat).ambient_texname.c_str()));
PyDict_SetItemString(matobj, "diffuse_texname", PyUnicode_FromString((*mat).diffuse_texname.c_str()));
PyDict_SetItemString(matobj, "specular_texname", PyUnicode_FromString((*mat).specular_texname.c_str()));
PyDict_SetItemString(matobj, "normal_texname", PyUnicode_FromString((*mat).normal_texname.c_str()));
PyDict_SetItemString(matobj, "specular_highlight_texname", PyUnicode_FromString((*mat).specular_highlight_texname.c_str()));
PyDict_SetItemString(matobj, "bump_texname", PyUnicode_FromString((*mat).bump_texname.c_str()));
PyDict_SetItemString(matobj, "displacement_texname", PyUnicode_FromString((*mat).displacement_texname.c_str()));
PyDict_SetItemString(matobj, "alpha_texname", PyUnicode_FromString((*mat).alpha_texname.c_str()));
PyDict_SetItemString(matobj, "ambient", pyTupleFromfloat3((*mat).ambient));
PyDict_SetItemString(matobj, "diffuse", pyTupleFromfloat3((*mat).diffuse));
PyDict_SetItemString(matobj, "specular", pyTupleFromfloat3((*mat).specular));
PyDict_SetItemString(matobj, "transmittance", pyTupleFromfloat3((*mat).transmittance));
PyDict_SetItemString(matobj, "emission", pyTupleFromfloat3((*mat).emission));
PyDict_SetItemString(matobj, "unknown_parameter", unknown_parameter);
PyDict_SetItemString(pymaterials, (*mat).name.c_str(), matobj);
}

View File

@@ -1,96 +0,0 @@
#------------------------------------------------------------------------------#
# This makefile was generated by 'cbp2make' tool rev.147 #
#------------------------------------------------------------------------------#
WORKDIR = `pwd`
CC = gcc
CXX = g++
AR = ar
LD = g++
WINDRES = windres
INC =
CFLAGS = -Wall -fexceptions `python3-config --cflags`
RESINC =
LIBDIR =
LIB =
LDFLAGS = `python3-config --ldflags`
INC_DEBUG = $(INC)
CFLAGS_DEBUG = $(CFLAGS) -g
RESINC_DEBUG = $(RESINC)
RCFLAGS_DEBUG = $(RCFLAGS)
LIBDIR_DEBUG = $(LIBDIR)
LIB_DEBUG = $(LIB)
LDFLAGS_DEBUG = $(LDFLAGS)
OBJDIR_DEBUG = obj/Debug
DEP_DEBUG =
OUT_DEBUG = bin/Debug/tinyobjloader.so
INC_RELEASE = $(INC)
CFLAGS_RELEASE = $(CFLAGS) -O2
RESINC_RELEASE = $(RESINC)
RCFLAGS_RELEASE = $(RCFLAGS)
LIBDIR_RELEASE = $(LIBDIR)
LIB_RELEASE = $(LIB)
LDFLAGS_RELEASE = $(LDFLAGS) -s
OBJDIR_RELEASE = obj/Release
DEP_RELEASE =
OUT_RELEASE = bin/Release/tinyobjloader.so
OBJ_DEBUG = $(OBJDIR_DEBUG)/main.o $(OBJDIR_DEBUG)/tiny_obj_loader.o
OBJ_RELEASE = $(OBJDIR_RELEASE)/main.o $(OBJDIR_RELEASE)/tiny_obj_loader.o
all: debug release
clean: clean_debug clean_release
before_debug:
test -d bin/Debug || mkdir -p bin/Debug
test -d $(OBJDIR_DEBUG) || mkdir -p $(OBJDIR_DEBUG)
after_debug:
debug: before_debug out_debug after_debug
out_debug: before_debug $(OBJ_DEBUG) $(DEP_DEBUG)
$(LD) -shared $(LIBDIR_DEBUG) $(OBJ_DEBUG) -o $(OUT_DEBUG) $(LDFLAGS_DEBUG) $(LIB_DEBUG)
$(OBJDIR_DEBUG)/main.o: main.cpp
$(CXX) $(CFLAGS_DEBUG) $(INC_DEBUG) -c main.cpp -o $(OBJDIR_DEBUG)/main.o
$(OBJDIR_DEBUG)/tiny_obj_loader.o: ../tiny_obj_loader.cc
$(CC) $(CFLAGS_DEBUG) $(INC_DEBUG) -c ../tiny_obj_loader.cc -o $(OBJDIR_DEBUG)/tiny_obj_loader.o
clean_debug:
rm -f $(OBJ_DEBUG) $(OUT_DEBUG)
rm -rf bin/Debug
rm -rf $(OBJDIR_DEBUG)
before_release:
test -d bin/Release || mkdir -p bin/Release
test -d $(OBJDIR_RELEASE) || mkdir -p $(OBJDIR_RELEASE)
after_release:
release: before_release out_release after_release
out_release: before_release $(OBJ_RELEASE) $(DEP_RELEASE)
$(LD) -shared $(LIBDIR_RELEASE) $(OBJ_RELEASE) -o $(OUT_RELEASE) $(LDFLAGS_RELEASE) $(LIB_RELEASE)
$(OBJDIR_RELEASE)/main.o: main.cpp
$(CXX) $(CFLAGS_RELEASE) $(INC_RELEASE) -c main.cpp -o $(OBJDIR_RELEASE)/main.o
$(OBJDIR_RELEASE)/tiny_obj_loader.o: ../tiny_obj_loader.cc
$(CC) $(CFLAGS_RELEASE) $(INC_RELEASE) -c ../tiny_obj_loader.cc -o $(OBJDIR_RELEASE)/tiny_obj_loader.o
clean_release:
rm -f $(OBJ_RELEASE) $(OUT_RELEASE)
rm -rf bin/Release
rm -rf $(OBJDIR_RELEASE)
.PHONY: before_debug after_debug clean_debug before_release after_release clean_release