Model Breakdown [SOLVED]

The time has come for me to fill the classrooms in my game with desks. I have 13 classrooms with 30 desks each, which amounts to 390 desks total, for the smallest school.

I want to make a single egg file that will load all 30 desks and position them, but since the geometry of each desk is the same, I’d rather not duplicate it 390 times in memory, which would be the case if I just exported the positioned desks from my modeling software. How would I go about creating an egg that contains 390 positions for the 120 polygon model, if it’s even possible?

Furthermore, I will need to be able to perform collision detection with the individual desks for two purposes. First, I need to be able to mouse pick them so that I can void any attempts to tell a character to move into the physical space occupied by a desk. Secondly, characters will need to perform collision detection with the desks when they move off my pre-defined paths, so they don’t pass through them. I know there is an egg octree structure created, I think, by Treeform that I can probably use to make this collision detection more efficient by creating a hierarchy. For instance, if you clicked in one classroom it wouldn’t check collisions for desks in other classrooms. I’ve looked at the egg octree before, but I’m not really sure how to use it. Can someone give me a hand with that?

If further information is needed to solve either of these problems, I’ll be happy to provide it.

edit: https://discourse.panda3d.org/viewtopic.php?t=2502&highlight this is the octree I was referring to, I guess it was made by raytaller and not Treeform after all.

Raytaller made the original (he is awesome), but it has problems. My version is better :slight_smile:

When you load an egg file a second time nothing is duplicated. So you could load the model 360 times in code. And position it there.

There is also in egg files which allow inclusion of other models. If you are using blender i think it can export egg that include other eggs see the blender docs.

But actually rendering 360 desks will be slow. Even if they are just 1 triangle. Modern cards use batches and you can only do about 300 batches before it slows down sharply. I recommend combining all desks into a single geom in your modeling program and export them this way (it would probably be just 1 batch then and run very fast). Yes its duplication of vertexes but it will be many times faster trust me.

Do the collision same way, combine everything, then export. Then run my octree script over it.

Treeform is right in his argument that many geoms produce more serious bottlenecks than the polycount. But to overcome both, how about making one object per classroom with 30 desks each?
This way you still have only a few objects and to overcome the polycount problem you can use LODs.

Another approach, although probably still experimental is rdb’s hardware instancing he mentioned on the blog some time ago: panda3d.org/blog/?p=44

For collisions I’d suggest exporting one sphere per desk or so - it’s the cheapest solid and works with all collision systems. Octrees are better for big, solid objects where the avatar is suposed to be somewhere around it, AFAIK. Here you’ll have a model that’s collided into from all directions and also from “inside” (avatars walking through the rows of desks).

I took your advice and made a separate geom for each classroom, with 30 desks in each geom. Thanks for the heads up about that geom vs. polycount info, I wasn’t aware of that.