29 using System.Collections.Generic;
31 using System.Drawing.Imaging;
33 using System.Reflection;
35 using System.Xml.Schema;
36 using System.Xml.Serialization;
39 using OpenMetaverse.StructuredData;
41 namespace OpenSim.Framework
82 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
84 private static readonly byte[] DEFAULT_TEXTURE =
new Primitive.TextureEntry(
new UUID(
"89556747-24cb-43ed-920b-47caed15465f")).GetBytes();
86 private byte[] m_textureEntry;
88 private ushort _pathBegin;
89 private byte _pathCurve;
90 private ushort _pathEnd;
91 private sbyte _pathRadiusOffset;
92 private byte _pathRevolutions;
93 private byte _pathScaleX;
94 private byte _pathScaleY;
95 private byte _pathShearX;
96 private byte _pathShearY;
97 private sbyte _pathSkew;
98 private sbyte _pathTaperX;
99 private sbyte _pathTaperY;
100 private sbyte _pathTwist;
101 private sbyte _pathTwistBegin;
103 private ushort _profileBegin;
104 private ushort _profileEnd;
105 private ushort _profileHollow;
106 private Vector3 _scale;
108 private byte _lastattach;
113 [XmlIgnore]
private UUID _sculptTexture;
114 [XmlIgnore]
private byte _sculptType;
115 [XmlIgnore]
private byte[] _sculptData = Utils.EmptyBytes;
118 [XmlIgnore]
private int _flexiSoftness;
119 [XmlIgnore]
private float _flexiTension;
120 [XmlIgnore]
private float _flexiDrag;
121 [XmlIgnore]
private float _flexiGravity;
122 [XmlIgnore]
private float _flexiWind;
123 [XmlIgnore]
private float _flexiForceX;
124 [XmlIgnore]
private float _flexiForceY;
125 [XmlIgnore]
private float _flexiForceZ;
128 [XmlIgnore]
private float _lightColorR;
129 [XmlIgnore]
private float _lightColorG;
130 [XmlIgnore]
private float _lightColorB;
131 [XmlIgnore]
private float _lightColorA = 1.0f;
132 [XmlIgnore]
private float _lightRadius;
133 [XmlIgnore]
private float _lightCutoff;
134 [XmlIgnore]
private float _lightFalloff;
135 [XmlIgnore]
private float _lightIntensity = 1.0f;
136 [XmlIgnore]
private bool _flexiEntry;
137 [XmlIgnore]
private bool _lightEntry;
138 [XmlIgnore]
private bool _sculptEntry;
141 [XmlIgnore]
private bool _projectionEntry;
142 [XmlIgnore]
private UUID _projectionTextureID;
143 [XmlIgnore]
private float _projectionFOV;
144 [XmlIgnore]
private float _projectionFocus;
145 [XmlIgnore]
private float _projectionAmb;
147 public byte ProfileCurve
154 byte hollowShapeByte = (byte)(value & 0xf0);
156 if (!Enum.IsDefined(typeof(
HollowShape), hollowShapeByte))
159 "[SHAPE]: Attempt to set a ProfileCurve with a hollow shape value of {0}, which isn't a valid enum. Replacing with default shape.",
162 this._hollowShape = HollowShape.Same;
170 byte profileShapeByte = (byte)(value & 0xf);
172 if (!Enum.IsDefined(typeof(
ProfileShape), profileShapeByte))
175 "[SHAPE]: Attempt to set a ProfileCurve with a profile shape value of {0}, which isn't a valid enum. Replacing with square.",
178 this._profileShape = ProfileShape.Square;
197 m_textureEntry = DEFAULT_TEXTURE;
208 PCode = (byte)prim.PrimData.PCode;
210 State = prim.PrimData.State;
211 LastAttachPoint = prim.PrimData.State;
212 PathBegin =
Primitive.PackBeginCut(prim.PrimData.PathBegin);
213 PathEnd = Primitive.PackEndCut(prim.PrimData.PathEnd);
214 PathScaleX = Primitive.PackPathScale(prim.PrimData.PathScaleX);
215 PathScaleY = Primitive.PackPathScale(prim.PrimData.PathScaleY);
216 PathShearX = (byte)
Primitive.PackPathShear(prim.PrimData.PathShearX);
217 PathShearY = (byte)
Primitive.PackPathShear(prim.PrimData.PathShearY);
218 PathSkew = Primitive.PackPathTwist(prim.PrimData.PathSkew);
219 ProfileBegin = Primitive.PackBeginCut(prim.PrimData.ProfileBegin);
220 ProfileEnd = Primitive.PackEndCut(prim.PrimData.ProfileEnd);
222 PathCurve = (byte)prim.PrimData.PathCurve;
223 ProfileCurve = (byte)prim.PrimData.ProfileCurve;
224 ProfileHollow = Primitive.PackProfileHollow(prim.PrimData.ProfileHollow);
225 PathRadiusOffset = Primitive.PackPathTwist(prim.PrimData.PathRadiusOffset);
226 PathRevolutions = Primitive.PackPathRevolutions(prim.PrimData.PathRevolutions);
227 PathTaperX = Primitive.PackPathTaper(prim.PrimData.PathTaperX);
228 PathTaperY = Primitive.PackPathTaper(prim.PrimData.PathTaperY);
229 PathTwist = Primitive.PackPathTwist(prim.PrimData.PathTwist);
230 PathTwistBegin = Primitive.PackPathTwist(prim.PrimData.PathTwistBegin);
232 m_textureEntry = prim.Textures.GetBytes();
234 if (prim.Sculpt != null)
236 SculptEntry = (prim.Sculpt.Type != OpenMetaverse.SculptType.None);
237 SculptData = prim.Sculpt.GetBytes();
238 SculptTexture = prim.Sculpt.SculptTexture;
243 SculptType = (byte)OpenMetaverse.SculptType.None;
248 public Primitive.TextureEntry
Textures
253 try {
return new Primitive.TextureEntry(m_textureEntry, 0, m_textureEntry.Length); }
256 m_log.Warn(
"[SHAPE]: Failed to decode texture, length=" + ((m_textureEntry != null) ? m_textureEntry.Length : 0));
257 return new Primitive.TextureEntry(UUID.Zero);
260 set { m_textureEntry = value.GetBytes(); }
263 public byte[] TextureEntry
265 get {
return m_textureEntry; }
270 m_textureEntry =
new byte[1];
272 m_textureEntry = value;
282 boxShape.SetScale(0.5f);
298 shape._pathCurve = (byte)
Extrusion.Straight;
300 shape._pathScaleX = 100;
301 shape._pathScaleY = 100;
310 shape._pathCurve = (byte)
Extrusion.Curve1;
312 shape._pathScaleX = 100;
313 shape._pathScaleY = 100;
322 shape._pathCurve = (byte)
Extrusion.Curve1;
325 shape._pathScaleX = 100;
326 shape._pathScaleY = 100;
333 _scale =
new Vector3(side, side, side);
343 _scale.X = _scale.Y = radius * 2f;
360 shape.SetHeigth(heigth);
361 shape.SetRadius(radius);
368 _pathBegin = Primitive.PackBeginCut(pathRange.X);
369 _pathEnd = Primitive.PackEndCut(pathRange.Y);
374 _pathBegin = Primitive.PackBeginCut(begin);
375 _pathEnd = Primitive.PackEndCut(end);
380 _sculptType = sculptType;
381 _sculptTexture = SculptTextureUUID;
386 _profileBegin = Primitive.PackBeginCut(profileRange.X);
387 _profileEnd = Primitive.PackEndCut(profileRange.Y);
392 _profileBegin = Primitive.PackBeginCut(begin);
393 _profileEnd = Primitive.PackEndCut(end);
396 public byte[] ExtraParams
400 return ExtraParamsToBytes();
404 ReadInExtraParamsBytes(value);
408 public ushort PathBegin {
417 public byte PathCurve {
426 public ushort PathEnd {
435 public sbyte PathRadiusOffset {
437 return _pathRadiusOffset;
440 _pathRadiusOffset = value;
444 public byte PathRevolutions {
446 return _pathRevolutions;
449 _pathRevolutions = value;
453 public byte PathScaleX {
462 public byte PathScaleY {
471 public byte PathShearX {
480 public byte PathShearY {
489 public sbyte PathSkew {
498 public sbyte PathTaperX {
507 public sbyte PathTaperY {
516 public sbyte PathTwist {
525 public sbyte PathTwistBegin {
527 return _pathTwistBegin;
530 _pathTwistBegin = value;
543 public ushort ProfileBegin {
545 return _profileBegin;
548 _profileBegin = value;
552 public ushort ProfileEnd {
561 public ushort ProfileHollow {
563 return _profileHollow;
566 _profileHollow = value;
588 public byte LastAttachPoint {
599 return _profileShape;
602 _profileShape = value;
611 _hollowShape = value;
615 public UUID SculptTexture {
617 return _sculptTexture;
620 _sculptTexture = value;
638 public byte[] SculptData
651 public int FlexiSoftness
655 return _flexiSoftness;
659 _flexiSoftness = value;
663 public float FlexiTension {
665 return _flexiTension;
668 _flexiTension = value;
672 public float FlexiDrag {
681 public float FlexiGravity {
683 return _flexiGravity;
686 _flexiGravity = value;
690 public float FlexiWind {
699 public float FlexiForceX {
704 _flexiForceX = value;
708 public float FlexiForceY {
713 _flexiForceY = value;
717 public float FlexiForceZ {
722 _flexiForceZ = value;
726 public float LightColorR {
733 else if (value > 1.0f)
736 _lightColorR = value;
740 public float LightColorG {
747 else if (value > 1.0f)
750 _lightColorG = value;
754 public float LightColorB {
761 else if (value > 1.0f)
764 _lightColorB = value;
768 public float LightColorA {
775 else if (value > 1.0f)
778 _lightColorA = value;
782 public float LightRadius {
787 _lightRadius = value;
791 public float LightCutoff {
796 _lightCutoff = value;
800 public float LightFalloff {
802 return _lightFalloff;
805 _lightFalloff = value;
809 public float LightIntensity {
811 return _lightIntensity;
814 _lightIntensity = value;
818 public bool FlexiEntry {
827 public bool LightEntry {
836 public bool SculptEntry {
841 _sculptEntry = value;
845 public bool ProjectionEntry {
847 return _projectionEntry;
850 _projectionEntry = value;
854 public UUID ProjectionTextureUUID {
856 return _projectionTextureID;
859 _projectionTextureID = value;
863 public float ProjectionFOV {
865 return _projectionFOV;
868 _projectionFOV = value;
872 public float ProjectionFocus {
874 return _projectionFocus;
877 _projectionFocus = value;
881 public float ProjectionAmbiance {
883 return _projectionAmb;
886 _projectionAmb = value;
892 return GetMeshKey(size, lod,
false);
895 public ulong
GetMeshKey(Vector3 size,
float lod,
bool convex)
899 hash = djb2(hash, this.PathCurve);
901 hash = djb2(hash, this.PathBegin);
902 hash = djb2(hash, this.PathEnd);
903 hash = djb2(hash, this.PathScaleX);
904 hash = djb2(hash, this.PathScaleY);
905 hash = djb2(hash, this.PathShearX);
906 hash = djb2(hash, this.PathShearY);
907 hash = djb2(hash, (byte)this.PathTwist);
908 hash = djb2(hash, (byte)this.PathTwistBegin);
909 hash = djb2(hash, (byte)this.PathRadiusOffset);
910 hash = djb2(hash, (byte)this.PathTaperX);
911 hash = djb2(hash, (byte)this.PathTaperY);
912 hash = djb2(hash, this.PathRevolutions);
913 hash = djb2(hash, (byte)this.PathSkew);
914 hash = djb2(hash, this.ProfileBegin);
915 hash = djb2(hash, this.ProfileEnd);
916 hash = djb2(hash, this.ProfileHollow);
920 byte[] scaleBytes = size.GetBytes();
921 for (
int i = 0; i < scaleBytes.Length; i++)
922 hash = djb2(hash, scaleBytes[i]);
925 byte[] lodBytes =
new byte[4];
926 Buffer.BlockCopy(BitConverter.GetBytes(lod), 0, lodBytes, 0, 4);
927 if (!BitConverter.IsLittleEndian)
929 Array.Reverse(lodBytes, 0, 4);
931 for (
int i = 0; i < lodBytes.Length; i++)
932 hash = djb2(hash, lodBytes[i]);
935 if (this.SculptEntry)
937 scaleBytes = this.SculptTexture.GetBytes();
938 for (
int i = 0; i < scaleBytes.Length; i++)
939 hash = djb2(hash, scaleBytes[i]);
943 hash = djb2(hash, 0xa5);
948 private ulong djb2(ulong hash, byte c)
950 return ((hash << 5) + hash) + (ulong)c;
953 private ulong djb2(ulong hash, ushort c)
955 hash = ((hash << 5) + hash) + (ulong)((byte)c);
956 return ((hash << 5) + hash) + (ulong)(c >> 8);
963 ushort FlexiEP = 0x10;
964 ushort LightEP = 0x20;
965 ushort SculptEP = 0x30;
966 ushort ProjectionEP = 0x40;
969 uint TotalBytesLength = 1;
971 uint ExtraParamsNum = 0;
975 TotalBytesLength += 16;
976 TotalBytesLength += 2 + 4;
982 TotalBytesLength += 16;
983 TotalBytesLength += 2 + 4;
989 TotalBytesLength += 17;
990 TotalBytesLength += 2 + 4;
993 if (_projectionEntry)
996 TotalBytesLength += 28;
997 TotalBytesLength += 2 + 4;
1000 byte[] returnbytes =
new byte[TotalBytesLength];
1005 returnbytes[i++] = (byte)ExtraParamsNum;
1009 byte[] FlexiData = GetFlexiBytes();
1011 returnbytes[i++] = (byte)(FlexiEP % 256);
1012 returnbytes[i++] = (byte)((FlexiEP >> 8) % 256);
1014 returnbytes[i++] = (byte)(FlexiData.Length % 256);
1015 returnbytes[i++] = (byte)((FlexiData.Length >> 8) % 256);
1016 returnbytes[i++] = (byte)((FlexiData.Length >> 16) % 256);
1017 returnbytes[i++] = (byte)((FlexiData.Length >> 24) % 256);
1018 Array.Copy(FlexiData, 0, returnbytes, i, FlexiData.Length);
1019 i += FlexiData.Length;
1024 byte[] LightData = GetLightBytes();
1026 returnbytes[i++] = (byte)(LightEP % 256);
1027 returnbytes[i++] = (byte)((LightEP >> 8) % 256);
1029 returnbytes[i++] = (byte)(LightData.Length % 256);
1030 returnbytes[i++] = (byte)((LightData.Length >> 8) % 256);
1031 returnbytes[i++] = (byte)((LightData.Length >> 16) % 256);
1032 returnbytes[i++] = (byte)((LightData.Length >> 24) % 256);
1033 Array.Copy(LightData, 0, returnbytes, i, LightData.Length);
1034 i += LightData.Length;
1039 byte[] SculptData = GetSculptBytes();
1041 returnbytes[i++] = (byte)(SculptEP % 256);
1042 returnbytes[i++] = (byte)((SculptEP >> 8) % 256);
1044 returnbytes[i++] = (byte)(SculptData.Length % 256);
1045 returnbytes[i++] = (byte)((SculptData.Length >> 8) % 256);
1046 returnbytes[i++] = (byte)((SculptData.Length >> 16) % 256);
1047 returnbytes[i++] = (byte)((SculptData.Length >> 24) % 256);
1048 Array.Copy(SculptData, 0, returnbytes, i, SculptData.Length);
1049 i += SculptData.Length;
1052 if (_projectionEntry)
1054 byte[] ProjectionData = GetProjectionBytes();
1056 returnbytes[i++] = (byte)(ProjectionEP % 256);
1057 returnbytes[i++] = (byte)((ProjectionEP >> 8) % 256);
1058 returnbytes[i++] = (byte)((ProjectionData.Length) % 256);
1059 returnbytes[i++] = (byte)((ProjectionData.Length >> 16) % 256);
1060 returnbytes[i++] = (byte)((ProjectionData.Length >> 20) % 256);
1061 returnbytes[i++] = (byte)((ProjectionData.Length >> 24) % 256);
1062 Array.Copy(ProjectionData, 0, returnbytes, i, ProjectionData.Length);
1063 i += ProjectionData.Length;
1066 if (!_flexiEntry && !_lightEntry && !_sculptEntry && !_projectionEntry)
1068 byte[] returnbyte =
new byte[1];
1078 const ushort FlexiEP = 0x10;
1079 const ushort LightEP = 0x20;
1080 const ushort SculptEP = 0x30;
1081 const ushort ProjectionEP = 0x40;
1088 _flexiEntry =
false;
1091 ReadFlexiData(data, 0);
1097 _lightEntry =
false;
1100 ReadLightData(data, 0);
1106 _sculptEntry =
false;
1109 ReadSculptData(data, 0);
1114 _projectionEntry =
false;
1117 ReadProjectionData(data, 0);
1124 if (data == null || data.Length == 1)
1127 const ushort FlexiEP = 0x10;
1128 const ushort LightEP = 0x20;
1129 const ushort SculptEP = 0x30;
1130 const ushort ProjectionEP = 0x40;
1132 bool lGotFlexi =
false;
1133 bool lGotLight =
false;
1134 bool lGotSculpt =
false;
1135 bool lGotFilter =
false;
1138 byte extraParamCount = 0;
1139 if (data.Length > 0)
1141 extraParamCount = data[i++];
1144 for (
int k = 0; k < extraParamCount; k++)
1146 ushort epType = Utils.BytesToUInt16(data, i);
1155 ReadFlexiData(data, i);
1161 ReadLightData(data, i);
1167 ReadSculptData(data, i);
1172 ReadProjectionData(data, i);
1180 _flexiEntry =
false;
1182 _lightEntry =
false;
1184 _sculptEntry =
false;
1186 _projectionEntry =
false;
1194 if (data.Length-pos >= 17)
1196 _sculptEntry =
true;
1197 byte[] SculptTextureUUID =
new byte[16];
1198 SculptTypel = data[16 + pos];
1199 Array.Copy(data, pos, SculptTextureUUID,0, 16);
1200 SculptUUID =
new UUID(SculptTextureUUID, 0);
1204 _sculptEntry =
false;
1205 SculptUUID = UUID.Zero;
1211 if (_sculptType != (byte)1 && _sculptType != (byte)2 && _sculptType != (byte)3 && _sculptType != (byte)4)
1215 _sculptTexture = SculptUUID;
1216 _sculptType = SculptTypel;
1222 byte[] data =
new byte[17];
1224 _sculptTexture.GetBytes().CopyTo(data, 0);
1225 data[16] = (byte)_sculptType;
1232 if (data.Length-pos >= 16)
1235 _flexiSoftness = ((data[pos] & 0x80) >> 6) | ((data[pos + 1] & 0x80) >> 7);
1237 _flexiTension = (float)(data[pos++] & 0x7F) / 10.0f;
1238 _flexiDrag = (float)(data[pos++] & 0x7F) / 10.0f;
1239 _flexiGravity = (float)(data[pos++] / 10.0f) - 10.0f;
1240 _flexiWind = (float)data[pos++] / 10.0f;
1241 Vector3 lForce =
new Vector3(data, pos);
1242 _flexiForceX = lForce.X;
1243 _flexiForceY = lForce.Y;
1244 _flexiForceZ = lForce.Z;
1248 _flexiEntry =
false;
1251 _flexiTension = 0.0f;
1253 _flexiGravity = 0.0f;
1263 byte[] data =
new byte[16];
1267 data[i] = (byte)((_flexiSoftness & 2) << 6);
1268 data[i + 1] = (byte)((_flexiSoftness & 1) << 7);
1270 data[i++] |= (byte)((byte)(_flexiTension * 10.01f) & 0x7F);
1271 data[i++] |= (byte)((byte)(_flexiDrag * 10.01f) & 0x7F);
1272 data[i++] = (byte)((_flexiGravity + 10.0f) * 10.01f);
1273 data[i++] = (byte)(_flexiWind * 10.01f);
1274 Vector3 lForce =
new Vector3(_flexiForceX, _flexiForceY, _flexiForceZ);
1275 lForce.GetBytes().CopyTo(data, i);
1282 if (data.Length - pos >= 16)
1285 Color4 lColor =
new Color4(data, pos,
false);
1286 _lightIntensity = lColor.A;
1288 _lightColorR = lColor.R;
1289 _lightColorG = lColor.G;
1290 _lightColorB = lColor.B;
1292 _lightRadius = Utils.BytesToFloat(data, pos + 4);
1293 _lightCutoff = Utils.BytesToFloat(data, pos + 8);
1294 _lightFalloff = Utils.BytesToFloat(data, pos + 12);
1298 _lightEntry =
false;
1306 _lightIntensity = 0f;
1312 byte[] data =
new byte[16];
1315 Color4 tmpColor =
new Color4(_lightColorR,_lightColorG,_lightColorB,_lightIntensity);
1317 tmpColor.GetBytes().CopyTo(data, 0);
1318 Utils.FloatToBytes(_lightRadius).CopyTo(data, 4);
1319 Utils.FloatToBytes(_lightCutoff).CopyTo(data, 8);
1320 Utils.FloatToBytes(_lightFalloff).CopyTo(data, 12);
1327 byte[] ProjectionTextureUUID =
new byte[16];
1329 if (data.Length - pos >= 28)
1331 _projectionEntry =
true;
1332 Array.Copy(data, pos, ProjectionTextureUUID,0, 16);
1333 _projectionTextureID =
new UUID(ProjectionTextureUUID, 0);
1335 _projectionFOV = Utils.BytesToFloat(data, pos + 16);
1336 _projectionFocus = Utils.BytesToFloat(data, pos + 20);
1337 _projectionAmb = Utils.BytesToFloat(data, pos + 24);
1341 _projectionEntry =
false;
1342 _projectionTextureID = UUID.Zero;
1343 _projectionFOV = 0f;
1344 _projectionFocus = 0f;
1345 _projectionAmb = 0f;
1351 byte[] data =
new byte[28];
1353 _projectionTextureID.GetBytes().CopyTo(data, 0);
1354 Utils.FloatToBytes(_projectionFOV).CopyTo(data, 16);
1355 Utils.FloatToBytes(_projectionFocus).CopyTo(data, 20);
1356 Utils.FloatToBytes(_projectionAmb).CopyTo(data, 24);
1369 return ToOmvPrimitive(
new Vector3(0.0f, 0.0f, 0.0f),
1370 new Quaternion(0.0f, 0.0f, 0.0f, 1.0f));
1382 OpenMetaverse.Primitive
prim =
new OpenMetaverse.Primitive();
1384 prim.Scale = this.Scale;
1385 prim.Position = position;
1388 if (this.SculptEntry)
1390 prim.Sculpt =
new Primitive.SculptData();
1392 prim.Sculpt.SculptTexture = this.SculptTexture;
1395 prim.PrimData.PathShearX = this.PathShearX < 128 ? (float)this.PathShearX * 0.01f : (
float)(this.PathShearX - 256) * 0.01f;
1396 prim.PrimData.PathShearY = this.PathShearY < 128 ? (float)this.PathShearY * 0.01f : (
float)(this.PathShearY - 256) * 0.01f;
1397 prim.PrimData.PathBegin = (float)this.PathBegin * 2.0e-5f;
1398 prim.PrimData.PathEnd = 1.0f - (float)this.PathEnd * 2.0e-5f;
1400 prim.PrimData.PathScaleX = (200 - this.PathScaleX) * 0.01f;
1401 prim.PrimData.PathScaleY = (200 - this.PathScaleY) * 0.01f;
1403 prim.PrimData.PathTaperX = this.PathTaperX * 0.01f;
1404 prim.PrimData.PathTaperY = this.PathTaperY * 0.01f;
1406 prim.PrimData.PathTwistBegin = this.PathTwistBegin * 0.01f;
1407 prim.PrimData.PathTwist = this.PathTwist * 0.01f;
1409 prim.PrimData.ProfileBegin = (float)this.ProfileBegin * 2.0e-5f;
1410 prim.PrimData.ProfileEnd = 1.0f - (float)this.ProfileEnd * 2.0e-5f;
1411 prim.PrimData.ProfileHollow = (float)this.ProfileHollow * 2.0e-5f;
1413 prim.PrimData.profileCurve = this.ProfileCurve;
1414 prim.PrimData.ProfileHole = (HoleType)this.
HollowShape;
1416 prim.PrimData.PathCurve = (PathCurve)this.PathCurve;
1417 prim.PrimData.PathRadiusOffset = 0.01f * this.PathRadiusOffset;
1418 prim.PrimData.PathRevolutions = 1.0f + 0.015f * this.PathRevolutions;
1419 prim.PrimData.PathSkew = 0.01f * this.PathSkew;
1421 prim.PrimData.PCode = OpenMetaverse.PCode.Prim;
1422 prim.PrimData.State = 0;
1424 if (this.FlexiEntry)
1426 prim.Flexible =
new Primitive.FlexibleData();
1427 prim.Flexible.Drag = this.FlexiDrag;
1428 prim.Flexible.Force =
new Vector3(this.FlexiForceX, this.FlexiForceY, this.FlexiForceZ);
1429 prim.Flexible.Gravity = this.FlexiGravity;
1430 prim.Flexible.Softness = this.FlexiSoftness;
1431 prim.Flexible.Tension = this.FlexiTension;
1432 prim.Flexible.Wind = this.FlexiWind;
1435 if (this.LightEntry)
1437 prim.Light =
new Primitive.LightData();
1438 prim.Light.Color =
new Color4(this.LightColorR, this.LightColorG, this.LightColorB, this.LightColorA);
1439 prim.Light.Cutoff = this.LightCutoff;
1440 prim.Light.Falloff = this.LightFalloff;
1441 prim.Light.Intensity = this.LightIntensity;
1442 prim.Light.Radius = this.LightRadius;
1445 prim.Textures = this.Textures;
1447 prim.Properties =
new Primitive.ObjectProperties();
1448 prim.Properties.Name =
"Object";
1449 prim.Properties.Description =
"";
1450 prim.Properties.CreatorID = UUID.Zero;
1451 prim.Properties.GroupID = UUID.Zero;
1452 prim.Properties.OwnerID = UUID.Zero;
1453 prim.Properties.Permissions =
new Permissions();
1454 prim.Properties.SalePrice = 10;
1455 prim.Properties.SaleType =
new SaleType();
1467 public const string MEDIA_TEXTURE_TYPE =
"sl";
1482 using (StringWriter sw =
new StringWriter())
1484 using (XmlTextWriter xtw =
new XmlTextWriter(sw))
1486 xtw.WriteStartElement(
"OSMedia");
1487 xtw.WriteAttributeString(
"type", MEDIA_TEXTURE_TYPE);
1488 xtw.WriteAttributeString(
"version",
"0.1");
1491 foreach (MediaEntry me
in this)
1493 OSD osd = (null == me ?
new OSD() : me.GetOSD());
1497 xtw.WriteStartElement(
"OSData");
1498 xtw.WriteRaw(OSDParser.SerializeLLSDXmlString(meArray));
1499 xtw.WriteEndElement();
1501 xtw.WriteEndElement();
1504 return sw.ToString();
1512 writer.WriteRaw(ToXml());
1524 using (StringReader sr =
new StringReader(rawXml))
1526 using (XmlTextReader xtr =
new XmlTextReader(sr))
1528 xtr.MoveToContent();
1530 string type = xtr.GetAttribute(
"type");
1533 if (type != MEDIA_TEXTURE_TYPE)
1536 xtr.ReadStartElement(
"OSMedia");
1538 OSDArray osdMeArray = (
OSDArray)OSDParser.DeserializeLLSDXml(xtr.ReadInnerXml());
1539 foreach (
OSD osdMe
in osdMeArray)
1541 MediaEntry me = (osdMe is
OSDMap ? MediaEntry.FromOSD(osdMe) :
new MediaEntry());
1545 xtr.ReadEndElement();
1552 if (reader.IsEmptyElement)
1555 ReadXml(reader.ReadInnerXml());
void SetScale(float side)
OpenMetaverse.StructuredData.OSDArray OSDArray
void SetPathRange(float begin, float end)
static PrimitiveBaseShape Create()
void SetProfileRange(float begin, float end)
OpenMetaverse.StructuredData.OSDMap OSDMap
PrimitiveBaseShape Copy()
byte[] ExtraParamsToBytes()
ulong GetMeshKey(Vector3 size, float lod)
void SetRadius(float radius)
void SetProfileRange(Vector3 profileRange)
void SetPathRange(Vector3 pathRange)
static PrimitiveBaseShape CreateCylinder()
OpenSim.Region.ScriptEngine.Shared.LSL_Types.Quaternion rotation
void ReadFlexiData(byte[] data, int pos)
void ReadProjectionData(byte[] data, int pos)
void SetSculptProperties(byte sculptType, UUID SculptTextureUUID)
OpenSim.Region.OptionalModules.Scripting.Minimodule.Object.SculptType SculptType
void ReadInUpdateExtraParam(ushort type, bool inUse, byte[] data)
byte[] GetProjectionBytes()
OpenMetaverse.StructuredData.OSD OSD
void ReadSculptData(byte[] data, int pos)
ulong GetMeshKey(Vector3 size, float lod, bool convex)
Primitive ToOmvPrimitive(Vector3 position, Quaternion rotation)
Creates a OpenMetaverse.Primitive and populates it with converted PrimitiveBaseShape values ...
static PrimitiveBaseShape CreateCylinder(float radius, float heigth)
System.Collections.IEnumerable IEnumerable
Primitive ToOmvPrimitive()
Creates a OpenMetaverse.Primitive and populates it with converted PrimitiveBaseShape values ...
static PrimitiveBaseShape CreateSphere()
void ReadInExtraParamsBytes(byte[] data)
void ReadLightData(byte[] data, int pos)
void SetHeigth(float height)
static PrimitiveBaseShape CreateBox()
PrimitiveBaseShape(Primitive prim)
Construct a PrimitiveBaseShape object from a OpenMetaverse.Primitive object