aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorUbitUmarov2012-02-19 18:10:00 +0000
committerUbitUmarov2012-02-19 18:10:00 +0000
commit60d68ee3122a974007adec6e651fad461d8abda4 (patch)
tree94908ebd64cd2bf5735f3a57c3510c8eac37d0c4
parent moved vehicle from SOG to SOP (diff)
downloadopensim-SC_OLD-60d68ee3122a974007adec6e651fad461d8abda4.zip
opensim-SC_OLD-60d68ee3122a974007adec6e651fad461d8abda4.tar.gz
opensim-SC_OLD-60d68ee3122a974007adec6e651fad461d8abda4.tar.bz2
opensim-SC_OLD-60d68ee3122a974007adec6e651fad461d8abda4.tar.xz
Vehicle XML serialization more complete. Inactived by coments in SceneObjectSerializar.cs until proper testing
-rw-r--r--OpenSim/Region/Framework/Scenes/SOPVehicle.cs223
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectPart.cs13
-rw-r--r--OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs28
3 files changed, 260 insertions, 4 deletions
diff --git a/OpenSim/Region/Framework/Scenes/SOPVehicle.cs b/OpenSim/Region/Framework/Scenes/SOPVehicle.cs
index 39786bd..b462867 100644
--- a/OpenSim/Region/Framework/Scenes/SOPVehicle.cs
+++ b/OpenSim/Region/Framework/Scenes/SOPVehicle.cs
@@ -26,6 +26,7 @@
26 */ 26 */
27 27
28using System; 28using System;
29using System.Collections.Generic;
29using OpenMetaverse; 30using OpenMetaverse;
30using OpenSim.Framework; 31using OpenSim.Framework;
31using OpenSim.Region.Physics.Manager; 32using OpenSim.Region.Physics.Manager;
@@ -33,6 +34,7 @@ using System.Xml;
33using OpenSim.Framework.Serialization; 34using OpenSim.Framework.Serialization;
34using OpenSim.Framework.Serialization.External; 35using OpenSim.Framework.Serialization.External;
35using OpenSim.Region.Framework.Scenes.Serialization; 36using OpenSim.Region.Framework.Scenes.Serialization;
37using OpenSim.Region.Framework.Scenes.Serialization;
36 38
37namespace OpenSim.Region.Framework.Scenes 39namespace OpenSim.Region.Framework.Scenes
38{ 40{
@@ -44,7 +46,7 @@ namespace OpenSim.Region.Framework.Scenes
44 { 46 {
45 get { return vd.m_type; } 47 get { return vd.m_type; }
46 } 48 }
47 49
48 public SOPVehicle() 50 public SOPVehicle()
49 { 51 {
50 vd = new VehicleData(); 52 vd = new VehicleData();
@@ -116,8 +118,6 @@ namespace OpenSim.Region.Framework.Scenes
116 vd.m_linearDeflectionTimescale = pValue; 118 vd.m_linearDeflectionTimescale = pValue;
117 break; 119 break;
118 case Vehicle.LINEAR_MOTOR_DECAY_TIMESCALE: 120 case Vehicle.LINEAR_MOTOR_DECAY_TIMESCALE:
119 // if (pValue < timestep) pValue = timestep;
120 // try to make impulses to work a bit better
121 if (pValue < timestep) pValue = timestep; 121 if (pValue < timestep) pValue = timestep;
122 else if (pValue > 120) pValue = 120; 122 else if (pValue > 120) pValue = 120;
123 vd.m_linearMotorDecayTimescale = pValue; 123 vd.m_linearMotorDecayTimescale = pValue;
@@ -439,7 +439,7 @@ namespace OpenSim.Region.Framework.Scenes
439 public void ToXml2(XmlTextWriter twriter) 439 public void ToXml2(XmlTextWriter twriter)
440 { 440 {
441 writer = twriter; 441 writer = twriter;
442 writer.WriteStartElement("SOGVehicle"); 442 writer.WriteStartElement("Vehicle");
443 443
444 XWint("TYPE", (int)vd.m_type); 444 XWint("TYPE", (int)vd.m_type);
445 XWint("FLAGS", (int)vd.m_flags); 445 XWint("FLAGS", (int)vd.m_flags);
@@ -483,5 +483,220 @@ namespace OpenSim.Region.Framework.Scenes
483 writer.WriteEndElement(); 483 writer.WriteEndElement();
484 writer = null; 484 writer = null;
485 } 485 }
486
487 private int XRint(XmlTextReader reader, string name)
488 {
489 return reader.ReadElementContentAsInt(name, String.Empty);
490 }
491
492 private float XRfloat(XmlTextReader reader, string name)
493 {
494 return reader.ReadElementContentAsFloat(name, String.Empty);
495 }
496
497 public Vector3 XRvector(XmlTextReader reader, string name)
498 {
499 Vector3 vec;
500 reader.ReadStartElement(name);
501 vec.X = reader.ReadElementContentAsFloat(reader.Name, String.Empty); // X or x
502 vec.Y = reader.ReadElementContentAsFloat(reader.Name, String.Empty); // Y or y
503 vec.Z = reader.ReadElementContentAsFloat(reader.Name, String.Empty); // Z or z
504 reader.ReadEndElement();
505 return vec;
506 }
507
508 public Quaternion XRquat(XmlTextReader reader, string name)
509 {
510 Quaternion q;
511 reader.ReadStartElement(name);
512 q.X = reader.ReadElementContentAsFloat(reader.Name, String.Empty);
513 q.Y = reader.ReadElementContentAsFloat(reader.Name, String.Empty);
514 q.Z = reader.ReadElementContentAsFloat(reader.Name, String.Empty);
515 q.W = reader.ReadElementContentAsFloat(reader.Name, String.Empty);
516 reader.ReadEndElement();
517 return q;
518 }
519
520 public void FromXml2(XmlTextReader reader, out bool errors)
521 {
522 errors = false;
523
524 Dictionary<string, Action<VehicleData, XmlTextReader>> m_VehicleXmlProcessors
525 = new Dictionary<string, Action<VehicleData, XmlTextReader>>();
526
527 m_VehicleXmlProcessors.Add("TYPE", ProcessXR_type);
528 m_VehicleXmlProcessors.Add("FLAGS", ProcessXR_flags);
529
530 // Linear properties
531 m_VehicleXmlProcessors.Add("LMDIR", ProcessXR_linearMotorDirection);
532 m_VehicleXmlProcessors.Add("LMFTIME", ProcessXR_linearFrictionTimescale);
533 m_VehicleXmlProcessors.Add("LMDTIME", ProcessXR_linearMotorDecayTimescale);
534 m_VehicleXmlProcessors.Add("LMTIME", ProcessXR_linearMotorTimescale);
535 m_VehicleXmlProcessors.Add("LMOFF", ProcessXR_linearMotorOffset);
536
537 //Angular properties
538 m_VehicleXmlProcessors.Add("AMDIR", ProcessXR_angularMotorDirection);
539 m_VehicleXmlProcessors.Add("AMTIME", ProcessXR_angularMotorTimescale);
540 m_VehicleXmlProcessors.Add("AMDTIME", ProcessXR_angularMotorDecayTimescale);
541 m_VehicleXmlProcessors.Add("AMFTIME", ProcessXR_angularFrictionTimescale);
542
543 //Deflection properties
544 m_VehicleXmlProcessors.Add("ADEFF", ProcessXR_angularDeflectionEfficiency);
545 m_VehicleXmlProcessors.Add("ADTIME", ProcessXR_angularDeflectionTimescale);
546 m_VehicleXmlProcessors.Add("LDEFF", ProcessXR_linearDeflectionEfficiency);
547 m_VehicleXmlProcessors.Add("LDTIME", ProcessXR_linearDeflectionTimescale);
548
549 //Banking properties
550 m_VehicleXmlProcessors.Add("BEFF", ProcessXR_bankingEfficiency);
551 m_VehicleXmlProcessors.Add("BMIX", ProcessXR_bankingMix);
552 m_VehicleXmlProcessors.Add("BTIME", ProcessXR_bankingTimescale);
553
554 //Hover and Buoyancy properties
555 m_VehicleXmlProcessors.Add("HHEI", ProcessXR_VhoverHeight);
556 m_VehicleXmlProcessors.Add("HEFF", ProcessXR_VhoverEfficiency);
557 m_VehicleXmlProcessors.Add("HTIME", ProcessXR_VhoverTimescale);
558
559 m_VehicleXmlProcessors.Add("VBUO", ProcessXR_VehicleBuoyancy);
560
561 //Attractor properties
562 m_VehicleXmlProcessors.Add("VAEFF", ProcessXR_verticalAttractionEfficiency);
563 m_VehicleXmlProcessors.Add("VATIME", ProcessXR_verticalAttractionTimescale);
564
565 m_VehicleXmlProcessors.Add("REF_FRAME", ProcessXR_referenceFrame);
566
567 vd = new VehicleData();
568
569 reader.ReadStartElement("Vehicle", String.Empty);
570
571 errors = ExternalRepresentationUtils.ExecuteReadProcessors(
572 vd,
573 m_VehicleXmlProcessors,
574 reader,
575 (o, nodeName, e)
576 =>
577 {
578 }
579 );
580
581 reader.ReadEndElement();
582 }
583
584 private void ProcessXR_type(VehicleData obj, XmlTextReader reader)
585 {
586 vd.m_type = (Vehicle)XRint(reader, "TYPE");
587 }
588 private void ProcessXR_flags(VehicleData obj, XmlTextReader reader)
589 {
590 vd.m_flags = (VehicleFlag)XRint(reader, "FLAGS");
591 }
592 // Linear properties
593 private void ProcessXR_linearMotorDirection(VehicleData obj, XmlTextReader reader)
594 {
595 vd.m_linearMotorDirection = XRvector(reader, "LMDIR");
596 }
597
598 private void ProcessXR_linearFrictionTimescale(VehicleData obj, XmlTextReader reader)
599 {
600 vd.m_linearFrictionTimescale = XRvector(reader, "LMFTIME");
601 }
602
603 private void ProcessXR_linearMotorDecayTimescale(VehicleData obj, XmlTextReader reader)
604 {
605 vd.m_linearMotorDecayTimescale = XRfloat(reader, "LMDTIME");
606 }
607 private void ProcessXR_linearMotorTimescale(VehicleData obj, XmlTextReader reader)
608 {
609 vd.m_linearMotorTimescale = XRfloat(reader, "LMTIME");
610 }
611 private void ProcessXR_linearMotorOffset(VehicleData obj, XmlTextReader reader)
612 {
613 vd.m_linearMotorOffset = XRvector(reader, "LMOFF");
614 }
615
616
617 //Angular properties
618 private void ProcessXR_angularMotorDirection(VehicleData obj, XmlTextReader reader)
619 {
620 vd.m_angularMotorDirection = XRvector(reader, "AMDIR");
621 }
622 private void ProcessXR_angularMotorTimescale(VehicleData obj, XmlTextReader reader)
623 {
624 vd.m_angularMotorTimescale = XRfloat(reader, "AMTIME");
625 }
626 private void ProcessXR_angularMotorDecayTimescale(VehicleData obj, XmlTextReader reader)
627 {
628 vd.m_angularMotorDecayTimescale = XRfloat(reader, "AMDTIME");
629 }
630 private void ProcessXR_angularFrictionTimescale(VehicleData obj, XmlTextReader reader)
631 {
632 vd.m_angularFrictionTimescale = XRvector(reader, "AMFTIME");
633 }
634
635 //Deflection properties
636 private void ProcessXR_angularDeflectionEfficiency(VehicleData obj, XmlTextReader reader)
637 {
638 vd.m_angularDeflectionEfficiency = XRfloat(reader, "ADEFF");
639 }
640 private void ProcessXR_angularDeflectionTimescale(VehicleData obj, XmlTextReader reader)
641 {
642 vd.m_angularDeflectionTimescale = XRfloat(reader, "ADTIME");
643 }
644 private void ProcessXR_linearDeflectionEfficiency(VehicleData obj, XmlTextReader reader)
645 {
646 vd.m_linearDeflectionEfficiency = XRfloat(reader, "LDEFF");
647 }
648 private void ProcessXR_linearDeflectionTimescale(VehicleData obj, XmlTextReader reader)
649 {
650 vd.m_linearDeflectionTimescale = XRfloat(reader, "LDTIME");
651 }
652
653 //Banking properties
654 private void ProcessXR_bankingEfficiency(VehicleData obj, XmlTextReader reader)
655 {
656 vd.m_bankingEfficiency = XRfloat(reader, "BEFF");
657 }
658 private void ProcessXR_bankingMix(VehicleData obj, XmlTextReader reader)
659 {
660 vd.m_bankingMix = XRfloat(reader, "BMIX");
661 }
662 private void ProcessXR_bankingTimescale(VehicleData obj, XmlTextReader reader)
663 {
664 vd.m_bankingTimescale = XRfloat(reader, "BTIME");
665 }
666
667 //Hover and Buoyancy properties
668 private void ProcessXR_VhoverHeight(VehicleData obj, XmlTextReader reader)
669 {
670 vd.m_VhoverHeight = XRfloat(reader, "HHEI");
671 }
672 private void ProcessXR_VhoverEfficiency(VehicleData obj, XmlTextReader reader)
673 {
674 vd.m_VhoverEfficiency = XRfloat(reader, "HEFF");
675 }
676 private void ProcessXR_VhoverTimescale(VehicleData obj, XmlTextReader reader)
677 {
678 vd.m_VhoverTimescale = XRfloat(reader, "HTIME");
679 }
680
681 private void ProcessXR_VehicleBuoyancy(VehicleData obj, XmlTextReader reader)
682 {
683 vd.m_VehicleBuoyancy = XRfloat(reader, "VBUO");
684 }
685
686 //Attractor properties
687 private void ProcessXR_verticalAttractionEfficiency(VehicleData obj, XmlTextReader reader)
688 {
689 vd.m_verticalAttractionEfficiency = XRfloat(reader, "VAEFF");
690 }
691 private void ProcessXR_verticalAttractionTimescale(VehicleData obj, XmlTextReader reader)
692 {
693 vd.m_verticalAttractionTimescale = XRfloat(reader, "VATIME");
694 }
695
696 private void ProcessXR_referenceFrame(VehicleData obj, XmlTextReader reader)
697 {
698 vd.m_referenceFrame = XRquat(reader, "REF_FRAME");
699
700 }
486 } 701 }
487} \ No newline at end of file 702} \ No newline at end of file
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
index eb59ffd..4cd5183 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
@@ -3177,6 +3177,18 @@ namespace OpenSim.Region.Framework.Scenes
3177 } 3177 }
3178 } 3178 }
3179 3179
3180 public SOPVehicle sopVehicle
3181 {
3182 get
3183 {
3184 return m_vehicle;
3185 }
3186 set
3187 {
3188 m_vehicle = value;
3189 }
3190 }
3191
3180 3192
3181 public int VehicleType 3193 public int VehicleType
3182 { 3194 {
@@ -3196,6 +3208,7 @@ namespace OpenSim.Region.Framework.Scenes
3196 public void SetVehicleType(int type) 3208 public void SetVehicleType(int type)
3197 { 3209 {
3198 m_vehicle = null; 3210 m_vehicle = null;
3211
3199 if (type == (int)Vehicle.TYPE_NONE) 3212 if (type == (int)Vehicle.TYPE_NONE)
3200 { 3213 {
3201 if (_parentID ==0 && PhysActor != null) 3214 if (_parentID ==0 && PhysActor != null)
diff --git a/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs b/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs
index 4b80e37..eaf32b8 100644
--- a/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs
+++ b/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs
@@ -349,6 +349,11 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
349 349
350 m_SOPXmlProcessors.Add("Buoyancy", ProcessBuoyancy); 350 m_SOPXmlProcessors.Add("Buoyancy", ProcessBuoyancy);
351 m_SOPXmlProcessors.Add("VolumeDetectActive", ProcessVolumeDetectActive); 351 m_SOPXmlProcessors.Add("VolumeDetectActive", ProcessVolumeDetectActive);
352
353 //Ubit comented until proper testing
354 // m_SOPXmlProcessors.Add("Vehicle", ProcessVehicle);
355
356
352 #endregion 357 #endregion
353 358
354 #region TaskInventoryXmlProcessors initialization 359 #region TaskInventoryXmlProcessors initialization
@@ -571,6 +576,25 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
571 obj.ClickAction = (byte)reader.ReadElementContentAsInt("ClickAction", String.Empty); 576 obj.ClickAction = (byte)reader.ReadElementContentAsInt("ClickAction", String.Empty);
572 } 577 }
573 578
579 private static void ProcessVehicle(SceneObjectPart obj, XmlTextReader reader)
580 {
581 bool errors = false;
582 SOPVehicle _vehicle = new SOPVehicle();
583
584 _vehicle.FromXml2(reader, out errors);
585
586 if (errors)
587 {
588 obj.sopVehicle = null;
589 m_log.DebugFormat(
590 "[SceneObjectSerializer]: Parsing Vehicle for object part {0} {1} encountered errors. Please see earlier log entries.",
591 obj.Name, obj.UUID);
592 }
593 else
594 obj.sopVehicle = _vehicle;
595 }
596
597
574 private static void ProcessShape(SceneObjectPart obj, XmlTextReader reader) 598 private static void ProcessShape(SceneObjectPart obj, XmlTextReader reader)
575 { 599 {
576 bool errors = false; 600 bool errors = false;
@@ -1231,6 +1255,10 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
1231 writer.WriteElementString("Buoyancy", sop.Buoyancy.ToString()); 1255 writer.WriteElementString("Buoyancy", sop.Buoyancy.ToString());
1232 writer.WriteElementString("VolumeDetectActive", sop.VolumeDetectActive.ToString().ToLower()); 1256 writer.WriteElementString("VolumeDetectActive", sop.VolumeDetectActive.ToString().ToLower());
1233 1257
1258 //Ubit comented until proper testing
1259 // if (sop.sopVehicle != null)
1260 // sop.sopVehicle.ToXml2(writer);
1261
1234 writer.WriteEndElement(); 1262 writer.WriteEndElement();
1235 } 1263 }
1236 1264