Question About World Loading and Rendering in Castle Game Engine (CGE)

Hello,

I am a beginner in Castle Game Engine (CGE).
Although I have been familiar with CGE for a long time, this is the first time I actually want to work with it.

I have created a simple 3D scene. About 25 years ago I had experience writing games (in DOS), and while working with CGE a question came to my mind—something that back then we had to manage manually.

If I create a large world, does CGE load the entire world and only render the objects visible to the camera,
or are objects far from the camera not loaded at all and only loaded when they are likely to enter the camera’s view, and then unloaded from memory after they leave the visible area?

In other words, do these things still need to be managed manually at runtime in CGE?

1 Like

Yes, CGE will load the entire world.

Yes. By default CGE only render objects visible within the camera’s frustum. Please note:

  • A CGE’s “world” can contains one or multiple “scenes” (TCastleScene).
  • A “scene” can contains one or multiple “shapes”.
  • CGE performs frustum culling per-shape.
    If you enable fog, then shapes beyond fog’s distance will not be rendered as well.

CGE does not support automatic data streaming (something you often see in open world games), so objects will not load / unload from memory even if it’s outside of view. You will have to manage it yourself if you want such behavior.

1 Like

Yes, my goal with this question was to understand whether, in an open-world scenario, objects are loaded and unloaded automatically or not.
So it turns out this needs to be handled manually.
It would be nice if the game engine handled this automatically, though.

Thank you very much for your complete and thorough explanation.

Hello, just to confirm Kagamma’s answer:

Our engine indeed does not support automatic “streaming” of 3D world. It is something you need to handle manually.

The usual strategy is that your world is composed of many TCastleScene instances (each one either loaded from a 3D model file, or constructed by code) and you load / unload them as necessary (ideally, not from disk, but from some cache in memory, e.g. you clone existing “template” TCastleScene or designs (see Components to reuse a design in other designs | Manual | Castle Game Engine ) ). We offer a number of features (frustum culling, per-scene and per-shape; LODs; toggling Exists; DistanceCulling, more info in optimization page) to make it efficient to render world with many scenes, but you still have to manage loading / instantiating them carefully, if you plan a truly huge world.

And “asynchronous loading of assets” (see section " 3.29. Asynchronous loading of assets" on roadmap) would allow to make it smoothly, but that is also a TODO for now. So for now, practically it may be necessary to have “loading screen” from time to time if you need to have a huge world in which player travels.

It would indeed be nice to overcome these limitations, but we’re open here – for now, the engine has these limitations. If you want to create something like “an infinite world”, you need to manually deal with this difficulty.

I hope this is useful :slight_smile: I encourage you to try the engine and see how far you can “push” with the existing capabilities and if you have any questions about how to deal with manual loading / unloading go ahead and ask here :slight_smile:

Thank you, Michalis, both for taking the time to reply to my emails and for answering this question here as well.
I understood Kagamma’s answer. I was just suggesting that such a working model could also be nice to have. Of course, the absence of it does not reduce the value of CGE in any way.
I am currently experimenting with it, and maybe it’s better to start with something smaller.
Sometimes I lose objects in the scene, and even by pressing F and changing the zoom I still can’t see where they are. I think if these kinds of questions come up again, I should ask them in a new topic.

1 Like