mirror of
https://github.com/quantum5/punyverse.git
synced 2025-04-24 13:11:57 -04:00
Fixed loading of models with texture.
This commit is contained in:
parent
cc3fe078a6
commit
e95e805551
|
@ -1,4 +1,4 @@
|
|||
/* Generated by Cython 0.18 on Tue Oct 22 20:02:13 2013 */
|
||||
/* Generated by Cython 0.18 on Sat Oct 26 13:44:10 2013 */
|
||||
|
||||
#define PY_SSIZE_T_CLEAN
|
||||
#include "Python.h"
|
||||
|
@ -8204,10 +8204,12 @@ static int __pyx_f_9punyverse_6_model_model_list(struct __pyx_obj_9punyverse_6_m
|
|||
float __pyx_t_12;
|
||||
float __pyx_t_13;
|
||||
float __pyx_t_14;
|
||||
PyObject *__pyx_t_15 = NULL;
|
||||
GLfloat __pyx_t_16[4];
|
||||
GLfloat __pyx_t_17[4];
|
||||
int __pyx_t_15;
|
||||
int __pyx_t_16;
|
||||
PyObject *__pyx_t_17 = NULL;
|
||||
GLfloat __pyx_t_18[4];
|
||||
GLfloat __pyx_t_19[4];
|
||||
GLfloat __pyx_t_20[4];
|
||||
int __pyx_lineno = 0;
|
||||
const char *__pyx_filename = NULL;
|
||||
int __pyx_clineno = 0;
|
||||
|
@ -8475,7 +8477,7 @@ static int __pyx_f_9punyverse_6_model_model_list(struct __pyx_obj_9punyverse_6_m
|
|||
* cdef int tex_id
|
||||
*
|
||||
* for g in model.groups: # <<<<<<<<<<<<<<
|
||||
* tex_id = 0
|
||||
* tex_id = load_texture(os.path.join(model.root, g.material.texture)) if (g.material and g.material.texture) else 0
|
||||
*
|
||||
*/
|
||||
if (unlikely(((PyObject *)__pyx_v_model->groups) == Py_None)) {
|
||||
|
@ -8498,14 +8500,61 @@ static int __pyx_f_9punyverse_6_model_model_list(struct __pyx_obj_9punyverse_6_m
|
|||
/* "punyverse\_model.pyx":306
|
||||
*
|
||||
* for g in model.groups:
|
||||
* tex_id = 0 # <<<<<<<<<<<<<<
|
||||
* tex_id = load_texture(os.path.join(model.root, g.material.texture)) if (g.material and g.material.texture) else 0 # <<<<<<<<<<<<<<
|
||||
*
|
||||
* if tex_id:
|
||||
*/
|
||||
__pyx_v_tex_id = 0;
|
||||
__pyx_t_8 = __Pyx_PyObject_IsTrue(((PyObject *)__pyx_v_g->material)); if (unlikely(__pyx_t_8 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 306; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
if (__pyx_t_8) {
|
||||
__pyx_t_15 = __Pyx_PyObject_IsTrue(((PyObject *)__pyx_v_g->material->texture)); if (unlikely(__pyx_t_15 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 306; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
__pyx_t_16 = __pyx_t_15;
|
||||
} else {
|
||||
__pyx_t_16 = __pyx_t_8;
|
||||
}
|
||||
if (__pyx_t_16) {
|
||||
__pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__load_texture); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 306; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
__Pyx_GOTREF(__pyx_t_1);
|
||||
__pyx_t_6 = __Pyx_GetName(__pyx_m, __pyx_n_s__os); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 306; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
__Pyx_GOTREF(__pyx_t_6);
|
||||
__pyx_t_5 = PyObject_GetAttr(__pyx_t_6, __pyx_n_s__path); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 306; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
__Pyx_GOTREF(__pyx_t_5);
|
||||
__Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
|
||||
__pyx_t_6 = PyObject_GetAttr(__pyx_t_5, __pyx_n_s__join); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 306; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
__Pyx_GOTREF(__pyx_t_6);
|
||||
__Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
|
||||
__pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 306; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
__Pyx_GOTREF(__pyx_t_5);
|
||||
__Pyx_INCREF(((PyObject *)__pyx_v_model->root));
|
||||
PyTuple_SET_ITEM(__pyx_t_5, 0, ((PyObject *)__pyx_v_model->root));
|
||||
__Pyx_GIVEREF(((PyObject *)__pyx_v_model->root));
|
||||
__Pyx_INCREF(((PyObject *)__pyx_v_g->material->texture));
|
||||
PyTuple_SET_ITEM(__pyx_t_5, 1, ((PyObject *)__pyx_v_g->material->texture));
|
||||
__Pyx_GIVEREF(((PyObject *)__pyx_v_g->material->texture));
|
||||
__pyx_t_17 = PyObject_Call(__pyx_t_6, ((PyObject *)__pyx_t_5), NULL); if (unlikely(!__pyx_t_17)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 306; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
__Pyx_GOTREF(__pyx_t_17);
|
||||
__Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
|
||||
__Pyx_DECREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0;
|
||||
__pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 306; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
__Pyx_GOTREF(__pyx_t_5);
|
||||
PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_17);
|
||||
__Pyx_GIVEREF(__pyx_t_17);
|
||||
__pyx_t_17 = 0;
|
||||
__pyx_t_17 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_5), NULL); if (unlikely(!__pyx_t_17)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 306; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
__Pyx_GOTREF(__pyx_t_17);
|
||||
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
|
||||
__Pyx_DECREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0;
|
||||
__pyx_t_9 = __pyx_t_17;
|
||||
__pyx_t_17 = 0;
|
||||
} else {
|
||||
__Pyx_INCREF(__pyx_int_0);
|
||||
__pyx_t_9 = __pyx_int_0;
|
||||
}
|
||||
__pyx_t_4 = __Pyx_PyInt_AsInt(__pyx_t_9); if (unlikely((__pyx_t_4 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 306; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
__Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
|
||||
__pyx_v_tex_id = __pyx_t_4;
|
||||
|
||||
/* "punyverse\_model.pyx":308
|
||||
* tex_id = 0
|
||||
* tex_id = load_texture(os.path.join(model.root, g.material.texture)) if (g.material and g.material.texture) else 0
|
||||
*
|
||||
* if tex_id: # <<<<<<<<<<<<<<
|
||||
* glEnable(GL_TEXTURE_2D)
|
||||
|
@ -8561,8 +8610,8 @@ static int __pyx_f_9punyverse_6_model_model_list(struct __pyx_obj_9punyverse_6_m
|
|||
* if g.material.texture is not None:
|
||||
* tex_id = load_texture(os.path.join(model.root, g.material.texture))
|
||||
*/
|
||||
__pyx_t_8 = (((PyObject *)__pyx_v_g->material) != Py_None);
|
||||
if (__pyx_t_8) {
|
||||
__pyx_t_16 = (((PyObject *)__pyx_v_g->material) != Py_None);
|
||||
if (__pyx_t_16) {
|
||||
|
||||
/* "punyverse\_model.pyx":316
|
||||
*
|
||||
|
@ -8571,8 +8620,8 @@ static int __pyx_f_9punyverse_6_model_model_list(struct __pyx_obj_9punyverse_6_m
|
|||
* tex_id = load_texture(os.path.join(model.root, g.material.texture))
|
||||
* if g.material.Ka:
|
||||
*/
|
||||
__pyx_t_8 = (__pyx_v_g->material->texture != ((PyObject*)Py_None));
|
||||
if (__pyx_t_8) {
|
||||
__pyx_t_16 = (__pyx_v_g->material->texture != ((PyObject*)Py_None));
|
||||
if (__pyx_t_16) {
|
||||
|
||||
/* "punyverse\_model.pyx":317
|
||||
* if g.material is not None:
|
||||
|
@ -8583,37 +8632,37 @@ static int __pyx_f_9punyverse_6_model_model_list(struct __pyx_obj_9punyverse_6_m
|
|||
*/
|
||||
__pyx_t_9 = __Pyx_GetName(__pyx_m, __pyx_n_s__load_texture); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 317; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
__Pyx_GOTREF(__pyx_t_9);
|
||||
__pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__os); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 317; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
__Pyx_GOTREF(__pyx_t_1);
|
||||
__pyx_t_6 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__path); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 317; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
__Pyx_GOTREF(__pyx_t_6);
|
||||
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
|
||||
__pyx_t_1 = PyObject_GetAttr(__pyx_t_6, __pyx_n_s__join); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 317; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
__Pyx_GOTREF(__pyx_t_1);
|
||||
__Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
|
||||
__pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 317; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
__Pyx_GOTREF(__pyx_t_6);
|
||||
__pyx_t_17 = __Pyx_GetName(__pyx_m, __pyx_n_s__os); if (unlikely(!__pyx_t_17)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 317; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
__Pyx_GOTREF(__pyx_t_17);
|
||||
__pyx_t_5 = PyObject_GetAttr(__pyx_t_17, __pyx_n_s__path); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 317; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
__Pyx_GOTREF(__pyx_t_5);
|
||||
__Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
|
||||
__pyx_t_17 = PyObject_GetAttr(__pyx_t_5, __pyx_n_s__join); if (unlikely(!__pyx_t_17)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 317; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
__Pyx_GOTREF(__pyx_t_17);
|
||||
__Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
|
||||
__pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 317; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
__Pyx_GOTREF(__pyx_t_5);
|
||||
__Pyx_INCREF(((PyObject *)__pyx_v_model->root));
|
||||
PyTuple_SET_ITEM(__pyx_t_6, 0, ((PyObject *)__pyx_v_model->root));
|
||||
PyTuple_SET_ITEM(__pyx_t_5, 0, ((PyObject *)__pyx_v_model->root));
|
||||
__Pyx_GIVEREF(((PyObject *)__pyx_v_model->root));
|
||||
__Pyx_INCREF(((PyObject *)__pyx_v_g->material->texture));
|
||||
PyTuple_SET_ITEM(__pyx_t_6, 1, ((PyObject *)__pyx_v_g->material->texture));
|
||||
PyTuple_SET_ITEM(__pyx_t_5, 1, ((PyObject *)__pyx_v_g->material->texture));
|
||||
__Pyx_GIVEREF(((PyObject *)__pyx_v_g->material->texture));
|
||||
__pyx_t_5 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_6), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 317; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
__Pyx_GOTREF(__pyx_t_5);
|
||||
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
|
||||
__Pyx_DECREF(((PyObject *)__pyx_t_6)); __pyx_t_6 = 0;
|
||||
__pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 317; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
__Pyx_GOTREF(__pyx_t_6);
|
||||
PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_5);
|
||||
__Pyx_GIVEREF(__pyx_t_5);
|
||||
__pyx_t_5 = 0;
|
||||
__pyx_t_5 = PyObject_Call(__pyx_t_9, ((PyObject *)__pyx_t_6), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 317; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
__pyx_t_1 = PyObject_Call(__pyx_t_17, ((PyObject *)__pyx_t_5), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 317; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
__Pyx_GOTREF(__pyx_t_1);
|
||||
__Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
|
||||
__Pyx_DECREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0;
|
||||
__pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 317; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
__Pyx_GOTREF(__pyx_t_5);
|
||||
PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_1);
|
||||
__Pyx_GIVEREF(__pyx_t_1);
|
||||
__pyx_t_1 = 0;
|
||||
__pyx_t_1 = PyObject_Call(__pyx_t_9, ((PyObject *)__pyx_t_5), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 317; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
__Pyx_GOTREF(__pyx_t_1);
|
||||
__Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
|
||||
__Pyx_DECREF(((PyObject *)__pyx_t_6)); __pyx_t_6 = 0;
|
||||
__pyx_t_4 = __Pyx_PyInt_AsInt(__pyx_t_5); if (unlikely((__pyx_t_4 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 317; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
__Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
|
||||
__Pyx_DECREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0;
|
||||
__pyx_t_4 = __Pyx_PyInt_AsInt(__pyx_t_1); if (unlikely((__pyx_t_4 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 317; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
|
||||
__pyx_v_tex_id = __pyx_t_4;
|
||||
goto __pyx_L12;
|
||||
}
|
||||
|
@ -8626,8 +8675,8 @@ static int __pyx_f_9punyverse_6_model_model_list(struct __pyx_obj_9punyverse_6_m
|
|||
* kx, ky, kz = g.material.Ka
|
||||
* glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, [kx, ky, kz, 1])
|
||||
*/
|
||||
__pyx_t_8 = (((PyObject *)__pyx_v_g->material->Ka) != Py_None) && (PyTuple_GET_SIZE(((PyObject *)__pyx_v_g->material->Ka)) != 0);
|
||||
if (__pyx_t_8) {
|
||||
__pyx_t_16 = (((PyObject *)__pyx_v_g->material->Ka) != Py_None) && (PyTuple_GET_SIZE(((PyObject *)__pyx_v_g->material->Ka)) != 0);
|
||||
if (__pyx_t_16) {
|
||||
|
||||
/* "punyverse\_model.pyx":319
|
||||
* tex_id = load_texture(os.path.join(model.root, g.material.texture))
|
||||
|
@ -8636,10 +8685,10 @@ static int __pyx_f_9punyverse_6_model_model_list(struct __pyx_obj_9punyverse_6_m
|
|||
* glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, [kx, ky, kz, 1])
|
||||
* if g.material.Kd:
|
||||
*/
|
||||
__pyx_t_5 = ((PyObject *)__pyx_v_g->material->Ka);
|
||||
__Pyx_INCREF(__pyx_t_5);
|
||||
if (likely(PyTuple_CheckExact(__pyx_t_5))) {
|
||||
PyObject* sequence = __pyx_t_5;
|
||||
__pyx_t_1 = ((PyObject *)__pyx_v_g->material->Ka);
|
||||
__Pyx_INCREF(__pyx_t_1);
|
||||
if (likely(PyTuple_CheckExact(__pyx_t_1))) {
|
||||
PyObject* sequence = __pyx_t_1;
|
||||
#if CYTHON_COMPILING_IN_CPYTHON
|
||||
Py_ssize_t size = Py_SIZE(sequence);
|
||||
#else
|
||||
|
@ -8651,53 +8700,53 @@ static int __pyx_f_9punyverse_6_model_model_list(struct __pyx_obj_9punyverse_6_m
|
|||
{__pyx_filename = __pyx_f[0]; __pyx_lineno = 319; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
}
|
||||
#if CYTHON_COMPILING_IN_CPYTHON
|
||||
__pyx_t_6 = PyTuple_GET_ITEM(sequence, 0);
|
||||
__pyx_t_5 = PyTuple_GET_ITEM(sequence, 0);
|
||||
__pyx_t_9 = PyTuple_GET_ITEM(sequence, 1);
|
||||
__pyx_t_1 = PyTuple_GET_ITEM(sequence, 2);
|
||||
__Pyx_INCREF(__pyx_t_6);
|
||||
__pyx_t_17 = PyTuple_GET_ITEM(sequence, 2);
|
||||
__Pyx_INCREF(__pyx_t_5);
|
||||
__Pyx_INCREF(__pyx_t_9);
|
||||
__Pyx_INCREF(__pyx_t_1);
|
||||
__Pyx_INCREF(__pyx_t_17);
|
||||
#else
|
||||
__pyx_t_6 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 319; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
__Pyx_GOTREF(__pyx_t_6);
|
||||
__pyx_t_5 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 319; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
__Pyx_GOTREF(__pyx_t_5);
|
||||
__pyx_t_9 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 319; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
__Pyx_GOTREF(__pyx_t_9);
|
||||
__pyx_t_1 = PySequence_ITEM(sequence, 2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 319; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
__Pyx_GOTREF(__pyx_t_1);
|
||||
__pyx_t_17 = PySequence_ITEM(sequence, 2); if (unlikely(!__pyx_t_17)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 319; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
__Pyx_GOTREF(__pyx_t_17);
|
||||
#endif
|
||||
__Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
|
||||
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
|
||||
} else if (1) {
|
||||
__Pyx_RaiseNoneNotIterableError(); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 319; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
} else
|
||||
{
|
||||
Py_ssize_t index = -1;
|
||||
__pyx_t_15 = PyObject_GetIter(__pyx_t_5); if (unlikely(!__pyx_t_15)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 319; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
__Pyx_GOTREF(__pyx_t_15);
|
||||
__Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
|
||||
__pyx_t_11 = Py_TYPE(__pyx_t_15)->tp_iternext;
|
||||
index = 0; __pyx_t_6 = __pyx_t_11(__pyx_t_15); if (unlikely(!__pyx_t_6)) goto __pyx_L14_unpacking_failed;
|
||||
__pyx_t_6 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 319; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
__Pyx_GOTREF(__pyx_t_6);
|
||||
index = 1; __pyx_t_9 = __pyx_t_11(__pyx_t_15); if (unlikely(!__pyx_t_9)) goto __pyx_L14_unpacking_failed;
|
||||
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
|
||||
__pyx_t_11 = Py_TYPE(__pyx_t_6)->tp_iternext;
|
||||
index = 0; __pyx_t_5 = __pyx_t_11(__pyx_t_6); if (unlikely(!__pyx_t_5)) goto __pyx_L14_unpacking_failed;
|
||||
__Pyx_GOTREF(__pyx_t_5);
|
||||
index = 1; __pyx_t_9 = __pyx_t_11(__pyx_t_6); if (unlikely(!__pyx_t_9)) goto __pyx_L14_unpacking_failed;
|
||||
__Pyx_GOTREF(__pyx_t_9);
|
||||
index = 2; __pyx_t_1 = __pyx_t_11(__pyx_t_15); if (unlikely(!__pyx_t_1)) goto __pyx_L14_unpacking_failed;
|
||||
__Pyx_GOTREF(__pyx_t_1);
|
||||
if (__Pyx_IternextUnpackEndCheck(__pyx_t_11(__pyx_t_15), 3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 319; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
index = 2; __pyx_t_17 = __pyx_t_11(__pyx_t_6); if (unlikely(!__pyx_t_17)) goto __pyx_L14_unpacking_failed;
|
||||
__Pyx_GOTREF(__pyx_t_17);
|
||||
if (__Pyx_IternextUnpackEndCheck(__pyx_t_11(__pyx_t_6), 3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 319; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
__pyx_t_11 = NULL;
|
||||
__Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
|
||||
__Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
|
||||
goto __pyx_L15_unpacking_done;
|
||||
__pyx_L14_unpacking_failed:;
|
||||
__Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
|
||||
__Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
|
||||
__pyx_t_11 = NULL;
|
||||
if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
|
||||
{__pyx_filename = __pyx_f[0]; __pyx_lineno = 319; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
__pyx_L15_unpacking_done:;
|
||||
}
|
||||
__pyx_t_14 = __pyx_PyFloat_AsFloat(__pyx_t_6); if (unlikely((__pyx_t_14 == (float)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 319; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
__Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
|
||||
__pyx_t_14 = __pyx_PyFloat_AsFloat(__pyx_t_5); if (unlikely((__pyx_t_14 == (float)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 319; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
__Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
|
||||
__pyx_t_13 = __pyx_PyFloat_AsFloat(__pyx_t_9); if (unlikely((__pyx_t_13 == (float)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 319; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
__Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
|
||||
__pyx_t_12 = __pyx_PyFloat_AsFloat(__pyx_t_1); if (unlikely((__pyx_t_12 == (float)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 319; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
|
||||
__pyx_t_12 = __pyx_PyFloat_AsFloat(__pyx_t_17); if (unlikely((__pyx_t_12 == (float)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 319; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
__Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
|
||||
__pyx_v_kx = __pyx_t_14;
|
||||
__pyx_v_ky = __pyx_t_13;
|
||||
__pyx_v_kz = __pyx_t_12;
|
||||
|
@ -8709,11 +8758,11 @@ static int __pyx_f_9punyverse_6_model_model_list(struct __pyx_obj_9punyverse_6_m
|
|||
* if g.material.Kd:
|
||||
* kx, ky, kz = g.material.Kd
|
||||
*/
|
||||
__pyx_t_16[0] = __pyx_v_kx;
|
||||
__pyx_t_16[1] = __pyx_v_ky;
|
||||
__pyx_t_16[2] = __pyx_v_kz;
|
||||
__pyx_t_16[3] = 1.0;
|
||||
glMaterialfv(__pyx_e_9punyverse_6_model_GL_FRONT_AND_BACK, __pyx_e_9punyverse_6_model_GL_AMBIENT, __pyx_t_16);
|
||||
__pyx_t_18[0] = __pyx_v_kx;
|
||||
__pyx_t_18[1] = __pyx_v_ky;
|
||||
__pyx_t_18[2] = __pyx_v_kz;
|
||||
__pyx_t_18[3] = 1.0;
|
||||
glMaterialfv(__pyx_e_9punyverse_6_model_GL_FRONT_AND_BACK, __pyx_e_9punyverse_6_model_GL_AMBIENT, __pyx_t_18);
|
||||
goto __pyx_L13;
|
||||
}
|
||||
__pyx_L13:;
|
||||
|
@ -8725,8 +8774,8 @@ static int __pyx_f_9punyverse_6_model_model_list(struct __pyx_obj_9punyverse_6_m
|
|||
* kx, ky, kz = g.material.Kd
|
||||
* glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, [kx, ky, kz, 1])
|
||||
*/
|
||||
__pyx_t_8 = (((PyObject *)__pyx_v_g->material->Kd) != Py_None) && (PyTuple_GET_SIZE(((PyObject *)__pyx_v_g->material->Kd)) != 0);
|
||||
if (__pyx_t_8) {
|
||||
__pyx_t_16 = (((PyObject *)__pyx_v_g->material->Kd) != Py_None) && (PyTuple_GET_SIZE(((PyObject *)__pyx_v_g->material->Kd)) != 0);
|
||||
if (__pyx_t_16) {
|
||||
|
||||
/* "punyverse\_model.pyx":322
|
||||
* glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, [kx, ky, kz, 1])
|
||||
|
@ -8735,10 +8784,10 @@ static int __pyx_f_9punyverse_6_model_model_list(struct __pyx_obj_9punyverse_6_m
|
|||
* glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, [kx, ky, kz, 1])
|
||||
* if g.material.Ks:
|
||||
*/
|
||||
__pyx_t_5 = ((PyObject *)__pyx_v_g->material->Kd);
|
||||
__Pyx_INCREF(__pyx_t_5);
|
||||
if (likely(PyTuple_CheckExact(__pyx_t_5))) {
|
||||
PyObject* sequence = __pyx_t_5;
|
||||
__pyx_t_1 = ((PyObject *)__pyx_v_g->material->Kd);
|
||||
__Pyx_INCREF(__pyx_t_1);
|
||||
if (likely(PyTuple_CheckExact(__pyx_t_1))) {
|
||||
PyObject* sequence = __pyx_t_1;
|
||||
#if CYTHON_COMPILING_IN_CPYTHON
|
||||
Py_ssize_t size = Py_SIZE(sequence);
|
||||
#else
|
||||
|
@ -8750,53 +8799,53 @@ static int __pyx_f_9punyverse_6_model_model_list(struct __pyx_obj_9punyverse_6_m
|
|||
{__pyx_filename = __pyx_f[0]; __pyx_lineno = 322; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
}
|
||||
#if CYTHON_COMPILING_IN_CPYTHON
|
||||
__pyx_t_1 = PyTuple_GET_ITEM(sequence, 0);
|
||||
__pyx_t_17 = PyTuple_GET_ITEM(sequence, 0);
|
||||
__pyx_t_9 = PyTuple_GET_ITEM(sequence, 1);
|
||||
__pyx_t_6 = PyTuple_GET_ITEM(sequence, 2);
|
||||
__Pyx_INCREF(__pyx_t_1);
|
||||
__pyx_t_5 = PyTuple_GET_ITEM(sequence, 2);
|
||||
__Pyx_INCREF(__pyx_t_17);
|
||||
__Pyx_INCREF(__pyx_t_9);
|
||||
__Pyx_INCREF(__pyx_t_6);
|
||||
__Pyx_INCREF(__pyx_t_5);
|
||||
#else
|
||||
__pyx_t_1 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 322; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
__Pyx_GOTREF(__pyx_t_1);
|
||||
__pyx_t_17 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_17)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 322; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
__Pyx_GOTREF(__pyx_t_17);
|
||||
__pyx_t_9 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 322; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
__Pyx_GOTREF(__pyx_t_9);
|
||||
__pyx_t_6 = PySequence_ITEM(sequence, 2); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 322; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
__Pyx_GOTREF(__pyx_t_6);
|
||||
__pyx_t_5 = PySequence_ITEM(sequence, 2); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 322; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
__Pyx_GOTREF(__pyx_t_5);
|
||||
#endif
|
||||
__Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
|
||||
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
|
||||
} else if (1) {
|
||||
__Pyx_RaiseNoneNotIterableError(); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 322; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
} else
|
||||
{
|
||||
Py_ssize_t index = -1;
|
||||
__pyx_t_15 = PyObject_GetIter(__pyx_t_5); if (unlikely(!__pyx_t_15)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 322; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
__Pyx_GOTREF(__pyx_t_15);
|
||||
__Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
|
||||
__pyx_t_11 = Py_TYPE(__pyx_t_15)->tp_iternext;
|
||||
index = 0; __pyx_t_1 = __pyx_t_11(__pyx_t_15); if (unlikely(!__pyx_t_1)) goto __pyx_L17_unpacking_failed;
|
||||
__Pyx_GOTREF(__pyx_t_1);
|
||||
index = 1; __pyx_t_9 = __pyx_t_11(__pyx_t_15); if (unlikely(!__pyx_t_9)) goto __pyx_L17_unpacking_failed;
|
||||
__Pyx_GOTREF(__pyx_t_9);
|
||||
index = 2; __pyx_t_6 = __pyx_t_11(__pyx_t_15); if (unlikely(!__pyx_t_6)) goto __pyx_L17_unpacking_failed;
|
||||
__pyx_t_6 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 322; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
__Pyx_GOTREF(__pyx_t_6);
|
||||
if (__Pyx_IternextUnpackEndCheck(__pyx_t_11(__pyx_t_15), 3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 322; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
|
||||
__pyx_t_11 = Py_TYPE(__pyx_t_6)->tp_iternext;
|
||||
index = 0; __pyx_t_17 = __pyx_t_11(__pyx_t_6); if (unlikely(!__pyx_t_17)) goto __pyx_L17_unpacking_failed;
|
||||
__Pyx_GOTREF(__pyx_t_17);
|
||||
index = 1; __pyx_t_9 = __pyx_t_11(__pyx_t_6); if (unlikely(!__pyx_t_9)) goto __pyx_L17_unpacking_failed;
|
||||
__Pyx_GOTREF(__pyx_t_9);
|
||||
index = 2; __pyx_t_5 = __pyx_t_11(__pyx_t_6); if (unlikely(!__pyx_t_5)) goto __pyx_L17_unpacking_failed;
|
||||
__Pyx_GOTREF(__pyx_t_5);
|
||||
if (__Pyx_IternextUnpackEndCheck(__pyx_t_11(__pyx_t_6), 3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 322; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
__pyx_t_11 = NULL;
|
||||
__Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
|
||||
__Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
|
||||
goto __pyx_L18_unpacking_done;
|
||||
__pyx_L17_unpacking_failed:;
|
||||
__Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
|
||||
__Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
|
||||
__pyx_t_11 = NULL;
|
||||
if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
|
||||
{__pyx_filename = __pyx_f[0]; __pyx_lineno = 322; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
__pyx_L18_unpacking_done:;
|
||||
}
|
||||
__pyx_t_12 = __pyx_PyFloat_AsFloat(__pyx_t_1); if (unlikely((__pyx_t_12 == (float)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 322; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
|
||||
__pyx_t_12 = __pyx_PyFloat_AsFloat(__pyx_t_17); if (unlikely((__pyx_t_12 == (float)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 322; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
__Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
|
||||
__pyx_t_13 = __pyx_PyFloat_AsFloat(__pyx_t_9); if (unlikely((__pyx_t_13 == (float)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 322; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
__Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
|
||||
__pyx_t_14 = __pyx_PyFloat_AsFloat(__pyx_t_6); if (unlikely((__pyx_t_14 == (float)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 322; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
__Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
|
||||
__pyx_t_14 = __pyx_PyFloat_AsFloat(__pyx_t_5); if (unlikely((__pyx_t_14 == (float)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 322; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
__Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
|
||||
__pyx_v_kx = __pyx_t_12;
|
||||
__pyx_v_ky = __pyx_t_13;
|
||||
__pyx_v_kz = __pyx_t_14;
|
||||
|
@ -8808,11 +8857,11 @@ static int __pyx_f_9punyverse_6_model_model_list(struct __pyx_obj_9punyverse_6_m
|
|||
* if g.material.Ks:
|
||||
* kx, ky, kz = g.material.Ks
|
||||
*/
|
||||
__pyx_t_17[0] = __pyx_v_kx;
|
||||
__pyx_t_17[1] = __pyx_v_ky;
|
||||
__pyx_t_17[2] = __pyx_v_kz;
|
||||
__pyx_t_17[3] = 1.0;
|
||||
glMaterialfv(__pyx_e_9punyverse_6_model_GL_FRONT_AND_BACK, __pyx_e_9punyverse_6_model_GL_DIFFUSE, __pyx_t_17);
|
||||
__pyx_t_19[0] = __pyx_v_kx;
|
||||
__pyx_t_19[1] = __pyx_v_ky;
|
||||
__pyx_t_19[2] = __pyx_v_kz;
|
||||
__pyx_t_19[3] = 1.0;
|
||||
glMaterialfv(__pyx_e_9punyverse_6_model_GL_FRONT_AND_BACK, __pyx_e_9punyverse_6_model_GL_DIFFUSE, __pyx_t_19);
|
||||
goto __pyx_L16;
|
||||
}
|
||||
__pyx_L16:;
|
||||
|
@ -8824,8 +8873,8 @@ static int __pyx_f_9punyverse_6_model_model_list(struct __pyx_obj_9punyverse_6_m
|
|||
* kx, ky, kz = g.material.Ks
|
||||
* glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, [kx, ky, kz, 1])
|
||||
*/
|
||||
__pyx_t_8 = (((PyObject *)__pyx_v_g->material->Ks) != Py_None) && (PyTuple_GET_SIZE(((PyObject *)__pyx_v_g->material->Ks)) != 0);
|
||||
if (__pyx_t_8) {
|
||||
__pyx_t_16 = (((PyObject *)__pyx_v_g->material->Ks) != Py_None) && (PyTuple_GET_SIZE(((PyObject *)__pyx_v_g->material->Ks)) != 0);
|
||||
if (__pyx_t_16) {
|
||||
|
||||
/* "punyverse\_model.pyx":325
|
||||
* glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, [kx, ky, kz, 1])
|
||||
|
@ -8834,10 +8883,10 @@ static int __pyx_f_9punyverse_6_model_model_list(struct __pyx_obj_9punyverse_6_m
|
|||
* glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, [kx, ky, kz, 1])
|
||||
* glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, g.material.shininess)
|
||||
*/
|
||||
__pyx_t_5 = ((PyObject *)__pyx_v_g->material->Ks);
|
||||
__Pyx_INCREF(__pyx_t_5);
|
||||
if (likely(PyTuple_CheckExact(__pyx_t_5))) {
|
||||
PyObject* sequence = __pyx_t_5;
|
||||
__pyx_t_1 = ((PyObject *)__pyx_v_g->material->Ks);
|
||||
__Pyx_INCREF(__pyx_t_1);
|
||||
if (likely(PyTuple_CheckExact(__pyx_t_1))) {
|
||||
PyObject* sequence = __pyx_t_1;
|
||||
#if CYTHON_COMPILING_IN_CPYTHON
|
||||
Py_ssize_t size = Py_SIZE(sequence);
|
||||
#else
|
||||
|
@ -8849,53 +8898,53 @@ static int __pyx_f_9punyverse_6_model_model_list(struct __pyx_obj_9punyverse_6_m
|
|||
{__pyx_filename = __pyx_f[0]; __pyx_lineno = 325; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
}
|
||||
#if CYTHON_COMPILING_IN_CPYTHON
|
||||
__pyx_t_6 = PyTuple_GET_ITEM(sequence, 0);
|
||||
__pyx_t_5 = PyTuple_GET_ITEM(sequence, 0);
|
||||
__pyx_t_9 = PyTuple_GET_ITEM(sequence, 1);
|
||||
__pyx_t_1 = PyTuple_GET_ITEM(sequence, 2);
|
||||
__Pyx_INCREF(__pyx_t_6);
|
||||
__pyx_t_17 = PyTuple_GET_ITEM(sequence, 2);
|
||||
__Pyx_INCREF(__pyx_t_5);
|
||||
__Pyx_INCREF(__pyx_t_9);
|
||||
__Pyx_INCREF(__pyx_t_1);
|
||||
__Pyx_INCREF(__pyx_t_17);
|
||||
#else
|
||||
__pyx_t_6 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 325; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
__Pyx_GOTREF(__pyx_t_6);
|
||||
__pyx_t_5 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 325; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
__Pyx_GOTREF(__pyx_t_5);
|
||||
__pyx_t_9 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 325; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
__Pyx_GOTREF(__pyx_t_9);
|
||||
__pyx_t_1 = PySequence_ITEM(sequence, 2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 325; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
__Pyx_GOTREF(__pyx_t_1);
|
||||
__pyx_t_17 = PySequence_ITEM(sequence, 2); if (unlikely(!__pyx_t_17)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 325; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
__Pyx_GOTREF(__pyx_t_17);
|
||||
#endif
|
||||
__Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
|
||||
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
|
||||
} else if (1) {
|
||||
__Pyx_RaiseNoneNotIterableError(); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 325; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
} else
|
||||
{
|
||||
Py_ssize_t index = -1;
|
||||
__pyx_t_15 = PyObject_GetIter(__pyx_t_5); if (unlikely(!__pyx_t_15)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 325; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
__Pyx_GOTREF(__pyx_t_15);
|
||||
__Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
|
||||
__pyx_t_11 = Py_TYPE(__pyx_t_15)->tp_iternext;
|
||||
index = 0; __pyx_t_6 = __pyx_t_11(__pyx_t_15); if (unlikely(!__pyx_t_6)) goto __pyx_L20_unpacking_failed;
|
||||
__pyx_t_6 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 325; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
__Pyx_GOTREF(__pyx_t_6);
|
||||
index = 1; __pyx_t_9 = __pyx_t_11(__pyx_t_15); if (unlikely(!__pyx_t_9)) goto __pyx_L20_unpacking_failed;
|
||||
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
|
||||
__pyx_t_11 = Py_TYPE(__pyx_t_6)->tp_iternext;
|
||||
index = 0; __pyx_t_5 = __pyx_t_11(__pyx_t_6); if (unlikely(!__pyx_t_5)) goto __pyx_L20_unpacking_failed;
|
||||
__Pyx_GOTREF(__pyx_t_5);
|
||||
index = 1; __pyx_t_9 = __pyx_t_11(__pyx_t_6); if (unlikely(!__pyx_t_9)) goto __pyx_L20_unpacking_failed;
|
||||
__Pyx_GOTREF(__pyx_t_9);
|
||||
index = 2; __pyx_t_1 = __pyx_t_11(__pyx_t_15); if (unlikely(!__pyx_t_1)) goto __pyx_L20_unpacking_failed;
|
||||
__Pyx_GOTREF(__pyx_t_1);
|
||||
if (__Pyx_IternextUnpackEndCheck(__pyx_t_11(__pyx_t_15), 3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 325; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
index = 2; __pyx_t_17 = __pyx_t_11(__pyx_t_6); if (unlikely(!__pyx_t_17)) goto __pyx_L20_unpacking_failed;
|
||||
__Pyx_GOTREF(__pyx_t_17);
|
||||
if (__Pyx_IternextUnpackEndCheck(__pyx_t_11(__pyx_t_6), 3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 325; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
__pyx_t_11 = NULL;
|
||||
__Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
|
||||
__Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
|
||||
goto __pyx_L21_unpacking_done;
|
||||
__pyx_L20_unpacking_failed:;
|
||||
__Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
|
||||
__Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
|
||||
__pyx_t_11 = NULL;
|
||||
if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
|
||||
{__pyx_filename = __pyx_f[0]; __pyx_lineno = 325; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
__pyx_L21_unpacking_done:;
|
||||
}
|
||||
__pyx_t_14 = __pyx_PyFloat_AsFloat(__pyx_t_6); if (unlikely((__pyx_t_14 == (float)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 325; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
__Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
|
||||
__pyx_t_14 = __pyx_PyFloat_AsFloat(__pyx_t_5); if (unlikely((__pyx_t_14 == (float)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 325; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
__Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
|
||||
__pyx_t_13 = __pyx_PyFloat_AsFloat(__pyx_t_9); if (unlikely((__pyx_t_13 == (float)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 325; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
__Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
|
||||
__pyx_t_12 = __pyx_PyFloat_AsFloat(__pyx_t_1); if (unlikely((__pyx_t_12 == (float)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 325; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
|
||||
__pyx_t_12 = __pyx_PyFloat_AsFloat(__pyx_t_17); if (unlikely((__pyx_t_12 == (float)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 325; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
__Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
|
||||
__pyx_v_kx = __pyx_t_14;
|
||||
__pyx_v_ky = __pyx_t_13;
|
||||
__pyx_v_kz = __pyx_t_12;
|
||||
|
@ -8907,11 +8956,11 @@ static int __pyx_f_9punyverse_6_model_model_list(struct __pyx_obj_9punyverse_6_m
|
|||
* glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, g.material.shininess)
|
||||
*
|
||||
*/
|
||||
__pyx_t_18[0] = __pyx_v_kx;
|
||||
__pyx_t_18[1] = __pyx_v_ky;
|
||||
__pyx_t_18[2] = __pyx_v_kz;
|
||||
__pyx_t_18[3] = 1.0;
|
||||
glMaterialfv(__pyx_e_9punyverse_6_model_GL_FRONT_AND_BACK, __pyx_e_9punyverse_6_model_GL_SPECULAR, __pyx_t_18);
|
||||
__pyx_t_20[0] = __pyx_v_kx;
|
||||
__pyx_t_20[1] = __pyx_v_ky;
|
||||
__pyx_t_20[2] = __pyx_v_kz;
|
||||
__pyx_t_20[3] = 1.0;
|
||||
glMaterialfv(__pyx_e_9punyverse_6_model_GL_FRONT_AND_BACK, __pyx_e_9punyverse_6_model_GL_SPECULAR, __pyx_t_20);
|
||||
goto __pyx_L19;
|
||||
}
|
||||
__pyx_L19:;
|
||||
|
@ -8948,18 +8997,18 @@ static int __pyx_f_9punyverse_6_model_model_list(struct __pyx_obj_9punyverse_6_m
|
|||
PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
|
||||
{__pyx_filename = __pyx_f[0]; __pyx_lineno = 330; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
}
|
||||
__pyx_t_5 = ((PyObject *)__pyx_v_g->faces); __Pyx_INCREF(__pyx_t_5); __pyx_t_2 = 0;
|
||||
__pyx_t_1 = ((PyObject *)__pyx_v_g->faces); __Pyx_INCREF(__pyx_t_1); __pyx_t_2 = 0;
|
||||
for (;;) {
|
||||
if (__pyx_t_2 >= PyList_GET_SIZE(__pyx_t_5)) break;
|
||||
if (__pyx_t_2 >= PyList_GET_SIZE(__pyx_t_1)) break;
|
||||
#if CYTHON_COMPILING_IN_CPYTHON
|
||||
__pyx_t_1 = PyList_GET_ITEM(__pyx_t_5, __pyx_t_2); __Pyx_INCREF(__pyx_t_1); __pyx_t_2++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 330; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
__pyx_t_17 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_17); __pyx_t_2++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 330; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
#else
|
||||
__pyx_t_1 = PySequence_ITEM(__pyx_t_5, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 330; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
__pyx_t_17 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_17)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 330; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
#endif
|
||||
if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_9punyverse_6_model_Face))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 330; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
if (!(likely(((__pyx_t_17) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_17, __pyx_ptype_9punyverse_6_model_Face))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 330; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
__Pyx_XDECREF(((PyObject *)__pyx_v_f));
|
||||
__pyx_v_f = ((struct __pyx_obj_9punyverse_6_model_Face *)__pyx_t_1);
|
||||
__pyx_t_1 = 0;
|
||||
__pyx_v_f = ((struct __pyx_obj_9punyverse_6_model_Face *)__pyx_t_17);
|
||||
__pyx_t_17 = 0;
|
||||
|
||||
/* "punyverse\_model.pyx":331
|
||||
* glBegin(GL_TRIANGLES)
|
||||
|
@ -8995,8 +9044,8 @@ static int __pyx_f_9punyverse_6_model_model_list(struct __pyx_obj_9punyverse_6_m
|
|||
* point(f, model, tex_id, sx, sy, sz, 2)
|
||||
* point(f, model, tex_id, sx, sy, sz, 3)
|
||||
*/
|
||||
__pyx_t_8 = (__pyx_v_f->type == __pyx_e_9punyverse_6_model_FACE_QUADS);
|
||||
if (__pyx_t_8) {
|
||||
__pyx_t_16 = (__pyx_v_f->type == __pyx_e_9punyverse_6_model_FACE_QUADS);
|
||||
if (__pyx_t_16) {
|
||||
|
||||
/* "punyverse\_model.pyx":336
|
||||
*
|
||||
|
@ -9028,7 +9077,7 @@ static int __pyx_f_9punyverse_6_model_model_list(struct __pyx_obj_9punyverse_6_m
|
|||
}
|
||||
__pyx_L24:;
|
||||
}
|
||||
__Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
|
||||
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
|
||||
|
||||
/* "punyverse\_model.pyx":339
|
||||
* point(f, model, tex_id, sx, sy, sz, 3)
|
||||
|
@ -9083,7 +9132,7 @@ static int __pyx_f_9punyverse_6_model_model_list(struct __pyx_obj_9punyverse_6_m
|
|||
__Pyx_XDECREF(__pyx_t_6);
|
||||
__Pyx_XDECREF(__pyx_t_9);
|
||||
__Pyx_XDECREF(__pyx_t_10);
|
||||
__Pyx_XDECREF(__pyx_t_15);
|
||||
__Pyx_XDECREF(__pyx_t_17);
|
||||
__Pyx_WriteUnraisable("punyverse._model.model_list", __pyx_clineno, __pyx_lineno, __pyx_filename);
|
||||
__pyx_r = 0;
|
||||
__pyx_L0:;
|
||||
|
|
|
@ -303,7 +303,7 @@ cpdef int model_list(WavefrontObject model, float sx=1, float sy=1, float sz=1,
|
|||
cdef int tex_id
|
||||
|
||||
for g in model.groups:
|
||||
tex_id = 0
|
||||
tex_id = load_texture(os.path.join(model.root, g.material.texture)) if (g.material and g.material.texture) else 0
|
||||
|
||||
if tex_id:
|
||||
glEnable(GL_TEXTURE_2D)
|
||||
|
|
|
@ -1,305 +0,0 @@
|
|||
from time import clock
|
||||
import os.path
|
||||
|
||||
include "_cyopengl.pxi"
|
||||
|
||||
from space_torus.texture import load_texture
|
||||
|
||||
cdef enum:
|
||||
FACE_TRIANGLES
|
||||
FACE_QUADS
|
||||
|
||||
cdef inline point(Face f, list vertices, list normals, list textures, float sx, float sy, float sz, int n, int tex_id):
|
||||
if f.norms:
|
||||
normal = normals[f.norms[n]]
|
||||
glNormal3f(normal[0], normal[1], normal[2])
|
||||
if tex_id:
|
||||
tex = textures[f.texs[n]]
|
||||
glTexCoord2f(tex[0], tex[1])
|
||||
|
||||
x, y, z = vertices[f.verts[n]]
|
||||
glVertex3f(x * sx, y * sy, z * sz)
|
||||
|
||||
cpdef model_list(WavefrontObject model, float sx=1, float sy=1, float sz=1, object rotation=(0, 0, 0)):
|
||||
for m, text in model.materials.iteritems():
|
||||
if text.texture:
|
||||
load_texture(os.path.join(model.root, text.texture))
|
||||
|
||||
display = glGenLists(1)
|
||||
|
||||
glNewList(display, GL_COMPILE)
|
||||
glPushMatrix()
|
||||
glPushAttrib(GL_CURRENT_BIT)
|
||||
|
||||
cdef float pitch, yaw, roll
|
||||
cdef kx, ky, kz
|
||||
|
||||
pitch, yaw, roll = rotation
|
||||
glPushAttrib(GL_TRANSFORM_BIT)
|
||||
glRotatef(pitch, 1, 0, 0)
|
||||
glRotatef(yaw, 0, 1, 0)
|
||||
glRotatef(roll, 0, 0, 1)
|
||||
glPopAttrib()
|
||||
|
||||
vertices = model.vertices
|
||||
textures = model.textures
|
||||
normals = model.normals
|
||||
|
||||
for g in model.groups:
|
||||
material = g.material
|
||||
|
||||
tex_id = load_texture(os.path.join(model.root, material.texture)) if (material and material.texture) else 0
|
||||
|
||||
if tex_id:
|
||||
glEnable(GL_TEXTURE_2D)
|
||||
glBindTexture(GL_TEXTURE_2D, tex_id)
|
||||
else:
|
||||
glBindTexture(GL_TEXTURE_2D, 0)
|
||||
glDisable(GL_TEXTURE_2D)
|
||||
|
||||
if material:
|
||||
if material.Ka:
|
||||
kx, ky, kz = material.Ka
|
||||
glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, [kx, ky, kz, 1])
|
||||
if material.Kd:
|
||||
kx, ky, kz = material.Kd
|
||||
glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, [kx, ky, kz, 1])
|
||||
if material.Ks:
|
||||
kx, ky, kz = material.Ks
|
||||
glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, [kx, ky, kz, 1])
|
||||
glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, material.shininess)
|
||||
|
||||
type = -1
|
||||
|
||||
for f in g.faces:
|
||||
if type != f.type:
|
||||
if type != -1:
|
||||
glEnd()
|
||||
glBegin(GL_TRIANGLES)
|
||||
type = f.type
|
||||
|
||||
point(f, vertices, normals, textures, sx, sy, sz, 0, tex_id)
|
||||
point(f, vertices, normals, textures, sx, sy, sz, 1, tex_id)
|
||||
point(f, vertices, normals, textures, sx, sy, sz, 2, tex_id)
|
||||
|
||||
if type == FACE_QUADS:
|
||||
point(f, vertices, normals, textures, sx, sy, sz, 2, tex_id)
|
||||
point(f, vertices, normals, textures, sx, sy, sz, 3, tex_id)
|
||||
point(f, vertices, normals, textures, sx, sy, sz, 0, tex_id)
|
||||
glEnd()
|
||||
|
||||
glPopAttrib()
|
||||
glPopMatrix()
|
||||
|
||||
glEndList()
|
||||
return display
|
||||
|
||||
def load_model(path):
|
||||
print "Loading model %s..." % path
|
||||
return WavefrontObject(os.path.join(os.path.dirname(__file__), 'assets', 'models', path))
|
||||
|
||||
cdef class WavefrontObject(object):
|
||||
cdef public str root
|
||||
cdef public list vertices, normals, textures, groups
|
||||
cdef public dict materials
|
||||
cdef Material current_material
|
||||
|
||||
cdef inline dispatch(self, str p):
|
||||
with open(p, 'r') as file:
|
||||
for line in file:
|
||||
line = line.strip()
|
||||
if not line or line[0] == '#':
|
||||
continue # Empty or comment
|
||||
words = line.split()
|
||||
type = words[0]
|
||||
if type == 'v':
|
||||
self.v(words)
|
||||
elif type == 'vn':
|
||||
self.vn(words)
|
||||
elif type == 'vt':
|
||||
self.vt(words)
|
||||
elif type == 'f':
|
||||
self.f(words)
|
||||
elif type == 'mtllib':
|
||||
self.mtllib(words)
|
||||
elif type == 'usemtl':
|
||||
self.usemtl(words)
|
||||
elif type == 'g' or type == 'o':
|
||||
self.g(words)
|
||||
elif type == 'newmtl':
|
||||
self.newmtl(words)
|
||||
elif type == 'Ka':
|
||||
self.Ka(words)
|
||||
elif type == 'Kd':
|
||||
self.Kd(words)
|
||||
elif type == 'Ks':
|
||||
self.Ks(words)
|
||||
elif type == 'Ns':
|
||||
self.Ns(words)
|
||||
elif type == 'map_Kd':
|
||||
self.map_Kd(words)
|
||||
|
||||
cdef inline newmtl(self, list words):
|
||||
material = Material(words[1])
|
||||
self.materials[words[1]] = material
|
||||
self.current_material = material
|
||||
|
||||
cdef inline Ka(self, list words):
|
||||
self.current_material.Ka = (float(words[1]), float(words[2]), float(words[3]))
|
||||
|
||||
cdef inline Kd(self, list words):
|
||||
self.current_material.Kd = (float(words[1]), float(words[2]), float(words[3]))
|
||||
|
||||
cdef inline Ks(self, list words):
|
||||
self.current_material.Ks = (float(words[1]), float(words[2]), float(words[3]))
|
||||
|
||||
cdef inline Ns(self, list words):
|
||||
self.current_material.shininess = min(float(words[1]), 125) # Seems to sometimes be > 125. TODO: find out why
|
||||
|
||||
cdef inline map_Kd(self, list words):
|
||||
self.current_material.texture = words[-1]
|
||||
|
||||
cdef inline v(self, list words):
|
||||
self.vertices.append((float(words[1]), float(words[2]), float(words[3])))
|
||||
|
||||
cdef inline vn(self, list words):
|
||||
self.normals.append((float(words[1]), float(words[2]), float(words[3])))
|
||||
|
||||
cdef inline vt(self, list words):
|
||||
l = len(words)
|
||||
x, y, z = 0, 0, 0
|
||||
if l >= 2:
|
||||
x = float(words[1])
|
||||
if l >= 3:
|
||||
# OBJ origin is at upper left, OpenGL origin is at lower left
|
||||
y = 1 - float(words[2])
|
||||
if l >= 4:
|
||||
z = float(words[3])
|
||||
self.textures.append((x, y, z))
|
||||
|
||||
cdef inline f(self, list words):
|
||||
l = len(words)
|
||||
type = -1
|
||||
cdef list face_vertices, face_normals, face_textures, raw_faces, vindices, nindices, tindicies
|
||||
cdef int current_value
|
||||
|
||||
face_vertices = []
|
||||
face_normals = []
|
||||
face_textures = []
|
||||
|
||||
vertex_count = l - 1
|
||||
if vertex_count == 3:
|
||||
type = FACE_TRIANGLES
|
||||
else:
|
||||
type = FACE_QUADS
|
||||
|
||||
raw_faces = []
|
||||
current_value = -1
|
||||
vindices = []
|
||||
nindices = []
|
||||
tindices = []
|
||||
|
||||
for i in xrange(1, vertex_count + 1):
|
||||
raw_faces = words[i].split('/')
|
||||
l = len(raw_faces)
|
||||
|
||||
current_value = int(raw_faces[0])
|
||||
|
||||
vindices.append(current_value - 1)
|
||||
face_vertices.append(self.vertices[current_value - 1])
|
||||
|
||||
if l == 1:
|
||||
continue
|
||||
|
||||
if l >= 2 and raw_faces[1]:
|
||||
current_value = int(raw_faces[1])
|
||||
if current_value <= len(self.textures):
|
||||
tindices.append(current_value - 1)
|
||||
face_textures.append(self.textures[current_value - 1])
|
||||
if l >= 3 and raw_faces[2]:
|
||||
current_value = int(raw_faces[2])
|
||||
nindices.append(current_value - 1)
|
||||
face_normals.append(self.normals[current_value - 1])
|
||||
|
||||
if not self.groups:
|
||||
group = Group()
|
||||
self.groups.append(group)
|
||||
else:
|
||||
group = self.groups[-1]
|
||||
group.vertices += face_vertices
|
||||
group.normals += face_normals
|
||||
group.textures += face_textures
|
||||
|
||||
idx_count = group.idx_count
|
||||
group.indices += (idx_count + 1, idx_count + 2, idx_count + 3)
|
||||
group.idx_count += 3
|
||||
|
||||
group.faces.append(Face(type, vindices, nindices, tindices, face_vertices, face_normals, face_textures))
|
||||
|
||||
cdef inline mtllib(self, list words):
|
||||
self.dispatch(os.path.join(self.root, words[1]))
|
||||
|
||||
cdef inline usemtl(self, list words):
|
||||
mat = words[1]
|
||||
if mat in self.materials:
|
||||
self.groups[-1].material = self.materials[mat]
|
||||
else:
|
||||
print "Warning: material %s undefined." % mat
|
||||
|
||||
cdef inline g(self, list words):
|
||||
self.groups.append(Group(words[1]))
|
||||
|
||||
def __init__(self, str path):
|
||||
self.root = os.path.dirname(path)
|
||||
self.vertices = []
|
||||
self.normals = []
|
||||
self.textures = []
|
||||
self.groups = []
|
||||
self.materials = {}
|
||||
self.dispatch(path)
|
||||
|
||||
cdef class Group(object):
|
||||
cdef public str name
|
||||
cdef public tuple min
|
||||
cdef public Material material
|
||||
cdef public list faces, indices, vertices, normals, textures
|
||||
cdef public int idx_count
|
||||
|
||||
def __init__(self, str name=None):
|
||||
if not name:
|
||||
name = clock()
|
||||
self.name = name
|
||||
self.material = None
|
||||
self.faces = []
|
||||
self.indices = []
|
||||
self.vertices = []
|
||||
self.normals = []
|
||||
self.textures = []
|
||||
self.idx_count = 0
|
||||
|
||||
cdef class Face(object):
|
||||
cdef public int type
|
||||
cdef public list verts, norms, texs, vertices, normals, textures
|
||||
|
||||
def __init__(self, int type, list verts, list norms, list texs, list vertices, list normals, list textures):
|
||||
self.type = type
|
||||
self.verts = verts
|
||||
self.norms = norms
|
||||
self.texs = texs
|
||||
self.vertices = vertices
|
||||
self.normals = normals
|
||||
self.textures = textures
|
||||
|
||||
cdef class Material(object):
|
||||
cdef public str name, texture
|
||||
cdef public tuple Ka, Kd, Ks
|
||||
cdef public double shininess
|
||||
|
||||
def __init__(self, str name, str texture=None, tuple Ka=(0, 0, 0), tuple Kd=(0, 0, 0), tuple Ks=(0, 0, 0),
|
||||
double shininess=0.0):
|
||||
self.name = name
|
||||
self.texture = texture
|
||||
self.Ka = Ka
|
||||
self.Kd = Kd
|
||||
self.Ks = Ks
|
||||
self.shininess = shininess
|
|
@ -149,11 +149,15 @@ def check_size(width, height):
|
|||
|
||||
|
||||
def load_texture(file):
|
||||
if file in cache:
|
||||
return cache[file]
|
||||
print "Loading image %s..." % file,
|
||||
if os.path.isabs(file):
|
||||
path = file
|
||||
file = os.path.basename(path)
|
||||
else:
|
||||
path = os.path.join(os.path.dirname(__file__), "assets", "textures", file)
|
||||
|
||||
path = os.path.join(os.path.dirname(__file__), "assets", "textures", file)
|
||||
if path in cache:
|
||||
return cache[path]
|
||||
print "Loading image %s..." % file,
|
||||
|
||||
try:
|
||||
file = open(path, 'rb')
|
||||
|
@ -214,6 +218,6 @@ def load_texture(file):
|
|||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, filter)
|
||||
gluBuild2DMipmaps(GL_TEXTURE_2D, len(raw.format), width, height, mode, GL_UNSIGNED_BYTE, texture)
|
||||
|
||||
cache[file] = id
|
||||
cache[path] = id
|
||||
|
||||
return id
|
Loading…
Reference in a new issue