Search code examples
python3drenderingpanda3d

Panda3D and Python, render only one frame and other questions


I would like to use Panda3D for my personal project, but after reading the documentation and some example sourcecodes, I still have a few questions:

  • How can I render just one frame and save it in a file? In fact I would need to render 2 different images: a single object, and a scene of multiple objects including the previous single object, but just one frame for each and they both need to be saved as image files.

  • The application will be coded in Python, and needs to be very scalable (be used by thousand of users). Would Panda3D fit the bill here? (about my program in Python, it's almost a constant complexity so no problem here, and 3D models will be low-poly and about 5 to 20 per scene).

  • I need to calculate the perspective projection of every object to the camera. Is it possible to directly access the vertexes and faces (position, parameters, etc..)?

  • Can I recolor my 3D objects? I need to set a simple color for the whole object, but a different color per object. Is it possible?

Please also note that I'm quite a newbie in the field of graphical and game development, but I know some bits of 3D modelling and 3D theory, as well as computer imaging theory.

Thank you for reading me.

PS: My main alternative currently is to use Soya3D or PySoy, but they don't seem to be very actively developped nor optimized, so although they would both have a smaller memory footprints, I don't know if they would really perform faster than Panda3D since they're not very optimized...


Solution

    • You can take a screenshot of your scene using self.win.saveScreenshot(Filename). Example:

      from panda3d.core import Filename
      
      file_name = Filename('whatever.png')) 
      self.win.saveScreenshot(file_name) 
      
    • I have never used the Panda3D Networking API myself but it is supposed to do a good job on the client side. Performance on the server side with thousand of users may not be as good, but you can code the server software using other more suitable technologies for heavy networking like C or NodeJS.

    • Yes, you can access and modify vertices and group them into faces. Default vertex data allows you to set vertex position, normal, color and texture coordinates, although you can set your own customized vertex format if you need to. Take a look at the manual: Panda3D Manual: Creating and filling a GeomVertexData

    • Yes, object color can be set using object.setColor(r,g,b,a) . More info: Panda3D Manual: Tinting and Recoloring

    Hope it helps!