Example #1
0
        public WorldLightEntry(DBC.Light light)
        {
            for (int i = 0; i < 18; ++i)
            {
                mColorTables.Add(new List<Vector3>());
                mTimeTables.Add(new List<uint>());
            }

            mParams = DBC.DBCStores.LightParams[light.skyParam];
            mLight = light;
            Position = new Vector3(mLight.x / 36.0f, mLight.y / 36.0f, mLight.z / 36.0f);
            InitColorTables();
        }
Example #2
0
        public WorldLightEntry(DBC.Light light)
        {
            for (int i = 0; i < 18; ++i)
            {
                mColorTables.Add(new List <Vector3>());
                mTimeTables.Add(new List <uint>());
            }

            mParams  = DBC.DBCStores.LightParams[light.skyParam];
            mLight   = light;
            Position = new Vector3(mLight.x / 36.0f, mLight.y / 36.0f, mLight.z / 36.0f);
            InitColorTables();
        }
Example #3
0
        private void button7_Click(object sender, EventArgs e)
        {
            DBC.Light light = new DBC.Light();
            light.ID = DBC.DBCStores.Light.MaxKey + 1;
            light.deathParam = 0;
            light.waterParam = 0;
            light.otherParam = 0;
            light.MapID = Game.GameManager.WorldManager.MapID;
            light.sunsetParam = 0;
            light.unk1 = light.unk2 = light.unk3 = 0;
            light.x = (((float)numericUpDown1.Value) + Utils.Metrics.MidPoint) * 36.0f;
            light.z = (((float)numericUpDown2.Value) + Utils.Metrics.MidPoint) * 36.0f;
            light.y = ((float)numericUpDown3.Value) * 36.0f;
            light.falloff = (float)numericUpDown4.Value * 36.0f;
            light.falloffEnd = (float)numericUpDown5.Value * 36.0f;

            uint maxIntParam = DBC.DBCStores.LightIntBand.MaxKey;
            maxIntParam /= 18;
            ++maxIntParam;

            uint maxLightParam = DBC.DBCStores.LightParams.MaxKey;
            ++maxLightParam;

            uint skyParam = (uint)Math.Max(maxIntParam, maxLightParam);
            light.skyParam = skyParam;

            DBC.LightParams param = new DBC.LightParams()
            {
                ID = skyParam,
                glow = (float)numericUpDown6.Value,
                cloudID = (uint)comboBox1.SelectedIndex,
                HighlightSky = (checkBox1.Checked ? 1u : 0u),
                oceanDeepAlpha = (float)numericUpDown10.Value,
                oceanShallowAlpha = (float)numericUpDown9.Value,
                waterDeepAlpha = (float)numericUpDown8.Value,
                waterShallowAlpha = (float)numericUpDown7.Value,
                skyboxID = (uint)textBox1.Tag
            };

            DBC.DBCStores.LightParams.AddEntry(skyParam, param);

            #region LightIntBand
            for (uint i = 0; i < 18; ++i)
            {
                DBC.LightIntBand lib = new DBC.LightIntBand();
                lib.Times = new uint[16];
                lib.Values = new uint[16];
                lib.ID = skyParam * 18 - 17 + i;
                switch ((World.ColorTableValues)i)
                {
                    case World.ColorTableValues.GlobalDiffuse:
                        {
                            var times = lightColorSelector1.Interpolator.TimeTable;
                            var colors = lightColorSelector1.Interpolator.ColorTable;

                            lib.NumEntries = (uint)times.Count;
                            for (int j = 0; j < times.Count; ++j)
                            {
                                lib.Times[j] = times[j];
                                lib.Values[j] = World.WorldLightEntry.ToUint(colors[j]);
                            }
                        }
                        break;

                    case World.ColorTableValues.GlobalAmbient:
                        {
                            var times = lightColorSelector2.Interpolator.TimeTable;
                            var colors = lightColorSelector2.Interpolator.ColorTable;

                            lib.NumEntries = (uint)times.Count;
                            for (int j = 0; j < times.Count; ++j)
                            {
                                lib.Times[j] = times[j];
                                lib.Values[j] = World.WorldLightEntry.ToUint(colors[j]);
                            }
                        }
                        break;

                    case World.ColorTableValues.Fog:
                        {
                            var times = lightColorSelector3.Interpolator.TimeTable;
                            var colors = lightColorSelector3.Interpolator.ColorTable;

                            lib.NumEntries = (uint)times.Count;
                            for (int j = 0; j < times.Count; ++j)
                            {
                                lib.Times[j] = times[j];
                                lib.Values[j] = World.WorldLightEntry.ToUint(colors[j]);
                            }
                        }
                        break;

                    case World.ColorTableValues.Color0:
                        {
                            var times = lightColorSelector4.Interpolator.TimeTable;
                            var colors = lightColorSelector4.Interpolator.ColorTable;

                            lib.NumEntries = (uint)times.Count;
                            for (int j = 0; j < times.Count; ++j)
                            {
                                lib.Times[j] = times[j];
                                lib.Values[j] = World.WorldLightEntry.ToUint(colors[j]);
                            }
                        }
                        break;

                    case World.ColorTableValues.Color1:
                        {
                            var times = lightColorSelector5.Interpolator.TimeTable;
                            var colors = lightColorSelector5.Interpolator.ColorTable;

                            lib.NumEntries = (uint)times.Count;
                            for (int j = 0; j < times.Count; ++j)
                            {
                                lib.Times[j] = times[j];
                                lib.Values[j] = World.WorldLightEntry.ToUint(colors[j]);
                            }
                        }
                        break;

                    case World.ColorTableValues.Color2:
                        {
                            var times = lightColorSelector6.Interpolator.TimeTable;
                            var colors = lightColorSelector6.Interpolator.ColorTable;

                            lib.NumEntries = (uint)times.Count;
                            for (int j = 0; j < times.Count; ++j)
                            {
                                lib.Times[j] = times[j];
                                lib.Values[j] = World.WorldLightEntry.ToUint(colors[j]);
                            }
                        }
                        break;

                    case World.ColorTableValues.Color3:
                        {
                            var times = lightColorSelector7.Interpolator.TimeTable;
                            var colors = lightColorSelector7.Interpolator.ColorTable;

                            lib.NumEntries = (uint)times.Count;
                            for (int j = 0; j < times.Count; ++j)
                            {
                                lib.Times[j] = times[j];
                                lib.Values[j] = World.WorldLightEntry.ToUint(colors[j]);
                            }
                        }
                        break;

                    case World.ColorTableValues.Color4:
                        {
                            var times = lightColorSelector8.Interpolator.TimeTable;
                            var colors = lightColorSelector8.Interpolator.ColorTable;

                            lib.NumEntries = (uint)times.Count;
                            for (int j = 0; j < times.Count; ++j)
                            {
                                lib.Times[j] = times[j];
                                lib.Values[j] = World.WorldLightEntry.ToUint(colors[j]);
                            }
                        }
                        break;

                    case World.ColorTableValues.SunColor:
                        {
                            var times = lightColorSelector9.Interpolator.TimeTable;
                            var colors = lightColorSelector9.Interpolator.ColorTable;

                            lib.NumEntries = (uint)times.Count;
                            for (int j = 0; j < times.Count; ++j)
                            {
                                lib.Times[j] = times[j];
                                lib.Values[j] = World.WorldLightEntry.ToUint(colors[j]);
                            }
                        }
                        break;

                    case World.ColorTableValues.SunHaloColor:
                        {
                            var times = lightColorSelector10.Interpolator.TimeTable;
                            var colors = lightColorSelector10.Interpolator.ColorTable;

                            lib.NumEntries = (uint)times.Count;
                            for (int j = 0; j < times.Count; ++j)
                            {
                                lib.Times[j] = times[j];
                                lib.Values[j] = World.WorldLightEntry.ToUint(colors[j]);
                            }
                        }
                        break;

                    case World.ColorTableValues.WaterDark:
                        {
                            var times = lightColorSelector11.Interpolator.TimeTable;
                            var colors = lightColorSelector11.Interpolator.ColorTable;

                            lib.NumEntries = (uint)times.Count;
                            for (int j = 0; j < times.Count; ++j)
                            {
                                lib.Times[j] = times[j];
                                lib.Values[j] = World.WorldLightEntry.ToUint(colors[j]);
                            }
                        }
                        break;

                    case World.ColorTableValues.WaterLight:
                        {
                            var times = lightColorSelector12.Interpolator.TimeTable;
                            var colors = lightColorSelector12.Interpolator.ColorTable;

                            lib.NumEntries = (uint)times.Count;
                            for (int j = 0; j < times.Count; ++j)
                            {
                                lib.Times[j] = times[j];
                                lib.Values[j] = World.WorldLightEntry.ToUint(colors[j]);
                            }
                        }
                        break;

                    case World.ColorTableValues.Shadow:
                        {
                            var times = lightColorSelector13.Interpolator.TimeTable;
                            var colors = lightColorSelector13.Interpolator.ColorTable;

                            lib.NumEntries = (uint)times.Count;
                            for (int j = 0; j < times.Count; ++j)
                            {
                                lib.Times[j] = times[j];
                                lib.Values[j] = World.WorldLightEntry.ToUint(colors[j]);
                            }
                        }
                        break;

                    default:
                        {
                            lib.NumEntries = 0;
                            break;
                        }
                }

                DBC.DBCStores.LightIntBand.AddEntry(lib.ID, lib);
            }
            #endregion

            for (int i = 0; i < 6; ++i)
            {
                DBC.LightFloatBand lfb = new DBC.LightFloatBand();
                lfb.ID = skyParam * 6 - 5 + (uint)i;
                lfb.NumEntries = 0;
                lfb.Times = new uint[16];
                lfb.Values = new float[16];
                DBC.DBCStores.LightFloatBand.AddEntry(lfb.ID, lfb);
            }

            DBC.DBCStores.Light.AddEntry(light.ID, light);

            World.WorldLightEntry wle = new World.WorldLightEntry(light);
            if (Game.GameManager.IsPandaria == false)
                Game.GameManager.SkyManager.GetSkyForMap(light.MapID).AddNewLight(wle);

            DBC.DBCStores.LightIntBand.SaveDBC();
            DBC.DBCStores.LightParams.SaveDBC();
            DBC.DBCStores.Light.SaveDBC();
            DBC.DBCStores.LightFloatBand.SaveDBC();
        }
Example #4
0
        private void button7_Click(object sender, EventArgs e)
        {
            DBC.Light light = new DBC.Light();
            light.ID          = DBC.DBCStores.Light.MaxKey + 1;
            light.deathParam  = 0;
            light.waterParam  = 0;
            light.otherParam  = 0;
            light.MapID       = Game.GameManager.WorldManager.MapID;
            light.sunsetParam = 0;
            light.unk1        = light.unk2 = light.unk3 = 0;
            light.x           = (((float)numericUpDown1.Value) + Utils.Metrics.MidPoint) * 36.0f;
            light.z           = (((float)numericUpDown2.Value) + Utils.Metrics.MidPoint) * 36.0f;
            light.y           = ((float)numericUpDown3.Value) * 36.0f;
            light.falloff     = (float)numericUpDown4.Value * 36.0f;
            light.falloffEnd  = (float)numericUpDown5.Value * 36.0f;

            uint maxIntParam = DBC.DBCStores.LightIntBand.MaxKey;

            maxIntParam /= 18;
            ++maxIntParam;

            uint maxLightParam = DBC.DBCStores.LightParams.MaxKey;

            ++maxLightParam;

            uint skyParam = (uint)Math.Max(maxIntParam, maxLightParam);

            light.skyParam = skyParam;

            DBC.LightParams param = new DBC.LightParams()
            {
                ID                = skyParam,
                glow              = (float)numericUpDown6.Value,
                cloudID           = (uint)comboBox1.SelectedIndex,
                HighlightSky      = (checkBox1.Checked ? 1u : 0u),
                oceanDeepAlpha    = (float)numericUpDown10.Value,
                oceanShallowAlpha = (float)numericUpDown9.Value,
                waterDeepAlpha    = (float)numericUpDown8.Value,
                waterShallowAlpha = (float)numericUpDown7.Value,
                skyboxID          = (uint)textBox1.Tag
            };

            DBC.DBCStores.LightParams.AddEntry(skyParam, param);

            #region LightIntBand
            for (uint i = 0; i < 18; ++i)
            {
                DBC.LightIntBand lib = new DBC.LightIntBand();
                lib.Times  = new uint[16];
                lib.Values = new uint[16];
                lib.ID     = skyParam * 18 - 17 + i;
                switch ((World.ColorTableValues)i)
                {
                case World.ColorTableValues.GlobalDiffuse:
                {
                    var times  = lightColorSelector1.Interpolator.TimeTable;
                    var colors = lightColorSelector1.Interpolator.ColorTable;

                    lib.NumEntries = (uint)times.Count;
                    for (int j = 0; j < times.Count; ++j)
                    {
                        lib.Times[j]  = times[j];
                        lib.Values[j] = World.WorldLightEntry.ToUint(colors[j]);
                    }
                }
                break;

                case World.ColorTableValues.GlobalAmbient:
                {
                    var times  = lightColorSelector2.Interpolator.TimeTable;
                    var colors = lightColorSelector2.Interpolator.ColorTable;

                    lib.NumEntries = (uint)times.Count;
                    for (int j = 0; j < times.Count; ++j)
                    {
                        lib.Times[j]  = times[j];
                        lib.Values[j] = World.WorldLightEntry.ToUint(colors[j]);
                    }
                }
                break;

                case World.ColorTableValues.Fog:
                {
                    var times  = lightColorSelector3.Interpolator.TimeTable;
                    var colors = lightColorSelector3.Interpolator.ColorTable;

                    lib.NumEntries = (uint)times.Count;
                    for (int j = 0; j < times.Count; ++j)
                    {
                        lib.Times[j]  = times[j];
                        lib.Values[j] = World.WorldLightEntry.ToUint(colors[j]);
                    }
                }
                break;

                case World.ColorTableValues.Color0:
                {
                    var times  = lightColorSelector4.Interpolator.TimeTable;
                    var colors = lightColorSelector4.Interpolator.ColorTable;

                    lib.NumEntries = (uint)times.Count;
                    for (int j = 0; j < times.Count; ++j)
                    {
                        lib.Times[j]  = times[j];
                        lib.Values[j] = World.WorldLightEntry.ToUint(colors[j]);
                    }
                }
                break;

                case World.ColorTableValues.Color1:
                {
                    var times  = lightColorSelector5.Interpolator.TimeTable;
                    var colors = lightColorSelector5.Interpolator.ColorTable;

                    lib.NumEntries = (uint)times.Count;
                    for (int j = 0; j < times.Count; ++j)
                    {
                        lib.Times[j]  = times[j];
                        lib.Values[j] = World.WorldLightEntry.ToUint(colors[j]);
                    }
                }
                break;

                case World.ColorTableValues.Color2:
                {
                    var times  = lightColorSelector6.Interpolator.TimeTable;
                    var colors = lightColorSelector6.Interpolator.ColorTable;

                    lib.NumEntries = (uint)times.Count;
                    for (int j = 0; j < times.Count; ++j)
                    {
                        lib.Times[j]  = times[j];
                        lib.Values[j] = World.WorldLightEntry.ToUint(colors[j]);
                    }
                }
                break;

                case World.ColorTableValues.Color3:
                {
                    var times  = lightColorSelector7.Interpolator.TimeTable;
                    var colors = lightColorSelector7.Interpolator.ColorTable;

                    lib.NumEntries = (uint)times.Count;
                    for (int j = 0; j < times.Count; ++j)
                    {
                        lib.Times[j]  = times[j];
                        lib.Values[j] = World.WorldLightEntry.ToUint(colors[j]);
                    }
                }
                break;

                case World.ColorTableValues.Color4:
                {
                    var times  = lightColorSelector8.Interpolator.TimeTable;
                    var colors = lightColorSelector8.Interpolator.ColorTable;

                    lib.NumEntries = (uint)times.Count;
                    for (int j = 0; j < times.Count; ++j)
                    {
                        lib.Times[j]  = times[j];
                        lib.Values[j] = World.WorldLightEntry.ToUint(colors[j]);
                    }
                }
                break;

                case World.ColorTableValues.SunColor:
                {
                    var times  = lightColorSelector9.Interpolator.TimeTable;
                    var colors = lightColorSelector9.Interpolator.ColorTable;

                    lib.NumEntries = (uint)times.Count;
                    for (int j = 0; j < times.Count; ++j)
                    {
                        lib.Times[j]  = times[j];
                        lib.Values[j] = World.WorldLightEntry.ToUint(colors[j]);
                    }
                }
                break;

                case World.ColorTableValues.SunHaloColor:
                {
                    var times  = lightColorSelector10.Interpolator.TimeTable;
                    var colors = lightColorSelector10.Interpolator.ColorTable;

                    lib.NumEntries = (uint)times.Count;
                    for (int j = 0; j < times.Count; ++j)
                    {
                        lib.Times[j]  = times[j];
                        lib.Values[j] = World.WorldLightEntry.ToUint(colors[j]);
                    }
                }
                break;

                case World.ColorTableValues.WaterDark:
                {
                    var times  = lightColorSelector11.Interpolator.TimeTable;
                    var colors = lightColorSelector11.Interpolator.ColorTable;

                    lib.NumEntries = (uint)times.Count;
                    for (int j = 0; j < times.Count; ++j)
                    {
                        lib.Times[j]  = times[j];
                        lib.Values[j] = World.WorldLightEntry.ToUint(colors[j]);
                    }
                }
                break;

                case World.ColorTableValues.WaterLight:
                {
                    var times  = lightColorSelector12.Interpolator.TimeTable;
                    var colors = lightColorSelector12.Interpolator.ColorTable;

                    lib.NumEntries = (uint)times.Count;
                    for (int j = 0; j < times.Count; ++j)
                    {
                        lib.Times[j]  = times[j];
                        lib.Values[j] = World.WorldLightEntry.ToUint(colors[j]);
                    }
                }
                break;

                case World.ColorTableValues.Shadow:
                {
                    var times  = lightColorSelector13.Interpolator.TimeTable;
                    var colors = lightColorSelector13.Interpolator.ColorTable;

                    lib.NumEntries = (uint)times.Count;
                    for (int j = 0; j < times.Count; ++j)
                    {
                        lib.Times[j]  = times[j];
                        lib.Values[j] = World.WorldLightEntry.ToUint(colors[j]);
                    }
                }
                break;

                default:
                {
                    lib.NumEntries = 0;
                    break;
                }
                }

                DBC.DBCStores.LightIntBand.AddEntry(lib.ID, lib);
            }
            #endregion

            for (int i = 0; i < 6; ++i)
            {
                DBC.LightFloatBand lfb = new DBC.LightFloatBand();
                lfb.ID         = skyParam * 6 - 5 + (uint)i;
                lfb.NumEntries = 0;
                lfb.Times      = new uint[16];
                lfb.Values     = new float[16];
                DBC.DBCStores.LightFloatBand.AddEntry(lfb.ID, lfb);
            }

            DBC.DBCStores.Light.AddEntry(light.ID, light);

            World.WorldLightEntry wle = new World.WorldLightEntry(light);
            if (Game.GameManager.IsPandaria == false)
            {
                Game.GameManager.SkyManager.GetSkyForMap(light.MapID).AddNewLight(wle);
            }

            DBC.DBCStores.LightIntBand.SaveDBC();
            DBC.DBCStores.LightParams.SaveDBC();
            DBC.DBCStores.Light.SaveDBC();
            DBC.DBCStores.LightFloatBand.SaveDBC();
        }