Example of game without models

Hey y’all! Hope you’re doing great!

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?

Thank you in advance!

Well, there is a manual section about how to do part of what you want to do.

https://docs.panda3d.org/1.10/python/programming/internal-structures/procedural-generation/index

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.

For debug purposes, it’s helpful to see where your object is without any dynamic generation. That’s something you can use a regular mesh/object for.

Interact in the sense of “close enough to each other to deform the others”. At least that’s what I think you’re going for.

Where can I learn more about how to implement full-screen shader?

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.

(The manual covers one way of doing this here.)

See also this project:

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.

1 Like

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…

1 Like

Ah, fair enough–I had forgotten that!

Well, a poor choice of example, then, although as you say the point still stands.

1 Like

Here are some pretty interesting procedural geometry samples made by Epihaius: GitHub - Epihaius/procedural_panda3d_model_primitives: Generate 3D-model primitives (e.g. boxes, spheres etc.) procedurally in your Panda3D projects.

There is even an open PR to include them in the Panda3D samples (just one of many, many open PRs :wink:): Add procedural geometry samples by Epihaius · Pull Request #677 · panda3d/panda3d · GitHub

1 Like

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.

1 Like

I also made an example of how to use compute shaders to create geometry on the fly a while ago:

1 Like

I believe that all these game examples by @janEntikan1 are fully procedurally generated:

1 Like