aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework/PrimitiveBaseShape.cs
diff options
context:
space:
mode:
authoronefang2019-09-11 16:36:50 +1000
committeronefang2019-09-11 16:36:50 +1000
commit50cd1ffd32f69228e566f2b0b89f86ea0d9fe489 (patch)
tree52f2ab0c04f1a5d7d6ac5dc872981b4b156447e7 /OpenSim/Framework/PrimitiveBaseShape.cs
parentRenamed branch to SledjChisl. (diff)
parentBump to release flavour, build 0. (diff)
downloadopensim-SC_OLD-50cd1ffd32f69228e566f2b0b89f86ea0d9fe489.zip
opensim-SC_OLD-50cd1ffd32f69228e566f2b0b89f86ea0d9fe489.tar.gz
opensim-SC_OLD-50cd1ffd32f69228e566f2b0b89f86ea0d9fe489.tar.bz2
opensim-SC_OLD-50cd1ffd32f69228e566f2b0b89f86ea0d9fe489.tar.xz
Merge branch 'SledjChisl'
Diffstat (limited to 'OpenSim/Framework/PrimitiveBaseShape.cs')
-rw-r--r--OpenSim/Framework/PrimitiveBaseShape.cs153
1 files changed, 131 insertions, 22 deletions
diff --git a/OpenSim/Framework/PrimitiveBaseShape.cs b/OpenSim/Framework/PrimitiveBaseShape.cs
index c8a5376..6e7a038 100644
--- a/OpenSim/Framework/PrimitiveBaseShape.cs
+++ b/OpenSim/Framework/PrimitiveBaseShape.cs
@@ -238,8 +238,8 @@ namespace OpenSim.Framework
238 SculptTexture = prim.Sculpt.SculptTexture; 238 SculptTexture = prim.Sculpt.SculptTexture;
239 SculptType = (byte)prim.Sculpt.Type; 239 SculptType = (byte)prim.Sculpt.Type;
240 } 240 }
241 else 241 else
242 { 242 {
243 SculptType = (byte)OpenMetaverse.SculptType.None; 243 SculptType = (byte)OpenMetaverse.SculptType.None;
244 } 244 }
245 } 245 }
@@ -328,6 +328,72 @@ namespace OpenSim.Framework
328 return shape; 328 return shape;
329 } 329 }
330 330
331 public static PrimitiveBaseShape CreateMesh(int numberOfFaces, UUID meshAssetID)
332 {
333 PrimitiveBaseShape shape = new PrimitiveBaseShape();
334
335 shape._pathScaleX = 100;
336 shape._pathScaleY = 100;
337
338 if(numberOfFaces <= 0) // oops ?
339 numberOfFaces = 1;
340
341 switch(numberOfFaces)
342 {
343 case 1: // torus
344 shape.ProfileCurve = (byte)ProfileShape.Circle | (byte)HollowShape.Triangle;
345 shape.PathCurve = (byte)Extrusion.Curve1;
346 shape._pathScaleY = 150;
347 break;
348
349 case 2: // torus with hollow (a sl viewer whould see 4 faces on a hollow sphere)
350 shape.ProfileCurve = (byte)ProfileShape.Circle | (byte)HollowShape.Triangle;
351 shape.PathCurve = (byte)Extrusion.Curve1;
352 shape.ProfileHollow = 27500;
353 shape._pathScaleY = 150;
354 break;
355
356 case 3: // cylinder
357 shape.ProfileCurve = (byte)ProfileShape.Circle | (byte)HollowShape.Triangle;
358 shape.PathCurve = (byte)Extrusion.Straight;
359 break;
360
361 case 4: // cylinder with hollow
362 shape.ProfileCurve = (byte)ProfileShape.Circle | (byte)HollowShape.Triangle;
363 shape.PathCurve = (byte)Extrusion.Straight;
364 shape.ProfileHollow = 27500;
365 break;
366
367 case 5: // prism
368 shape.ProfileCurve = (byte)ProfileShape.EquilateralTriangle | (byte)HollowShape.Triangle;
369 shape.PathCurve = (byte)Extrusion.Straight;
370 break;
371
372 case 6: // box
373 shape.ProfileCurve = (byte)ProfileShape.Square | (byte)HollowShape.Triangle;
374 shape.PathCurve = (byte)Extrusion.Straight;
375 break;
376
377 case 7: // box with hollow
378 shape.ProfileCurve = (byte)ProfileShape.Square | (byte)HollowShape.Triangle;
379 shape.PathCurve = (byte)Extrusion.Straight;
380 shape.ProfileHollow = 27500;
381 break;
382
383 default: // 8 faces box with cut
384 shape.ProfileCurve = (byte)ProfileShape.Square | (byte)HollowShape.Triangle;
385 shape.PathCurve = (byte)Extrusion.Straight;
386 shape.ProfileBegin = 9375;
387 break;
388 }
389
390 shape.SculptEntry = true;
391 shape.SculptType = (byte)OpenMetaverse.SculptType.Mesh;
392 shape.SculptTexture = meshAssetID;
393
394 return shape;
395 }
396
331 public void SetScale(float side) 397 public void SetScale(float side)
332 { 398 {
333 _scale = new Vector3(side, side, side); 399 _scale = new Vector3(side, side, side);
@@ -728,7 +794,12 @@ namespace OpenSim.Framework
728 return _lightColorR; 794 return _lightColorR;
729 } 795 }
730 set { 796 set {
731 _lightColorR = value; 797 if (value < 0)
798 _lightColorR = 0;
799 else if (value > 1.0f)
800 _lightColorR = 1.0f;
801 else
802 _lightColorR = value;
732 } 803 }
733 } 804 }
734 805
@@ -737,7 +808,12 @@ namespace OpenSim.Framework
737 return _lightColorG; 808 return _lightColorG;
738 } 809 }
739 set { 810 set {
740 _lightColorG = value; 811 if (value < 0)
812 _lightColorG = 0;
813 else if (value > 1.0f)
814 _lightColorG = 1.0f;
815 else
816 _lightColorG = value;
741 } 817 }
742 } 818 }
743 819
@@ -746,7 +822,12 @@ namespace OpenSim.Framework
746 return _lightColorB; 822 return _lightColorB;
747 } 823 }
748 set { 824 set {
749 _lightColorB = value; 825 if (value < 0)
826 _lightColorB = 0;
827 else if (value > 1.0f)
828 _lightColorB = 1.0f;
829 else
830 _lightColorB = value;
750 } 831 }
751 } 832 }
752 833
@@ -755,7 +836,12 @@ namespace OpenSim.Framework
755 return _lightColorA; 836 return _lightColorA;
756 } 837 }
757 set { 838 set {
758 _lightColorA = value; 839 if (value < 0)
840 _lightColorA = 0;
841 else if (value > 1.0f)
842 _lightColorA = 1.0f;
843 else
844 _lightColorA = value;
759 } 845 }
760 } 846 }
761 847
@@ -869,6 +955,11 @@ namespace OpenSim.Framework
869 955
870 public ulong GetMeshKey(Vector3 size, float lod) 956 public ulong GetMeshKey(Vector3 size, float lod)
871 { 957 {
958 return GetMeshKey(size, lod, false);
959 }
960
961 public ulong GetMeshKey(Vector3 size, float lod, bool convex)
962 {
872 ulong hash = 5381; 963 ulong hash = 5381;
873 964
874 hash = djb2(hash, this.PathCurve); 965 hash = djb2(hash, this.PathCurve);
@@ -914,6 +1005,9 @@ namespace OpenSim.Framework
914 hash = djb2(hash, scaleBytes[i]); 1005 hash = djb2(hash, scaleBytes[i]);
915 } 1006 }
916 1007
1008 if(convex)
1009 hash = djb2(hash, 0xa5);
1010
917 return hash; 1011 return hash;
918 } 1012 }
919 1013
@@ -1417,7 +1511,7 @@ namespace OpenSim.Framework
1417 prim.Textures = this.Textures; 1511 prim.Textures = this.Textures;
1418 1512
1419 prim.Properties = new Primitive.ObjectProperties(); 1513 prim.Properties = new Primitive.ObjectProperties();
1420 prim.Properties.Name = "Primitive"; 1514 prim.Properties.Name = "Object";
1421 prim.Properties.Description = ""; 1515 prim.Properties.Description = "";
1422 prim.Properties.CreatorID = UUID.Zero; 1516 prim.Properties.CreatorID = UUID.Zero;
1423 prim.Properties.GroupID = UUID.Zero; 1517 prim.Properties.GroupID = UUID.Zero;
@@ -1488,35 +1582,50 @@ namespace OpenSim.Framework
1488 { 1582 {
1489 MediaList ml = new MediaList(); 1583 MediaList ml = new MediaList();
1490 ml.ReadXml(rawXml); 1584 ml.ReadXml(rawXml);
1585 if(ml.Count == 0)
1586 return null;
1491 return ml; 1587 return ml;
1492 } 1588 }
1493 1589
1494 public void ReadXml(string rawXml) 1590 public void ReadXml(string rawXml)
1495 { 1591 {
1496 using (StringReader sr = new StringReader(rawXml)) 1592 try
1497 { 1593 {
1498 using (XmlTextReader xtr = new XmlTextReader(sr)) 1594 using (StringReader sr = new StringReader(rawXml))
1499 { 1595 {
1500 xtr.MoveToContent(); 1596 using (XmlTextReader xtr = new XmlTextReader(sr))
1597 {
1598 xtr.ProhibitDtd = true;
1501 1599
1502 string type = xtr.GetAttribute("type"); 1600 xtr.MoveToContent();
1503 //m_log.DebugFormat("[MOAP]: Loaded media texture entry with type {0}", type);
1504 1601
1505 if (type != MEDIA_TEXTURE_TYPE) 1602 string type = xtr.GetAttribute("type");
1506 return; 1603 //m_log.DebugFormat("[MOAP]: Loaded media texture entry with type {0}", type);
1507 1604
1508 xtr.ReadStartElement("OSMedia"); 1605 if (type != MEDIA_TEXTURE_TYPE)
1606 return;
1509 1607
1510 OSDArray osdMeArray = (OSDArray)OSDParser.DeserializeLLSDXml(xtr.ReadInnerXml()); 1608 xtr.ReadStartElement("OSMedia");
1511 foreach (OSD osdMe in osdMeArray) 1609 OSD osdp = OSDParser.DeserializeLLSDXml(xtr.ReadInnerXml());
1512 { 1610 if(osdp == null || !(osdp is OSDArray))
1513 MediaEntry me = (osdMe is OSDMap ? MediaEntry.FromOSD(osdMe) : new MediaEntry()); 1611 return;
1514 Add(me);
1515 }
1516 1612
1517 xtr.ReadEndElement(); 1613 OSDArray osdMeArray = osdp as OSDArray;
1614 if(osdMeArray.Count == 0)
1615 return;
1616
1617 foreach (OSD osdMe in osdMeArray)
1618 {
1619 MediaEntry me = (osdMe is OSDMap ? MediaEntry.FromOSD(osdMe) : new MediaEntry());
1620 Add(me);
1621 }
1622 }
1518 } 1623 }
1519 } 1624 }
1625 catch
1626 {
1627 m_log.Debug("PrimitiveBaseShape] error decoding MOAP xml" );
1628 }
1520 } 1629 }
1521 1630
1522 public void ReadXml(XmlReader reader) 1631 public void ReadXml(XmlReader reader)