a bit confused about panda's structure

So I have been looking for a good 3d game engine for C++ programmer, and it looks like panda3d has everything I need.

Just I’m not sure how I can work with the lower graphic layer like OpenGL. Also there doesn’t seem to be any kind of function that create 3d primitives like sphere, cube and such. Maybe I didn’t look hard enough, confusing myself with the manual right now.

Specifically, I’m trying to work on a SpriteManager class that sort of handle 2d actors that move about in 3d space. So I want to gain a deeper understanding of how panda’s general structure is really like before I do that.


I am bob and I will be glad to assist you. (hehe no I am kidding though I will try to help :smiley:)

I dunno completely that panda3d has simple primitives to build simple shapes? (This is an "I dunno, someone else will clarify this for us"sort of answer :wink:)

However I do know that panda3d abstracts the openGL/DirectX layer for you (this is a good thing)
A. It’s much easier for people to do things without playing with openGL or D3D…

and secondly it allows you to switch between openGL/DirectX as a rendering backend… so you could build up your whole game and if someone’s gfx card supports directx better than opengl, they simply change an option in a config file (or in your game, for that matter) and they now use directX, because your code (most the time) has no direct calls to either one.

panda3d uses the concept of “nodepaths” which is AMAZING imo.
I’ve yet to play around with the C++ side of panda myself yet, however I do know that things such as OnscreenImage, would allow you to build 2d sprites in the 3 render area, you can also use egg-texture-cards (command line tool) that basically takes a texture(s, for animations) and builds a 2d sprite model (basically)

After which you can make the appropriate call to loader, to load the model, and place it in the “3d” render node.

in C++ the call is something like window->loader->load_model(“path/to/model/without/dotegg/on/the/end”)

(you should look in the manual for that, inside the hello world example (moving the panda)

after which you should notice that the model has to be put under a render node, if you wanted it inside 2d space (that stretches) then you would say for ex: mymodel.reparentTo(render2d)

or for 2d rendering that goes with the window (aspect ratio)

or for the 3d render node, it’s simply called render

of course, the above probably look more like pseudo code to you, those are actually python code,so you’ll have to find the appropriate c++ ones, sorry I’m useless in that area, hopefully I answered a few questions though.


Thank you, that was definitely helpful.

I found out the part in the manual that mention OpenGL/D3D. OnscreenImage and egg-texture-cards are the info I was looking for.

Thanks again.

As Bob…erm, powerpup118 guessed, Panda doesn’t have any inbuilt methods for procedurally generating primitive types. Sphere and cube at least are included as models though.

I played around with the manual a bit and managed to make a ‘cube’ function using GeomPrimitive and attach the node like this:

geom = Geom(vdata)

node = GeomNode('gnode')

nodePath = self.render.attachNewNode(node)

(as in the manual)However it won’t display any cube. Strangely enough, when I include this piece of code:

# Load the environment model.
self.environ = self.loader.loadModel("models/environment")
# Reparent the model to render.
# Apply scale and position transforms on the model.
self.environ.setScale(0.25, 0.25, 0.25)
self.environ.setPos(-8, 42, 0)

(from the helloWorld tut)The cube would display :open_mouth: along with the model. Could I be missing anything here :blush:.

You don’t show us the full code you’re using to generate the procedural cube, so it’s hard to speculate on what you might be missing. But in general, unless there’s a real good reason to generate your models procedurally, it’s usually better to load them from a file instead. The procedural model generation is very low-level and easy to get wrong; it’s provided only for those rare cases that actually need it.

The normal pipeline is to create your models in a modeling package like Blender, and then load them into Panda via loadModel().


Oh, I see, thanks for answering anyway.

[generating primitives)