Getting started

hi, im new on the forum but i try make something in P3d for some time. I read lot of posts here, read the official manual and check sample programs added to p3d. But it is still not enough for me. I have experience in python programming (i made about 30 web portals with Django and Pylons technology and some desktop apps with pyQt), and even some in gamedev (i made about 15 simple Javascript games, mostly for facebook).
Im looking maybe for some sources of almost finished and complete game to learn something about panda’s mechanics, i.e. how to create welcome menu for example with ‘new game’, ‘credits’ and ‘exit’ buttons? How to create whole level from small 3d pieces i have (like rocks, trees houses)? And how to handle each level (one level in one file? or like one xml? i have no idea)? And many many more questions. I think that analyzing finished project would help me answer that, am i right?

Good luck with that. I’ve had the same problem when I checked this engine a while ago. The tutorials stop when it starts to get interesting. Also, last time I checked, some of the info on the docs were very outdated. It’s a pity really.

I posted a similar request a long time ago

discourse.panda3d.org/viewtopic … highlight=

but the little response I got, got me discouraged and looked elsewhere. I check back here from time to time to see if the situation has changed.

Hard to say one way or the other. Theres many different ways you can do things. Some people load everything in one big file, others load everything as needed.

For example, my cube game I just posted is base on loading everthing one at a time and then randomly placing them in a path.

As for the hello world tut, yes, I think they stop too early myself, but they also left it up to you on what you want to do. Basic things a game needs are a camera, a level/map, a few objects, and a collision step up. The rest would be up to you on how and what you on what you do with thos.

As for the buttons, best way to learn something is to just try it out and see how it works. If you need help understanding anything, you can always ask the forum for help.

I’ll also be adding things like this to my cube game if you like to check out the code maybe sometime. I’ll still need more time before I add in the help menu (whitch will use buttons), but a lot of the basic controls are in plane site to use.

Once you get on to the more advances stuff, like collision, I would recommand looking up astelix
at discourse.panda3d.org/viewtopic.php?t=7918. He has many good examples for anyone getting into the collision setups.

I think one of the great strengths of Panda is that it doesn’t dictate how to structure your game, it just provides the tools you need to do so.

How the game is structured will depend on the game itself.
I’ve structured my own project around the types of objects that can exist in the game. For example:
The Game class loads a Mission.
The Mission class spawns a Level, Agents (characters), and Entities (items, weapons).
The Level class loads the level geometry and starts any Tasks the level needs to function such as physics.
The Agent class takes care of creating an Actor, loading animations, AI, playing sound files, and all the things it needs to do.

There is no special “Panda way” to write your code. I could just as easily take my Python code and replace the Panda functions with those of another engine. Infact this is exactly what happened when I switch from using DirectPython to Panda.

The tutorials and samples plus the samples posted on the forums only give you an introduction to Panda. You’re expected to be quite autonomous and learn more from the particular manual sections, from the API reference or from the sources directly (especially the latter helped me a lot a few times).
Panda is a toolbox and you’re the manufacturer. If you don’t know how to use your tools, they’re useless for you.
My way was to just set myself some goals and try everything to reach those: learning by doing.
If you know what you need help with, post a request on these forums. If you don’t know exactly what you want… well, that makes the whole thing a bit difficult.

Previous Python knowledge will help.

Here are some open source projects from the forums:
discourse.panda3d.org/viewtopic.php?t=6688
discourse.panda3d.org/viewtopic.php?t=7506
discourse.panda3d.org/viewtopi … fdb86c9ed3
discourse.panda3d.org/viewtopic.php?t=7807
p3dp.com/doku.php?id=mavasher:epoch
discourse.panda3d.org/viewtopic … t=gravhook
discourse.panda3d.org/viewtopic … fdb86c9ed3
There is probably more…

panda3d.org/manual/index.php/DirectGUI

You can use the .egg format for both levels and characters.
It supports stuff like instancing so you can probably get some performance optimization, but not as good as with hardware instancig, which requires Cg knowledge.
Also the .egg format has ‘LOD support’ ( switching between premade models with different detail depending on the camera distance.

Unfortunatly, there is no official level editor for Panda but the tool you used to create your game pieces can be used as one.
Knowing that, you have two solution, putting all your objects, terrain, walls and everything in one scene and export it as egg or the second method, piece by piece, that is my favorite.

How to do that ?

  • In a new scene add empties and name them according to you needs (tree1, tree2,… etc) and export it as an egg.
  • Convert your small pieces to egg too. (one egg for each object)
  • In panda, load everything you just exported.
    self.environ = loader.loadModel("/MyDir/world1.egg")
    self.environ.reparentTo(render)

    self.tree1= loader.loadModel("/MyOtherDir/tree.egg")
    self.tree1.reparentTo(render)
    self.tree1.setPos(self.environ.find("**/tree1").getPos())

    self.tree2= loader.loadModel("/MyOtherDir/tree.egg")
    self.tree2.reparentTo(render)
    self.tree2.setPos(self.environ.find("**/tree2").getPos())

As you can see, you load several time the same egg file and give it the adequate position “tree1” and “tree2” which are the name of your empties.

Now, why is this solution my favorite ?
Suppose you have two levels. your second level is an other egg file with many empty objects too as “tree1” and “tree2”. Guess what? The trees are already loaded, you just need to change their positions :slight_smile:
Also, exporting a big scene each time you performed a small change can quickly become ennoying (take 10sec * numberOfChanges)while exporting a hundred of emtpy take less than a sec.
Other free benefit: You decided to add ten branches to your tree. You just need to change one and only one file and the changes applies on all of them.

This technique is not new and can be improuved by instancing your trees with a shader (hope rdb will release it soon) for loading it once and only one time.