public override void AddRenderObjects() { var minCorner = m_planet.PositionLeftBottomCorner; m_renderObjectIDs = new uint[16]; for (int index = 0; index < 16; ++index) { m_renderObjectIDs[index] = MyRenderProxy.RENDER_ID_UNASSIGNED; } int runningRenderObjectIndex = 0; Debug.Assert((m_planet.Size % MyVoxelCoordSystems.RenderCellSizeInLodVoxels(0)) == Vector3I.Zero); var clipmapSizeLod0 = m_planet.Size / MyVoxelCoordSystems.RenderCellSizeInLodVoxels(0); Vector3 atmosphereWavelengths = new Vector3(); atmosphereWavelengths.X = 1.0f / (float)Math.Pow(m_planet.AtmosphereWavelengths.X, 4.0); atmosphereWavelengths.Y = 1.0f / (float)Math.Pow(m_planet.AtmosphereWavelengths.Y, 4.0); atmosphereWavelengths.Z = 1.0f / (float)Math.Pow(m_planet.AtmosphereWavelengths.Z, 4.0); var voxel = (Entity as MyVoxelBase); SetRenderObjectID(runningRenderObjectIndex++, MyRenderProxy.CreateClipmap( MatrixD.CreateTranslation(minCorner), clipmapSizeLod0, m_planet.ScaleGroup, m_planet.PositionComp.GetPosition(), m_planet.AtmosphereRadius, m_planet.AverageRadius, m_planet.HasAtmosphere, atmosphereWavelengths, m_planet.SpherizeWithDistance, RenderFlags.Visible | RenderFlags.DrawOutsideViewDistance | RenderFlags.CastShadows, IntersectStorage)); if (m_planet.HasAtmosphere) { MatrixD matrix = MatrixD.Identity * m_planet.AtmosphereRadius; matrix.M44 = 1; matrix.Translation = Entity.PositionComp.GetPosition(); SetRenderObjectID(runningRenderObjectIndex++, MyRenderProxy.CreateRenderEntityAtmosphere(this.Entity.GetFriendlyName() + " " + this.Entity.EntityId.ToString(), "Models\\Environment\\Atmosphere_sphere.mwm", matrix, MyMeshDrawTechnique.ATMOSPHERE, RenderFlags.Visible | RenderFlags.DrawOutsideViewDistance, GetRenderCullingOptions(), m_planet.AtmosphereRadius, m_planet.AverageRadius, atmosphereWavelengths)); SetRenderObjectID(runningRenderObjectIndex++, MyRenderProxy.CreateRenderEntityAtmosphere(this.Entity.GetFriendlyName() + " " + this.Entity.EntityId.ToString(), "Models\\Environment\\Atmosphere_sphere.mwm", matrix, MyMeshDrawTechnique.PLANET_SURFACE, RenderFlags.Visible | RenderFlags.DrawOutsideViewDistance, GetRenderCullingOptions(), m_planet.AtmosphereRadius, m_planet.AverageRadius, atmosphereWavelengths)); UpdateAtmosphereSettings(m_planet.AtmosphereSettings); } if (m_renderEnabled == false) { MyRenderProxy.EnableRenderModule((uint)MyRenderModuleEnum.Atmosphere, true); m_renderEnabled = true; } m_shadowHelperRenderObjectIndex = runningRenderObjectIndex; MatrixD shadowHelperWorldMatrix = MatrixD.CreateScale(m_planet.MinimumRadius); shadowHelperWorldMatrix.Translation = m_planet.WorldMatrix.Translation; SetRenderObjectID(runningRenderObjectIndex++, MyRenderProxy.CreateRenderEntity("Shadow helper", "Models\\Environment\\Sky\\ShadowHelperSphere.mwm", shadowHelperWorldMatrix, MyMeshDrawTechnique.MESH, RenderFlags.Visible | RenderFlags.CastShadows | RenderFlags.DrawOutsideViewDistance | RenderFlags.NoBackFaceCulling | RenderFlags.SkipInMainView, CullingOptions.Default, Color.White, new Vector3(1, 1, 1))); MyPlanetGeneratorDefinition definition = m_planet.Generator; if (!MyFakes.ENABLE_PLANETARY_CLOUDS || definition == null || definition.CloudLayers == null) { return; } foreach (var cloudLayer in definition.CloudLayers) { double minScaledAltitude = (m_planet.AverageRadius + m_planet.MaximumRadius) / 2.0; double layerAltitude = minScaledAltitude + (m_planet.MaximumRadius - minScaledAltitude) * cloudLayer.RelativeAltitude; Vector3D rotationAxis = Vector3D.Normalize(cloudLayer.RotationAxis == Vector3D.Zero ? Vector3D.Up : cloudLayer.RotationAxis); int index = runningRenderObjectIndex + m_cloudLayerRenderObjectIndexList.Count; SetRenderObjectID(index, MyRenderProxy.CreateRenderEntityCloudLayer(this.Entity.GetFriendlyName() + " " + this.Entity.EntityId.ToString(), cloudLayer.Model, cloudLayer.Textures, Entity.PositionComp.GetPosition(), layerAltitude, minScaledAltitude, cloudLayer.ScalingEnabled, cloudLayer.FadeOutRelativeAltitudeStart, cloudLayer.FadeOutRelativeAltitudeEnd, cloudLayer.ApplyFogRelativeDistance, m_planet.MaximumRadius, MyMeshDrawTechnique.CLOUD_LAYER, RenderFlags.Visible | RenderFlags.DrawOutsideViewDistance, GetRenderCullingOptions(), rotationAxis, cloudLayer.AngularVelocity, cloudLayer.InitialRotation)); m_cloudLayerRenderObjectIndexList.Add(index); } runningRenderObjectIndex += definition.CloudLayers.Count; }