I’m in the process of trying to write my own python that sits on top of the Panda3D C++ (yes I realize this is a lot of work) so that I can end up with something for a 2D game I am developing that will run faster than using the generic direct gui. (based on python speed profiling I have done regarding different ways to do things over the past couple years)
In the end regarding my python I’d like to end up with a main object for Panda3D which has window objects which each have their own functions and variables as needed. Bascially I don’t want everything on a single object.
I’m assuming that having multiple windows means that I need to create my own versions of render2d/pixel2d for the additional windows. Is this assumption correct?
Over the last couple weeks during my lunch break I’ve been trying to figure out if and how nodepaths like render2d/pixel2d would be associated with a window created from the graphicsEngine.makeOutput command. So far I have been unable to find any code that associates these 2 things together. BufferViewer takes in both the window and render2d but it doesn’t appear to associate them in any way.
There must be something that I am missing or something I don’t understand. Does anyone know if there is an association between these 2 things or does render2d exist for all windows that are created? If so how do you choose which window you want to add something like an OnscreenImage to?
I haven’t taken a look at any of the C++ because I don’t really have much experience with it. So if an association is happening within there I definitely haven’t seen it yet.
If anyone knows how windows and nodepaths are associated (if they are) I would really appreciate an answer. Thanks.
I suggest looking at direct/showbase/ShowBase.py. This contains the code that ties this all together.
Whether you need a different render2d for a different window depends on whether you want the other window to contain other 2D content. If you want to display the same GUI on both windows, you can reuse the same scene graph.
In short, how a window is associated with a scene graph:
The window contains a list of DisplayRegions, created using win.makeDisplayRegion. Each display region contains a “camera”. The camera is placed in a scene graph, such as render2d, which is how it determines what it renders.
In ShowBase you can see how it sets this up: setupRender2d() creates the render2d scene graph, and makeCamera2d creates the display region, a camera with orthographic lens, associates the camera with the display region, and puts the camera in the render2d graph.
Thanks for replying. That is exactly what I was looking for.
I was looking for something with an object in the middle but I didn’t realize there were two.
Now I can continue with the work I am doing. Thank you so much.
While looking through Panda3d’s python along with a bunch of profiling I’ve done since I started working on a game I have found some things that could be changed in Panda3d’s python to improve the speed at which it runs. I’ve also found a couple spots in the code that will actually blow up in python 3 but I’ve never hit any of those spots with the code I’ve run yet any I have no idea if anyone else has either.
At some point I could submit the changes but I’m not sure how you’d like them or which branch you’d like them for. If you want the changes sooner I could make a unified diff and email it somewhere or upload it here.
I’m not sure what you mean when you refer to “Panda3D’s Python”. Panda uses stock CPython, so performance improvements for the Python interpreter should be submitted to the Python bug tracker.
Changes to the Panda source base should preferably be submitted as pull requests to the master branch on GitHub.
By Panda3D’s python I am referring to the python code in:
I’ll get a pull request to master set up right now since I have a little time.
There will be:
Some changes to improve speed.
Some formatting changes to make things more consistant/readable.
A couple changes so things don’t blow up in python 3.
I decided since it is taking a while to get the changes in that I’d skip the formatting changes since they don’t affect the speed of the code.
It appears that editing directly on github can cause some strange issues. A strange character got inserted where I made changes. Seeing if I can remove this and if it exists in any other places.
My latest pull request should no longer have that weird character. It appears it only happened in one place. Had to commit it back to == with no spaces and then I could commit back to “is”. Github couldn’t see the character and even if I replaced the whole line it thought it was the same as before and wouldn’t let me commit.