SimplyMaya Forums

Welcome to the forum, feel free to ask questions here.

Home / forum / Your Work / Work In Progress / OpenGL tinkering
Register FAQ Members List Calendar Mark Forums Read

New Thread
 
Thread Tools
Old 12-04-2010, 01:03 AM   #1
elephantinc
Level 32 pachyderm
 
elephantinc's Avatar
 
Join Date: Dec 2007
Location: England
Posts: 1,859
Thanks: 12
Thanked 43 Times in 37 Posts
Default OpenGL tinkering

I've been experimenting with openGL (using pyOpenGL for python)
So far I've managed to get a textured cube to rotate. I've got my code and a screen shot attached in the zip file. As you can see on the screenshot, there are strange things going on at the edges of the cubes. Does anyone know of a likely cause/solution?

Next I'm going to try to display an .obj file.
Attached Files
File Type: zip archive.zip (152.4 KB, 32 views)
elephantinc is offline   Reply With Quote
Old 13-04-2010, 06:33 PM   #2
elephantinc
Level 32 pachyderm
 
elephantinc's Avatar
 
Join Date: Dec 2007
Location: England
Posts: 1,859
Thanks: 12
Thanked 43 Times in 37 Posts
Default

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?
elephantinc is offline   Reply With Quote
Old 14-04-2010, 12:11 AM   #3
ctbram
Moderator
 
ctbram's Avatar
 
Join Date: Jan 2004
Location: Michigan, USA
Posts: 2,997
Thanks: 42
Thanked 582 Times in 532 Posts
Default

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
ctbram is offline   Reply With Quote
Old 14-04-2010, 12:55 AM   #4
stwert
EduSciVis-er
 
Join Date: Dec 2005
Location: Toronto
Posts: 3,373
Thanks: 74
Thanked 710 Times in 642 Posts
Default

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?
stwert is offline   Reply With Quote
Old 14-04-2010, 10:03 AM   #5
elephantinc
Level 32 pachyderm
 
elephantinc's Avatar
 
Join Date: Dec 2007
Location: England
Posts: 1,859
Thanks: 12
Thanked 43 Times in 37 Posts
Default

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.
elephantinc is offline   Reply With Quote
Old 14-04-2010, 04:14 PM   #6
elephantinc
Level 32 pachyderm
 
elephantinc's Avatar
 
Join Date: Dec 2007
Location: England
Posts: 1,859
Thanks: 12
Thanked 43 Times in 37 Posts
Default

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.
Attached Thumbnails
Click image for larger version

Name:	picture 2.png
Views:	97
Size:	136.6 KB
ID:	44055  

Last edited by elephantinc : 14-04-2010 at 05:27 PM.
elephantinc is offline   Reply With Quote
Old 14-04-2010, 06:53 PM   #7
gster123
Moderator
 
gster123's Avatar
 
Join Date: May 2005
Location: Manchester Uk
Posts: 6,300
Thanks: 1
Thanked 51 Times in 45 Posts
Default

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
gster123 is offline   Reply With Quote
New Thread

« Previous Thread | Next Thread »

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off

1 Month

$34

Month-to-month billing
$34/month
Unlimited access to all videos
Project files to download
Easy to cancel at anytime
 
 

3 months

$87

Billing every 3 months
$29/month
Unlimited access to all videos
Project files to download
Easy to cancel at anytime
Save $5 per month or $15 in total compared to monthly billing with this package.

12 months

$288

Billing every 12 months
$24/month
Unlimited access to all videos
Project files to download
Easy to cancel at anytime
Save $10 per month or $120 in total compared to monthly billing with this package.

Your plan will automatically renew. You can cancel at any time via your PayPal account to avoid being charged again.

You can view the FAQ on our video plans here. You can contact us directly here. By clicking one of the buttons above, you agree to our Terms and Privacy Policy.