ShowBase alternative


#1

I’ve written a little alternative class that can replace ShowBase as the base for starting Panda3D programs from python. The most important change is getting rid of all the buildins. It’s simpler, and more maintainable, it may be faster as I got rid of many things that I never used and don’t think many people use (mouse-camera control, BulletinBoard, Jobs, physics, etc), but performance was not the goal. I also got rid of things that people probably use like profiling and sound/music managers because … well I figured it was a good idea at the time.

I won’t propose for this to replace ShowBase, because it will break a lot of existing code and it won’t work in some scenarios at all (eg. multiple windows) but I think it’s an interesting and more pythonic way to start your programs.

Because there are no buildins some functions can become a bit long so I’ve put some replacement/wrapper functions like self.load_model() and self.load_tex() (else you may end up with “self.panda_app.loader.load_model()” and that’s just too long for me). I’ve also copied functions from DirectObject to have them in snake_case, so even if you can’t do taskMgr.add(…) you can do self.add_task(…).

I’ve also made a wrapper for ConfigVariable*, because I’m sorry but getting config vars like: myGameServer = ConfigVariableString(‘my-game-server’, ‘127.0.0.1’) .get_value() is just Eyugh!, why not myGameServer =Config[‘my-game-server’] ? That’s what I did. And also… having default values for config vars scattered all over the sourcecode is also wrong in my book.

Feel free to use it for anything you want, you can get it here:
github.com/wezu/panda3dapp


#2

Oh, it’s great! It’s interesting that several points covered by your alternative are in 2.0’s roadmap! :wink: