archive.zip (152.4 KB, 213 views)
#
2
13-04-2010
, 06:33 PM
Level 32 pachyderm
Join Date: Dec 2007
Location: England
I've finished my class to load and display .obj files. It works on some models but doesn't work on anything I export and I get a rather strange error:
Code:
Traceback (most recent call last):
File "/Users/Elephant_Inc/Desktop/bpwpapcode/Chapter11/tankdemo.py", line 92, in <module>
run()
File "/Users/Elephant_Inc/Desktop/bpwpapcode/Chapter11/tankdemo.py", line 64, in run
tank_model.read_obj('elephanilla.obj')
File "/Users/Elephant_Inc/Desktop/bpwpapcode/Chapter11/model3d.py", line 120, in read_obj
texture_path = os.path.join(model_path, material.texture_fname)
File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/posixpath.py", line 60, in join
if b.startswith('/'):
AttributeError: 'NoneType' object has no attribute 'startswith'
I've triangulated the mesh (I have a thing in the program to check for that anyway). Does anyone know what the cause could be?
#
3
14-04-2010
, 12:11 AM
Moderator
Join Date: Jan 2004
Location: Michigan, USA
well from the traceback it appears things start to go south starting at line 60 and the error does not seem to be with the .obj file at that point but with hashing the path "/" character.
"If I have seen further it is by standing on the shoulders of giants." Sir Isaac Newton, 1675
#
4
14-04-2010
, 12:55 AM
EduSciVis-er
Join Date: Dec 2005
Location: Toronto
Well it's not necessarily the / character itself, but that you've got a NoneType (essentially nothing) when it's expecting a string or something like that. Basically I don't think the .obj is getting passed in correctly, but I think you already knew that. Could you try with a simple cube or something?
#
5
14-04-2010
, 10:03 AM
Level 32 pachyderm
Join Date: Dec 2007
Location: England
I tried it with a cube and got the same error, but I tried it with someone else's model and it did work. I wonder if Maya does something my program doesn't like.
I'll go back to the cube and see if I can find anything strange in there.
Code:
texture_path = os.path.join(model_path, material.texture_fname)
This seems to be the problem with my program. Maybe it doesn't like the fact that it has no texture.
edit: :attn:
I've got it to work. It didn't like the fact that no texture was specified.
Thanks for the help.
Last edited by elephantinc; 14-04-2010 at 11:59 AM.
#
6
14-04-2010
, 04:14 PM
Level 32 pachyderm
Join Date: Dec 2007
Location: England
Here's my elephanilla model rendered using my program:
As you can see, all the duplicated features (eyes, tusks etc.) don't seem to display properly. So far I've had no luck figuring out what's causing it.
It seems that the half facing away from the camera (that shouldn't be drawn) is being draw but the half that is facing the camera isn't being.
After a bit of testing, it seems to happen when I duplicate/mirror the features. If I duplicate with out mirroring them, they display fine.
Reversing the normals seems to fix it but messes up the lighting
edit: After freezing transformation and reversing normals, it displays correctly! Now I'm going to add some camera controls and then I'll try and make it a bit less picky.
Last edited by elephantinc; 14-04-2010 at 05:27 PM.
#
7
14-04-2010
, 06:53 PM
Moderator
Join Date: May 2005
Location: Manchester Uk
You've always got to remember to freeze transforms and delete history, and set the normals before taking into any realtime app.
"No pressure, no diamonds" Thomas Carlyle
You may not post new threads |
You may not post replies |
You may not post attachments |
You may not edit your posts |
BB code is On |
Smilies are On |
[IMG] code is On |
HTML code is Off
|