//mxd private void UpdateGldefsLight() { DynamicLightData light = General.Map.Data.GldefsEntries[thing.Type]; //apply settings lightRenderStyle = light.Subtractive ? DynamicLightRenderStyle.NEGATIVE : DynamicLightRenderStyle.NORMAL; lightColor = new Color4((float)lightRenderStyle / 100.0f, light.Color.Red, light.Color.Green, light.Color.Blue); Vector2D o = new Vector2D(light.Offset.X, light.Offset.Y).GetRotated(thing.Angle - Angle2D.PIHALF); lightOffset = new Vector3(o.x, o.y, light.Offset.Z); lightType = light.Type; if (lightType == DynamicLightType.SECTOR) { lightPrimaryRadius = light.Interval * thing.Sector.Brightness / 5.0f; } else { lightPrimaryRadius = light.PrimaryRadius; lightSecondaryRadius = light.SecondaryRadius; } lightInterval = light.Interval; UpdateLightRadius(lightInterval); }
//mxd protected void CheckLightState() { //mxd. Check if thing is light int light_id = Array.IndexOf(GZBuilder.GZGeneral.GZ_LIGHTS, thing.Type); if (light_id != -1) { isGldefsLight = false; lightInterval = -1; UpdateLight(light_id); UpdateBoundingBox(lightRadius, lightRadius * 2); } //check if we have light from GLDEFS else if (General.Map.Data.GldefsEntries.ContainsKey(thing.Type)) { isGldefsLight = true; UpdateGldefsLight(); UpdateBoundingBox(lightRadius, lightRadius * 2); } else { UpdateBoundingBox((int)thing.Size, thingheight); lightType = DynamicLightType.NONE; lightRadius = -1; lightPrimaryRadius = -1; lightSecondaryRadius = -1; lightRenderStyle = DynamicLightRenderStyle.NONE; lightInterval = -1; isGldefsLight = false; } }
// Constructor protected VisualThing(Thing t) { // Initialize this.thing = t; this.renderpass = RenderPass.Mask; this.position = Matrix.Identity; //mxd lightType = DynamicLightType.NONE; lightRenderStyle = DynamicLightRenderStyle.NONE; lightPrimaryRadius = -1; lightSecondaryRadius = -1; lightInterval = -1; lightColor = new Color4(); boundingBox = new Vector3D[9]; // Register as resource General.Map.Graphics.RegisterResource(this); }
//mxd. Update light info private void UpdateLight(int lightId) { if (lightId < GZBuilder.GZGeneral.GZ_LIGHT_TYPES[2]) //if it's gzdoom light { int n; if (lightId < GZBuilder.GZGeneral.GZ_LIGHT_TYPES[0]) { n = 0; lightRenderStyle = DynamicLightRenderStyle.NORMAL; //lightColor.Alpha used in shader to perform some calculations based on light type lightColor = new Color4((float)lightRenderStyle / 100.0f, thing.Args[0] / DYNLIGHT_INTENSITY_SCALER, thing.Args[1] / DYNLIGHT_INTENSITY_SCALER, thing.Args[2] / DYNLIGHT_INTENSITY_SCALER); } else if (lightId < GZBuilder.GZGeneral.GZ_LIGHT_TYPES[1]) { n = 10; lightRenderStyle = DynamicLightRenderStyle.ADDITIVE; lightColor = new Color4((float)lightRenderStyle / 100.0f, thing.Args[0] / DYNLIGHT_INTENSITY_SCALER, thing.Args[1] / DYNLIGHT_INTENSITY_SCALER, thing.Args[2] / DYNLIGHT_INTENSITY_SCALER); } else { n = 20; lightRenderStyle = DynamicLightRenderStyle.NEGATIVE; lightColor = new Color4((float)lightRenderStyle / 100.0f, thing.Args[0] / SUBLIGHT_INTENSITY_SCALER, thing.Args[1] / SUBLIGHT_INTENSITY_SCALER, thing.Args[2] / SUBLIGHT_INTENSITY_SCALER); } lightType = (DynamicLightType)(thing.Type - 9800 - n); if (lightType == DynamicLightType.SECTOR) { int scaler = 1; if (thing.Sector != null) { scaler = thing.Sector.Brightness / 4; } lightPrimaryRadius = (thing.Args[3] * scaler); } else { lightPrimaryRadius = (thing.Args[3] * 2); //works... that.. way in GZDoom if (lightType > 0) { lightSecondaryRadius = (thing.Args[4] * 2); } } } else //it's one of vavoom lights { lightRenderStyle = DynamicLightRenderStyle.VAVOOM; lightType = (DynamicLightType)thing.Type; if (lightType == DynamicLightType.VAVOOM_COLORED) { lightColor = new Color4((float)lightRenderStyle / 100.0f, thing.Args[1] / DYNLIGHT_INTENSITY_SCALER, thing.Args[2] / DYNLIGHT_INTENSITY_SCALER, thing.Args[3] / DYNLIGHT_INTENSITY_SCALER); } else { lightColor = new Color4((float)lightRenderStyle / 100.0f, 0.5f, 0.5f, 0.5f); } lightPrimaryRadius = (thing.Args[0] * 8); } UpdateLightRadius(); }
public DynamicLightData() { Style = DynamicLightRenderStyle.NORMAL; Color = new Color3(); Offset = new Vector3(); }