Esempio n. 1
0
        public void FromLightShare(RegionLightShareData ls)
        {
            WaterData water = new WaterData();

            water.waterFogColor   = ls.waterColor / 256f;
            water.waterFogDensity = (float)Math.Pow(2.0f, ls.waterFogDensityExponent);
            //water.waterFogDensity = ls.waterFogDensityExponent;
            water.underWaterFogMod = ls.underwaterFogModifier;
            water.normScale        = ls.reflectionWaveletScale;
            water.fresnelScale     = ls.fresnelScale;
            water.fresnelOffset    = ls.fresnelOffset;
            water.scaleAbove       = ls.refractScaleAbove;
            water.scaleBelow       = ls.refractScaleBelow;
            water.blurMultiplier   = ls.blurMultiplier;
            water.wave1Dir         = ls.littleWaveDirection;
            water.wave2Dir         = ls.bigWaveDirection;
            water.normalMap        = ls.normalMapTexture;
            water.Name             = "LightshareWater";

            SkyData sky = new SkyData();

            convertFromAngles(sky, 2.0f * (float)Math.PI * ls.sunMoonPosition, 2.0f * (float)Math.PI * ls.eastAngle);
            sky.sunlight_color      = ls.sunMoonColor * 3.0f;
            sky.ambient             = new Vector3(ls.ambient.X * 3.0f, ls.ambient.Y * 3.0f, ls.ambient.Z * 3.0f);
            sky.blue_horizon        = new Vector3(ls.horizon.X * 2.0f, ls.horizon.Y * 2.0f, ls.horizon.Z * 2.0f);
            sky.blue_density        = new Vector3(ls.blueDensity.X * 2.0f, ls.blueDensity.Y * 2.0f, ls.blueDensity.Z * 2.0f);;
            sky.haze_horizon        = ls.hazeHorizon;
            sky.haze_density        = ls.hazeDensity;
            sky.cloud_shadow        = ls.cloudCoverage;
            sky.density_multiplier  = ls.densityMultiplier / 1000.0f;
            sky.distance_multiplier = ls.distanceMultiplier;
            sky.max_y              = ls.maxAltitude;
            sky.cloud_color        = new Vector3(ls.cloudColor.X, ls.cloudColor.Y, ls.cloudColor.Z);
            sky.cloud_pos_density1 = ls.cloudXYDensity;
            sky.cloud_pos_density2 = ls.cloudDetailXYDensity;
            sky.cloud_scale        = ls.cloudScale;
            sky.gamma              = ls.sceneGamma;
            sky.glow = new Vector3((2f - ls.sunGlowSize) * 20f, 0f, -ls.sunGlowFocus * 5f);
            sky.cloud_scroll_rate = new Vector2(ls.cloudScrollX, ls.cloudScrollY);
            if (ls.cloudScrollXLock)
            {
                sky.cloud_scroll_rate.X = 0;
            }
            if (ls.cloudScrollYLock)
            {
                sky.cloud_scroll_rate.Y = 0;
            }
            sky.star_brightness = ls.starBrightness * 250f;
            sky.Name            = "LightshareSky";

            Cycle      = new DayCycle();
            Cycle.Name = "Lightshare";
            Cycle.waterframes.Add(water.Name, water);
            DayCycle.TrackEntry track = new DayCycle.TrackEntry(-1, water.Name);
            Cycle.waterTrack.Add(track);

            Cycle.skyframes.Add(sky.Name, sky);
            track = new DayCycle.TrackEntry(-1, sky.Name);
            Cycle.skyTrack0.Add(track);
        }
Esempio n. 2
0
        public bool replaceWaterFromOSD(string name, OSDMap map)
        {
            WaterData water = new WaterData();

            if (string.IsNullOrWhiteSpace(name))
            {
                name = "Water";
            }
            try
            {
                water.FromOSD(name, map);
            }
            catch
            {
                return(false);
            }
            waterframes.Clear();
            waterframes[name] = water;
            waterTrack.Clear();
            TrackEntry t = new TrackEntry()
            {
                time      = -1,
                frameName = name
            };

            waterTrack.Add(t);
            return(true);
        }
Esempio n. 3
0
        public void FromWLOSD(OSDArray array)
        {
            CompareTrackEntries cte = new CompareTrackEntries();
            TrackEntry          track;

            OSDArray skytracksArray = null;

            if (array.Count > 1)
            {
                skytracksArray = array[1] as OSDArray;
            }
            if (skytracksArray != null)
            {
                foreach (OSD setting in skytracksArray)
                {
                    OSDArray innerSetting = setting as OSDArray;
                    if (innerSetting != null)
                    {
                        track = new TrackEntry((float)innerSetting[0].AsReal(), innerSetting[1].AsString());
                        skyTrack0.Add(track);
                    }
                }
                skyTrack0.Sort(cte);
            }

            OSDMap skyFramesArray = null;

            if (array.Count > 2)
            {
                skyFramesArray = array[2] as OSDMap;
            }
            if (skyFramesArray != null)
            {
                foreach (KeyValuePair <string, OSD> kvp in skyFramesArray)
                {
                    SkyData sky = new SkyData();
                    sky.FromWLOSD(kvp.Key, kvp.Value);
                    skyframes[kvp.Key] = sky;
                }
            }

            WaterData water    = new WaterData();
            OSDMap    watermap = null;

            if (array.Count > 3)
            {
                watermap = array[3] as OSDMap;
            }
            if (watermap != null)
            {
                water.FromWLOSD("WLWater", watermap);
            }

            waterframes["WLWater"] = water;
            track = new TrackEntry(-1f, "WLWater");
            waterTrack.Add(track);

            Name = "WLDaycycle";

            if (skyTrack0.Count == 1 && skyTrack0[0].time == -1f)
            {
                IsStaticDayCycle = true;
            }
        }
Esempio n. 4
0
        public void FromOSD(OSDMap map)
        {
            CompareTrackEntries cte = new CompareTrackEntries();
            OSD otmp;

            if (map.TryGetValue("frames", out otmp) && otmp is OSDMap)
            {
                OSDMap mframes = otmp as OSDMap;
                foreach (KeyValuePair <string, OSD> kvp in mframes)
                {
                    OSDMap v = kvp.Value as OSDMap;
                    if (v.TryGetValue("type", out otmp))
                    {
                        string type = otmp;
                        if (type.Equals("water"))
                        {
                            WaterData water = new WaterData();
                            water.FromOSD(kvp.Key, v);
                            waterframes[kvp.Key] = water;
                        }
                        else if (type.Equals("sky"))
                        {
                            SkyData sky = new SkyData();
                            sky.FromOSD(kvp.Key, v);
                            skyframes[kvp.Key] = sky;
                        }
                    }
                }
            }

            if (map.TryGetValue("name", out otmp))
            {
                Name = otmp;
            }
            else
            {
                Name = "DayCycle";
            }

            OSDArray track;

            if (map.TryGetValue("tracks", out otmp) && otmp is OSDArray)
            {
                OSDArray tracks = otmp as OSDArray;
                if (tracks.Count > 0)
                {
                    track = tracks[0] as OSDArray;
                    if (track != null && track.Count > 0)
                    {
                        for (int i = 0; i < track.Count; ++i)
                        {
                            OSDMap d = track[i] as OSDMap;
                            if (d.TryGetValue("key_keyframe", out OSD dtime))
                            {
                                if (d.TryGetValue("key_name", out OSD dname))
                                {
                                    TrackEntry t = new TrackEntry()
                                    {
                                        time      = dtime,
                                        frameName = dname
                                    };
                                    waterTrack.Add(t);
                                }
                            }
                        }
                        waterTrack.Sort(cte);
                    }
                }
                if (tracks.Count > 1)
                {
                    track = tracks[1] as OSDArray;
                    if (track != null && track.Count > 0)
                    {
                        for (int i = 0; i < track.Count; ++i)
                        {
                            OSDMap d = track[i] as OSDMap;
                            if (d.TryGetValue("key_keyframe", out OSD dtime))
                            {
                                if (d.TryGetValue("key_name", out OSD dname))
                                {
                                    TrackEntry t = new TrackEntry();
                                    t.time      = dtime;
                                    t.frameName = dname;
                                    skyTrack0.Add(t);
                                }
                            }
                        }
                        skyTrack0.Sort(cte);
                    }
                }
                if (tracks.Count > 2)
                {
                    for (int st = 2, dt = 0; st < tracks.Count && dt < 3; ++st, ++dt)
                    {
                        track = tracks[st] as OSDArray;
                        if (track != null && track.Count > 0)
                        {
                            skyTracks[dt] = new List <TrackEntry>();
                            for (int i = 0; i < track.Count; ++i)
                            {
                                OSDMap d = track[i] as OSDMap;
                                if (d.TryGetValue("key_keyframe", out OSD dtime))
                                {
                                    if (d.TryGetValue("key_name", out OSD dname))
                                    {
                                        TrackEntry t = new TrackEntry();
                                        t.time      = dtime;
                                        t.frameName = dname;
                                        skyTracks[dt].Add(t);
                                    }
                                }
                            }
                            skyTracks[dt].Sort(cte);
                        }
                    }
                }
            }
        }