RenderMaterials POST Cap now return material entries when invoked with an OSDArray of MaterialIDs
parent
9ae24cac2f
commit
258804cc04
|
@ -48,7 +48,7 @@ using Ionic.Zlib;
|
||||||
// You will need to uncomment these lines if you are adding a region module to some other assembly which does not already
|
// You will need to uncomment these lines if you are adding a region module to some other assembly which does not already
|
||||||
// specify its assembly. Otherwise, the region modules in the assembly will not be picked up when OpenSimulator scans
|
// specify its assembly. Otherwise, the region modules in the assembly will not be picked up when OpenSimulator scans
|
||||||
// the available DLLs
|
// the available DLLs
|
||||||
//[assembly: Addin("MyModule", "1.0")]
|
//[assembly: Addin("MaterialsDemoModule", "1.0")]
|
||||||
//[assembly: AddinDependency("OpenSim", "0.5")]
|
//[assembly: AddinDependency("OpenSim", "0.5")]
|
||||||
|
|
||||||
namespace OpenSim.Region.OptionalModules.MaterialsDemoModule
|
namespace OpenSim.Region.OptionalModules.MaterialsDemoModule
|
||||||
|
@ -159,6 +159,8 @@ namespace OpenSim.Region.OptionalModules.MaterialsDemoModule
|
||||||
|
|
||||||
OSDMap materialsFromViewer = null;
|
OSDMap materialsFromViewer = null;
|
||||||
|
|
||||||
|
OSDArray respArr = new OSDArray();
|
||||||
|
|
||||||
if (req.ContainsKey("Zipped"))
|
if (req.ContainsKey("Zipped"))
|
||||||
{
|
{
|
||||||
OSD osd = null;
|
OSD osd = null;
|
||||||
|
@ -169,7 +171,37 @@ namespace OpenSim.Region.OptionalModules.MaterialsDemoModule
|
||||||
{
|
{
|
||||||
osd = ZDecompressBytesToOsd(inBytes);
|
osd = ZDecompressBytesToOsd(inBytes);
|
||||||
|
|
||||||
if (osd != null && osd is OSDMap)
|
if (osd != null)
|
||||||
|
{
|
||||||
|
if (osd is OSDArray) // assume array of MaterialIDs designating requested material entries
|
||||||
|
{
|
||||||
|
foreach (OSD elem in (OSDArray)osd)
|
||||||
|
{
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
UUID id = new UUID(elem.AsBinary(), 0);
|
||||||
|
|
||||||
|
if (m_knownMaterials.ContainsKey(id))
|
||||||
|
{
|
||||||
|
m_log.Info("[MaterialsDemoModule]: request for known material ID: " + id.ToString());
|
||||||
|
OSDMap matMap = new OSDMap();
|
||||||
|
matMap["ID"] = OSD.FromBinary(id.GetBytes());
|
||||||
|
|
||||||
|
matMap["Material"] = m_knownMaterials[id];
|
||||||
|
respArr.Add(matMap);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
m_log.Info("[MaterialsDemoModule]: request for UNKNOWN material ID: " + id.ToString());
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
// report something here?
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (osd is OSDMap) // reqest to assign a material
|
||||||
{
|
{
|
||||||
materialsFromViewer = osd as OSDMap;
|
materialsFromViewer = osd as OSDMap;
|
||||||
|
|
||||||
|
@ -206,7 +238,8 @@ namespace OpenSim.Region.OptionalModules.MaterialsDemoModule
|
||||||
m_log.Debug("[MaterialsDemoModule]: null SOP for localId: " + matLocalID.ToString());
|
m_log.Debug("[MaterialsDemoModule]: null SOP for localId: " + matLocalID.ToString());
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
var te = sop.Shape.Textures;
|
//var te = sop.Shape.Textures;
|
||||||
|
var te = new Primitive.TextureEntry(sop.Shape.TextureEntry, 0, sop.Shape.TextureEntry.Length);
|
||||||
|
|
||||||
if (te == null)
|
if (te == null)
|
||||||
{
|
{
|
||||||
|
@ -252,7 +285,18 @@ namespace OpenSim.Region.OptionalModules.MaterialsDemoModule
|
||||||
|
|
||||||
m_log.Debug("[MaterialsDemoModule]: setting material ID for face " + face.ToString() + " to " + id.ToString());
|
m_log.Debug("[MaterialsDemoModule]: setting material ID for face " + face.ToString() + " to " + id.ToString());
|
||||||
|
|
||||||
sop.UpdateTextureEntry(te);
|
//we cant use sop.UpdateTextureEntry(te); because it filters so do it manually
|
||||||
|
|
||||||
|
if (sop.ParentGroup != null)
|
||||||
|
{
|
||||||
|
sop.Shape.TextureEntry = te.GetBytes();
|
||||||
|
sop.TriggerScriptChangedEvent(Changed.TEXTURE);
|
||||||
|
sop.UpdateFlag = UpdateRequired.FULL;
|
||||||
|
sop.ParentGroup.HasGroupChanged = true;
|
||||||
|
|
||||||
|
sop.ScheduleFullUpdate();
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -265,6 +309,8 @@ namespace OpenSim.Region.OptionalModules.MaterialsDemoModule
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
m_log.Warn("[MaterialsDemoModule]: exception decoding zipped CAP payload: " + e.Message);
|
m_log.Warn("[MaterialsDemoModule]: exception decoding zipped CAP payload: " + e.Message);
|
||||||
|
@ -274,6 +320,7 @@ namespace OpenSim.Region.OptionalModules.MaterialsDemoModule
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
resp["Zipped"] = ZCompressOSD(respArr, false);
|
||||||
string response = OSDParser.SerializeLLSDXmlString(resp);
|
string response = OSDParser.SerializeLLSDXmlString(resp);
|
||||||
|
|
||||||
m_log.Debug("[MaterialsDemoModule]: cap request: " + request);
|
m_log.Debug("[MaterialsDemoModule]: cap request: " + request);
|
||||||
|
|
Loading…
Reference in New Issue