Using Sceneloader to "stream" large worlds
by Rich Wilson · in Torque X 2D · 10/12/2007 (4:04 pm) · 3 replies
Let's say I have a large map composed of several screens that I want the player to seamlessly transition between. So when the player is in screen A, all of the screens adjacent to A are loaded. Moving one screen to the right would unload the 3 leftmost screens and load in 3 new screens on the right.
Does the existing sceneLoader work this way? would I have to have every screen offset in their own scene files, or can I offset a chunk of data after loading it?
Does the existing sceneLoader work this way? would I have to have every screen offset in their own scene files, or can I offset a chunk of data after loading it?
About the author
#2
10/13/2007 (2:06 pm)
That sounds like something very cool to implement, and probably wouldn't be too difficult if you don't mind a short "loading pause", but for this to be seamless you will need to make some changes to the torquex engine, for instance adding a separate thread to handle your sceneloading. Right now the sceneloader will take over everything once you tell it to load a scene and will not relequish control until its done (correct me if i'm wrong).
#3
If you want to implement asynchronous loading, be aware that Torque X does not fully support multithreading yet (see www.garagegames.com/mg/forums/result.thread.php?qt=68013 and www.garagegames.com/mg/forums/result.thread.php?qt=66702).
You might need to at least register the objects (adding them to the game) in the Torque X thread.
You could do this by adding a thread-safe queue that allows adding objects to it from any thread and that periodically receives ticks from the Torque X thread which allows the queue to register all objects in the queue to the game being in the Torque X thread.
There might be other thread-related problems, but I do not have the source code, so what I said is just a guess (although it is working fine for me).
10/14/2007 (9:29 am)
SceneLoader.Load seems to be designed for loading the scene in a different thread: After loading, the delegate set by SceneLoader.OnSceneLoaded is called to continue initializing the scene. Unfortunately, the namespace GarageGames.Torque.GameUtil is completely missing in the API doc v1.0.0.0, so no further details are available without the source code.If you want to implement asynchronous loading, be aware that Torque X does not fully support multithreading yet (see www.garagegames.com/mg/forums/result.thread.php?qt=68013 and www.garagegames.com/mg/forums/result.thread.php?qt=66702).
You might need to at least register the objects (adding them to the game) in the Torque X thread.
You could do this by adding a thread-safe queue that allows adding objects to it from any thread and that periodically receives ticks from the Torque X thread which allows the queue to register all objects in the queue to the game being in the Torque X thread.
There might be other thread-related problems, but I do not have the source code, so what I said is just a guess (although it is working fine for me).
Torque Owner Thomas Buscaglia