public QuadNode(Planet _planet, QuadNode _parent, ShapeGenerator _shapeGenerator, ClimateGenerator _climateGenerator, int _level, Vector3 _position, Vector3 _left, Vector3 _forward, float _size) { planet = _planet; parent = _parent; shapeGenerator = _shapeGenerator; climateGenerator = _climateGenerator; level = _level; position = _position; left = _left; forward = _forward; size = _size; position -= left * (size / 2); position -= forward * (size / 2); children = null; Initialize(); }
void Start() { cameraTransform = mainCamera.transform; shapeGenerator = new ShapeGenerator(shapeSettings, seed); climateGenerator = new ClimateGenerator(climateSettings, seed); float halfRadius = shapeSettings.planetRadius / 2.0f; nodes = new List <QuadNode> { new QuadNode(this, null, shapeGenerator, climateGenerator, 1, new Vector3(0.0f, 0.0f, -halfRadius), Vector3.left, Vector3.down, shapeSettings.planetRadius), // back new QuadNode(this, null, shapeGenerator, climateGenerator, 1, new Vector3(0.0f, 0.0f, halfRadius), Vector3.right, Vector3.down, shapeSettings.planetRadius), // forward new QuadNode(this, null, shapeGenerator, climateGenerator, 1, new Vector3(-halfRadius, 0.0f, 0.0f), Vector3.forward, Vector3.down, shapeSettings.planetRadius), // left new QuadNode(this, null, shapeGenerator, climateGenerator, 1, new Vector3(halfRadius, 0.0f, 0.0f), Vector3.back, Vector3.down, shapeSettings.planetRadius), // right new QuadNode(this, null, shapeGenerator, climateGenerator, 1, new Vector3(0.0f, halfRadius, 0.0f), Vector3.forward, Vector3.left, shapeSettings.planetRadius), // up new QuadNode(this, null, shapeGenerator, climateGenerator, 1, new Vector3(0.0f, -halfRadius, 0.0f), Vector3.back, Vector3.left, shapeSettings.planetRadius) // down }; foreach (QuadNode node in nodes) { node.SubDivide(); } }