public void AddTemplateGroups(MySolarSystemMapData data) { return; // Template groups in solar map are disabled if (SolarMapData.TemplateGroups == null) { return; } Random rnd = new Random(0); foreach (var g in SolarMapData.TemplateGroups) { for (int i = 0; i < g.Count; i++) { var pos = GetRandomPosition(rnd); Vector3 offset; MyMwcVector3Int sector = MySolarSystemUtils.KmToSectors(pos, out offset); var mark = new MySolarSystemMapNavigationMark(sector, "", null, Color.White, TransparentGeometry.MyTransparentMaterialEnum.SolarMapOutpost); mark.Importance = g.Importance; mark.DrawVerticalLine = false; data.NavigationMarks.Add(mark); data.ImportantObjects.Add(new MyImportantSolarObject() { NavigationMark = mark, TemplateGroup = g.TemplateGroup }); //entities.Add(new MySolarSystemMapEntity(sector, offset, 0, "", MySolarSystemEntityEnum.OutpostIcon)); } } }
public bool IsSectorInArea(MyMwcVector3Int sectorPosition) { Vector3 sectorPos = MySolarSystemUtils.SectorsToKm(sectorPosition); Vector3 fromSectorToCenter = sectorPos - Position; float fromSectorToCenterDist = fromSectorToCenter.Length(); return(fromSectorToCenterDist <= Radius); }
private void AddEntity(MySolarSystemMapData data, Vector3 posMillKm, float radiusMillKm, string name, MySolarSystemEntityEnum entityType, Color color, object entityData = null) { float radius = radiusMillKm * MyBgrCubeConsts.MILLION_KM; Vector3 offset; MyMwcVector3Int sector = MySolarSystemUtils.MillionKmToSectors(posMillKm, out offset); var entity = new MySolarSystemMapEntity(sector, offset, radius, name, entityType, color); entity.EntityData = entityData; data.Entities.Add(entity); }
private void UpdateWorldPosition(MySolarSystemMapCamera camera) { MyMwcVector3Int sectorOffset; sectorOffset.X = Sector.X - camera.TargetSector.X; sectorOffset.Y = Sector.Y - camera.TargetSector.Y; sectorOffset.Z = Sector.Z - camera.TargetSector.Z; m_worldPosition = MySolarMapRenderer.MillionKmToGameUnits(MySolarSystemUtils.SectorsToMillionKm(sectorOffset)) + /*new Vector3(0f, RADIUS * m_offsetIndex, 0f) + */ camera.CameraToTarget - camera.Target; }
public override float GetSectorInterpolator(MyMwcVector3Int sectorPosition) { Vector3 sectorPos = MySolarSystemUtils.SectorsToKm(sectorPosition); Vector3 fromSectorToCenter = sectorPos - Position; float fromSectorToCenterDist = fromSectorToCenter.Length(); if (fromSectorToCenterDist > Radius) { // Out of circle zone return(0); } float cubicInterpolator = MathHelper.SmoothStep(0, 1, fromSectorToCenterDist / Radius); return(cubicInterpolator); }
public override float GetSectorInterpolator(MyMwcVector3Int sectorPosition) { //Sem ja Vector3 sectorPos = MySolarSystemUtils.SectorsToKm(sectorPosition); //vzdalenost od stredu vesmiru ke mne //stred vesmiru Vector3 centerToSector = sectorPos - OrbitProperties.OrbitCenter; float sectorToCenterDist = centerToSector.Length(); //Stred pulmesice //stred vesmiru Vector3 centerToZone = OrbitProperties.AreaCenter - OrbitProperties.OrbitCenter; float orbitRadius = centerToZone.Length(); //vzdalenost mezi orbitama float distFromOrbit = Math.Abs(orbitRadius - sectorToCenterDist); if (distFromOrbit > OrbitProperties.MaxDistanceFromOrbitHigh) { // Not in area (not on ring) return(0); } // //float baseAngle = MyMath.AngleTo(centerToZone, Vector3.UnitZ).Y; //float angle = MyMath.AngleTo(centerToZone, centerToSector).Y; float angle = MyMath.AngleBetween(centerToSector, centerToZone); if (Math.Abs(angle) > HalfAngle) { // Not in area (other part of orbit) return(0); } float angleInterpolator = angle / HalfAngle; float maxDistFromOrbitAtAngle = MathHelper.SmoothStep(OrbitProperties.MaxDistanceFromOrbitHigh, OrbitProperties.MaxDistanceFromOrbitLow, angleInterpolator); if (distFromOrbit > maxDistFromOrbitAtAngle) { // Not in area (not in shape of zone) return(0); } float interpolator = distFromOrbit / maxDistFromOrbitAtAngle; interpolator = 1 - (float)Math.Pow(interpolator, 3); return(interpolator); }
/// <summary> /// Rebuild the areas /// </summary> public static void CreateRimeArea() { Areas[MySolarSystemAreaEnum.Rime] = new MySolarSystemAreaOrbit() { Name = "Rime", AreaType = MySolarSystemArea.AreaEnum.PostPlanet, OrbitProperties = new MyOrbitProperties() { OrbitCenter = Vector3.Zero, AreaCenter = MySolarSystemUtils.SectorsToKm(MyBgrCubeConsts.RIME_SECTOR), LongSpread = 0.05f, MaxDistanceFromOrbitLow = 2.1f * MyBgrCubeConsts.MILLION_KM, MaxDistanceFromOrbitHigh = 8.4f * MyBgrCubeConsts.MILLION_KM, }, SolarMapData = new MySolarMapData() { DustColor = new Vector3(0.8f, 0.11f, 0.08f), DustColorVariability = new Vector4(0.15f), TemplateGroups = new MyTemplateGroupInfo[] { new MyTemplateGroupInfo { Importance = 1, Count = 0, TemplateGroup = MyTemplateGroupEnum.RandomStations }, new MyTemplateGroupInfo { Importance = 0.5f, Count = 0, TemplateGroup = MyTemplateGroupEnum.RandomStations }, } }, SectorData = new MySolarSectorData() { SunProperties = RimeSunProperties, FogProperties = RimeFogProperties, ImpostorProperties = RimeImpostorsProperties, GodRaysProperties = RimeGodRaysProperties, DebrisProperties = DefaultDebrisProperties, SectorObjectsCounts = RimeObjectsProperties, PrimaryAsteroidMaterials = DefaultAsteroidMaterials, SecondaryAsteroidMaterials = DefaultAsteroidMaterials, ParticleDustProperties = RimeDustProperties, }, }; }
/// <summary> /// Rebuild the areas /// </summary> public static void CreateChineseRafinaryArea() { Areas[MySolarSystemAreaEnum.ChineseRafinary] = new MySolarSystemAreaOrbit() { Name = "Chinese Rafinary", AreaType = MySolarSystemArea.AreaEnum.PostPlanet, OrbitProperties = new MyOrbitProperties() { OrbitCenter = Vector3.Zero, AreaCenter = MySolarSystemUtils.SectorsToKm(MyBgrCubeConsts.CHINESERAFINARY_SECTOR), LongSpread = 0.15f, MaxDistanceFromOrbitLow = 4.1f * MyBgrCubeConsts.MILLION_KM, MaxDistanceFromOrbitHigh = 9.4f * MyBgrCubeConsts.MILLION_KM, }, SolarMapData = new MySolarMapData() { DustColor = new Vector3(0.32f, 0.71f, 0.18f), DustColorVariability = new Vector4(0.15f), TemplateGroups = new MyTemplateGroupInfo[] { new MyTemplateGroupInfo { Importance = 1, Count = 0, TemplateGroup = MyTemplateGroupEnum.RandomStations }, new MyTemplateGroupInfo { Importance = 0.5f, Count = 0, TemplateGroup = MyTemplateGroupEnum.RandomStations }, } }, SectorData = new MySolarSectorData() { SunProperties = ChineseRafinarySunProperties, FogProperties = ChineseRafinaryFogProperties, ImpostorProperties = ChineseRafinaryImpostorsProperties, DebrisProperties = DefaultDebrisProperties, SectorObjectsCounts = ChineseRafinaryObjectsProperties, PrimaryAsteroidMaterials = ChineseRafinaryAsteroidMaterials, SecondaryAsteroidMaterials = ChineseRafinarySecondaryMaterials, ParticleDustProperties = ChineseRafinaryDustProperties, }, }; }
private void UpdateRenderedSizeAndOffsetPosition() { m_actualRenderedSize = MySolarSystemUtils.CalculateDistanceUnscalingTo( m_worldPosition, MySolarSystemMapNavigationMark.RADIUS, MySolarSystemMapNavigationMark.SCALE_DISTANCE_FROM); }
public override void AddUniverseEntities(MySolarSystemMapData data) { if (MyMissions.ActiveMission == null && MyMissions.GetAvailableMissions().Count == 0) { AddTemplateGroups(data); } const float maxObjCenterFromOrbit = 0.25f; Random rnd = new Random(0); float orbitRadius = OrbitProperties.AreaCenter.Length(); float baseAngle = MyMath.AngleTo(OrbitProperties.AreaCenter, Vector3.UnitZ).Y; //count of groups per orbit side float step = CalculateStep((OrbitProperties.MaxDistanceFromOrbitHigh + OrbitProperties.MaxDistanceFromOrbitLow) / 2); int testMaxCount = 0; for (float i = baseAngle - HalfAngle; i < baseAngle + HalfAngle; i += step) { float interpolator = 1 - Math.Abs((i - baseAngle) / HalfAngle); // (i + halfLen) / halfLen / 2; float maxDistFromOrbitAtAngle = MathHelper.SmoothStep(OrbitProperties.MaxDistanceFromOrbitLow, OrbitProperties.MaxDistanceFromOrbitHigh, interpolator); step = CalculateStep((OrbitProperties.MaxDistanceFromOrbitHigh + maxDistFromOrbitAtAngle) / 2); //Vector3 centerPos = new Vector3((float)Math.Sin(i) * distance, 0, (float)Math.Cos(i) * distance); //5 = billboards count in smaller group for (int j = 0; j < 2; j++) { Vector2 distFromOrbit = Vector2.Normalize(new Vector2(rnd.Float(-1, 1), rnd.Float(-1, 1))); //distFromOrbit = new Vector2(); distFromOrbit *= maxDistFromOrbitAtAngle * maxObjCenterFromOrbit; float dist = orbitRadius + distFromOrbit.X; float i2 = i + rnd.FloatCubic(-step * maxObjCenterFromOrbit, step * maxObjCenterFromOrbit); float x = (float)Math.Sin(i2) * dist; float z = (float)Math.Cos(i2) * dist; float y = distFromOrbit.Y; Vector3 pos = OrbitProperties.OrbitCenter + new Vector3(x, y, z); Vector3 offset; MyMwcVector3Int sector = MySolarSystemUtils.KmToSectors(pos, out offset); float size = maxDistFromOrbitAtAngle * (1 - maxObjCenterFromOrbit); if (this.SolarMapData != null) { Vector4 clr = new Vector4(this.SolarMapData.DustColor, 1.0f); Color color = rnd.Color(new Color(clr - this.SolarMapData.DustColorVariability), new Color(clr + this.SolarMapData.DustColorVariability)); data.Entities.Add(new MySolarSystemMapEntity(sector, offset, 2 * size, "Dust", MySolarSystemEntityEnum.DustField, color)); testMaxCount++; } if ((AreaType & AreaEnum.PostPlanet) != 0 && j % 2 == 0) { data.Entities.Add(new MySolarSystemMapEntity(sector, offset, size * (1 - maxObjCenterFromOrbit), "Asteroids", MySolarSystemEntityEnum.AsteroidField, Color.White)); testMaxCount++; } //AddEntity(m_data, pos, radius * wide * 4, name + " dust", MySolarSystemEntityEnum.Test1_Dust, rnd.Color(baseColor, colorVariation)); } } //Do not allow to solar area to add more than 1000 objects //System.Diagnostics.Debug.Assert(testMaxCount < 3000); MySolarAreaBorderLine newLine = new MySolarAreaBorderLine(); newLine.AreaCenter = OrbitProperties.AreaCenter; newLine.DistanceHigh = OrbitProperties.MaxDistanceFromOrbitHigh; newLine.DistanceLow = OrbitProperties.MaxDistanceFromOrbitLow; newLine.Spread = OrbitProperties.LongSpread; newLine.col = new Vector4(SolarMapData.DustColor, 1f); data.AreasBorderLines.Add(newLine); }
public void Generate(int sectorCacheCapacity) { m_data = new MySolarSystemMapData(sectorCacheCapacity); // Sun AddEntity(m_data, Vector3.Zero, MyBgrCubeConsts.SUN_RADIUS, MyTextsWrapper.Get(MyTextsWrapperEnum.Sun).ToString(), MySolarSystemEntityEnum.Sun, Color.White); // Orbits (just orbit lines) AddEntity(m_data, Vector3.Zero, MyBgrCubeConsts.MERCURY_POSITION.Length(), "Mercury orbit", MySolarSystemEntityEnum.Orbit, Color.White); AddEntity(m_data, Vector3.Zero, MyBgrCubeConsts.VENUS_POSITION.Length(), "Venus orbit", MySolarSystemEntityEnum.Orbit, Color.White); AddEntity(m_data, Vector3.Zero, MyBgrCubeConsts.EARTH_POSITION.Length(), "Earth orbit", MySolarSystemEntityEnum.Orbit, Color.White); AddEntity(m_data, Vector3.Zero, MyBgrCubeConsts.MARS_POSITION.Length(), "Mars orbit", MySolarSystemEntityEnum.Orbit, Color.White); AddEntity(m_data, Vector3.Zero, MyBgrCubeConsts.JUPITER_POSITION.Length(), "Jupiter orbit", MySolarSystemEntityEnum.Orbit, Color.White); AddEntity(m_data, Vector3.Zero, MyBgrCubeConsts.SATURN_POSITION.Length(), "Saturn orbit", MySolarSystemEntityEnum.Orbit, Color.White); AddEntity(m_data, Vector3.Zero, MyBgrCubeConsts.URANUS_POSITION.Length(), "Uranus orbit", MySolarSystemEntityEnum.Orbit, Color.White); AddEntity(m_data, Vector3.Zero, MyBgrCubeConsts.NEPTUNE_POSITION.Length(), "Neptune orbit", MySolarSystemEntityEnum.Orbit, Color.White); foreach (var a in MySolarSystemConstants.Areas) { a.Value.AddUniverseEntities(m_data); m_data.Areas.Add(a.Key); } if (MyFakes.ENABLE_RANDOM_STATIONS_IN_SOLAR_SYSTEM && MyMissions.ActiveMission == null && MyMissions.GetAvailableMissions().Count == 0) { foreach (var a in MyFactions.FactionAreas) { if (a.Key == CommonLIB.AppCode.ObjectBuilders.MyMwcObjectBuilder_FactionEnum.CSR) { continue; } foreach (var circle in a.Value) { Random r = new Random(circle.Position.GetHashCode() ^ circle.Radius.GetHashCode()); var radius = circle.Radius / 100000000; float count = MathHelper.Pi * radius * radius; count = MathHelper.Clamp(count, 0, 10); if (count < 1) { count = r.Next(0, 2); } for (int i = 0; i < count; i++) { float dist = rnd.Float() * circle.Radius; float angle = (float)(rnd.NextDouble() * 2 * MathHelper.Pi); float x = (float)Math.Sin(angle) * dist; float z = (float)Math.Cos(angle) * dist; var pos = circle.GetCenter() + new Vector3(x, 0, z); //pos = circle.GetCenter(); Vector3 offset; MyMwcVector3Int sector = MySolarSystemUtils.KmToSectors(pos, out offset); var mark = new MySolarSystemMapNavigationMark(sector, "", null, Color.White, MyTransparentMaterialEnum.SolarMapOutpost); mark.Importance = rnd.Next(2, 5) / 4.0f; mark.DrawVerticalLine = false; m_data.NavigationMarks.Add(mark); m_data.ImportantObjects.Add(new MyImportantSolarObject() { NavigationMark = mark, TemplateGroup = MyTemplateGroupEnum.RandomStations }); } } } } // Filip resize solar map const float factionMapScale = 1.75f; // Faction map - size of map is same as saturn orbit AddEntity(m_data, Vector3.Zero, MyBgrCubeConsts.SATURN_POSITION.Length() / factionMapScale, "Faction map", MySolarSystemEntityEnum.FactionMap, Color.White); AddEntity(m_data, new Vector3(-352, 0, -40), 0, MyTextsWrapper.Get(MyTextsWrapperEnum.FactionRussian).ToString(), MySolarSystemEntityEnum.FactionInfo, Color.IndianRed, MyTransparentMaterialEnum.FactionRussia); AddEntity(m_data, new Vector3(-432, 0, -628), 0, MyTextsWrapper.Get(MyTextsWrapperEnum.FactionRussian).ToString(), MySolarSystemEntityEnum.FactionInfo, Color.IndianRed, MyTransparentMaterialEnum.FactionRussia); AddEntity(m_data, new Vector3(0, 0, 300), 0, MyTextsWrapper.Get(MyTextsWrapperEnum.FactionChineseShort).ToString(), MySolarSystemEntityEnum.FactionInfo, Color.Brown, MyTransparentMaterialEnum.FactionChina); AddEntity(m_data, new Vector3(-150, 0, 95), 0, MyTextsWrapper.Get(MyTextsWrapperEnum.FactionJapan).ToString(), MySolarSystemEntityEnum.FactionInfo, Color.DeepSkyBlue, MyTransparentMaterialEnum.FactionJapan); AddEntity(m_data, new Vector3(300, 0, 108), 0, MyTextsWrapper.Get(MyTextsWrapperEnum.FactionFreeAsia).ToString(), MySolarSystemEntityEnum.FactionInfo, Color.HotPink, MyTransparentMaterialEnum.FactionFreeAsia); AddEntity(m_data, new Vector3(300, 0, -40), 0, MyTextsWrapper.Get(MyTextsWrapperEnum.FactionSaudiShort).ToString(), MySolarSystemEntityEnum.FactionInfo, Color.Gold, MyTransparentMaterialEnum.FactionSaudi); AddEntity(m_data, new Vector3(220, 0, -180), 0, MyTextsWrapper.Get(MyTextsWrapperEnum.FactionEuroamericanShort).ToString(), MySolarSystemEntityEnum.FactionInfo, Color.CornflowerBlue, MyTransparentMaterialEnum.FactionEAC); //AddEntity(m_data, new Vector3(65, 0, -135), 0, "CSR", MySolarSystemEntityEnum.FactionInfo, Color.DarkKhaki, MyTransparentMaterialEnum.FactionCSR); AddEntity(m_data, new Vector3(37, 0, -160), 0, MyTextsWrapper.Get(MyTextsWrapperEnum.FactionIndia).ToString(), MySolarSystemEntityEnum.FactionInfo, Color.SandyBrown, MyTransparentMaterialEnum.FactionIndia); AddEntity(m_data, new Vector3(-30, 0, -160), 0, MyTextsWrapper.Get(MyTextsWrapperEnum.FactionChurchShort).ToString(), MySolarSystemEntityEnum.FactionInfo, Color.Yellow, MyTransparentMaterialEnum.FactionChurch); AddEntity(m_data, new Vector3(-85, 0, -150), 0, MyTextsWrapper.Get(MyTextsWrapperEnum.FactionOmnicorpShort).ToString(), MySolarSystemEntityEnum.FactionInfo, Color.LightGreen, MyTransparentMaterialEnum.FactionOmnicorp); AddEntity(m_data, new Vector3(-108, 0, -358), 0, MyTextsWrapper.Get(MyTextsWrapperEnum.FactionFourthReichShort).ToString(), MySolarSystemEntityEnum.FactionInfo, Color.LightSteelBlue, MyTransparentMaterialEnum.FactionFourthReich); // Some navigation marks for testing //AddNavigationMark(m_data, new MyMwcVector3Int(1000000, 0, 1000000), "Mark1"); //AddNavigationMark(m_data, new MyMwcVector3Int(3000000, 0, -1500000), "Mark2"); }