//level - level of parent public OctreeNode(int level, OctreeQuantizer parent) { nodes = new OctreeNode[8]; if (level < 7) { parent.AddLevelNode(level, this); } }
public OctreeNode(int level, OctreeQuantizer parent) //level - level of parent { nodes = new OctreeNode[8]; if (level < 7) { parent.AddLevelNode(level, this); } }
//level - depth level public void AddColor(Color color, int level, OctreeQuantizer parent) { // if this node is a leaf, then increase a color amount, and pixel presence if (level == 8) { red += color.R; green += color.G; blue += color.B; pixelCount++; } else if (level < 8) // otherwise goes one level deeper { // calculates an index for the next sub-branch int index = GetColorIndexAtLevel(color, level); //current level // if that branch doesn't exist, grows it if (nodes[index] == null) { nodes[index] = new OctreeNode(level, parent); } // adds a color to that branch nodes[index].AddColor(color, level + 1, parent); } }