using transparent thin surfaces to make a 2d game

hi all!

i’m planning to make a 2d game. but due to design of the game, it’s better to make it 3d. (there will be a lot of objects, a lot of zooming, rotating, camera action, etc.). I tried it using pyglet, and performance was very very low, so i want to give panda3d a chance :slight_smile:

but the problem is, i don’t know anything about 3d, nothing… and i’m also not very interested in 3d, i will basically use it so that i can manage my 2d world better.

before starting to write the core parts, i wanted to ask you guys about the best way to do this. i read and tried some tutorials, and it seems like creating cascading transparent objects and setting textures on them, and then moving or rotating these objects or camera is the best way to go. even better, if i can create these basic models on the fly, as needed.

what do you think? is this the best way to do it? what other alternatives are there?

Sounds reasonable. Should be pretty easy to use CardMaker, or egg-texture-cards, to create a bunch of textured polygon sprites that you can stack up in the scene as you wish.

You can just parent everything to render2d (or aspect2d), ignoring render completely, and you don’t have to think about the third dimension. To control stacking order, you can create toplevel nodes, A, B, and C, for instance, in that order; and parent everything that you want to be in the background to A, the midground to B, and the foreground to C. (You can also use binning to control render order explicitly on a per-node basis, but it might be easier to use the implicit node ordering instead.)


thx for your reply.

i searched for render2d and aspect2d in api docs, but couldn’t find anything. could you point me to the right direction?

some more questions:

is it possible to create these transparent objects (models? meshes? sorry i’m not familiar with terminology) on the fly, without having a model file loaded? (they will just be different in size. one will be 32x32, another will be 128x64, etc.)

another question: if i use render2d or aspect2d, will i be able to use hardware acceleration, or will they be treated as low performance on-screen hud images?

another question: again following your example, can camera be handled in the same way, or is it just used for real 3d objects? (this may be a silly question, i couldn’t read about render2d or aspect2d)

render2d is the root of the scene graph for 2-d objects (as opposed to render, which is the root for 3-d objects). aspect2d is a child of render2d which is scaled to compensate for the non-square shape of the window.

You may also be interested in pixel2d, which is another child of render2d that is scaled to make the coordinate system more familiar to 2-d systems: its units are pixels, rather than abstract screen units.

All four nodes are described in the manual, but not in the generated API; in general, you should look to the manual first before searching the API references. And there are also numerous references to these nodes throughout the forums and in pretty much every example program.

Also, take a good look at the “solar system” example program, which is a 2-d system almost exactly as I describe.

You can certainly create this geometry on the fly; that’s what CardMaker does. And everything onscreen is hardware accelerated.

Manipulating the camera is mainly useful for 3d objects. There is a camera for render2d, but that’s just a technical detail, and there’s not usually any reason to manipulate it.