//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 static List <Line3D> GetDynamicLightShapes(IEnumerable <Thing> things, bool highlight) { List <Line3D> circles = new List <Line3D>(); if (General.Map.DOOM) { return(circles); } const int linealpha = 128; foreach (Thing t in things) { int lightid = Array.IndexOf(GZGeneral.GZ_LIGHTS, t.Type); if (lightid == -1) { continue; } // TODO: this basically duplicates VisualThing.UpdateLight()... // Determine light radiii int primaryradius; int secondaryradius = 0; if (lightid < GZGeneral.GZ_LIGHT_TYPES[2]) //if it's gzdoom light { int n; if (lightid < GZGeneral.GZ_LIGHT_TYPES[0]) { n = 0; } else if (lightid < GZGeneral.GZ_LIGHT_TYPES[1]) { n = 10; } else { n = 20; } DynamicLightType lightType = (DynamicLightType)(t.Type - 9800 - n); if (lightType == DynamicLightType.SECTOR) { if (t.Sector == null) { t.DetermineSector(); } int scaler = (t.Sector != null ? t.Sector.Brightness / 4 : 2); primaryradius = t.Args[3] * scaler; } else { primaryradius = t.Args[3] * 2; //works... that.. way in GZDoom if (lightType > 0) { secondaryradius = t.Args[4] * 2; } } } else //it's one of vavoom lights { primaryradius = t.Args[0] * 8; } // Check radii... if (primaryradius < 1 && secondaryradius < 1) { continue; } // Determine light color PixelColor color; if (highlight) { color = General.Colors.Highlight.WithAlpha(linealpha); } else { switch (t.Type) { case 1502: // Vavoom light color = new PixelColor(linealpha, 255, 255, 255); break; case 1503: // Vavoom colored light color = new PixelColor(linealpha, (byte)t.Args[1], (byte)t.Args[2], (byte)t.Args[3]); break; default: color = new PixelColor(linealpha, (byte)t.Args[0], (byte)t.Args[1], (byte)t.Args[2]); break; } } // Add lines if visible if (primaryradius > 0) { circles.AddRange(MakeCircleLines(t.Position, color, primaryradius, CIRCLE_SIDES)); } if (secondaryradius > 0) { circles.AddRange(MakeCircleLines(t.Position, color, secondaryradius, CIRCLE_SIDES)); } } // Done return(circles); }