Vehicle XML serialization more complete. Inactived by coments in SceneObjectSerializar.cs until proper testing
parent
b77d354e6d
commit
60d68ee312
|
@ -26,6 +26,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
using OpenMetaverse;
|
using OpenMetaverse;
|
||||||
using OpenSim.Framework;
|
using OpenSim.Framework;
|
||||||
using OpenSim.Region.Physics.Manager;
|
using OpenSim.Region.Physics.Manager;
|
||||||
|
@ -33,6 +34,7 @@ using System.Xml;
|
||||||
using OpenSim.Framework.Serialization;
|
using OpenSim.Framework.Serialization;
|
||||||
using OpenSim.Framework.Serialization.External;
|
using OpenSim.Framework.Serialization.External;
|
||||||
using OpenSim.Region.Framework.Scenes.Serialization;
|
using OpenSim.Region.Framework.Scenes.Serialization;
|
||||||
|
using OpenSim.Region.Framework.Scenes.Serialization;
|
||||||
|
|
||||||
namespace OpenSim.Region.Framework.Scenes
|
namespace OpenSim.Region.Framework.Scenes
|
||||||
{
|
{
|
||||||
|
@ -44,7 +46,7 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
{
|
{
|
||||||
get { return vd.m_type; }
|
get { return vd.m_type; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public SOPVehicle()
|
public SOPVehicle()
|
||||||
{
|
{
|
||||||
vd = new VehicleData();
|
vd = new VehicleData();
|
||||||
|
@ -116,8 +118,6 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
vd.m_linearDeflectionTimescale = pValue;
|
vd.m_linearDeflectionTimescale = pValue;
|
||||||
break;
|
break;
|
||||||
case Vehicle.LINEAR_MOTOR_DECAY_TIMESCALE:
|
case Vehicle.LINEAR_MOTOR_DECAY_TIMESCALE:
|
||||||
// if (pValue < timestep) pValue = timestep;
|
|
||||||
// try to make impulses to work a bit better
|
|
||||||
if (pValue < timestep) pValue = timestep;
|
if (pValue < timestep) pValue = timestep;
|
||||||
else if (pValue > 120) pValue = 120;
|
else if (pValue > 120) pValue = 120;
|
||||||
vd.m_linearMotorDecayTimescale = pValue;
|
vd.m_linearMotorDecayTimescale = pValue;
|
||||||
|
@ -439,7 +439,7 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
public void ToXml2(XmlTextWriter twriter)
|
public void ToXml2(XmlTextWriter twriter)
|
||||||
{
|
{
|
||||||
writer = twriter;
|
writer = twriter;
|
||||||
writer.WriteStartElement("SOGVehicle");
|
writer.WriteStartElement("Vehicle");
|
||||||
|
|
||||||
XWint("TYPE", (int)vd.m_type);
|
XWint("TYPE", (int)vd.m_type);
|
||||||
XWint("FLAGS", (int)vd.m_flags);
|
XWint("FLAGS", (int)vd.m_flags);
|
||||||
|
@ -483,5 +483,220 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
writer.WriteEndElement();
|
writer.WriteEndElement();
|
||||||
writer = null;
|
writer = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private int XRint(XmlTextReader reader, string name)
|
||||||
|
{
|
||||||
|
return reader.ReadElementContentAsInt(name, String.Empty);
|
||||||
|
}
|
||||||
|
|
||||||
|
private float XRfloat(XmlTextReader reader, string name)
|
||||||
|
{
|
||||||
|
return reader.ReadElementContentAsFloat(name, String.Empty);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Vector3 XRvector(XmlTextReader reader, string name)
|
||||||
|
{
|
||||||
|
Vector3 vec;
|
||||||
|
reader.ReadStartElement(name);
|
||||||
|
vec.X = reader.ReadElementContentAsFloat(reader.Name, String.Empty); // X or x
|
||||||
|
vec.Y = reader.ReadElementContentAsFloat(reader.Name, String.Empty); // Y or y
|
||||||
|
vec.Z = reader.ReadElementContentAsFloat(reader.Name, String.Empty); // Z or z
|
||||||
|
reader.ReadEndElement();
|
||||||
|
return vec;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Quaternion XRquat(XmlTextReader reader, string name)
|
||||||
|
{
|
||||||
|
Quaternion q;
|
||||||
|
reader.ReadStartElement(name);
|
||||||
|
q.X = reader.ReadElementContentAsFloat(reader.Name, String.Empty);
|
||||||
|
q.Y = reader.ReadElementContentAsFloat(reader.Name, String.Empty);
|
||||||
|
q.Z = reader.ReadElementContentAsFloat(reader.Name, String.Empty);
|
||||||
|
q.W = reader.ReadElementContentAsFloat(reader.Name, String.Empty);
|
||||||
|
reader.ReadEndElement();
|
||||||
|
return q;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void FromXml2(XmlTextReader reader, out bool errors)
|
||||||
|
{
|
||||||
|
errors = false;
|
||||||
|
|
||||||
|
Dictionary<string, Action<VehicleData, XmlTextReader>> m_VehicleXmlProcessors
|
||||||
|
= new Dictionary<string, Action<VehicleData, XmlTextReader>>();
|
||||||
|
|
||||||
|
m_VehicleXmlProcessors.Add("TYPE", ProcessXR_type);
|
||||||
|
m_VehicleXmlProcessors.Add("FLAGS", ProcessXR_flags);
|
||||||
|
|
||||||
|
// Linear properties
|
||||||
|
m_VehicleXmlProcessors.Add("LMDIR", ProcessXR_linearMotorDirection);
|
||||||
|
m_VehicleXmlProcessors.Add("LMFTIME", ProcessXR_linearFrictionTimescale);
|
||||||
|
m_VehicleXmlProcessors.Add("LMDTIME", ProcessXR_linearMotorDecayTimescale);
|
||||||
|
m_VehicleXmlProcessors.Add("LMTIME", ProcessXR_linearMotorTimescale);
|
||||||
|
m_VehicleXmlProcessors.Add("LMOFF", ProcessXR_linearMotorOffset);
|
||||||
|
|
||||||
|
//Angular properties
|
||||||
|
m_VehicleXmlProcessors.Add("AMDIR", ProcessXR_angularMotorDirection);
|
||||||
|
m_VehicleXmlProcessors.Add("AMTIME", ProcessXR_angularMotorTimescale);
|
||||||
|
m_VehicleXmlProcessors.Add("AMDTIME", ProcessXR_angularMotorDecayTimescale);
|
||||||
|
m_VehicleXmlProcessors.Add("AMFTIME", ProcessXR_angularFrictionTimescale);
|
||||||
|
|
||||||
|
//Deflection properties
|
||||||
|
m_VehicleXmlProcessors.Add("ADEFF", ProcessXR_angularDeflectionEfficiency);
|
||||||
|
m_VehicleXmlProcessors.Add("ADTIME", ProcessXR_angularDeflectionTimescale);
|
||||||
|
m_VehicleXmlProcessors.Add("LDEFF", ProcessXR_linearDeflectionEfficiency);
|
||||||
|
m_VehicleXmlProcessors.Add("LDTIME", ProcessXR_linearDeflectionTimescale);
|
||||||
|
|
||||||
|
//Banking properties
|
||||||
|
m_VehicleXmlProcessors.Add("BEFF", ProcessXR_bankingEfficiency);
|
||||||
|
m_VehicleXmlProcessors.Add("BMIX", ProcessXR_bankingMix);
|
||||||
|
m_VehicleXmlProcessors.Add("BTIME", ProcessXR_bankingTimescale);
|
||||||
|
|
||||||
|
//Hover and Buoyancy properties
|
||||||
|
m_VehicleXmlProcessors.Add("HHEI", ProcessXR_VhoverHeight);
|
||||||
|
m_VehicleXmlProcessors.Add("HEFF", ProcessXR_VhoverEfficiency);
|
||||||
|
m_VehicleXmlProcessors.Add("HTIME", ProcessXR_VhoverTimescale);
|
||||||
|
|
||||||
|
m_VehicleXmlProcessors.Add("VBUO", ProcessXR_VehicleBuoyancy);
|
||||||
|
|
||||||
|
//Attractor properties
|
||||||
|
m_VehicleXmlProcessors.Add("VAEFF", ProcessXR_verticalAttractionEfficiency);
|
||||||
|
m_VehicleXmlProcessors.Add("VATIME", ProcessXR_verticalAttractionTimescale);
|
||||||
|
|
||||||
|
m_VehicleXmlProcessors.Add("REF_FRAME", ProcessXR_referenceFrame);
|
||||||
|
|
||||||
|
vd = new VehicleData();
|
||||||
|
|
||||||
|
reader.ReadStartElement("Vehicle", String.Empty);
|
||||||
|
|
||||||
|
errors = ExternalRepresentationUtils.ExecuteReadProcessors(
|
||||||
|
vd,
|
||||||
|
m_VehicleXmlProcessors,
|
||||||
|
reader,
|
||||||
|
(o, nodeName, e)
|
||||||
|
=>
|
||||||
|
{
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
reader.ReadEndElement();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ProcessXR_type(VehicleData obj, XmlTextReader reader)
|
||||||
|
{
|
||||||
|
vd.m_type = (Vehicle)XRint(reader, "TYPE");
|
||||||
|
}
|
||||||
|
private void ProcessXR_flags(VehicleData obj, XmlTextReader reader)
|
||||||
|
{
|
||||||
|
vd.m_flags = (VehicleFlag)XRint(reader, "FLAGS");
|
||||||
|
}
|
||||||
|
// Linear properties
|
||||||
|
private void ProcessXR_linearMotorDirection(VehicleData obj, XmlTextReader reader)
|
||||||
|
{
|
||||||
|
vd.m_linearMotorDirection = XRvector(reader, "LMDIR");
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ProcessXR_linearFrictionTimescale(VehicleData obj, XmlTextReader reader)
|
||||||
|
{
|
||||||
|
vd.m_linearFrictionTimescale = XRvector(reader, "LMFTIME");
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ProcessXR_linearMotorDecayTimescale(VehicleData obj, XmlTextReader reader)
|
||||||
|
{
|
||||||
|
vd.m_linearMotorDecayTimescale = XRfloat(reader, "LMDTIME");
|
||||||
|
}
|
||||||
|
private void ProcessXR_linearMotorTimescale(VehicleData obj, XmlTextReader reader)
|
||||||
|
{
|
||||||
|
vd.m_linearMotorTimescale = XRfloat(reader, "LMTIME");
|
||||||
|
}
|
||||||
|
private void ProcessXR_linearMotorOffset(VehicleData obj, XmlTextReader reader)
|
||||||
|
{
|
||||||
|
vd.m_linearMotorOffset = XRvector(reader, "LMOFF");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//Angular properties
|
||||||
|
private void ProcessXR_angularMotorDirection(VehicleData obj, XmlTextReader reader)
|
||||||
|
{
|
||||||
|
vd.m_angularMotorDirection = XRvector(reader, "AMDIR");
|
||||||
|
}
|
||||||
|
private void ProcessXR_angularMotorTimescale(VehicleData obj, XmlTextReader reader)
|
||||||
|
{
|
||||||
|
vd.m_angularMotorTimescale = XRfloat(reader, "AMTIME");
|
||||||
|
}
|
||||||
|
private void ProcessXR_angularMotorDecayTimescale(VehicleData obj, XmlTextReader reader)
|
||||||
|
{
|
||||||
|
vd.m_angularMotorDecayTimescale = XRfloat(reader, "AMDTIME");
|
||||||
|
}
|
||||||
|
private void ProcessXR_angularFrictionTimescale(VehicleData obj, XmlTextReader reader)
|
||||||
|
{
|
||||||
|
vd.m_angularFrictionTimescale = XRvector(reader, "AMFTIME");
|
||||||
|
}
|
||||||
|
|
||||||
|
//Deflection properties
|
||||||
|
private void ProcessXR_angularDeflectionEfficiency(VehicleData obj, XmlTextReader reader)
|
||||||
|
{
|
||||||
|
vd.m_angularDeflectionEfficiency = XRfloat(reader, "ADEFF");
|
||||||
|
}
|
||||||
|
private void ProcessXR_angularDeflectionTimescale(VehicleData obj, XmlTextReader reader)
|
||||||
|
{
|
||||||
|
vd.m_angularDeflectionTimescale = XRfloat(reader, "ADTIME");
|
||||||
|
}
|
||||||
|
private void ProcessXR_linearDeflectionEfficiency(VehicleData obj, XmlTextReader reader)
|
||||||
|
{
|
||||||
|
vd.m_linearDeflectionEfficiency = XRfloat(reader, "LDEFF");
|
||||||
|
}
|
||||||
|
private void ProcessXR_linearDeflectionTimescale(VehicleData obj, XmlTextReader reader)
|
||||||
|
{
|
||||||
|
vd.m_linearDeflectionTimescale = XRfloat(reader, "LDTIME");
|
||||||
|
}
|
||||||
|
|
||||||
|
//Banking properties
|
||||||
|
private void ProcessXR_bankingEfficiency(VehicleData obj, XmlTextReader reader)
|
||||||
|
{
|
||||||
|
vd.m_bankingEfficiency = XRfloat(reader, "BEFF");
|
||||||
|
}
|
||||||
|
private void ProcessXR_bankingMix(VehicleData obj, XmlTextReader reader)
|
||||||
|
{
|
||||||
|
vd.m_bankingMix = XRfloat(reader, "BMIX");
|
||||||
|
}
|
||||||
|
private void ProcessXR_bankingTimescale(VehicleData obj, XmlTextReader reader)
|
||||||
|
{
|
||||||
|
vd.m_bankingTimescale = XRfloat(reader, "BTIME");
|
||||||
|
}
|
||||||
|
|
||||||
|
//Hover and Buoyancy properties
|
||||||
|
private void ProcessXR_VhoverHeight(VehicleData obj, XmlTextReader reader)
|
||||||
|
{
|
||||||
|
vd.m_VhoverHeight = XRfloat(reader, "HHEI");
|
||||||
|
}
|
||||||
|
private void ProcessXR_VhoverEfficiency(VehicleData obj, XmlTextReader reader)
|
||||||
|
{
|
||||||
|
vd.m_VhoverEfficiency = XRfloat(reader, "HEFF");
|
||||||
|
}
|
||||||
|
private void ProcessXR_VhoverTimescale(VehicleData obj, XmlTextReader reader)
|
||||||
|
{
|
||||||
|
vd.m_VhoverTimescale = XRfloat(reader, "HTIME");
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ProcessXR_VehicleBuoyancy(VehicleData obj, XmlTextReader reader)
|
||||||
|
{
|
||||||
|
vd.m_VehicleBuoyancy = XRfloat(reader, "VBUO");
|
||||||
|
}
|
||||||
|
|
||||||
|
//Attractor properties
|
||||||
|
private void ProcessXR_verticalAttractionEfficiency(VehicleData obj, XmlTextReader reader)
|
||||||
|
{
|
||||||
|
vd.m_verticalAttractionEfficiency = XRfloat(reader, "VAEFF");
|
||||||
|
}
|
||||||
|
private void ProcessXR_verticalAttractionTimescale(VehicleData obj, XmlTextReader reader)
|
||||||
|
{
|
||||||
|
vd.m_verticalAttractionTimescale = XRfloat(reader, "VATIME");
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ProcessXR_referenceFrame(VehicleData obj, XmlTextReader reader)
|
||||||
|
{
|
||||||
|
vd.m_referenceFrame = XRquat(reader, "REF_FRAME");
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -3177,6 +3177,18 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public SOPVehicle sopVehicle
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return m_vehicle;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
m_vehicle = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public int VehicleType
|
public int VehicleType
|
||||||
{
|
{
|
||||||
|
@ -3196,6 +3208,7 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
public void SetVehicleType(int type)
|
public void SetVehicleType(int type)
|
||||||
{
|
{
|
||||||
m_vehicle = null;
|
m_vehicle = null;
|
||||||
|
|
||||||
if (type == (int)Vehicle.TYPE_NONE)
|
if (type == (int)Vehicle.TYPE_NONE)
|
||||||
{
|
{
|
||||||
if (_parentID ==0 && PhysActor != null)
|
if (_parentID ==0 && PhysActor != null)
|
||||||
|
|
|
@ -349,6 +349,11 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
|
||||||
|
|
||||||
m_SOPXmlProcessors.Add("Buoyancy", ProcessBuoyancy);
|
m_SOPXmlProcessors.Add("Buoyancy", ProcessBuoyancy);
|
||||||
m_SOPXmlProcessors.Add("VolumeDetectActive", ProcessVolumeDetectActive);
|
m_SOPXmlProcessors.Add("VolumeDetectActive", ProcessVolumeDetectActive);
|
||||||
|
|
||||||
|
//Ubit comented until proper testing
|
||||||
|
// m_SOPXmlProcessors.Add("Vehicle", ProcessVehicle);
|
||||||
|
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region TaskInventoryXmlProcessors initialization
|
#region TaskInventoryXmlProcessors initialization
|
||||||
|
@ -571,6 +576,25 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
|
||||||
obj.ClickAction = (byte)reader.ReadElementContentAsInt("ClickAction", String.Empty);
|
obj.ClickAction = (byte)reader.ReadElementContentAsInt("ClickAction", String.Empty);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void ProcessVehicle(SceneObjectPart obj, XmlTextReader reader)
|
||||||
|
{
|
||||||
|
bool errors = false;
|
||||||
|
SOPVehicle _vehicle = new SOPVehicle();
|
||||||
|
|
||||||
|
_vehicle.FromXml2(reader, out errors);
|
||||||
|
|
||||||
|
if (errors)
|
||||||
|
{
|
||||||
|
obj.sopVehicle = null;
|
||||||
|
m_log.DebugFormat(
|
||||||
|
"[SceneObjectSerializer]: Parsing Vehicle for object part {0} {1} encountered errors. Please see earlier log entries.",
|
||||||
|
obj.Name, obj.UUID);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
obj.sopVehicle = _vehicle;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
private static void ProcessShape(SceneObjectPart obj, XmlTextReader reader)
|
private static void ProcessShape(SceneObjectPart obj, XmlTextReader reader)
|
||||||
{
|
{
|
||||||
bool errors = false;
|
bool errors = false;
|
||||||
|
@ -1231,6 +1255,10 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
|
||||||
writer.WriteElementString("Buoyancy", sop.Buoyancy.ToString());
|
writer.WriteElementString("Buoyancy", sop.Buoyancy.ToString());
|
||||||
writer.WriteElementString("VolumeDetectActive", sop.VolumeDetectActive.ToString().ToLower());
|
writer.WriteElementString("VolumeDetectActive", sop.VolumeDetectActive.ToString().ToLower());
|
||||||
|
|
||||||
|
//Ubit comented until proper testing
|
||||||
|
// if (sop.sopVehicle != null)
|
||||||
|
// sop.sopVehicle.ToXml2(writer);
|
||||||
|
|
||||||
writer.WriteEndElement();
|
writer.WriteEndElement();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue