public override void AddRenderObjects()
        {
            var minCorner = m_planet.PositionLeftBottomCorner;

            m_renderObjectIDs = new uint[] { MyRenderProxy.RENDER_ID_UNASSIGNED, MyRenderProxy.RENDER_ID_UNASSIGNED, MyRenderProxy.RENDER_ID_UNASSIGNED };
            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);

            SetRenderObjectID(0,
                              MyRenderProxy.CreateClipmap(
                                  MatrixD.CreateTranslation(minCorner),
                                  clipmapSizeLod0,
                                  m_planet.ScaleGroup,
                                  m_planet.PositionComp.GetPosition(),
                                  m_planet.AtmosphereRadius,
                                  m_planet.AveragePlanetRadius,
                                  m_planet.HasAtmosphere,
                                  atmosphereWavelengths));

            if (m_planet.HasAtmosphere)
            {
                MatrixD matrix = MatrixD.Identity * m_planet.AtmosphereRadius;
                matrix.M44         = 1;
                matrix.Translation = Entity.PositionComp.GetPosition();

                SetRenderObjectID(1, VRageRender.MyRenderProxy.CreateRenderEntityAtmosphere(this.Entity.GetFriendlyName() + " " + this.Entity.EntityId.ToString(),
                                                                                            "Models\\Environment\\Atmosphere_sphere.mwm",
                                                                                            matrix,
                                                                                            MyMeshDrawTechnique.ATMOSPHERE,
                                                                                            RenderFlags.Visible,
                                                                                            GetRenderCullingOptions(),
                                                                                            m_planet.AtmosphereRadius,
                                                                                            m_planet.AveragePlanetRadius,
                                                                                            atmosphereWavelengths));

                SetRenderObjectID(2, VRageRender.MyRenderProxy.CreateRenderEntityAtmosphere(this.Entity.GetFriendlyName() + " " + this.Entity.EntityId.ToString(),
                                                                                            "Models\\Environment\\Atmosphere_sphere.mwm",
                                                                                            matrix,
                                                                                            MyMeshDrawTechnique.PLANET_SURFACE,
                                                                                            RenderFlags.Visible,
                                                                                            GetRenderCullingOptions(),
                                                                                            m_planet.AtmosphereRadius,
                                                                                            m_planet.AveragePlanetRadius,
                                                                                            atmosphereWavelengths));
            }

            if (m_renderEnabled == false)
            {
                VRageRender.MyRenderProxy.EnableRenderModule((uint)VRageRender.MyRenderModuleEnum.Atmosphere, true);
                m_renderEnabled = true;
            }
        }
        public override void AddRenderObjects()
        {
            //Debug.Assert((m_voxelMap.Size % MyVoxelCoordSystems.RenderCellSizeInLodVoxels(0)) == Vector3I.Zero);
            var clipmapSizeLod0 = m_voxelMap.Size / MyVoxelCoordSystems.RenderCellSizeInLodVoxels(0);

            var worldMatrix = MatrixD.CreateWorld(m_voxelMap.PositionLeftBottomCorner, m_voxelMap.Orientation.Forward, m_voxelMap.Orientation.Up);

            SetRenderObjectID(0,
                              MyRenderProxy.CreateClipmap(
                                  worldMatrix,
                                  clipmapSizeLod0,
                                  m_voxelMap.ScaleGroup,
                                  Vector3D.Zero, additionalFlags: RenderFlags.Visible | RenderFlags.CastShadows));
        }
예제 #3
0
        public override void AddRenderObjects()
        {
            var minCorner = (Vector3D)(Entity as IMyVoxelDrawable).PositionLeftBottomCorner;

            m_renderObjectIDs = new uint[] { MyRenderProxy.RENDER_ID_UNASSIGNED };

            Debug.Assert((m_voxelMap.Size % MyVoxelConstants.RENDER_CELL_SIZE_IN_VOXELS) == Vector3I.Zero);
            var clipmapSizeLod0 = m_voxelMap.Size / MyVoxelConstants.RENDER_CELL_SIZE_IN_VOXELS;

            SetRenderObjectID(0,
                              MyRenderProxy.CreateClipmap(
                                  MatrixD.CreateTranslation(minCorner),
                                  clipmapSizeLod0,
                                  m_voxelMap.ScaleGroup,
                                  Vector3D.Zero));
        }
예제 #4
0
        public override void AddRenderObjects()
        {
            var minCorner = (Vector3D)(Container.Entity as IMyVoxelDrawable).PositionLeftBottomCorner;

            m_renderObjectIDs = new uint[] { MyRenderProxy.RENDER_ID_UNASSIGNED };

            Debug.Assert((m_voxelMap.Size % MyVoxelCoordSystems.RenderCellSizeInLodVoxels(0)) == Vector3I.Zero);
            var clipmapSizeLod0 = m_voxelMap.Size / MyVoxelCoordSystems.RenderCellSizeInLodVoxels(0);

            SetRenderObjectID(0,
                              MyRenderProxy.CreateClipmap(
                                  MatrixD.CreateTranslation(minCorner),
                                  clipmapSizeLod0,
                                  m_voxelMap.ScaleGroup,
                                  Vector3D.Zero));
        }
예제 #5
0
        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;
        }