diff options
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/SOPVehicle.cs')
-rw-r--r-- | OpenSim/Region/Framework/Scenes/SOPVehicle.cs | 223 |
1 files changed, 219 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 | ||
28 | using System; | 28 | using System; |
29 | using System.Collections.Generic; | ||
29 | using OpenMetaverse; | 30 | using OpenMetaverse; |
30 | using OpenSim.Framework; | 31 | using OpenSim.Framework; |
31 | using OpenSim.Region.Physics.Manager; | 32 | using OpenSim.Region.Physics.Manager; |
@@ -33,6 +34,7 @@ using System.Xml; | |||
33 | using OpenSim.Framework.Serialization; | 34 | using OpenSim.Framework.Serialization; |
34 | using OpenSim.Framework.Serialization.External; | 35 | using OpenSim.Framework.Serialization.External; |
35 | using OpenSim.Region.Framework.Scenes.Serialization; | 36 | using OpenSim.Region.Framework.Scenes.Serialization; |
37 | using OpenSim.Region.Framework.Scenes.Serialization; | ||
36 | 38 | ||
37 | namespace OpenSim.Region.Framework.Scenes | 39 | namespace 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 |