/// <summary> /// Sends the vertices in a given quadtree of material information to the specified iterators. /// </summary> public static void SendQuadtree <R>(Quadtree <Material> Source, Axis PlaneAxis, int PlaneLevel, Point <int> Offset, IIterator <ColorNormalVertex, R> Positive, IIterator <ColorNormalVertex, R> Negative) { Material val; if (Source.Homogenous(out val)) { IMaterial m = val.Description; if (m != null) { int s = Source.Size; ITileableMaterial tm = m as ITileableMaterial; if (tm != null) { Vector <double> normal; var proj = Material.Project(PlaneAxis, val.Direction, PlaneLevel, new Point <int>(Offset.X, Offset.Y), new Point <int>(s, s), out normal); Send(tm.CreateTileableRenderable(proj, normal, new Point <int>(s, s)), val.Direction == Polarity.Positive ? Positive : Negative); } else { for (int x = 0; x < s; x++) { for (int y = 0; y < s; y++) { Vector <double> normal; var proj = Material.Project(PlaneAxis, val.Direction, PlaneLevel, new Point <int>(x + Offset.X, y + Offset.Y), new Point <int>(1, 1), out normal); Send(m.CreateRenderable(proj, normal), val.Direction == Polarity.Positive ? Positive : Negative); } } } } } else { int hs = 1 << (Source.Depth - 1); for (int x = 0; x < 2; x++) { for (int y = 0; y < 2; y++) { SendQuadtree(Source[x * 2 + y], PlaneAxis, PlaneLevel, new Point <int>(Offset.X + x * hs, Offset.Y + y * hs), Positive, Negative); } } } }