AjaxVM / pyggel

PYGGEL (PYthon Graphical Game Engine and Libraries)
1 stars 0 forks source link

pyggel cannot load a mesh with a texture. #17

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. load an .obj file with a .mtl file associated with it that has a texture file

What is the expected output? What do you see instead?
Expected output is a textured mesh. what you get is index out of range error

What version of the product are you using? On what operating system?
wc Rev:504

Please provide any additional information below.

C:\Programing\3dgame>python main.py

Traceback (most recent call last):
  File "main.py", line 93, in <module>
    main()
  File "main.py", line 28, in main
    tile0 = pyggel.mesh.OBJ("data/mesh/world/test0.obj", pos=(0, 0, 0),colorize=
[1, 1, 1, 1])
  File "build\bdist.win32\egg\pyggel\mesh.py", line 78, in OBJ
  File "build\bdist.win32\egg\pyggel\mesh.py", line 106, in compile
IndexError: list index out of range

Original issue reported on code.google.com by a.bucky....@gmail.com on 25 Sep 2014 at 4:28

GoogleCodeExporter commented 9 years ago
Suggesting to add "continue" 
line such as below:
        if values[0] in ("o", "g"):
            objs.append(ObjGroup(values[1]))
            continue

"""
pyggel.mesh
This library (PYGGEL) is licensed under the LGPL by Matthew Roe and PYGGEL 
contributors.

The mesh module contains mesh classes for different kinds of meshes, as well as 
loaders for various kinds of meshes.
"""

from include import *
import os
import image, view, data, misc, math3d
from scene import BaseSceneObject
import time
import random
import math

def OBJ(filename, pos=(0,0,0), rotation=(0,0,0), colorize=(1,1,1,1)):
    """Load a WaveFront OBJ mesh.
       filename must be the filename of the mesh to load
       pos/rotation/colorize are the starting attributes of the mesh object."""
    view.require_init()

    objs = []
    mtls = {}

    vertices = []
    normals = []
    texcoords = []

    for line in open(filename, "r"):
        if line.startswith('#'): continue
        values = line.split()
        if not values: continue
        ###print values
        if values[0] in ("o", "g"):
            objs.append(ObjGroup(values[1]))
            continue

Original comment by rtr...@vt.edu on 6 Aug 2015 at 10:49