public void AddStaticLight(cLight light) { /* * System.Diagnostics.Debug.WriteLine( * string.Format("light pos: {0}, {1}", light.Pos.X, light.Pos.Y)); */ staticLights.Add(light); }
public static cLight GetEnvironLight(Vector2f centre, float radius, Color color) { cLight light = new cLight(centre); light.LinearizeFactor = 0.99f; light.Radius = radius; light.Color = color; light.Bleed = 0.01f; return(light); }
private void renderALight(cLight light, RenderTarget target, AABB viewRect) { /* * Vector3f glColor = new Vector3f(0, 0, 0); * glColor.X = ((float)light.Color.R / 255.0f); * glColor.Y = ((float)light.Color.G / 255.0f); * glColor.Z = ((float)light.Color.B / 255.0f); */ Vector2f newPos = new Vector2f(light.Pos.X - viewRect.topLeft.X, light.Pos.Y - viewRect.topLeft.Y); //autenuationShader.SetUniform("lightPos", new Vec2(newPos.X, target.Size.Y - newPos.Y)); autenuationShader.SetUniform("lightPos", new Vec2(newPos.X, target.Size.Y - newPos.Y)); autenuationShader.SetUniform("lightColor", new Vec3(light.GLcolor.X, light.GLcolor.Y, light.GLcolor.Z)); autenuationShader.SetUniform("radius", light.Radius); autenuationShader.SetUniform("bleed", light.Bleed); autenuationShader.SetUniform("linearizeFactor", light.LinearizeFactor); DrawingBase.DrawDirLightByDVec(target, newPos, light.Radius, light.Dir, light.SpreadAngle, light.Color, BlendMode.Add, autenuationShader); /* * Vector2f newPos = new Vector2f(); * newPos.X = light.Pos.X - viewRect.topLeft.X; //(light.Pos.X / defaultTarget.Size.X) * target.Size.X; * newPos.Y = light.Pos.Y - viewRect.topLeft.Y;//(light.Pos.Y / defaultTarget.Size.Y) * target.Size.Y; * * lightSprite.Position = new Vector2f(light.Pos.X - viewRect.topLeft.X, light.Pos.Y - viewRect.topLeft.Y); * lightSprite.Color = light.Color; * * float scale = 1.0f + (light.Radius / (lightTexture.Size.X /2.0f)); * lightSprite.Scale = new Vector2f(scale, scale); * * * // BlendMode bm = new BlendMode(BlendMode.Factor.Zero, BlendMode.Factor.DstColor, BlendMode.Equation.Add, * // BlendMode.Factor.Zero, BlendMode.Factor.OneMinusSrcAlpha, BlendMode.Equation.Add); * * target.Draw(lightSprite, new RenderStates(BlendMode.Add)); */ }
public void loadLightsFromTmxMap(TmxMap map) { foreach (var tmxLight in map.ObjectGroups["Lights"].Objects) { Vector2f pos = new Vector2f(); pos.X = (float)(tmxLight.X + tmxLight.Width / 2.0); pos.Y = (float)(tmxLight.Y + tmxLight.Height / 2.0); cLight light = new cLight(pos); // custom props conversion string hexColor = tmxLight.Properties["color"]; light.Color = Utils.GetSfmlColorFromHex(hexColor); light.Radius = float.Parse(tmxLight.Properties["radius"]); light.Bleed = float.Parse(tmxLight.Properties["intensity"]); this.AddStaticLight(light); } }
public override void Enter() { Vector2f worldSize = new Vector2f(m_AppController.MainWindow.Size.X, m_AppController.MainWindow.Size.Y); m_View.Size = new Vector2f(worldSize.X, worldSize.Y); m_View.Center = new Vector2f(worldSize.X / 2.0f, worldSize.Y / 2.0f); m_View.Viewport = new FloatRect(0.0f, 0.0f, 1.0f, 1.0f); m_View.Zoom(0.6f); //0.6f m_AppController.MainWindow.SetView(m_View); viewRect = new cAABB(); viewRect.SetDims(m_View.Size); worldEnvironment = new cEnvironment(); // Constants.LIGHTMAP_COLOR lightMap = new cLightSystem(Constants.LIGHTMAP_COLOR); //((uint)m_World.WorldBounds.dims.X, (uint)m_World.WorldBounds.dims.Y, Constants.LIGHTMAP_COLOR); m_World = new cWorld(this, m_AppController.MainWindow.Size); //lightMap.Create((uint)m_World.WorldBounds.dims.X, (uint)m_World.WorldBounds.dims.Y); lightMap.Create(m_AppController.MainWindow.Size.X, m_AppController.MainWindow.Size.Y); this.staticTexture = new RenderTexture((uint)m_World.WorldBounds.dims.X, (uint)m_World.WorldBounds.dims.Y); this.staticTexture.SetActive(true); this.staticTexture.Clear(new Color(0, 0, 0, 0)); //this.staticTexture.SetView(m_View); Vector2f playerStart = new Vector2f(m_World.LevelStartRegion.center.X, m_World.LevelStartRegion.rightBottom.Y); playerStart.X -= Constants.CHAR_FRAME_WIDTH / 2.0f; playerStart.Y -= Constants.CHAR_FRAME_HEIGHT; m_Player = new cPlayer(this, playerStart); entityPool = new cEntityPool(this, m_World.WorldBounds.dims, m_Player); //vizekhez adunk fényt List <cWaterBlock> waterBlocks = m_World.GetWaterBlocks(); foreach (cWaterBlock wb in waterBlocks) { cLight waterLight = new cLight(); //víz blokkokhoz adunk fényt, mert jól néz ki waterLight.Pos = new Vector2f(wb.Area.center.X, wb.Area.topLeft.Y + Constants.TILE_SIZE / 2.0f); waterLight.Radius = (wb.Area.dims.X + wb.Area.dims.Y) * 0.8f; waterLight.Bleed = 0.00001f; // 0.00001f; waterLight.LinearizeFactor = 0.95f; waterLight.Color = new Color(41, 174, 232); // 96,156,164 lightMap.AddStaticLight(waterLight); } //háttér, környezeti tárgyak megjelenítése worldEnvironment.SetWaterBlocks(waterBlocks); this.particleManager = new cParticleManager(this); // lightMap.renderStaticLightsToTexture(); gameCommands = new Queue <Action>(50); //Pálya idő start levelTimer.Start(); }
public void AddDynamicLight(cLight light) { dynamicLights.Add(light); }
public void remove(cLight light) { staticLights.Remove(light); }
public void AddStaticLight(cLight light) { staticLights.Add(light); }