But generating one point inside volume efficiently gives gray hairs.
Pseudo code:
class VoxelVolume { private float[,,] volume = new float[32, 32, 32]; public Vector3 OneRandomPointInVolume() { // total can be pre-calcultated (optimization) float total = 0.0f; foreach(voxel in volume) total += voxel; // now, each points chance is // (voxel.value) / total // but what kind of "dice" is neaded to get the result!!! return result; }}
Any ideas on how to get one positive that
has chance of points value divided by sum of volume?
(no random shooting algorithms! (bad performance!))
/Tyrian