aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
authorMelanie2012-02-19 20:24:00 +0100
committerMelanie2012-02-19 20:24:00 +0100
commit433d5f1d3e60438fcad9019fc6e7c0fd11386a8e (patch)
tree22a6bc8b9f1cdf4f230cbbbc3c5437a91c5a025e /OpenSim
parentFix merge issues in prebuild (diff)
parentsimplified vehicle fromXml. Use still comented on SceneObjectSerialized.cs (diff)
downloadopensim-SC_OLD-433d5f1d3e60438fcad9019fc6e7c0fd11386a8e.zip
opensim-SC_OLD-433d5f1d3e60438fcad9019fc6e7c0fd11386a8e.tar.gz
opensim-SC_OLD-433d5f1d3e60438fcad9019fc6e7c0fd11386a8e.tar.bz2
opensim-SC_OLD-433d5f1d3e60438fcad9019fc6e7c0fd11386a8e.tar.xz
Merge branch 'ubitwork'
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/Framework/Scenes/SOPVehicle.cs263
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectPart.cs13
-rw-r--r--OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs28
3 files changed, 300 insertions, 4 deletions
diff --git a/OpenSim/Region/Framework/Scenes/SOPVehicle.cs b/OpenSim/Region/Framework/Scenes/SOPVehicle.cs
index 39786bd..d3c2d27 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,260 @@ namespace OpenSim.Region.Framework.Scenes
483 writer.WriteEndElement(); 483 writer.WriteEndElement();
484 writer = null; 484 writer = null;
485 } 485 }
486
487
488
489 XmlTextReader reader;
490
491 private int XRint()
492 {
493 return reader.ReadElementContentAsInt();
494 }
495
496 private float XRfloat()
497 {
498 return reader.ReadElementContentAsFloat();
499 }
500
501 public Vector3 XRvector()
502 {
503 Vector3 vec;
504 reader.ReadStartElement();
505 vec.X = reader.ReadElementContentAsFloat();
506 vec.Y = reader.ReadElementContentAsFloat();
507 vec.Z = reader.ReadElementContentAsFloat();
508 reader.ReadEndElement();
509 return vec;
510 }
511
512 public Quaternion XRquat()
513 {
514 Quaternion q;
515 reader.ReadStartElement();
516 q.X = reader.ReadElementContentAsFloat();
517 q.Y = reader.ReadElementContentAsFloat();
518 q.Z = reader.ReadElementContentAsFloat();
519 q.W = reader.ReadElementContentAsFloat();
520 reader.ReadEndElement();
521 return q;
522 }
523
524 public static bool EReadProcessors(
525 Dictionary<string, Action> processors,
526 XmlTextReader xtr)
527 {
528 bool errors = false;
529
530 string nodeName = string.Empty;
531 while (xtr.NodeType != XmlNodeType.EndElement)
532 {
533 nodeName = xtr.Name;
534
535 // m_log.DebugFormat("[ExternalRepresentationUtils]: Processing: {0}", nodeName);
536
537 Action p = null;
538 if (processors.TryGetValue(xtr.Name, out p))
539 {
540 // m_log.DebugFormat("[ExternalRepresentationUtils]: Found {0} processor, nodeName);
541
542 try
543 {
544 p();
545 }
546 catch (Exception e)
547 {
548 errors = true;
549 if (xtr.NodeType == XmlNodeType.EndElement)
550 xtr.Read();
551 }
552 }
553 else
554 {
555 // m_log.DebugFormat("[LandDataSerializer]: caught unknown element {0}", nodeName);
556 xtr.ReadOuterXml(); // ignore
557 }
558 }
559
560 return errors;
561 }
562
563
564
565 public void FromXml2(XmlTextReader _reader, out bool errors)
566 {
567 errors = false;
568 reader = _reader;
569
570 Dictionary<string, Action> m_VehicleXmlProcessors
571 = new Dictionary<string, Action>();
572
573 m_VehicleXmlProcessors.Add("TYPE", ProcessXR_type);
574 m_VehicleXmlProcessors.Add("FLAGS", ProcessXR_flags);
575
576 // Linear properties
577 m_VehicleXmlProcessors.Add("LMDIR", ProcessXR_linearMotorDirection);
578 m_VehicleXmlProcessors.Add("LMFTIME", ProcessXR_linearFrictionTimescale);
579 m_VehicleXmlProcessors.Add("LMDTIME", ProcessXR_linearMotorDecayTimescale);
580 m_VehicleXmlProcessors.Add("LMTIME", ProcessXR_linearMotorTimescale);
581 m_VehicleXmlProcessors.Add("LMOFF", ProcessXR_linearMotorOffset);
582
583 //Angular properties
584 m_VehicleXmlProcessors.Add("AMDIR", ProcessXR_angularMotorDirection);
585 m_VehicleXmlProcessors.Add("AMTIME", ProcessXR_angularMotorTimescale);
586 m_VehicleXmlProcessors.Add("AMDTIME", ProcessXR_angularMotorDecayTimescale);
587 m_VehicleXmlProcessors.Add("AMFTIME", ProcessXR_angularFrictionTimescale);
588
589 //Deflection properties
590 m_VehicleXmlProcessors.Add("ADEFF", ProcessXR_angularDeflectionEfficiency);
591 m_VehicleXmlProcessors.Add("ADTIME", ProcessXR_angularDeflectionTimescale);
592 m_VehicleXmlProcessors.Add("LDEFF", ProcessXR_linearDeflectionEfficiency);
593 m_VehicleXmlProcessors.Add("LDTIME", ProcessXR_linearDeflectionTimescale);
594
595 //Banking properties
596 m_VehicleXmlProcessors.Add("BEFF", ProcessXR_bankingEfficiency);
597 m_VehicleXmlProcessors.Add("BMIX", ProcessXR_bankingMix);
598 m_VehicleXmlProcessors.Add("BTIME", ProcessXR_bankingTimescale);
599
600 //Hover and Buoyancy properties
601 m_VehicleXmlProcessors.Add("HHEI", ProcessXR_VhoverHeight);
602 m_VehicleXmlProcessors.Add("HEFF", ProcessXR_VhoverEfficiency);
603 m_VehicleXmlProcessors.Add("HTIME", ProcessXR_VhoverTimescale);
604
605 m_VehicleXmlProcessors.Add("VBUO", ProcessXR_VehicleBuoyancy);
606
607 //Attractor properties
608 m_VehicleXmlProcessors.Add("VAEFF", ProcessXR_verticalAttractionEfficiency);
609 m_VehicleXmlProcessors.Add("VATIME", ProcessXR_verticalAttractionTimescale);
610
611 m_VehicleXmlProcessors.Add("REF_FRAME", ProcessXR_referenceFrame);
612
613 vd = new VehicleData();
614
615 reader.ReadStartElement("Vehicle", String.Empty);
616
617 errors = EReadProcessors(
618 m_VehicleXmlProcessors,
619 reader);
620
621 reader.ReadEndElement();
622 reader = null;
623 }
624
625 private void ProcessXR_type()
626 {
627 vd.m_type = (Vehicle)XRint();
628 }
629 private void ProcessXR_flags()
630 {
631 vd.m_flags = (VehicleFlag)XRint();
632 }
633 // Linear properties
634 private void ProcessXR_linearMotorDirection()
635 {
636 vd.m_linearMotorDirection = XRvector();
637 }
638
639 private void ProcessXR_linearFrictionTimescale()
640 {
641 vd.m_linearFrictionTimescale = XRvector();
642 }
643
644 private void ProcessXR_linearMotorDecayTimescale()
645 {
646 vd.m_linearMotorDecayTimescale = XRfloat();
647 }
648 private void ProcessXR_linearMotorTimescale()
649 {
650 vd.m_linearMotorTimescale = XRfloat();
651 }
652 private void ProcessXR_linearMotorOffset()
653 {
654 vd.m_linearMotorOffset = XRvector();
655 }
656
657
658 //Angular properties
659 private void ProcessXR_angularMotorDirection()
660 {
661 vd.m_angularMotorDirection = XRvector();
662 }
663 private void ProcessXR_angularMotorTimescale()
664 {
665 vd.m_angularMotorTimescale = XRfloat();
666 }
667 private void ProcessXR_angularMotorDecayTimescale()
668 {
669 vd.m_angularMotorDecayTimescale = XRfloat();
670 }
671 private void ProcessXR_angularFrictionTimescale()
672 {
673 vd.m_angularFrictionTimescale = XRvector();
674 }
675
676 //Deflection properties
677 private void ProcessXR_angularDeflectionEfficiency()
678 {
679 vd.m_angularDeflectionEfficiency = XRfloat();
680 }
681 private void ProcessXR_angularDeflectionTimescale()
682 {
683 vd.m_angularDeflectionTimescale = XRfloat();
684 }
685 private void ProcessXR_linearDeflectionEfficiency()
686 {
687 vd.m_linearDeflectionEfficiency = XRfloat();
688 }
689 private void ProcessXR_linearDeflectionTimescale()
690 {
691 vd.m_linearDeflectionTimescale = XRfloat();
692 }
693
694 //Banking properties
695 private void ProcessXR_bankingEfficiency()
696 {
697 vd.m_bankingEfficiency = XRfloat();
698 }
699 private void ProcessXR_bankingMix()
700 {
701 vd.m_bankingMix = XRfloat();
702 }
703 private void ProcessXR_bankingTimescale()
704 {
705 vd.m_bankingTimescale = XRfloat();
706 }
707
708 //Hover and Buoyancy properties
709 private void ProcessXR_VhoverHeight()
710 {
711 vd.m_VhoverHeight = XRfloat();
712 }
713 private void ProcessXR_VhoverEfficiency()
714 {
715 vd.m_VhoverEfficiency = XRfloat();
716 }
717 private void ProcessXR_VhoverTimescale()
718 {
719 vd.m_VhoverTimescale = XRfloat();
720 }
721
722 private void ProcessXR_VehicleBuoyancy()
723 {
724 vd.m_VehicleBuoyancy = XRfloat();
725 }
726
727 //Attractor properties
728 private void ProcessXR_verticalAttractionEfficiency()
729 {
730 vd.m_verticalAttractionEfficiency = XRfloat();
731 }
732 private void ProcessXR_verticalAttractionTimescale()
733 {
734 vd.m_verticalAttractionTimescale = XRfloat();
735 }
736
737 private void ProcessXR_referenceFrame()
738 {
739 vd.m_referenceFrame = XRquat();
740 }
486 } 741 }
487} \ No newline at end of file 742} \ No newline at end of file
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
index de1dd8c..613f9b5 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
@@ -3180,6 +3180,18 @@ namespace OpenSim.Region.Framework.Scenes
3180 } 3180 }
3181 } 3181 }
3182 3182
3183 public SOPVehicle sopVehicle
3184 {
3185 get
3186 {
3187 return m_vehicle;
3188 }
3189 set
3190 {
3191 m_vehicle = value;
3192 }
3193 }
3194
3183 3195
3184 public int VehicleType 3196 public int VehicleType
3185 { 3197 {
@@ -3199,6 +3211,7 @@ namespace OpenSim.Region.Framework.Scenes
3199 public void SetVehicleType(int type) 3211 public void SetVehicleType(int type)
3200 { 3212 {
3201 m_vehicle = null; 3213 m_vehicle = null;
3214
3202 if (type == (int)Vehicle.TYPE_NONE) 3215 if (type == (int)Vehicle.TYPE_NONE)
3203 { 3216 {
3204 if (_parentID ==0 && PhysActor != null) 3217 if (_parentID ==0 && PhysActor != null)
diff --git a/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs b/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs
index 19cb9fb..9f6dabb 100644
--- a/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs
+++ b/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs
@@ -350,6 +350,11 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
350 350
351 m_SOPXmlProcessors.Add("Buoyancy", ProcessBuoyancy); 351 m_SOPXmlProcessors.Add("Buoyancy", ProcessBuoyancy);
352 m_SOPXmlProcessors.Add("VolumeDetectActive", ProcessVolumeDetectActive); 352 m_SOPXmlProcessors.Add("VolumeDetectActive", ProcessVolumeDetectActive);
353
354 //Ubit comented until proper testing
355 // m_SOPXmlProcessors.Add("Vehicle", ProcessVehicle);
356
357
353 #endregion 358 #endregion
354 359
355 #region TaskInventoryXmlProcessors initialization 360 #region TaskInventoryXmlProcessors initialization
@@ -572,6 +577,25 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
572 obj.ClickAction = (byte)reader.ReadElementContentAsInt("ClickAction", String.Empty); 577 obj.ClickAction = (byte)reader.ReadElementContentAsInt("ClickAction", String.Empty);
573 } 578 }
574 579
580 private static void ProcessVehicle(SceneObjectPart obj, XmlTextReader reader)
581 {
582 bool errors = false;
583 SOPVehicle _vehicle = new SOPVehicle();
584
585 _vehicle.FromXml2(reader, out errors);
586
587 if (errors)
588 {
589 obj.sopVehicle = null;
590 m_log.DebugFormat(
591 "[SceneObjectSerializer]: Parsing Vehicle for object part {0} {1} encountered errors. Please see earlier log entries.",
592 obj.Name, obj.UUID);
593 }
594 else
595 obj.sopVehicle = _vehicle;
596 }
597
598
575 private static void ProcessShape(SceneObjectPart obj, XmlTextReader reader) 599 private static void ProcessShape(SceneObjectPart obj, XmlTextReader reader)
576 { 600 {
577 List<string> errorNodeNames; 601 List<string> errorNodeNames;
@@ -1234,6 +1258,10 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
1234 writer.WriteElementString("Buoyancy", sop.Buoyancy.ToString()); 1258 writer.WriteElementString("Buoyancy", sop.Buoyancy.ToString());
1235 writer.WriteElementString("VolumeDetectActive", sop.VolumeDetectActive.ToString().ToLower()); 1259 writer.WriteElementString("VolumeDetectActive", sop.VolumeDetectActive.ToString().ToLower());
1236 1260
1261 //Ubit comented until proper testing
1262 // if (sop.sopVehicle != null)
1263 // sop.sopVehicle.ToXml2(writer);
1264
1237 writer.WriteEndElement(); 1265 writer.WriteEndElement();
1238 } 1266 }
1239 1267