So, I’m very new to Panda3D and there seem to be very few tutorials out there. However, all of them use models for characters and scenarios, and I was wanting to learn how to draw simple geometric shapes procedurally. So, if I were to make a simple 2D simulation with a top-view camera where boids (could be simple triangles or circles) fly around in the scene, how would I approach this? Can anyone help me with the code for creating these agents?
But you still need to load some kind of model for your boids, while they don’t interact with one another? Otherwise you just won’t see anything.
I have a function that takes verts and faces and creates objects, but those are static, so I don’t think they will fit what you want to do with boids. May be a starting point though.
First of all, thank you for your quick response! Just some follow-ups:
But you still need to load some kind of model for your boids
What do you mean by that? Can’t I procedurally generate a 2D shape such as a square or a triangle and have it move around?
while they don’t interact with one another?
I’m not sure if you’re asking if I want them to interact with one another, but essentially I do (eventually, but now I’m in the learning phase and I just wanted to make the visuals work).
I think that you should be able to do this via a full-screen shader: pass it the locations of your boids, and then have it assign colour based on those locations.
I’m starting to think Panda3D may not fit my needs the way I initially thought. The end goal is to make a 2D evolution simulation using genetic algorithms and neural networks, and since the individuals will be procedurally generated there will be no models, images, or meshes. I was just looking for an engine/software that allows me to have thousands of procedurally generated agents interacting with one another, but I’m having trouble with even drawing simple shapes on screen hahah. Any suggestions if I should consider another software?
I don’t have a specific link, but I daresay that there are shader tutorials around that would cover the basics. (Considering also the manual’s information on the matter, which conveys some of the tools that Panda provides to this end.)
You would then create (in code) a simple quad that covers the screen, and apply your shader to that.
That doesn’t necessarily hold: Procedural generation can be used to produce models on-the-fly that are then rendered. A model isn’t necessarily a file on your disk–it can exist simply in RAM.
Still, for “thousands of agents”, a shader might be more efficient.
Which brings me to another concern: I’d suggest running a performance test to check that Python runs fast enough to control quite so many at an acceptable frame-rate.
While I agree in general with what you said, I should add that my game does indeed have images and models - my creatures are procedurally generated, but in an external software, i.e. the meshes are not created on the fly but actually saved to disk…
Hey, take a look at the code here, it might help you, since it just spawns a bunch of squares after some time, with collision-detection enabled:
It’s not optimized, but if you play around with it, you might learn some things, if all you want is to have simple shapes drawn on the screen that can move around.