public void SetPlanet(PlanetConfig planetCfg) { this.planetCfg = planetCfg; zoom = 1; tetha = Mathf.PI; phi = Mathf.PI / 2; radius = 2 * (PlanetConfig.PlanetRadius + planetCfg.PlanetSurfaceMaxHeight / 2); SetPosition(); }
//public float GetGeneratedValue(GeoVector position) //{ // if (!IsCalculated) // return 0; // int currentIndex = (int)ZoomLevel; // int x = (int)(PlanetConfig.PointSize * (position.x % cfg.globalSizesX[currentIndex]) / cfg.globalSizesX[currentIndex]); // int y = (int)(PlanetConfig.PointSize * (position.y % cfg.globalSizesY[currentIndex]) / cfg.globalSizesY[currentIndex]); // if(Surface.Points[x,y].HasValue) // { // if(Surface.Points[x, y].is) // } // return Surface[x, y]; //} #endregion //---------------------------------------------------------------factory methods-------------------------------------------------------------------------------------- public static Unit CreatePlanetUnit(PlanetConfig cfg) { var unit = CreateUnit(cfg, Vector2Int.zero, new GeoRange(new GeoVector(0, 0), Mathf.PI * 2, Mathf.PI), null, 0); unit.CreatePlanetUnits(); return(unit); }
private System.Collections.IEnumerator PlanetCoroutine(PlanetConfig cfg, Image minimap) { Instance = this; Cleanup(); yield return(new WaitForSeconds(.5f)); root = Unit.CreatePlanetUnit(cfg); yield return(new WaitForSeconds(.5f)); root.Render(7); yield return(new WaitForSeconds(4f)); //moon = Unit.CreateRenderedPlanet(cfg2); ResetMinimap(minimap); root.ZoomTo(new GeoVector(Mathf.PI, Mathf.PI / 2), 0); }
static Unit CreateUnit( PlanetConfig cfg, Vector2Int localIdx, GeoRange rect, Unit parentUnit, int zoomLevel) { //var unit = new GameObject().AddComponent<Unit>(); //unit.name = localIdx.ToString(); //unit.transform.parent = parentGo; var unit = new Unit { Parent = parentUnit, cfg = cfg, ZoomLevel = zoomLevel }; if (parentUnit == null) { unit.dataStart = localIdx; } else { unit.dataStart = parentUnit.dataStart * PlanetConfig.UnitSize + localIdx; } unit.LocalIndex = localIdx; if (zoomLevel == 0) { //unit.Surface = SurfaceArea.Load(); if (unit.Surface == null) { unit.Surface = new SurfaceArea(rect); unit.Surface.Points = PerlinNoiseGenerator.CreatePlanetSurfacePoints(cfg); //unit.Surface.Save(); } } else { unit.Surface = new SurfaceArea(rect); } return(unit); }
//---------------------------------------------------------------METHODS-------------------------------------------------------------------------------------- /// <summary> /// Main /// </summary> public void StartPlanetCoroutine(PlanetConfig cfg, Image minimap) { StartCoroutine(PlanetCoroutine(cfg, minimap)); }