diff --git a/OpenMetaverse/Primitives/Primitive.cs b/OpenMetaverse/Primitives/Primitive.cs
index 2196b18b..08beef15 100644
--- a/OpenMetaverse/Primitives/Primitive.cs
+++ b/OpenMetaverse/Primitives/Primitive.cs
@@ -433,6 +433,97 @@ namespace OpenMetaverse
}
}
+ ///
+ /// Information on the light properties of a primitive as texture map
+ ///
+ public class LightImage
+ {
+ ///
+ public UUID LightTexture;
+ ///
+ public Vector3 Params;
+
+ ///
+ /// Default constructor
+ ///
+ public LightImage()
+ {
+ }
+
+ ///
+ ///
+ ///
+ ///
+ ///
+ public LightImage(byte[] data, int pos)
+ {
+ if (data.Length - pos >= 28)
+ {
+ LightTexture = new UUID(data, pos);
+ Params = new Vector3(data, pos + 16);
+ }
+ else
+ {
+ LightTexture = UUID.Zero;
+ Params = Vector3.Zero;
+ }
+ }
+
+ ///
+ ///
+ ///
+ ///
+ public byte[] GetBytes()
+ {
+ byte[] data = new byte[28];
+
+ // Alpha channel in color is intensity
+ LightTexture.ToBytes(data, 0);
+ Params.ToBytes(data, 16);
+
+ return data;
+ }
+
+ public OSD GetOSD()
+ {
+ OSDMap map = new OSDMap();
+
+ map["texture"] = OSD.FromUUID(LightTexture);
+ map["params"] = OSD.FromVector3(Params);
+
+ return map;
+ }
+
+ public static LightImage FromOSD(OSD osd)
+ {
+ LightImage light = new LightImage();
+
+ if (osd.Type == OSDType.Map)
+ {
+ OSDMap map = (OSDMap)osd;
+
+ light.LightTexture = map["texture"].AsUUID();
+ light.Params = map["params"].AsVector3();
+ }
+
+ return light;
+ }
+
+ public override int GetHashCode()
+ {
+ return LightTexture.GetHashCode() ^ Params.GetHashCode();
+ }
+
+ ///
+ ///
+ ///
+ ///
+ public override string ToString()
+ {
+ return String.Format("LightTexture: {0} Params; {1]", LightTexture, Params);
+ }
+ }
+
///
/// Information on the sculpt properties of a sculpted primitive
///
@@ -724,6 +815,8 @@ namespace OpenMetaverse
///
public LightData Light;
///
+ public LightImage LightMap;
+ ///
public SculptData Sculpt;
///
public ClickAction ClickAction;
@@ -879,6 +972,7 @@ namespace OpenMetaverse
CollisionPlane = prim.CollisionPlane;
Flexible = prim.Flexible;
Light = prim.Light;
+ LightMap = prim.LightMap;
Sculpt = prim.Sculpt;
ClickAction = prim.ClickAction;
Sound = prim.Sound;
@@ -979,10 +1073,13 @@ namespace OpenMetaverse
if (Textures != null)
prim["textures"] = Textures.GetOSD();
-
+
if (Light != null)
prim["light"] = Light.GetOSD();
+ if (LightMap != null)
+ prim["light_image"] = LightMap.GetOSD();
+
if (Flexible != null)
prim["flex"] = Flexible.GetOSD();
@@ -1055,7 +1152,10 @@ namespace OpenMetaverse
if (map["light"])
prim.Light = LightData.FromOSD(map["light"]);
-
+
+ if (map["light_image"])
+ prim.LightMap = LightImage.FromOSD(map["light_image"]);
+
if (map["sculpt"])
prim.Sculpt = SculptData.FromOSD(map["sculpt"]);
@@ -1097,6 +1197,8 @@ namespace OpenMetaverse
Flexible = new FlexibleData(data, i);
else if (type == ExtraParamType.Light)
Light = new LightData(data, i);
+ else if (type == ExtraParamType.LightImage)
+ LightMap = new LightImage(data, i);
else if (type == ExtraParamType.Sculpt || type == ExtraParamType.Mesh)
Sculpt = new SculptData(data, i);
@@ -1111,6 +1213,7 @@ namespace OpenMetaverse
{
byte[] flexible = null;
byte[] light = null;
+ byte[] lightmap = null;
byte[] sculpt = null;
byte[] buffer = null;
int size = 1;
@@ -1129,6 +1232,12 @@ namespace OpenMetaverse
size += light.Length + 6;
++count;
}
+ if (LightMap != null)
+ {
+ lightmap = LightMap.GetBytes();
+ size += lightmap.Length + 6;
+ ++count;
+ }
if (Sculpt != null)
{
sculpt = Sculpt.GetBytes();
@@ -1162,6 +1271,17 @@ namespace OpenMetaverse
Buffer.BlockCopy(light, 0, buffer, pos, light.Length);
pos += light.Length;
}
+ if (lightmap != null)
+ {
+ Buffer.BlockCopy(Utils.UInt16ToBytes((ushort)ExtraParamType.LightImage), 0, buffer, pos, 2);
+ pos += 2;
+
+ Buffer.BlockCopy(Utils.UIntToBytes((uint)lightmap.Length), 0, buffer, pos, 4);
+ pos += 4;
+
+ Buffer.BlockCopy(lightmap, 0, buffer, pos, lightmap.Length);
+ pos += lightmap.Length;
+ }
if (sculpt != null)
{
if (Sculpt.Type == SculptType.Mesh)
diff --git a/OpenMetaverseTypes/EnumsPrimitive.cs b/OpenMetaverseTypes/EnumsPrimitive.cs
index aaa2e402..fbe2721b 100644
--- a/OpenMetaverseTypes/EnumsPrimitive.cs
+++ b/OpenMetaverseTypes/EnumsPrimitive.cs
@@ -230,6 +230,8 @@ namespace OpenMetaverse
Light = 0x20,
/// Whether this object is a sculpted prim
Sculpt = 0x30,
+ /// Whether this object is a light image map
+ LightImage = 0x40,
/// Whether this object is a mesh
Mesh = 0x60,
}