Continuous Rotation Use HeightFields
Front View Side View Top View Bottom View Back View other side View Top View
So now we've added in rotation, what does this mean as far as code? Well first off we need to figure out what order to traverse the volume, I do this by transforming each axis of the volume to screen space, then look at the relevant Z component of the vector, if Z is negative, then walk that axis backwards.
In order to be a little efficient, I incrementalize the screen space walk, we don't want a matrix transform for every voxel. I'm assuming that floating point precision is good enough for the entire volume, but the incrementals could be calculated for every z slice. The rendering loop looks like:
origin = voxel origin * transform matrix
x increment = (x axis - origin )/x voxels
y increment = (y axis - origin )/y scanline
z increment = (z axis - origin )/z slices
For each z slice
ypoint = origin
For each y scanline
xpoint = ypoint
For each x voxel
blend( xpoint.x, xpoint.y, voxel )
xpoint += x increment
end x
ypoint += y increment
end y
origin += z increment
end z
To further optimize, all of the incrementals ought to be done in fixed point math, since even on the PPRO floating point adds are about 4X slower than integer. This code is about an order of magnitude slower than that demonstrated in the non transformed renderer.
I also haven't address some of the aliasing issues or rounding error. That goes in the next rev!