Hello,
We've settled on the OBJ format for our little project now that Soya has
support for it, and I've run into a few issues with it.
First, if the OBJ has more than one character of whitespace separating
each field, the importer dies. This is because the split() function
used to split up the fields in each line explicitly specifies a single
space as the delimiter, which means a break of two spaces gives you an
empty field between the two you actually want.
This is remedied by not specifying a delimiter at all, as dictated in
the function documentation. "If sep is not specified or is None,
...words are separated by arbitrary length strings of whitespace
characters. Consecutive whitespace delimiters are treated as a single
delimiter..."
Therefore, change lines 38 and 81 in objmtl2soya.py from:
line=line.strip(' ')
to:
line=line.strip()
and it's fixed!
Second, some of my models have negative face numbers. These numbers are
indexes into the arrays of vertex positions and texture coordinates, so
an "index of -1 means the last member added to the respective array, -2
is the one before that, and so on." The current face code assumes a
positive integer.
To fix this, replace lines 100 through 103 in objmtl2soya.py with:
if int(spface[0]) < 0:
gv=geometric_vertices[int(spface[0])]
else:
gv=geometric_vertices[int(spface[0])-1]
if len(spface)>=2 and spface[1]!='':
if int(spface[1]) < 0:
tv=texture_vertices[int(spface[1])]
else:
tv=texture_vertices[int(spface[1])-1]
If there's a more elegant way to to not subtract one if the face is
negative, you can do that, too. ;) Thanks to Sean Lynch for the
suggestion on IRC.
Now, what's this about the texture vertices not being shared with the
geometry vertices? Is this wasting memory or going to expose issues
with Soya or something? Is anyone thinking about swizzling the model
and making them shared on import?
Thanks,
Vito