public void DrawChildMeshes(int res, float minx, float miny, float width, gl.Transform transform, Vector3 Camera, TriangleDrawer graphics, Shader shader, bool onlyborders, float zoom, float precision, int maxprecision) { const int Spread = 4, sq = Spread * Spread; res /= Spread; float step = width / Spread; MeshHolder[] childs = Childs; if (childs == null) { childs = new MeshHolder[sq]; int k = 0; for (int j = 0; j < Spread; j++) { float mny = miny + step * j; for (int i = 0; i < Spread; i++) { float mnx = minx + step * i; childs[k] = new MeshHolder(Parent = this, shapeGenerator, LocalUp, AxisA, AxisB, mnx, mny, step); k++; } } Childs = childs; } for (int i = 0; i < sq; i++) { childs[i].DrawMesh(transform, Camera, graphics, shader, onlyborders, zoom, precision, maxprecision); } }
public MeshHolder(MeshHolder parent, ShapeGenerator shapeGenerator, Vector3 localUp, Vector3 axisA, Vector3 axisB, float minx, float miny, float width) { Parent = parent; this.shapeGenerator = shapeGenerator; LocalUp = localUp; AxisA = axisA; AxisB = axisB; ShapeSettings shapeSettings = shapeGenerator.settings; Vector3 PlanetCentre = shapeSettings.position; float radius = shapeSettings.PlanetRadius; Vector3 MiddlepointOnUnitCube = LocalUp * .5f + (minx + width * .5f - .5f) * AxisA + (miny + width * .5f - .5f) * AxisB; Vector3 MiddlePointOnUnitSphere = MiddlepointOnUnitCube.normalized; this.minx = minx; this.miny = miny; this.width = width; }