Re: [pygame] 3D sample code
Will McGugan wrote: [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] wrote: On Thu, June 7, 2007 2:45 pm, Horst JENS wrote: On Mon, 2007-06-04 at 21:19 +0100, Will McGugan wrote: I've just posted some sample code for using OpenGL with PyGame. Hope you find it interesting. http://www.willmcgugan.com/2007/06/04/opengl-sample-code-for-pygame/ that's exactly what i was looking for... thanks! It is interesting. Am I right in understanding that you basically have to choose between Pygame's normal (SDL) drawing functions, like surface.blit, and OpenGL's? You can't just draw a 3D scene like that of the code above, and then blit an interface or text atop it. Instead you have to switch to a 2D mode, turn your Pygame drawing into an OpenGL texture, and draw a rectangle textured with the new drawing -- and delete/replace the texture every time you want to change something. That's so cumbersome that I've barely ever gotten it to work; is there a better way to integrate OpenGL and Pygame graphics? You're right that you cant use any of the regular SDL drawing functions with OpenGL - or any other accelarated 3D API. You can work with 2D graphics in OpenGL though, by drawing texture quads. If you wrap that in a simplified interface, then the code doesn't look much different from what you are used to in 2D PyGame. Will Is there a way to render 3d objects out to disk only, and use the renders in a normal Pygame program? Is there any advantage to doing so, in speed, or memory, or anything?
Re: [pygame] 3D sample code
You're right that you cant use any of the regular SDL drawing functions with OpenGL - or any other accelarated 3D API. You can work with 2D graphics in OpenGL though, by drawing texture quads. If you wrap that in a simplified interface, then the code doesn't look much different from what you are used to in 2D PyGame. For such a simplified interface, you might find Lamina useful. http://cheeseshop.python.org/pypi/Lamina/0.1.2 David -- [EMAIL PROTECTED] Pitcher's Duel - pitchersduel.python-hosting.com
Re: [pygame] 3D sample code
Will McGugan: I don't think it would be pracitcal to render 3D models and blit them in 2D. Happy to be proven wrong though. Well, consider games like powermanga. They generated their sprites using 3-D tools and saved them to disk. When I was working on an SDL game in C, I noted that since I rotated only in integer degrees, I could set up 360-long cache arrays for sprite rotations. This sped up rendering immensely, so long as nothing ever zoomed in or out. So if your 3-D game tends to repeat a few basic perspectives on an object, you may actually consider memoizing renderings to a weakref LRU/MRU structure of some sort. -- Here is the memo if you didn't receive it: GNOME and Nick Moffitt Free Software is all about *SAVING THE WORLD* not [EMAIL PROTECTED] drawing pissy little buttons on the screen. -- Jeff Waugh
[pygame] Numeric/NumPy/Numarray Clarification
I've been messing around with PyGame and the OpenGL bindings for a while now, and I've recently begun to start seeing the light of using the array classes from numpy for various math operation. The thing is... Does anyone have any sort of clear idea about which package I should have installed out of Numeric, NumPy and Numarray? They all seem to be by the same bunch of people, but the fact that they all seem to do the same thing, but are named differently and have no clues about them to let you know which one does/has what bundled in with it. For instance, in the pygame repository there's a little plasma demo that uses RandomArray which is suppsedly in the Numeric package. I have the Numeric package installed, but after searching through the /usr/lib/python2.4/site-packages directory, I did not find RandomArray in the Numeric package, but I *did* find a RandomArray2 module inside the Numarray package. So in the code, I had to replace from RandomArray import * to from numarray.random_array.RandomArray2 import *. Ultimately, that did the trick of solving the missing RandomArray import problem, but seriously, I just want a nice, clean site-packages directory, and just need some pointers on which bloody package I *should* have installed, or at the very least, someone explain to me the differences between the three apparently different packages. Sorry for the long-windedness, but it's just kinda frustrating not knowing if I have the right package installed. Thanks :) ~Chris CONFIDENTIAL NOTICE: This email including any attachments, contains confidential information belonging to the sender. It may also be privileged or otherwise protected by work product immunity or other legal rules. This information is intended only for the use of the individual or entity named above. If you are not the intended recipient, you are hereby notified that any disclosure, copying, distribution or the taking of any action in reliance on the contents of this emailed information is strictly prohibited. If you have received this email in error, please immediately notify us by reply email of the error and then delete this email immediately.
Re: [pygame] 3D sample code
Kamilche wrote: Is there a way to render 3d objects out to disk only, and use the renders in a normal Pygame program? Is there any advantage to doing so, in speed, or memory, or anything? It is possible to render to a texture and grab that back, but I don't think you could do that in PyGame without creating an OpenGL display first. I don't think it would be pracitcal to render 3D models and blit them in 2D. Happy to be proven wrong though. Although maybe it could be done with a software based OpenGL implementation, like Mesa3D. :-/ Will
Re: [pygame] 3D sample code
Nick Moffitt wrote: Will McGugan: I don't think it would be pracitcal to render 3D models and blit them in 2D. Happy to be proven wrong though. Well, consider games like powermanga. They generated their sprites using 3-D tools and saved them to disk. I think Kamilche was suggesting doing it on the fly. If you were just going to generate images offline, then you probably wouldnt use OpenGL.
[pygame] mac app stuck on minimized
Hi Been pulling my hair out over this. On Mac OS X while running my app from the command line the window minimize and click to maximize worked fine. When I packaged it up using py2applet it stopped maximizing when the icon was clicked. Solution: In the setup.py generated by py2app change the argv_emulation = true to false run the setup as normal and the window will behave normally thanks to; http://mail.python.org/pipermail/pythonmac-sig/2007-May/018917.html Regards Sean
[pygame] Dirty Rect Animation
Hello, all; I was working on some code for my game and read about the optimization of feeding a list of rects to the update function. I was curious if it would be worthwhile to try to optimize the list that is fed to the function. Specifically, I would try to shorten the list by merging rects that had significant areas of overlap. However, I can't tell if the function itself might perform this work itself. Does anyone know? Thank you, JC
Re: [pygame] 3D sample code
On Fri, June 8, 2007 2:30 pm, Kamilche wrote: Is there a way to render 3d objects out to disk only, and use the renders in a normal Pygame program? Is there any advantage to doing so, in speed, or memory, or anything? Take a look at the program at http://pygame.org/projects/10/326/, Peter Rogers' pygame-blender converter. It uses Blender (freeware) to render a 3D object to a set of animation frames.
Re: [pygame] 3D sample code
On Fri, June 8, 2007 1:09 pm, David wrote: You're right that you cant use any of the regular SDL drawing functions with OpenGL - or any other accelarated 3D API. You can work with 2D graphics in OpenGL though, by drawing texture quads. If you wrap that in a simplified interface, then the code doesn't look much different from what you are used to in 2D PyGame. For such a simplified interface, you might find Lamina useful. http://cheeseshop.python.org/pypi/Lamina/0.1.2 It does sound useful. When I tried the demos, though, they said no module named la. I figured this might mean lamina, but changing it to that didn't help. Then I thought it might be something from OcempGUI (which I don't have installed), so I tried running a very basic demo: code ## Hacked-together Lamina test import lamina from pygame import display, key, init, event from pygame import time as pytime from pygame.locals import * import OpenGL.GL as ogl import OpenGL.GLU as oglu # create gui with appropriate constructor gui = GUI_Constructor() # create LaminaPanelSurface gui_screen = lamina.LaminaPanelSurface( (640,480), (-1,1,2,2) ) # draw widgets on surface gui.draw( gui_screen.surf ) /code Result: Traceback (most recent call last): File C:/Documents and Settings/Owner/Desktop/lamina/lamina_test_k.py, line 12, in ? gui = GUI_Constructor() NameError: name 'GUI_Constructor' is not defined That happens even with spyre and lamina in the same directory.
Re: [pygame] Dirty Rect Animation
I'm fairly certain that update does NOT merge incoming rects or do any other optomization on input. It iterates through all of the rects in the list and updates that portion of the screen. So you can optimize it considerably by merging rects where it makes sense, rather than sending a rect for each of your 1000 sprites you want to draw :) You could also check out DR0ID's optimized drawing routine and see what he does. If I recall, it handles dirty rects.
Re: [pygame] 3D sample code
On Fri, June 8, 2007 11:29 pm, Richard Jones wrote: On Sat, 9 Jun 2007, Kamilche wrote: Is there a way to render 3d objects out to disk only, and use the renders in a normal Pygame program? Is there any advantage to doing so, in speed, or memory, or anything? Sure, POV-Ray http://www.povray.org/ :) There's even pypov http://arrowtheory.com/software/python/pypov/ There's also Art of Illusion: http://artofillusion.org/ . It's very different in interface from POV-Ray. Or for people more interested in quick results than precision, Google Sketchup.