protected override MyMwcObjectBuilder_Base GetObjectBuilderInternal(bool getExactCopy) { MyMwcObjectBuilder_PrefabLight objectBuilder = base.GetObjectBuilderInternal(getExactCopy) as MyMwcObjectBuilder_PrefabLight; objectBuilder.PointColor = m_light.Color; objectBuilder.PointFalloff = m_light.Falloff; objectBuilder.PointIntensity = m_IntensityMax;//we use this local value because intenisty in mpoint light may change due to effects objectBuilder.PointRange = m_light.Range; objectBuilder.PointOffset = m_light.PointLightOffset; objectBuilder.SpotAgle = m_light.ReflectorConeDegrees; objectBuilder.SpotSpecular = objectBuilder.PointSpecular = m_light.SpecularColor; objectBuilder.PointEnabled = m_light.PointOn; objectBuilder.Effect = m_effect; objectBuilder.LightType = (MyLightPrefabTypeEnum)m_light.LightType; objectBuilder.FlashOffset = this.FlashOffset; objectBuilder.SpotColor = m_light.ReflectorColor; objectBuilder.SpotFalloff = m_light.ReflectorFalloff; objectBuilder.SpotIntensity = ReflectorIntensityMax;//we use this local value because intenisty in mpoint light may change due to effects objectBuilder.SpotRange = m_light.ReflectorRange; objectBuilder.SpotEnabled = m_light.ReflectorOn; objectBuilder.ShadowsDistance = m_light.ShadowDistance; return(objectBuilder); }
protected override void InitPrefab(string displayName, Vector3 relativePosition, Matrix localOrientation, MyMwcObjectBuilder_PrefabBase objectBuilder, MyPrefabConfiguration prefabConfig) { m_prefabLightConfig = prefabConfig as MyPrefabConfigurationLight; MyMwcObjectBuilder_PrefabLight objectBuilderLight = objectBuilder as MyMwcObjectBuilder_PrefabLight; m_light = MyLights.AddLight(); m_light.LightType = (MyLight.LightTypeEnum)objectBuilderLight.LightType; m_light.Start(m_light.LightType, 1); m_light.UseInForwardRender = true; //grab first dummy and set it as point source //since we dont support yet more lights in one prefab. add just the first one MyModel model = MyModels.GetModelOnlyDummies(m_prefabLightConfig.ModelLod0Enum); m_pointLocalMatrix = Matrix.Identity; bool dummyFound = false; foreach (KeyValuePair <string, MyModelDummy> pair in model.Dummies) { if (pair.Key.StartsWith("Dummy", StringComparison.InvariantCultureIgnoreCase)) { m_pointLocalMatrix = pair.Value.Matrix; dummyFound = true; break; } } Debug.Assert(dummyFound, "Dummy 'POINT_LIGHT_POS' not found in light prefab model: " + model.AssetName); m_light.Color = objectBuilderLight.PointColor; m_light.ReflectorColor = objectBuilderLight.SpotColor; m_light.Falloff = objectBuilderLight.PointFalloff; m_light.ReflectorFalloff = objectBuilderLight.SpotFalloff; m_IntensityMax = m_light.Intensity = objectBuilderLight.PointIntensity; m_light.ReflectorIntensity = ReflectorIntensityMax = objectBuilderLight.SpotIntensity; m_light.ReflectorRange = MathHelper.Clamp(objectBuilderLight.SpotRange, 1, MyLightsConstants.MAX_SPOTLIGHT_RANGE); m_light.Range = MathHelper.Clamp(objectBuilderLight.PointRange, 1, MyLightsConstants.MAX_POINTLIGHT_RADIUS); m_light.PointLightOffset = objectBuilderLight.PointOffset; this.FlashOffset = objectBuilderLight.FlashOffset; //to add reflector range to builders m_light.SpecularColor = objectBuilderLight.PointSpecular; m_light.ReflectorConeDegrees = objectBuilderLight.SpotAgle; m_effect = objectBuilderLight.Effect; //m_light.LightOn = true; m_lastBlickChange = MyMinerGame.TotalGamePlayTimeInMilliseconds; // here set the properties of glare for the prefab light m_light.GlareOn = true; m_light.Glare.Type = MyLightGlare.GlareTypeEnum.Normal; m_light.Glare.QuerySize = .8f; m_light.ShadowDistance = objectBuilderLight.ShadowsDistance; m_light.Glare.Intensity = m_light.Intensity; UpdateEffect(); CastShadows = false; UpdateLightWorldMatrix(); }