private void OnEnable() { Star = GameObject.FindGameObjectWithTag("Star"); PlanetSize = GameObject.Find("PlanetSize").GetComponent<InputField>(); PlanetSpeed = GameObject.Find("PlanetSpeed").GetComponent<InputField>(); sliders = GameObject.Find("Sliders").GetComponent<Sliders>(); planetValues = GetComponent<PlanetValues>(); starValues = Star.GetComponent<StarValues>(); rb = GetComponent<Rigidbody>(); planetValues.planetSize = int.Parse(PlanetSize.text); planetValues.planetSpeed = int.Parse(PlanetSpeed.text); planetValues.oxy = sliders.oxygenValue; planetValues.nitro = sliders.nitrogenValue; planetValues.carb = sliders.co2Value; target = Star.transform; Vector3 targetRot = new Vector3(target.transform.position.x, transform.position.y, target.transform.position.z); transform.LookAt(targetRot); transform.Rotate(0, 90, 0); transform.localScale = new Vector3(planetValues.planetSize, planetValues.planetSize, planetValues.planetSize); rb.AddForce(rb.transform.forward * int.Parse(PlanetSpeed.text)); planetValues.planetMass = ((planetValues.planetSize / 5f)* (planetValues.planetSize / 5f)); rb.mass = planetValues.planetMass; /////////////////// coloring = new Gradient(); colorKey = new GradientColorKey[2]; colorKey[0].color = Random.ColorHSV(); colorKey[0].time = 0.0f; colorKey[1].color = Random.ColorHSV(); colorKey[1].time = 1.0f; alphaKey = new GradientAlphaKey[2]; alphaKey[0].alpha = 1.0f; alphaKey[0].time = 0.0f; alphaKey[1].alpha = 0.0f; alphaKey[1].time = 1.0f; coloring.SetKeys(colorKey, alphaKey); if (texture == null) { texture = new Texture2D(resolution, resolution, TextureFormat.RGB24, true); //texture.name = "Planet Texture"; texture.wrapMode = TextureWrapMode.Clamp; texture.filterMode = FilterMode.Trilinear; texture.anisoLevel = 9; GetComponent<MeshRenderer>().material.mainTexture = texture; } FillTexture(); }
private static EphemerisResult SwephCalculation(Configuration config, InputCalculation input) { EphemerisResult result = new EphemerisResult(); String star = String.Empty; List <String> searchPaths = new List <string>(); // Initialize paths var paths = config.SearchPaths.Where(s => !String.IsNullOrWhiteSpace(s)).Union(new String[] { "." }); foreach (var path in paths.Select(s => s.Trim())) { if (path == ".") { searchPaths.Add(AppDomain.CurrentDomain.BaseDirectory); searchPaths.Add(System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "SwephData")); } else { searchPaths.Add(path.Trim()); } } using (var sweph = new SweNet.Sweph()) { sweph.OnLoadFile += (s, e) => { var f = e.FileName.Replace("[ephe]", "").Trim('\\', '/'); foreach (var p in searchPaths) { var fName = System.IO.Path.Combine(p, f); if (System.IO.File.Exists(fName)) { e.File = new System.IO.FileStream(fName, System.IO.FileMode.Open, System.IO.FileAccess.Read, System.IO.FileShare.Read); return; } } }; // Prepare result result.Reset(); // Initialize engine sweph.Ephemeris = input.EphemerisMode; if (sweph.Ephemeris == EphemerisMode.JPL) { sweph.swe_set_jpl_file(input.JplFile); } sweph.PositionCenter = input.PositionCenter; if (sweph.PositionCenter == PositionCenter.Topocentric) { sweph.swe_set_topo(input.Longitude, input.Latitude, input.Altitude); } sweph.HouseSystem = input.HouseSystem; // Dates and Times if (input.DateUT != null) { result.JulianDay = sweph.JulianDay(input.DateUT.Value); result.DateUTC = sweph.DateUT(result.JulianDay); result.EphemerisTime = sweph.EphemerisTime(result.JulianDay); } else if (input.DateET != null) { result.JulianDay = sweph.JulianDay(input.DateET.Value); result.DateUTC = sweph.DateUT(result.JulianDay); result.EphemerisTime = new EphemerisTime(result.JulianDay, 0.0); } else if (input.JulianDay != null) { result.JulianDay = input.JulianDay.Value; result.DateUTC = sweph.DateUT(result.JulianDay); result.EphemerisTime = sweph.EphemerisTime(result.JulianDay); } result.SideralTime = sweph.swe_sidtime(result.JulianDay) + (input.Longitude / 15.0); if (result.SideralTime >= 24.0) { result.SideralTime -= 24.0; } if (result.SideralTime < 0.0) { result.SideralTime += 24.0; } // Calculation String serr = null; Double[] x = new double[24]; var iflgret = sweph.swe_calc(result.EphemerisTime, Planet.EclipticNutation, x, ref serr); result.TrueEclipticObliquity = x[0]; result.MeanEclipticObliquity = x[1]; result.NutationLongitude = x[2]; result.NutationObliquity = x[3]; // Planets foreach (var planet in input.Planets) { if (planet == Planet.Earth) { continue; // Exclude Earth if geo or topo } serr = null; var pi = new PlanetValues() { Planet = planet }; result.Planets.Add(pi); // Ecliptic position if (planet == Planet.FixedStar) { iflgret = sweph.swe_fixstar(star, result.EphemerisTime, x, ref serr); pi.PlanetName = star; } else { iflgret = sweph.swe_calc(result.EphemerisTime, planet, x, ref serr); pi.PlanetName = sweph.swe_get_planet_name(planet); if (planet.IsAsteroid) { pi.PlanetName = String.Format("#{0}", planet - Planet.FirstAsteroid); } } if (iflgret >= 0) { pi.Longitude = x[0]; pi.Latitude = x[1]; pi.Distance = x[2]; pi.LongitudeSpeed = x[3]; pi.LatitudeSpeed = x[4]; pi.DistanceSpeed = x[5]; pi.HousePosition = sweph.swe_house_pos(result.ARMC, input.Latitude, result.TrueEclipticObliquity, x, ref serr); if (pi.HousePosition == 0) { iflgret = SwissEph.ERR; } } if (iflgret < 0) { if (!String.IsNullOrEmpty(serr)) { pi.ErrorMessage = serr; } } else if (!String.IsNullOrEmpty(serr) && String.IsNullOrEmpty(pi.WarnMessage)) { pi.WarnMessage = serr; } } /* * //* equator position * / * if (fmt.IndexOfAny("aADdQ".ToCharArray()) >= 0) { * iflag2 = iflag | SwissEph.SEFLG_EQUATORIAL; * if (ipl == SwissEph.SE_FIXSTAR) * iflgret = sweph.swe_fixstar(star, tjd_et, iflag2, xequ, ref serr); * else * iflgret = sweph.swe_calc(tjd_et, ipl, iflag2, xequ, ref serr); * } * //* ecliptic cartesian position * / * if (fmt.IndexOfAny("XU".ToCharArray()) >= 0) { * iflag2 = iflag | SwissEph.SEFLG_XYZ; * if (ipl == SwissEph.SE_FIXSTAR) * iflgret = sweph.swe_fixstar(star, tjd_et, iflag2, xcart, ref serr); * else * iflgret = sweph.swe_calc(tjd_et, ipl, iflag2, xcart, ref serr); * } * //* equator cartesian position * / * if (fmt.IndexOfAny("xu".ToCharArray()) >= 0) { * iflag2 = iflag | SwissEph.SEFLG_XYZ | SwissEph.SEFLG_EQUATORIAL; * if (ipl == SwissEph.SE_FIXSTAR) * iflgret = sweph.swe_fixstar(star, tjd_et, iflag2, xcartq, ref serr); * else * iflgret = sweph.swe_calc(tjd_et, ipl, iflag2, xcartq, ref serr); * } * spnam = se_pname; */ // Houses double[] cusps = new double[input.HouseSystem == HouseSystem.GauquelinSector ? 37 : 13]; double[] ascmc = new double[10]; var hNames = new String[] { "", "I", "II", "III", "IV", "V", "VI", "VII", "VIII", "IX", "X", "XI", "XII" }; var amNames = new String[] { "Ascendant", "MC", "ARMC", "Vertex", "Equatorial ascendant", "Co-ascendant (Walter Koch)", "Co-ascendant (Michael Munkasey)", "Polar ascendant (M. Munkasey)" }; sweph.swe_houses_ex(result.JulianDay, input.Latitude, input.Longitude, cusps, ascmc); for (int i = 1; i <= 12; i++) { result.Houses.Add(new HouseValues() { House = i, HouseName = hNames[i], Cusp = cusps[i] }); } for (int i = 0; i < 7; i++) { result.ASMCs.Add(new HouseValues() { House = i, HouseName = amNames[i], Cusp = ascmc[i] }); } } return(result); }
// Start is called before the first frame update void OnEnable() { planetValues = GetComponent <PlanetValues>(); }