Reading Krakatoa PRT file?

The major problem (at first glance) appears to be that the code reading the particle data from the uncompressed buffer is not using the Channel.Offset value to determine where the channel’s data is located within a single particle. It appears to be incorrectly assuming that the channels are stored contiguously within the order they are defined in the header.

Here is a simple PRT file that I created. It has two channels: { Position float32[3]; Density float32[1] }. There are two particles with values: {“Position” : (0,1,2), “Density” : 123.5 } and {“Position” : (3,4,5), “Density” : 456.5 }. When I send this file to your program I get:

Density 1 4 0 3 Position 3 4 123.5 3 4 456.5 0 0

So the reader is not horribly crushing the data, just mixing it up. You can refer to the PRT file spec here: http://www.thinkboxsoftware.com/krak-prt-file-format/
prt_test.zip (238 Bytes)

In the Channel Definition Section:

[code]Channel definitions (44 bytes each)

(32 bytes) A null-terminated string indicating the channel name. Must match the regex “[a-zA-Z_][0-9a-zA-Z_]*”.
(4 bytes) A 32 bit int indicating channel data type. Supported channel data types are indicated in the table below.
(4 bytes) A 32 bit int indicating channel arity (number of data values that each particle has for this channel).
*** (4 bytes) A 32 bit int indicating channel offset, relative to the start of the particle. ***[/code]

The highlighted quantity is the byte offset of each channel from the start of a particle. This corresponds to the quantity ‘struct Channel::Offset’.