[SOLVED] loading and unloading models

Due to performance issues, I’d like to unload models and load new ones. This is when you enter a building “in game mode”, then I’d like to remove all the scene and load new one. Is there a way to do that?

Also, I displayed FPS on the screen, but is there a way to display number of polys or verts rendered?

Apologies if my question seems too basic. I’m not yet proficient with Panda.

My problem is that I load many models (.egg files) into 3D scene. I can unload them using myModel.removeNode(), but I wanted to check with the community what’s the best approach and common practice here.

My idea was to create a separate file, say called load_game_models.py and use import to run it. Then I could create unload_game_models.py and import it when needed. Yet maybe there is a way to unload all the models with a single command?

Also, does Panda render the polygons, which are not visible?

Let me explain why I ask this question. I created a building model and I program it, so you could “enter” the building. I can either add the interior building model to the whole scene or I can unload all the models and load it separately. The latter would work well if Panda renders all the polys no matter what.

I tested my code on low performance and high performance computers to see how it works. On low comps it makes a difference. If I “swamp” the scene with something over 50,000 polys the output starts to be choppy.

Any advise/comments on the above mentioned topic would be really helpful.

removeNode() should be enough. You could also use loader.unloadModel() to remove the model from cash (or memory?) but I don’t think that’s really a necessity.

The question about rendering visible polygons is a bit complex.

There’s view frustum culling in panda. Object that are totally out of the cameras view are not rendered, but there’s no occlusion culling - things that are invisible to the camera because they are behind some other objects will still be rendered (send to the gpu).

So if you have a interior and a exterior then both will be send to the graphic card if the camera is facing them even if the interior is hidden behind a wall.

You could hide the interior behind an OccluderNode, but I can’t give you more then the manual page about that:
panda3d.org/manual/index.php … er_Culling

Hiding and showing the interior and/or exterior seems a good option for me. You don’t have to remove them totally, just use NodePath.hide()

You can use pstat for some benchmarking and performance tuning, there’s a good page in the manual about that:
panda3d.org/manual/index.php … ith_PStats

Many thanks. This will keep me busy with studying the Manual.

Yes, I mostly refered to occlusion culling - things that are behind some other objects. Hiding the Interiors sounds like a good solution.

I was also thinking to hide parts of the map based on the location. In other words if you enter a certain segment of the map (based on X, Y coords) the proper package of models will unhide. Something like this. This would eliminate small objects, which are far away or behind other objects.

Is there a quick way to see how many polys are rendered by Panda (or verts)? Same as you can see FPS in the upper-right corner. This would be enough at least for a start, till I make a full use of PStats.

Yes, but that quick way is PStats. :slight_smile:

David

OK thanks. :smiley: Off to study this section of the Manual.

I’m marking the topic as ‘Solved’. Again many thanks for your help and advise. I really appreciate that.