MegaFlow .FLW format

We have added a custom xml based file format for velocity grid data to be imported with, this will allow people with custom flow data to create a file that can be read and used by MegaFlow. The format for the FLW files is described below, as it is XML based it can be extended in the future to support more data options.

Example FLW file

<Fluid grid="2,2,2" size="10.0,10.0,10.0,20.0,20.0,20.0">
    <Vel data="0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"/>

The simple example above describes a very small 2x2x2 vector field save in FLW format. The main ‘Fluid’ element has two attributes, grid and size, the ‘grid’ attribute is a set of 3 comma separated int values that describes how many samples there are in the following data along the x, y and z axis, so in this case the grid will be 2x2x2. The next attribute ‘size’ describes the size of the bounding volume for the flow data, the 6 comma separated float values are the min and max size in the x, y and z direction.

The next child element is ‘Vel’ this will contain the velocity data for the grid, the ‘data’ attribute will contain all the velocity data for the grid as a list of 3 floats describing the velocity in the x, y and z direction, these values are comma separated. The order the grid values should be written is to write a set of values along the x axis, then move up the y axis by 1 and write another line then finally move along the z axis. So to write out the values you would do something like:

for ( int z = 0; z < gridz; z++ )
    for ( int y = 0; y < gridy; y++ )
        for ( int x = 0; x < gridx; x++ )
            Vector3 v = getFluidVelAt(x, y, z);

You must be logged in to post a comment.