mirror of
https://github.com/opensim/opensim.git
synced 2026-08-10 11:33:28 +08:00
allow the use of Sky or water from a asset, not just full daycycle. This may need more work
This commit is contained in:
@@ -137,6 +137,59 @@ namespace OpenSim.Framework
|
||||
array[3] = new OSDMap();
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
public bool replaceSkyFromOSD(string name, OSDMap map)
|
||||
{
|
||||
SkyData sky = new SkyData();
|
||||
if (string.IsNullOrWhiteSpace(name))
|
||||
name = "Sky";
|
||||
try
|
||||
{
|
||||
sky.FromOSD(name, map);
|
||||
}
|
||||
catch
|
||||
{
|
||||
return false;
|
||||
}
|
||||
skyframes.Clear();
|
||||
skyframes[name] = sky;
|
||||
|
||||
TrackEntry t = new TrackEntry()
|
||||
{
|
||||
time = -1,
|
||||
frameName = name
|
||||
};
|
||||
skyTrack0.Clear();
|
||||
skyTrack0.Add(t);
|
||||
skyTracks = new List<TrackEntry>[3];
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public void FromOSD(OSDMap map)
|
||||
{
|
||||
CompareTrackEntries cte = new CompareTrackEntries();
|
||||
@@ -188,9 +241,11 @@ namespace OpenSim.Framework
|
||||
{
|
||||
if (d.TryGetValue("key_name", out OSD dname))
|
||||
{
|
||||
TrackEntry t = new TrackEntry();
|
||||
t.time = dtime;
|
||||
t.frameName = dname;
|
||||
TrackEntry t = new TrackEntry()
|
||||
{
|
||||
time = dtime,
|
||||
frameName = dname
|
||||
};
|
||||
waterTrack.Add(t);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -373,16 +373,52 @@ namespace OpenSim.Framework
|
||||
OSDMap map = osd as OSDMap;
|
||||
if (map == null)
|
||||
return false;
|
||||
if(!map.TryGetValue("type", out OSD tmp))
|
||||
if (!map.TryGetValue("type", out OSD tmp))
|
||||
return false;
|
||||
string type = tmp.AsString();
|
||||
if(type != "daycycle")
|
||||
if (type != "daycycle")
|
||||
return false;
|
||||
Cycle = new DayCycle();
|
||||
Cycle.FromOSD(map);
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool FromAssetOSD(string name, OSD osd)
|
||||
{
|
||||
OSDMap map = osd as OSDMap;
|
||||
if (map == null)
|
||||
return false;
|
||||
if (!map.TryGetValue("type", out OSD tmp))
|
||||
return false;
|
||||
string type = tmp.AsString();
|
||||
|
||||
bool ok = false;
|
||||
if (type == "water")
|
||||
{
|
||||
if (Cycle == null)
|
||||
Cycle = new DayCycle();
|
||||
ok = Cycle.replaceWaterFromOSD(name, map);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (type == "daycycle")
|
||||
{
|
||||
Cycle = new DayCycle();
|
||||
Cycle.FromOSD(map);
|
||||
ok = true;
|
||||
}
|
||||
else if(type == "sky")
|
||||
{
|
||||
if (Cycle == null)
|
||||
Cycle = new DayCycle();
|
||||
ok = Cycle.replaceSkyFromOSD(name, map);
|
||||
}
|
||||
}
|
||||
if(ok && !string.IsNullOrWhiteSpace(name))
|
||||
Cycle.Name = name;
|
||||
return ok;
|
||||
}
|
||||
|
||||
public OSD ToOSD()
|
||||
{
|
||||
OSDMap env = new OSDMap();
|
||||
|
||||
Reference in New Issue
Block a user