Beispiel #1
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;
            }
        }
Beispiel #2
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);
                        }
                    }
                }
            }
        }