Question

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...

Was it helpful?

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!

OTHER TIPS

  • You can use a buffer with setOneShot enabled to make it render only a single frame. You can start Panda3D without a window by setting the "window-type" PRC variable to "none", and then opening an offscreen buffer yourself. (Note: offscreen buffers without a host window may not be supported universally.) If you set "window-type" to "offscreen", base.win will actually be a buffer (which may be a bit easier than having to set up your own), after which you can call base.graphicsEngine.render_frame() to render a single frame while avoiding the overhead of the task manager. You have to call it twice because of double-buffering.
  • Yes. Panda3D is used by Disney for some of their MMORPGs. I do have to add that Panda's high-level networking interfaces are poorly documented.
  • You can calculate the transformation from an object to the camera using nodepath.get_transform(base.cam), which is a TransformState object that you may optionally convert into a matrix using ts.get_mat(). This is surprisingly fast, since Panda maintains a composition cache for transformations so that this doesn't have to happen multiple times. You can get the projection matrix (from view space to clip space) using lens.get_projection_mat() or the inverse using lens.get_projection_mat_inv(). You may also access the individual vertex data using the Geom interfaces, this is described to detail in the Panda3D manual.
  • You can use set_color to change the base colour of the object (replacing any vertex colours), or you can use set_color_scale to tint the objects, ie. applying a colour that is multiplied with the existing colour. You can also apply a Material object if you use lights and want to use different colours for the diffuse, specular and ambient components.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top