Saves and loads simulation objects to external files.
This node can be used to save or load simulation objects in external files. It can also work in an automatic mode where it saves files if they do not already exist, and loads files if they do exist. This node serves two purposes. One is to provide a cache of a simulation or some of the objects in a simulation that is persistent across Houdini sessions. The other is to allow the output of one simulation to be loaded into another simulation without having both simulations running in the same hip file.
When using this node it is important to understand the relationship between an object and its creator node. Every object and piece of data in a DOP simulation keeps a record of the DOP Node that created it. This is how from frame to frame each object always follows the same path through the DOP Network. When loading objects from a file, the original creator node may not exist any more. Creator nodes are saved to files as paths relative to the owner DOP Network.
When loading a file, the DOP node matching that path is found and set as the creator for the object or data. If no matching node is found, the File DOP is set as the creator for the object. Data is left with no creator node because data does not flow through a DOP Network the way objects do, so it is not a problem to have data without a creator node. The File DOP also has an option to take ownership of all loaded objects whether a matching DOP node for its creator path is found or not. This is useful in cases where the File DOP is loading objects from another network which might have had DOP nodes with the same names, but which don’t really represent the same thing.
When saving objects to a file, the objects are saved at the end of a timestep. When loading a file, the objects are loaded at the start of the timestep so that they can act as affector objects for other objects in the scene. But these objects are protected from modification by the DOP Network or by any solvers. So the state of these objects at the end of the timestep will be exactly the same as it was at the start of the timestep when the objects were just loaded.
It is also important to understand the difference between a File DOP and the simulation cache. The cache is created and maintained entirely automatically by the DOP Network. The cache always stores the whole state of a simulation, whereas the File DOP can be used to store only part of a simulation. The cache is deleted and recreated automatically when the DOP Network is changed. Having a File DOP in a DOP Network does not affect the operation of the cache in any way.
Parameters
| Activation | When this parameter is zero, this node neither saves nor loads a file. Because this node is processed only once, the object specific local variables cannot be used in this node. | ||||||||
| Operation Mode | Indicates the mode of operation for this node.
| ||||||||
| File | The name of the file to which the objects should be saved or loaded. This should usually be an expression involving the simulation time or simulation frame number. | ||||||||
| Take Ownership of Loaded Objects | Turning on this parameter causes the File DOP to be set as the creator node for all objects loaded from the specified file. This option is useful when using the File DOP to load objects from a file created by a different DOP Network, where some nodes in the current network may have the same names as the nodes in the source network. | ||||||||
| Match By Name | Loaded objects normally will replace any object in the scene with the same object id. This allows the file dop to know which objects to replace when it created the objects in an earlier frame. One problem with this is if the simulation file has new objects created over time, the object ids of the loaded sim might match those created by the live network. Instead, one can match by the name of the object. This requires that all objects in the .sim file have unique names, but allows layering of simulations without concern of the simulations stomping on each other. If Match By Name is turned on, any relationships stored in the .sim file will be ignored to avoid them overriding live objects. | ||||||||
| Match Prefix | When Match By Name is on this prefix is prepended to the name of loaded objects to determine the name that will be matched with in the current sim. This can be used to create a namespace for loaded objects to ensure they don’t replace live objects. | ||||||||
| Compress .sim Files | Determines if .sim files written to disk for caching will be compressed. Compression can reduce the size of the disk cache significantly, but can also increase the time to cache significantly. If loading or writing to cache seems slow, try using uncompressed .sim files, especially with fluid sims. |
Inputs
| First | The objects connected to this input are saved to the file when this DOP is in Write mode. When in Read mode, the node connected to this input is not processed in any way unless the specified file cannot be found. |
Outputs
| First | Outputs the objects loaded from the file when in Read mode. In Write mode, the objects from the input are passed to this output. |
Local variables
| ST | This value is the simulation time for which the node is being evaluated. This value may not be equal to the current Houdini time represented by the variable T, depending on the settings of the DOP Network Offset Time and Time Scale parameters. This value is guaranteed to have a value of zero at the
start of a simulation, so when testing for the first timestep of a
simulation, it is best to use a test like |
| SF | This value is the simulation frame (or more accurately, the simulation time step number) for which the node is being evaluated. This value may not be equal to the current Houdini frame number represented by the variable F, depending on the settings of the DOP Network parameters. Instead, this value is equal to the simulation time (ST) divided by the simulation timestep size (TIMESTEP). |
| TIMESTEP | This value is the size of a simulation timestep. This value is useful to scale values that are expressed in units per second, but are applied on each timestep. |
| SFPS | This value is the inverse of the TIMESTEP value. It is the number of timesteps per second of simulation time. |
| SNOBJ | This is the number of objects in the simulation. For nodes that create objects such as the Empty Object node, this value will increase for each object that is evaluated. A good way to guarantee unique object names is to use an expression
like |
| NOBJ | This value is the number of objects that will be evaluated by the current node during this timestep. This value will often be different from SNOBJ, as many nodes do not process all the objects in a simulation. This value may return 0 if the node does not process each object sequentially (such as the Group DOP). |
| OBJ | This value is the index of the specific object being processed by the node. This value will always run from zero to NOBJ-1 in a given timestep. This value does not identify the current object within the simulation like OBJID or OBJNAME, just the object’s position in the current order of processing. This value is useful for generating a random number for each object, or simply splitting the objects into two or more groups to be processed in different ways. This value will be -1 if the node does not process objects sequentially (such as the Group DOP). |
| OBJID | This is the unique object identifier for the object being processed. Every object is assigned an integer value that is unique among all objects in the simulation for all time. Even if an object is deleted, its identifier is never reused. The object identifier can always be used to uniquely identify a given object. This makes this variable very useful in situations where each object needs to be treated differently. It can be used to produce a unique random number for each object, for example. This value is also the best way to look up information on an object using the dopfield expression function. This value will be -1 if the node does not process objects sequentially (such as the Group DOP). |
| ALLOBJIDS | This string contains a space separated list of the unique object identifiers for every object being processed by the current node. |
| ALLOBJNAMES | This string contains a space separated list of the names of every object being processed by the current node. |
| OBJCT | This value is the simulation time (see variable ST) at which the current object was created. Therefore, to check if an object was created
on the current timestep, the expression |
| OBJCF | This value is the simulation frame (see variable SF) at which the current object was created. This value is equivalent to using the dopsttoframe expression on the OBJCT variable. This value will be zero if the node does not process objects sequentially (such as the Group DOP). |
| OBJNAME | This is a string value containing the name of the object being processed. Object names are not guaranteed to be unique within a simulation. However, if you name your objects carefully so that they are unique, the object name can be a much easier way to identify an object than the unique object identifier, OBJID. The object name can
also be used to treat a number of similar objects (with the same
name) as a virtual group. If there are 20 objects named “myobject”,
specifying |
| DOPNET | This is a string value containing the full path of the current DOP Network. This value is most useful in DOP subnet digital assets where you want to know the path to the DOP Network that contains the node. |
Note
Most dynamics nodes have local variables with the same names as the node’s parameters. For example, in a Position node, you could write the expression:
$tx + 0.1
...to make the object move 0.1 units along the X axis at each timestep.
Examples
| CacheToDisk | Load | Launch |
This example shows how to use the File DOP to cache a simulation to disk and read it back in. | |