Re: COLLADA (DAE) vizualization example

295 views
Skip to first unread message

Nathan

unread,
Sep 18, 2012, 6:27:10 PM9/18/12
to pyglet...@googlegroups.com
On Tue, Sep 18, 2012 at 2:28 PM, Andrey Nechypurenko <andre...@googlemail.com> wrote:
Hi Folks,

I am currently working on the project where it is necessary to visualize COLLADA (DAE) files. For these purposes I decided for pyglet OpenGL wrappers and pycollada (which is the library to read collada files). To learn how to do it I have made an example and just want to let pyglet community know about it. Maybe it could be useful for somebody.

The example has two renderers - the old-style which uses OpenGL display lists and the modern-style which uses GLSL shaders and VBOs (with pyglet's batches). So to some extent, it could be also considered as an example how to visualize 3D models with pyglet using modern OpenGL techniques.

Regards,
Andrey.


Looks interesting--but it doesn't work for me.  :-(  Here's my experience:

1) 'python setup.py install' for pycollada failed trying to automatically install numpy
2) I installed numpy myself: 'pip install numpy'
3) Then installing pycollada worked.
4) examples/daeview.py crashed with this output:

daeview $ python daeview.py 
Creating display list...
It could take some time. Please be patient :-) .
  diffuse = Texture speedometr_bmp: (not available)
  diffuse = Texture compas_bmp: (not available)
  diffuse = Texture speedometr_bmp: (not available)
  diffuse = Texture earth2_jpg: (not available)
done. Ready to render.
Traceback (most recent call last):
  File "daeview.py", line 69, in <module>
    pyglet.app.run()
  File "/Users/nathan/.pythonbrew/pythons/Python-2.7.3/lib/python2.7/site-packages/pyglet/app/__init__.py", line 123, in run
    event_loop.run()
  File "/Users/nathan/.pythonbrew/pythons/Python-2.7.3/lib/python2.7/site-packages/pyglet/app/base.py", line 127, in run
    self._legacy_setup()
  File "/Users/nathan/.pythonbrew/pythons/Python-2.7.3/lib/python2.7/site-packages/pyglet/app/base.py", line 218, in _legacy_setup
    window.dispatch_pending_events()
  File "/Users/nathan/.pythonbrew/pythons/Python-2.7.3/lib/python2.7/site-packages/pyglet/window/cocoa/__init__.py", line 322, in dispatch_pending_events
    EventDispatcher.dispatch_event(self, *event)
  File "/Users/nathan/.pythonbrew/pythons/Python-2.7.3/lib/python2.7/site-packages/pyglet/event.py", line 355, in dispatch_event
    if handler(*args):
  File "daeview.py", line 26, in on_draw
    daerender.render(window.rotate_x, window.rotate_y, window.rotate_z)
  File "/Users/nathan/proj/extra/pycollada/examples/daeview/renderer/OldStyleRenderer.py", line 180, in render
    glCallList(self.displist)
  File "/Users/nathan/.pythonbrew/pythons/Python-2.7.3/lib/python2.7/site-packages/pyglet/gl/lib.py", line 105, in errcheck
    raise GLException(msg)
pyglet.gl.lib.GLException: invalid operation

5) So I switched the renderer in daeview.py to "GLSLRenderer" by swapping the commented renderer lines as instructed, and got this crash:

daeview $ python daeview.py 
Running with OpenGL version:
Traceback (most recent call last):
  File "daeview.py", line 63, in <module>
    daerender = renderer.GLSLRenderer(collada_file)
  File "/Users/nathan/proj/extra/pycollada/examples/daeview/renderer/GLSLRenderer.py", line 48, in __init__
    print 'Running with OpenGL version:', glutils.getOpenGLVersion()
  File "/Users/nathan/proj/extra/pycollada/examples/daeview/renderer/glutils.py", line 13, in getOpenGLVersion
    return cast(versionString, c_char_p).value
NameError: global name 'cast' is not defined


I'm using pyglet 1.2dev (completely up-to-date tip of the hg repo), python 2.7.3 installed via pythonbrew, on OS X 10.8.1.

~ Nathan

Andrey Nechypurenko

unread,
Sep 20, 2012, 6:03:45 PM9/20/12
to pyglet...@googlegroups.com
Hi Nathan,

I could not comment on installation issues since I am neither maintainer of pycollada nor experienced python developer.

Regarding daeview errors - you are right, there were couple of bugs when running on Mac OSX (I have no Mac and did not test on OSX). Nevertheless, with the help from Jeff Terrace these bugs are fixed now. Please pull the new version from git if you like to try it once again.

BTW, this example is now merged into the main pycollada repository. So it is probably better to pull get the latest version from there.

Regards,
Andrey.

Nathan

unread,
Sep 20, 2012, 6:13:57 PM9/20/12
to pyglet...@googlegroups.com
Cool!  It worked!

FYI, it displays a black screen until you click the mouse or press a keyboard -- I don't know if that was intentional.

But I get this output:

daeview $ ./daeview.py 
Running with OpenGL version: 2.1 ATI-1.0.29
Initializing shaders...
  phong
  lambert
  blinn
  constant
  texture
  done.
Creating GL buffer objects for geometry...
  diffuse = Texture speedometr_bmp: (not available)
  diffuse = Texture compas_bmp: (not available)
  diffuse = Texture speedometr_bmp: (not available)
  diffuse = Texture earth2_jpg: (not available)
done. Ready to render.
Renderer cleaning up

I attached a screenshot.  Apparently you drag the mouse around and get to look at a model of a dashboard and steering wheel.

~ Nathan
Screen Shot 2012-09-20 at 4.11.58 PM.png

Andrey Nechypurenko

unread,
Sep 20, 2012, 6:22:44 PM9/20/12
to pyglet...@googlegroups.com
On Friday, September 21, 2012 12:13:58 AM UTC+2, Nathan wrote:
Cool!  It worked!

Great!
 
FYI, it displays a black screen until you click the mouse or press a keyboard -- I don't know if that was intentional.

That is odd... and definitely not intentional :-) . There is no such problem on Windows or Linux. I have to investigate why it happens.
 
But I get this output:

daeview $ ./daeview.py 
Running with OpenGL version: 2.1 ATI-1.0.29
Initializing shaders...
  phong
  lambert
  blinn
  constant
  texture
  done.
Creating GL buffer objects for geometry...
  diffuse = Texture speedometr_bmp: (not available)
  diffuse = Texture compas_bmp: (not available)
  diffuse = Texture speedometr_bmp: (not available)
  diffuse = Texture earth2_jpg: (not available)

Could you please try what Jeff suggested at the end of this thread? Probably he did not commit his changes yet but it should be easy to modify your local copy to see if it solves the problem.

Thanks,
Andrey.
 

Nathan

unread,
Sep 20, 2012, 6:25:22 PM9/20/12
to pyglet...@googlegroups.com
On Thu, Sep 20, 2012 at 4:22 PM, Andrey Nechypurenko <andre...@googlemail.com> wrote:

Could you please try what Jeff suggested at the end of this thread? Probably he did not commit his changes yet but it should be easy to modify your local copy to see if it solves the problem.

Thanks,
Andrey.

I don't have "Pillow" installed, so I don't see how that would be relevant (?)

~ Nathan 

Andrey Nechypurenko

unread,
Sep 20, 2012, 6:26:26 PM9/20/12
to pyglet...@googlegroups.com

Could you please try what Jeff suggested at the end of this thread? Probably he did not commit his changes yet but it should be easy to modify your local copy to see if it solves the problem.

Forget to say, that to display textures PIL should be also installed.

Nathan

unread,
Sep 20, 2012, 6:30:02 PM9/20/12
to pyglet...@googlegroups.com
On Thu, Sep 20, 2012 at 4:26 PM, Andrey Nechypurenko <andre...@googlemail.com> wrote:

Could you please try what Jeff suggested at the end of this thread? Probably he did not commit his changes yet but it should be easy to modify your local copy to see if it solves the problem.

Forget to say, that to display textures PIL should be also installed.

Ah, yes, that looks a bit nicer, doesn't it? (attachment)

~ Nathan
Screen Shot 2012-09-20 at 4.29.20 PM.png

Andrey Nechypurenko

unread,
Sep 20, 2012, 6:42:50 PM9/20/12
to pyglet...@googlegroups.com

Ah, yes, that looks a bit nicer, doesn't it? (attachment)

Now it looks exactly as it should be! :-) Glad that you finally get it running.

BTW, this file (cockpit) contains COLLADA animations for steering wheel and arrows. I am currently extending this example to support animation. I think it will considerably simplify development of the in-game user interface. For programmers, the only thing they will need to know is the name of the animation, for example, to rotate the steering wheel. How this animation will actually looks like is specified by 3D artist using corresponding animation support in Blender or whatever else 3D authoring tool.

Regarding the first repainting issue - without real investigation, I tend to say that it is an pyglet's OSX-specific issue since it works fine on Windows and Linux and do not see any reasons why the window is not updated after being shown. But it is a kind of speculation. I did not really investigate this particular problem yet.

--
Andrey.

Reply all
Reply to author
Forward
0 new messages