Game Development Community

Streaming engine/Dynamic Datablock Creation

by Sean H. · in Torque 3D Professional · 04/09/2011 (9:10 am) · 5 replies

So I'm planning out a dynamic object/resource streaming system for torque. This system would work similar to other streaming content systems where resources are dynamically created as the player moves through the world. In this system, resources will be dynamically created and destroyed maintaining the lowest possible amount of system memory usage.

In order for this to work properly, I would need to create datablocks and load resources from disk while the game is running. My initial idea was to simply create the datablocks one at a time as necessary. Later, I realized that loading resources asynchronously in a separate thread might be a better way to go.

Here's my question, is there anything prohibitive in simply creating datablocks and objects dynamically thru script while the game is running? This would be for single-player only so I'm not worried about sending the datablocks to clients. If it's not feasible to create datablocks the normal way but instead using a separate processing thread, is there anything prohibitive in creating datablocks and loading content asynchronously in a separate thread?

Any advice would be helpful.

#1
04/13/2011 (7:38 pm)
Any advice would be helpful. :)
#2
04/14/2011 (12:55 am)
I'm not quite sure what you want to do. When you say "creating datablocks and objects dynamically thru script" do you mean creating the actual datablocks or creating objects based on the datablocks?

There is no problem creating a new object when you want to, but streaming large chunks of objects as the player gets closer to them should really be handled in the c++ side of things not the TorqueScript side.

If you want to dynamically create new datablocks I would think that you can but I'm not sure why you would want to. A datablock just has the initial values for the variables in an object, you can change most of these using torquescripot after the object is created.
#3
04/14/2011 (9:12 am)
Good luck =)
#4
04/15/2011 (5:42 pm)
Quote:
When you say "creating datablocks and objects dynamically thru script" do you mean creating the actual datablocks or creating objects based on the datablocks?

both actually. a shapebase-derived object would need it's datablock to be present before it can be instantiated. The streaming system would create the datablock for an object, and then create the object once the datablock is loaded. my question was mainly regarding creating datablocks dynamically through script.

Quote:
If you want to dynamically create new datablocks I would think that you can but I'm not sure why you would want to.

When a datablock is created, it loads resources from disk including textures, and sounds. By default, torque loads all resources at mission load. If I can control when datablocks are created and deleted, then I am also controlling when resources are loaded from disk. This seems like the key to creating a true streaming system in torque. I just wonder if this is a feasible direction to go with this.


#5
04/15/2011 (8:05 pm)
You can "exec" the datablock .cs files whenever you want through your code which would allow you to control when some datablocks are loaded, but I'm an not sure if you can delete a datablock after you no longer need it.