2009-05-08 15:47:59 +00:00
/ *
* Copyright ( c ) Contributors , http : //opensimulator.org/
* See CONTRIBUTORS . TXT for a full list of copyright holders .
*
* Redistribution and use in source and binary forms , with or without
* modification , are permitted provided that the following conditions are met :
* * Redistributions of source code must retain the above copyright
* notice , this list of conditions and the following disclaimer .
* * Redistributions in binary form must reproduce the above copyright
* notice , this list of conditions and the following disclaimer in the
* documentation and / or other materials provided with the distribution .
2009-06-01 06:37:14 +00:00
* * Neither the name of the OpenSimulator Project nor the
2009-05-08 15:47:59 +00:00
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission .
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ` ` AS IS ' ' AND ANY
* EXPRESS OR IMPLIED WARRANTIES , INCLUDING , BUT NOT LIMITED TO , THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED . IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT , INDIRECT , INCIDENTAL , SPECIAL , EXEMPLARY , OR CONSEQUENTIAL DAMAGES
* ( INCLUDING , BUT NOT LIMITED TO , PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES ;
* LOSS OF USE , DATA , OR PROFITS ; OR BUSINESS INTERRUPTION ) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY , WHETHER IN CONTRACT , STRICT LIABILITY , OR TORT
* ( INCLUDING NEGLIGENCE OR OTHERWISE ) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE , EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE .
* /
using System ;
2010-10-13 15:16:41 +00:00
using System.Collections.Generic ;
using System.Drawing ;
2009-05-08 15:47:59 +00:00
using System.IO ;
using System.Reflection ;
using System.Xml ;
using log4net ;
using OpenMetaverse ;
2009-05-14 16:33:04 +00:00
using OpenSim.Framework ;
2010-11-21 21:16:52 +00:00
using OpenSim.Region.Framework.Interfaces ;
2009-05-08 15:47:59 +00:00
using OpenSim.Region.Framework.Scenes ;
namespace OpenSim.Region.Framework.Scenes.Serialization
{
/// <summary>
/// Serialize and deserialize scene objects.
/// </summary>
/// This should really be in OpenSim.Framework.Serialization but this would mean circular dependency problems
/// right now - hopefully this isn't forever.
public class SceneObjectSerializer
{
private static readonly ILog m_log = LogManager . GetLogger ( MethodBase . GetCurrentMethod ( ) . DeclaringType ) ;
2010-11-21 21:16:52 +00:00
private static IUserManagement m_UserManagement ;
2009-05-08 15:47:59 +00:00
/// <summary>
/// Deserialize a scene object from the original xml format
/// </summary>
/// <param name="serialization"></param>
/// <returns></returns>
2009-05-08 16:44:00 +00:00
public static SceneObjectGroup FromOriginalXmlFormat ( string serialization )
2009-05-08 15:47:59 +00:00
{
2009-05-08 16:44:00 +00:00
return FromOriginalXmlFormat ( UUID . Zero , serialization ) ;
2009-05-08 15:47:59 +00:00
}
/// <summary>
/// Deserialize a scene object from the original xml format
/// </summary>
/// <param name="serialization"></param>
/// <returns></returns>
2009-05-08 19:18:37 +00:00
public static SceneObjectGroup FromOriginalXmlFormat ( UUID fromUserInventoryItemID , string xmlData )
2009-05-08 15:47:59 +00:00
{
//m_log.DebugFormat("[SOG]: Starting deserialization of SOG");
//int time = System.Environment.TickCount;
try
{
StringReader sr ;
XmlTextReader reader ;
XmlNodeList parts ;
XmlDocument doc ;
int linkNum ;
doc = new XmlDocument ( ) ;
2009-05-08 19:18:37 +00:00
doc . LoadXml ( xmlData ) ;
2009-05-08 15:47:59 +00:00
parts = doc . GetElementsByTagName ( "RootPart" ) ;
if ( parts . Count = = 0 )
throw new Exception ( "Invalid Xml format - no root part" ) ;
2009-09-16 22:06:08 +00:00
sr = new StringReader ( parts [ 0 ] . InnerXml ) ;
reader = new XmlTextReader ( sr ) ;
SceneObjectGroup sceneObject = new SceneObjectGroup ( SceneObjectPart . FromXml ( fromUserInventoryItemID , reader ) ) ;
reader . Close ( ) ;
sr . Close ( ) ;
2009-05-08 15:47:59 +00:00
parts = doc . GetElementsByTagName ( "Part" ) ;
for ( int i = 0 ; i < parts . Count ; i + + )
{
sr = new StringReader ( parts [ i ] . InnerXml ) ;
reader = new XmlTextReader ( sr ) ;
SceneObjectPart part = SceneObjectPart . FromXml ( reader ) ;
linkNum = part . LinkNum ;
2009-05-08 18:05:54 +00:00
sceneObject . AddPart ( part ) ;
2009-05-08 15:47:59 +00:00
part . LinkNum = linkNum ;
part . TrimPermissions ( ) ;
part . StoreUndoState ( ) ;
reader . Close ( ) ;
sr . Close ( ) ;
}
// Script state may, or may not, exist. Not having any, is NOT
// ever a problem.
2009-05-08 18:05:54 +00:00
sceneObject . LoadScriptState ( doc ) ;
2009-09-16 22:06:08 +00:00
return sceneObject ;
2009-05-08 15:47:59 +00:00
}
catch ( Exception e )
{
m_log . ErrorFormat (
2009-05-08 19:18:37 +00:00
"[SERIALIZER]: Deserialization of xml failed with {0}. xml was {1}" , e , xmlData ) ;
2009-09-16 22:06:08 +00:00
return null ;
2009-05-08 15:47:59 +00:00
}
2009-09-30 16:00:09 +00:00
}
2009-05-08 18:05:54 +00:00
2010-10-17 17:35:38 +00:00
2009-05-08 19:18:37 +00:00
/// <summary>
2009-05-14 18:08:54 +00:00
/// Serialize a scene object to the original xml format
2009-05-08 19:18:37 +00:00
/// </summary>
2009-05-14 18:08:54 +00:00
/// <param name="sceneObject"></param>
2009-09-30 16:00:09 +00:00
/// <returns></returns>
2009-05-14 18:08:54 +00:00
public static string ToOriginalXmlFormat ( SceneObjectGroup sceneObject )
{
using ( StringWriter sw = new StringWriter ( ) )
{
using ( XmlTextWriter writer = new XmlTextWriter ( sw ) )
{
ToOriginalXmlFormat ( sceneObject , writer ) ;
}
return sw . ToString ( ) ;
}
2009-09-30 16:00:09 +00:00
}
2011-04-13 20:17:43 +00:00
2009-05-14 18:08:54 +00:00
/// <summary>
/// Serialize a scene object to the original xml format
/// </summary>
/// <param name="sceneObject"></param>
2009-09-30 16:00:09 +00:00
/// <returns></returns>
2009-05-14 18:08:54 +00:00
public static void ToOriginalXmlFormat ( SceneObjectGroup sceneObject , XmlTextWriter writer )
2011-04-13 20:17:43 +00:00
{
ToOriginalXmlFormat ( sceneObject , writer , false ) ;
}
/// <summary>
/// Serialize a scene object to the original xml format
/// </summary>
/// <param name="sceneObject"></param>
/// <param name="writer"></param>
/// <param name="noRootElement">If false, don't write the enclosing SceneObjectGroup element</param>
/// <returns></returns>
public static void ToOriginalXmlFormat ( SceneObjectGroup sceneObject , XmlTextWriter writer , bool noRootElement )
2009-05-14 18:08:54 +00:00
{
//m_log.DebugFormat("[SERIALIZER]: Starting serialization of {0}", Name);
//int time = System.Environment.TickCount;
2011-04-13 20:17:43 +00:00
if ( ! noRootElement )
writer . WriteStartElement ( String . Empty , "SceneObjectGroup" , String . Empty ) ;
2009-05-14 18:08:54 +00:00
writer . WriteStartElement ( String . Empty , "RootPart" , String . Empty ) ;
2010-10-17 17:41:38 +00:00
ToXmlFormat ( sceneObject . RootPart , writer ) ;
2009-05-14 18:08:54 +00:00
writer . WriteEndElement ( ) ;
writer . WriteStartElement ( String . Empty , "OtherParts" , String . Empty ) ;
2010-09-17 00:30:46 +00:00
SceneObjectPart [ ] parts = sceneObject . Parts ;
for ( int i = 0 ; i < parts . Length ; i + + )
2009-05-14 18:08:54 +00:00
{
2010-09-17 00:30:46 +00:00
SceneObjectPart part = parts [ i ] ;
if ( part . UUID ! = sceneObject . RootPart . UUID )
2009-05-14 18:08:54 +00:00
{
2010-09-17 00:30:46 +00:00
writer . WriteStartElement ( String . Empty , "Part" , String . Empty ) ;
2010-10-17 17:41:38 +00:00
ToXmlFormat ( part , writer ) ;
2010-09-17 00:30:46 +00:00
writer . WriteEndElement ( ) ;
2009-05-14 18:08:54 +00:00
}
}
writer . WriteEndElement ( ) ; // OtherParts
sceneObject . SaveScriptedState ( writer ) ;
2011-04-13 20:17:43 +00:00
if ( ! noRootElement )
writer . WriteEndElement ( ) ; // SceneObjectGroup
2009-05-14 18:08:54 +00:00
//m_log.DebugFormat("[SERIALIZER]: Finished serialization of SOG {0}, {1}ms", Name, System.Environment.TickCount - time);
2011-04-13 20:17:43 +00:00
}
2009-06-05 18:44:44 +00:00
2010-10-17 17:41:38 +00:00
protected static void ToXmlFormat ( SceneObjectPart part , XmlTextWriter writer )
2009-06-05 18:44:44 +00:00
{
2010-10-17 17:35:38 +00:00
SOPToXml2 ( writer , part , new Dictionary < string , object > ( ) ) ;
2009-06-05 18:44:44 +00:00
}
2009-05-14 18:08:54 +00:00
2009-05-08 19:18:37 +00:00
public static SceneObjectGroup FromXml2Format ( string xmlData )
{
//m_log.DebugFormat("[SOG]: Starting deserialization of SOG");
//int time = System.Environment.TickCount;
try
{
XmlDocument doc = new XmlDocument ( ) ;
doc . LoadXml ( xmlData ) ;
XmlNodeList parts = doc . GetElementsByTagName ( "SceneObjectPart" ) ;
2009-09-16 22:06:08 +00:00
if ( parts . Count = = 0 )
2009-05-08 19:18:37 +00:00
{
2009-09-16 22:06:08 +00:00
m_log . ErrorFormat ( "[SERIALIZER]: Deserialization of xml failed: No SceneObjectPart nodes. xml was " + xmlData ) ;
return null ;
2009-05-08 19:18:37 +00:00
}
2009-09-16 22:06:08 +00:00
StringReader sr = new StringReader ( parts [ 0 ] . OuterXml ) ;
XmlTextReader reader = new XmlTextReader ( sr ) ;
SceneObjectGroup sceneObject = new SceneObjectGroup ( SceneObjectPart . FromXml ( reader ) ) ;
reader . Close ( ) ;
sr . Close ( ) ;
2009-05-08 19:18:37 +00:00
// Then deal with the rest
for ( int i = 1 ; i < parts . Count ; i + + )
{
2009-09-16 22:06:08 +00:00
sr = new StringReader ( parts [ i ] . OuterXml ) ;
reader = new XmlTextReader ( sr ) ;
2009-05-08 19:18:37 +00:00
SceneObjectPart part = SceneObjectPart . FromXml ( reader ) ;
2010-06-12 06:29:20 +00:00
int originalLinkNum = part . LinkNum ;
2009-05-08 19:18:37 +00:00
sceneObject . AddPart ( part ) ;
2010-06-12 06:29:20 +00:00
2011-04-20 21:59:06 +00:00
//DSG SYNC
2010-12-27 20:15:39 +00:00
//KittyL: 12/27/2010, added ActorID for symmetric synch model
2011-01-04 22:19:44 +00:00
//part.SetLastUpdateActorID();
2010-12-27 20:15:39 +00:00
2010-06-12 06:29:20 +00:00
// SceneObjectGroup.AddPart() tries to be smart and automatically set the LinkNum.
// We override that here
if ( originalLinkNum ! = 0 )
part . LinkNum = originalLinkNum ;
2009-05-08 19:18:37 +00:00
part . StoreUndoState ( ) ;
reader . Close ( ) ;
sr . Close ( ) ;
}
// Script state may, or may not, exist. Not having any, is NOT
// ever a problem.
sceneObject . LoadScriptState ( doc ) ;
2009-09-16 22:06:08 +00:00
return sceneObject ;
2009-05-08 19:18:37 +00:00
}
catch ( Exception e )
{
m_log . ErrorFormat ( "[SERIALIZER]: Deserialization of xml failed with {0}. xml was {1}" , e , xmlData ) ;
2009-09-16 22:06:08 +00:00
return null ;
2009-05-08 19:18:37 +00:00
}
2009-09-30 16:00:09 +00:00
}
2009-05-08 19:18:37 +00:00
2009-05-08 18:05:54 +00:00
/// <summary>
2009-05-14 18:08:54 +00:00
/// Serialize a scene object to the 'xml2' format.
2009-05-08 18:05:54 +00:00
/// </summary>
/// <param name="sceneObject"></param>
2009-09-30 16:00:09 +00:00
/// <returns></returns>
2009-05-14 18:08:54 +00:00
public static string ToXml2Format ( SceneObjectGroup sceneObject )
2009-05-08 18:05:54 +00:00
{
using ( StringWriter sw = new StringWriter ( ) )
{
using ( XmlTextWriter writer = new XmlTextWriter ( sw ) )
{
2010-10-17 17:35:38 +00:00
SOGToXml2 ( writer , sceneObject , new Dictionary < string , object > ( ) ) ;
2009-05-08 18:05:54 +00:00
}
return sw . ToString ( ) ;
}
2009-05-14 18:08:54 +00:00
}
2009-05-08 18:05:54 +00:00
2010-10-13 15:16:41 +00:00
#region manual serialization
private delegate void SOPXmlProcessor ( SceneObjectPart sop , XmlTextReader reader ) ;
private static Dictionary < string , SOPXmlProcessor > m_SOPXmlProcessors = new Dictionary < string , SOPXmlProcessor > ( ) ;
private delegate void TaskInventoryXmlProcessor ( TaskInventoryItem item , XmlTextReader reader ) ;
private static Dictionary < string , TaskInventoryXmlProcessor > m_TaskInventoryXmlProcessors = new Dictionary < string , TaskInventoryXmlProcessor > ( ) ;
private delegate void ShapeXmlProcessor ( PrimitiveBaseShape shape , XmlTextReader reader ) ;
private static Dictionary < string , ShapeXmlProcessor > m_ShapeXmlProcessors = new Dictionary < string , ShapeXmlProcessor > ( ) ;
static SceneObjectSerializer ( )
{
#region SOPXmlProcessors initialization
m_SOPXmlProcessors . Add ( "AllowedDrop" , ProcessAllowedDrop ) ;
m_SOPXmlProcessors . Add ( "CreatorID" , ProcessCreatorID ) ;
2010-11-21 21:16:52 +00:00
m_SOPXmlProcessors . Add ( "CreatorData" , ProcessCreatorData ) ;
2010-10-13 15:16:41 +00:00
m_SOPXmlProcessors . Add ( "FolderID" , ProcessFolderID ) ;
m_SOPXmlProcessors . Add ( "InventorySerial" , ProcessInventorySerial ) ;
m_SOPXmlProcessors . Add ( "TaskInventory" , ProcessTaskInventory ) ;
m_SOPXmlProcessors . Add ( "UUID" , ProcessUUID ) ;
m_SOPXmlProcessors . Add ( "LocalId" , ProcessLocalId ) ;
m_SOPXmlProcessors . Add ( "Name" , ProcessName ) ;
m_SOPXmlProcessors . Add ( "Material" , ProcessMaterial ) ;
m_SOPXmlProcessors . Add ( "PassTouches" , ProcessPassTouches ) ;
m_SOPXmlProcessors . Add ( "RegionHandle" , ProcessRegionHandle ) ;
m_SOPXmlProcessors . Add ( "ScriptAccessPin" , ProcessScriptAccessPin ) ;
m_SOPXmlProcessors . Add ( "GroupPosition" , ProcessGroupPosition ) ;
m_SOPXmlProcessors . Add ( "OffsetPosition" , ProcessOffsetPosition ) ;
m_SOPXmlProcessors . Add ( "RotationOffset" , ProcessRotationOffset ) ;
m_SOPXmlProcessors . Add ( "Velocity" , ProcessVelocity ) ;
m_SOPXmlProcessors . Add ( "AngularVelocity" , ProcessAngularVelocity ) ;
m_SOPXmlProcessors . Add ( "Acceleration" , ProcessAcceleration ) ;
m_SOPXmlProcessors . Add ( "Description" , ProcessDescription ) ;
m_SOPXmlProcessors . Add ( "Color" , ProcessColor ) ;
m_SOPXmlProcessors . Add ( "Text" , ProcessText ) ;
m_SOPXmlProcessors . Add ( "SitName" , ProcessSitName ) ;
m_SOPXmlProcessors . Add ( "TouchName" , ProcessTouchName ) ;
m_SOPXmlProcessors . Add ( "LinkNum" , ProcessLinkNum ) ;
m_SOPXmlProcessors . Add ( "ClickAction" , ProcessClickAction ) ;
m_SOPXmlProcessors . Add ( "Shape" , ProcessShape ) ;
m_SOPXmlProcessors . Add ( "Scale" , ProcessScale ) ;
m_SOPXmlProcessors . Add ( "UpdateFlag" , ProcessUpdateFlag ) ;
m_SOPXmlProcessors . Add ( "SitTargetOrientation" , ProcessSitTargetOrientation ) ;
m_SOPXmlProcessors . Add ( "SitTargetPosition" , ProcessSitTargetPosition ) ;
m_SOPXmlProcessors . Add ( "SitTargetPositionLL" , ProcessSitTargetPositionLL ) ;
m_SOPXmlProcessors . Add ( "SitTargetOrientationLL" , ProcessSitTargetOrientationLL ) ;
m_SOPXmlProcessors . Add ( "ParentID" , ProcessParentID ) ;
m_SOPXmlProcessors . Add ( "CreationDate" , ProcessCreationDate ) ;
m_SOPXmlProcessors . Add ( "Category" , ProcessCategory ) ;
m_SOPXmlProcessors . Add ( "SalePrice" , ProcessSalePrice ) ;
m_SOPXmlProcessors . Add ( "ObjectSaleType" , ProcessObjectSaleType ) ;
m_SOPXmlProcessors . Add ( "OwnershipCost" , ProcessOwnershipCost ) ;
m_SOPXmlProcessors . Add ( "GroupID" , ProcessGroupID ) ;
m_SOPXmlProcessors . Add ( "OwnerID" , ProcessOwnerID ) ;
m_SOPXmlProcessors . Add ( "LastOwnerID" , ProcessLastOwnerID ) ;
m_SOPXmlProcessors . Add ( "BaseMask" , ProcessBaseMask ) ;
m_SOPXmlProcessors . Add ( "OwnerMask" , ProcessOwnerMask ) ;
m_SOPXmlProcessors . Add ( "GroupMask" , ProcessGroupMask ) ;
m_SOPXmlProcessors . Add ( "EveryoneMask" , ProcessEveryoneMask ) ;
m_SOPXmlProcessors . Add ( "NextOwnerMask" , ProcessNextOwnerMask ) ;
m_SOPXmlProcessors . Add ( "Flags" , ProcessFlags ) ;
m_SOPXmlProcessors . Add ( "CollisionSound" , ProcessCollisionSound ) ;
m_SOPXmlProcessors . Add ( "CollisionSoundVolume" , ProcessCollisionSoundVolume ) ;
2010-10-13 22:44:25 +00:00
m_SOPXmlProcessors . Add ( "MediaUrl" , ProcessMediaUrl ) ;
2010-10-19 07:04:02 +00:00
m_SOPXmlProcessors . Add ( "TextureAnimation" , ProcessTextureAnimation ) ;
m_SOPXmlProcessors . Add ( "ParticleSystem" , ProcessParticleSystem ) ;
2010-12-27 20:15:39 +00:00
2011-05-04 21:36:18 +00:00
/ *
2011-04-20 21:59:06 +00:00
//DSG SYNC
2011-03-07 23:51:59 +00:00
m_SOPXmlProcessors . Add ( "LocalFlags" , ProcessLocalFlags ) ;
2011-02-04 01:21:00 +00:00
//m_SOPXmlProcessors.Add("LastUpdateTimeStamp", ProcessUpdateTimeStamp);
//m_SOPXmlProcessors.Add("LastUpdateActorID", ProcessLastUpdateActorID);
2011-02-16 22:29:08 +00:00
m_SOPXmlProcessors . Add ( "IsAttachment" , ProcessIsAttachment ) ;
m_SOPXmlProcessors . Add ( "AttachedAvatar" , ProcessAttachedAvatar ) ;
m_SOPXmlProcessors . Add ( "AttachedPos" , ProcessAttachedPos ) ;
m_SOPXmlProcessors . Add ( "AttachmentPoint" , ProcessAttachmentPoint ) ;
m_SOPXmlProcessors . Add ( "AggregateScriptEvents" , ProcessAggregateScriptEvents ) ;
2011-02-03 20:01:08 +00:00
m_SOPXmlProcessors . Add ( "BucketSyncInfoList" , ProcessBucketSyncInfo ) ;
2011-04-20 21:59:06 +00:00
//end of DSG SYNC
2011-05-04 21:36:18 +00:00
* * /
2010-12-27 20:15:39 +00:00
2010-10-13 15:16:41 +00:00
# endregion
#region TaskInventoryXmlProcessors initialization
m_TaskInventoryXmlProcessors . Add ( "AssetID" , ProcessTIAssetID ) ;
m_TaskInventoryXmlProcessors . Add ( "BasePermissions" , ProcessTIBasePermissions ) ;
m_TaskInventoryXmlProcessors . Add ( "CreationDate" , ProcessTICreationDate ) ;
m_TaskInventoryXmlProcessors . Add ( "CreatorID" , ProcessTICreatorID ) ;
2010-11-22 01:19:24 +00:00
m_TaskInventoryXmlProcessors . Add ( "CreatorData" , ProcessTICreatorData ) ;
2010-10-13 15:16:41 +00:00
m_TaskInventoryXmlProcessors . Add ( "Description" , ProcessTIDescription ) ;
m_TaskInventoryXmlProcessors . Add ( "EveryonePermissions" , ProcessTIEveryonePermissions ) ;
m_TaskInventoryXmlProcessors . Add ( "Flags" , ProcessTIFlags ) ;
m_TaskInventoryXmlProcessors . Add ( "GroupID" , ProcessTIGroupID ) ;
m_TaskInventoryXmlProcessors . Add ( "GroupPermissions" , ProcessTIGroupPermissions ) ;
m_TaskInventoryXmlProcessors . Add ( "InvType" , ProcessTIInvType ) ;
m_TaskInventoryXmlProcessors . Add ( "ItemID" , ProcessTIItemID ) ;
m_TaskInventoryXmlProcessors . Add ( "OldItemID" , ProcessTIOldItemID ) ;
m_TaskInventoryXmlProcessors . Add ( "LastOwnerID" , ProcessTILastOwnerID ) ;
m_TaskInventoryXmlProcessors . Add ( "Name" , ProcessTIName ) ;
m_TaskInventoryXmlProcessors . Add ( "NextPermissions" , ProcessTINextPermissions ) ;
m_TaskInventoryXmlProcessors . Add ( "OwnerID" , ProcessTIOwnerID ) ;
m_TaskInventoryXmlProcessors . Add ( "CurrentPermissions" , ProcessTICurrentPermissions ) ;
m_TaskInventoryXmlProcessors . Add ( "ParentID" , ProcessTIParentID ) ;
m_TaskInventoryXmlProcessors . Add ( "ParentPartID" , ProcessTIParentPartID ) ;
m_TaskInventoryXmlProcessors . Add ( "PermsGranter" , ProcessTIPermsGranter ) ;
m_TaskInventoryXmlProcessors . Add ( "PermsMask" , ProcessTIPermsMask ) ;
m_TaskInventoryXmlProcessors . Add ( "Type" , ProcessTIType ) ;
2010-10-17 17:35:38 +00:00
m_TaskInventoryXmlProcessors . Add ( "OwnerChanged" , ProcessTIOwnerChanged ) ;
2010-10-13 15:16:41 +00:00
# endregion
#region ShapeXmlProcessors initialization
m_ShapeXmlProcessors . Add ( "ProfileCurve" , ProcessShpProfileCurve ) ;
m_ShapeXmlProcessors . Add ( "TextureEntry" , ProcessShpTextureEntry ) ;
m_ShapeXmlProcessors . Add ( "ExtraParams" , ProcessShpExtraParams ) ;
m_ShapeXmlProcessors . Add ( "PathBegin" , ProcessShpPathBegin ) ;
m_ShapeXmlProcessors . Add ( "PathCurve" , ProcessShpPathCurve ) ;
m_ShapeXmlProcessors . Add ( "PathEnd" , ProcessShpPathEnd ) ;
m_ShapeXmlProcessors . Add ( "PathRadiusOffset" , ProcessShpPathRadiusOffset ) ;
m_ShapeXmlProcessors . Add ( "PathRevolutions" , ProcessShpPathRevolutions ) ;
m_ShapeXmlProcessors . Add ( "PathScaleX" , ProcessShpPathScaleX ) ;
m_ShapeXmlProcessors . Add ( "PathScaleY" , ProcessShpPathScaleY ) ;
m_ShapeXmlProcessors . Add ( "PathShearX" , ProcessShpPathShearX ) ;
m_ShapeXmlProcessors . Add ( "PathShearY" , ProcessShpPathShearY ) ;
m_ShapeXmlProcessors . Add ( "PathSkew" , ProcessShpPathSkew ) ;
m_ShapeXmlProcessors . Add ( "PathTaperX" , ProcessShpPathTaperX ) ;
m_ShapeXmlProcessors . Add ( "PathTaperY" , ProcessShpPathTaperY ) ;
m_ShapeXmlProcessors . Add ( "PathTwist" , ProcessShpPathTwist ) ;
m_ShapeXmlProcessors . Add ( "PathTwistBegin" , ProcessShpPathTwistBegin ) ;
m_ShapeXmlProcessors . Add ( "PCode" , ProcessShpPCode ) ;
m_ShapeXmlProcessors . Add ( "ProfileBegin" , ProcessShpProfileBegin ) ;
m_ShapeXmlProcessors . Add ( "ProfileEnd" , ProcessShpProfileEnd ) ;
m_ShapeXmlProcessors . Add ( "ProfileHollow" , ProcessShpProfileHollow ) ;
m_ShapeXmlProcessors . Add ( "Scale" , ProcessShpScale ) ;
m_ShapeXmlProcessors . Add ( "State" , ProcessShpState ) ;
m_ShapeXmlProcessors . Add ( "ProfileShape" , ProcessShpProfileShape ) ;
m_ShapeXmlProcessors . Add ( "HollowShape" , ProcessShpHollowShape ) ;
m_ShapeXmlProcessors . Add ( "SculptTexture" , ProcessShpSculptTexture ) ;
m_ShapeXmlProcessors . Add ( "SculptType" , ProcessShpSculptType ) ;
m_ShapeXmlProcessors . Add ( "SculptData" , ProcessShpSculptData ) ;
m_ShapeXmlProcessors . Add ( "FlexiSoftness" , ProcessShpFlexiSoftness ) ;
m_ShapeXmlProcessors . Add ( "FlexiTension" , ProcessShpFlexiTension ) ;
m_ShapeXmlProcessors . Add ( "FlexiDrag" , ProcessShpFlexiDrag ) ;
m_ShapeXmlProcessors . Add ( "FlexiGravity" , ProcessShpFlexiGravity ) ;
m_ShapeXmlProcessors . Add ( "FlexiWind" , ProcessShpFlexiWind ) ;
m_ShapeXmlProcessors . Add ( "FlexiForceX" , ProcessShpFlexiForceX ) ;
m_ShapeXmlProcessors . Add ( "FlexiForceY" , ProcessShpFlexiForceY ) ;
m_ShapeXmlProcessors . Add ( "FlexiForceZ" , ProcessShpFlexiForceZ ) ;
m_ShapeXmlProcessors . Add ( "LightColorR" , ProcessShpLightColorR ) ;
m_ShapeXmlProcessors . Add ( "LightColorG" , ProcessShpLightColorG ) ;
m_ShapeXmlProcessors . Add ( "LightColorB" , ProcessShpLightColorB ) ;
m_ShapeXmlProcessors . Add ( "LightColorA" , ProcessShpLightColorA ) ;
m_ShapeXmlProcessors . Add ( "LightRadius" , ProcessShpLightRadius ) ;
m_ShapeXmlProcessors . Add ( "LightCutoff" , ProcessShpLightCutoff ) ;
m_ShapeXmlProcessors . Add ( "LightFalloff" , ProcessShpLightFalloff ) ;
m_ShapeXmlProcessors . Add ( "LightIntensity" , ProcessShpLightIntensity ) ;
m_ShapeXmlProcessors . Add ( "FlexiEntry" , ProcessShpFlexiEntry ) ;
m_ShapeXmlProcessors . Add ( "LightEntry" , ProcessShpLightEntry ) ;
m_ShapeXmlProcessors . Add ( "SculptEntry" , ProcessShpSculptEntry ) ;
2010-10-13 22:44:25 +00:00
m_ShapeXmlProcessors . Add ( "Media" , ProcessShpMedia ) ;
2010-10-13 15:16:41 +00:00
# endregion
}
#region SOPXmlProcessors
2011-04-20 21:59:06 +00:00
//DSG SYNC NOTE: -- assignments in de-serialization should directly set the values w/o triggering SceneObjectPart.UpdateBucketSyncInfo;
2010-10-13 15:16:41 +00:00
private static void ProcessAllowedDrop ( SceneObjectPart obj , XmlTextReader reader )
{
2011-02-16 22:29:08 +00:00
obj . AllowedDrop = Util . ReadBoolean ( reader ) ;
2010-10-13 15:16:41 +00:00
}
private static void ProcessCreatorID ( SceneObjectPart obj , XmlTextReader reader )
{
2010-11-27 19:40:54 +00:00
obj . CreatorID = Util . ReadUUID ( reader , "CreatorID" ) ;
2010-10-13 15:16:41 +00:00
}
2010-11-21 21:16:52 +00:00
private static void ProcessCreatorData ( SceneObjectPart obj , XmlTextReader reader )
{
obj . CreatorData = reader . ReadElementContentAsString ( "CreatorData" , String . Empty ) ;
}
2010-10-13 15:16:41 +00:00
private static void ProcessFolderID ( SceneObjectPart obj , XmlTextReader reader )
{
2010-11-27 19:40:54 +00:00
obj . FolderID = Util . ReadUUID ( reader , "FolderID" ) ;
2010-10-13 15:16:41 +00:00
}
private static void ProcessInventorySerial ( SceneObjectPart obj , XmlTextReader reader )
{
obj . InventorySerial = ( uint ) reader . ReadElementContentAsInt ( "InventorySerial" , String . Empty ) ;
}
private static void ProcessTaskInventory ( SceneObjectPart obj , XmlTextReader reader )
{
obj . TaskInventory = ReadTaskInventory ( reader , "TaskInventory" ) ;
}
private static void ProcessUUID ( SceneObjectPart obj , XmlTextReader reader )
{
2010-11-27 19:40:54 +00:00
obj . UUID = Util . ReadUUID ( reader , "UUID" ) ;
2010-10-13 15:16:41 +00:00
}
private static void ProcessLocalId ( SceneObjectPart obj , XmlTextReader reader )
{
obj . LocalId = ( uint ) reader . ReadElementContentAsLong ( "LocalId" , String . Empty ) ;
}
private static void ProcessName ( SceneObjectPart obj , XmlTextReader reader )
{
obj . Name = reader . ReadElementString ( "Name" ) ;
}
private static void ProcessMaterial ( SceneObjectPart obj , XmlTextReader reader )
{
obj . Material = ( byte ) reader . ReadElementContentAsInt ( "Material" , String . Empty ) ;
}
private static void ProcessPassTouches ( SceneObjectPart obj , XmlTextReader reader )
{
2010-11-29 16:43:33 +00:00
obj . PassTouches = Util . ReadBoolean ( reader ) ;
2010-10-13 15:16:41 +00:00
}
private static void ProcessRegionHandle ( SceneObjectPart obj , XmlTextReader reader )
{
obj . RegionHandle = ( ulong ) reader . ReadElementContentAsLong ( "RegionHandle" , String . Empty ) ;
}
private static void ProcessScriptAccessPin ( SceneObjectPart obj , XmlTextReader reader )
{
obj . ScriptAccessPin = reader . ReadElementContentAsInt ( "ScriptAccessPin" , String . Empty ) ;
}
private static void ProcessGroupPosition ( SceneObjectPart obj , XmlTextReader reader )
{
2011-02-10 01:17:16 +00:00
obj . GroupPosition = Util . ReadVector ( reader , "GroupPosition" ) ;
//obj.SetGroupPosition(Util.ReadVector(reader, "GroupPosition"));
2010-10-13 15:16:41 +00:00
}
private static void ProcessOffsetPosition ( SceneObjectPart obj , XmlTextReader reader )
{
2011-02-10 01:17:16 +00:00
obj . OffsetPosition = Util . ReadVector ( reader , "OffsetPosition" ) ; ;
//obj.SetOffsetPosition(Util.ReadVector(reader, "OffsetPosition"));
2010-10-13 15:16:41 +00:00
}
private static void ProcessRotationOffset ( SceneObjectPart obj , XmlTextReader reader )
{
2011-02-10 01:17:16 +00:00
obj . RotationOffset = Util . ReadQuaternion ( reader , "RotationOffset" ) ;
//obj.SetRotationOffset(Util.ReadQuaternion(reader, "RotationOffset"));
2010-10-13 15:16:41 +00:00
}
private static void ProcessVelocity ( SceneObjectPart obj , XmlTextReader reader )
{
2011-02-10 01:17:16 +00:00
obj . Velocity = Util . ReadVector ( reader , "Velocity" ) ;
//obj.SetVelocity(Util.ReadVector(reader, "Velocity"));
2010-10-13 15:16:41 +00:00
}
private static void ProcessAngularVelocity ( SceneObjectPart obj , XmlTextReader reader )
{
2011-02-10 01:17:16 +00:00
obj . AngularVelocity = Util . ReadVector ( reader , "AngularVelocity" ) ;
//obj.SetVelocity(Util.ReadVector(reader, "AngularVelocity"));
2010-10-13 15:16:41 +00:00
}
private static void ProcessAcceleration ( SceneObjectPart obj , XmlTextReader reader )
{
2010-11-27 19:40:54 +00:00
obj . Acceleration = Util . ReadVector ( reader , "Acceleration" ) ;
2010-10-13 15:16:41 +00:00
}
private static void ProcessDescription ( SceneObjectPart obj , XmlTextReader reader )
{
obj . Description = reader . ReadElementString ( "Description" ) ;
}
private static void ProcessColor ( SceneObjectPart obj , XmlTextReader reader )
{
reader . ReadStartElement ( "Color" ) ;
if ( reader . Name = = "R" )
{
float r = reader . ReadElementContentAsFloat ( "R" , String . Empty ) ;
float g = reader . ReadElementContentAsFloat ( "G" , String . Empty ) ;
float b = reader . ReadElementContentAsFloat ( "B" , String . Empty ) ;
float a = reader . ReadElementContentAsFloat ( "A" , String . Empty ) ;
obj . Color = Color . FromArgb ( ( int ) a , ( int ) r , ( int ) g , ( int ) b ) ;
reader . ReadEndElement ( ) ;
}
}
private static void ProcessText ( SceneObjectPart obj , XmlTextReader reader )
{
obj . Text = reader . ReadElementString ( "Text" , String . Empty ) ;
}
private static void ProcessSitName ( SceneObjectPart obj , XmlTextReader reader )
{
obj . SitName = reader . ReadElementString ( "SitName" , String . Empty ) ;
}
private static void ProcessTouchName ( SceneObjectPart obj , XmlTextReader reader )
{
obj . TouchName = reader . ReadElementString ( "TouchName" , String . Empty ) ;
}
private static void ProcessLinkNum ( SceneObjectPart obj , XmlTextReader reader )
{
obj . LinkNum = reader . ReadElementContentAsInt ( "LinkNum" , String . Empty ) ;
}
private static void ProcessClickAction ( SceneObjectPart obj , XmlTextReader reader )
{
obj . ClickAction = ( byte ) reader . ReadElementContentAsInt ( "ClickAction" , String . Empty ) ;
}
private static void ProcessShape ( SceneObjectPart obj , XmlTextReader reader )
{
obj . Shape = ReadShape ( reader , "Shape" ) ;
}
private static void ProcessScale ( SceneObjectPart obj , XmlTextReader reader )
{
2011-02-10 01:17:16 +00:00
obj . Scale = Util . ReadVector ( reader , "Scale" ) ;
2010-10-13 15:16:41 +00:00
}
private static void ProcessUpdateFlag ( SceneObjectPart obj , XmlTextReader reader )
{
obj . UpdateFlag = ( byte ) reader . ReadElementContentAsInt ( "UpdateFlag" , String . Empty ) ;
}
private static void ProcessSitTargetOrientation ( SceneObjectPart obj , XmlTextReader reader )
{
2010-11-27 19:40:54 +00:00
obj . SitTargetOrientation = Util . ReadQuaternion ( reader , "SitTargetOrientation" ) ;
2010-10-13 15:16:41 +00:00
}
private static void ProcessSitTargetPosition ( SceneObjectPart obj , XmlTextReader reader )
{
2010-11-27 19:40:54 +00:00
obj . SitTargetPosition = Util . ReadVector ( reader , "SitTargetPosition" ) ;
2010-10-13 15:16:41 +00:00
}
private static void ProcessSitTargetPositionLL ( SceneObjectPart obj , XmlTextReader reader )
{
2010-11-27 19:40:54 +00:00
obj . SitTargetPositionLL = Util . ReadVector ( reader , "SitTargetPositionLL" ) ;
2010-10-13 15:16:41 +00:00
}
private static void ProcessSitTargetOrientationLL ( SceneObjectPart obj , XmlTextReader reader )
{
2010-11-27 19:40:54 +00:00
obj . SitTargetOrientationLL = Util . ReadQuaternion ( reader , "SitTargetOrientationLL" ) ;
2010-10-13 15:16:41 +00:00
}
private static void ProcessParentID ( SceneObjectPart obj , XmlTextReader reader )
{
string str = reader . ReadElementContentAsString ( "ParentID" , String . Empty ) ;
obj . ParentID = Convert . ToUInt32 ( str ) ;
}
private static void ProcessCreationDate ( SceneObjectPart obj , XmlTextReader reader )
{
obj . CreationDate = reader . ReadElementContentAsInt ( "CreationDate" , String . Empty ) ;
}
private static void ProcessCategory ( SceneObjectPart obj , XmlTextReader reader )
{
obj . Category = ( uint ) reader . ReadElementContentAsInt ( "Category" , String . Empty ) ;
}
private static void ProcessSalePrice ( SceneObjectPart obj , XmlTextReader reader )
{
obj . SalePrice = reader . ReadElementContentAsInt ( "SalePrice" , String . Empty ) ;
}
private static void ProcessObjectSaleType ( SceneObjectPart obj , XmlTextReader reader )
{
obj . ObjectSaleType = ( byte ) reader . ReadElementContentAsInt ( "ObjectSaleType" , String . Empty ) ;
}
private static void ProcessOwnershipCost ( SceneObjectPart obj , XmlTextReader reader )
{
obj . OwnershipCost = reader . ReadElementContentAsInt ( "OwnershipCost" , String . Empty ) ;
}
private static void ProcessGroupID ( SceneObjectPart obj , XmlTextReader reader )
{
2010-11-27 19:40:54 +00:00
obj . GroupID = Util . ReadUUID ( reader , "GroupID" ) ;
2010-10-13 15:16:41 +00:00
}
private static void ProcessOwnerID ( SceneObjectPart obj , XmlTextReader reader )
{
2010-11-27 19:40:54 +00:00
obj . OwnerID = Util . ReadUUID ( reader , "OwnerID" ) ;
2010-10-13 15:16:41 +00:00
}
private static void ProcessLastOwnerID ( SceneObjectPart obj , XmlTextReader reader )
{
2010-11-27 19:40:54 +00:00
obj . LastOwnerID = Util . ReadUUID ( reader , "LastOwnerID" ) ;
2010-10-13 15:16:41 +00:00
}
private static void ProcessBaseMask ( SceneObjectPart obj , XmlTextReader reader )
{
obj . BaseMask = ( uint ) reader . ReadElementContentAsInt ( "BaseMask" , String . Empty ) ;
}
private static void ProcessOwnerMask ( SceneObjectPart obj , XmlTextReader reader )
{
obj . OwnerMask = ( uint ) reader . ReadElementContentAsInt ( "OwnerMask" , String . Empty ) ;
}
private static void ProcessGroupMask ( SceneObjectPart obj , XmlTextReader reader )
{
obj . GroupMask = ( uint ) reader . ReadElementContentAsInt ( "GroupMask" , String . Empty ) ;
}
private static void ProcessEveryoneMask ( SceneObjectPart obj , XmlTextReader reader )
{
obj . EveryoneMask = ( uint ) reader . ReadElementContentAsInt ( "EveryoneMask" , String . Empty ) ;
}
private static void ProcessNextOwnerMask ( SceneObjectPart obj , XmlTextReader reader )
{
obj . NextOwnerMask = ( uint ) reader . ReadElementContentAsInt ( "NextOwnerMask" , String . Empty ) ;
}
private static void ProcessFlags ( SceneObjectPart obj , XmlTextReader reader )
{
2010-11-29 16:43:33 +00:00
obj . Flags = Util . ReadEnum < PrimFlags > ( reader , "Flags" ) ;
2010-10-13 15:16:41 +00:00
}
private static void ProcessCollisionSound ( SceneObjectPart obj , XmlTextReader reader )
{
2010-11-27 19:40:54 +00:00
obj . CollisionSound = Util . ReadUUID ( reader , "CollisionSound" ) ;
2010-10-13 15:16:41 +00:00
}
private static void ProcessCollisionSoundVolume ( SceneObjectPart obj , XmlTextReader reader )
{
obj . CollisionSoundVolume = reader . ReadElementContentAsFloat ( "CollisionSoundVolume" , String . Empty ) ;
}
2010-10-13 22:44:25 +00:00
private static void ProcessMediaUrl ( SceneObjectPart obj , XmlTextReader reader )
{
obj . MediaUrl = reader . ReadElementContentAsString ( "MediaUrl" , String . Empty ) ;
}
2010-10-19 07:04:02 +00:00
private static void ProcessTextureAnimation ( SceneObjectPart obj , XmlTextReader reader )
{
obj . TextureAnimation = Convert . FromBase64String ( reader . ReadElementContentAsString ( "TextureAnimation" , String . Empty ) ) ;
}
private static void ProcessParticleSystem ( SceneObjectPart obj , XmlTextReader reader )
{
obj . ParticleSystem = Convert . FromBase64String ( reader . ReadElementContentAsString ( "ParticleSystem" , String . Empty ) ) ;
}
2010-12-27 20:15:39 +00:00
2011-04-20 21:59:06 +00:00
//DSG SYNC
2011-02-04 01:21:00 +00:00
/ *
2010-12-27 20:15:39 +00:00
private static void ProcessUpdateTimeStamp ( SceneObjectPart obj , XmlTextReader reader )
{
obj . LastUpdateTimeStamp = reader . ReadElementContentAsLong ( "LastUpdateTimeStamp" , string . Empty ) ;
}
private static void ProcessLastUpdateActorID ( SceneObjectPart obj , XmlTextReader reader )
{
obj . LastUpdateActorID = reader . ReadElementContentAsString ( "LastUpdateActorID" , string . Empty ) ;
}
2011-03-07 23:51:59 +00:00
* * /
2011-02-16 22:29:08 +00:00
2011-02-08 23:55:00 +00:00
private static void ProcessLocalFlags ( SceneObjectPart obj , XmlTextReader reader )
{
obj . LocalFlags = Util . ReadEnum < PrimFlags > ( reader , "LocalFlags" ) ;
}
2011-03-07 23:51:59 +00:00
2011-02-16 22:29:08 +00:00
private static void ProcessIsAttachment ( SceneObjectPart obj , XmlTextReader reader )
{
obj . IsAttachment = Util . ReadBoolean ( reader ) ;
}
private static void ProcessAttachedAvatar ( SceneObjectPart obj , XmlTextReader reader )
{
obj . AttachedAvatar = Util . ReadUUID ( reader , "AttachedAvatar" ) ;
}
private static void ProcessAttachedPos ( SceneObjectPart obj , XmlTextReader reader )
{
obj . AttachedPos = Util . ReadVector ( reader , "AttachedPos" ) ;
}
private static void ProcessAttachmentPoint ( SceneObjectPart obj , XmlTextReader reader )
{
obj . AttachmentPoint = ( uint ) reader . ReadElementContentAsInt ( "AttachmentPoint" , string . Empty ) ;
}
private static void ProcessAggregateScriptEvents ( SceneObjectPart obj , XmlTextReader reader )
{
obj . AggregateScriptEvents = Util . ReadEnum < scriptEvents > ( reader , "AggregateScriptEvents" ) ;
}
2011-02-03 20:01:08 +00:00
public static void ProcessBucketSyncInfo ( SceneObjectPart obj , XmlTextReader reader )
{
obj . BucketSyncInfoList = new Dictionary < string , BucketSyncInfo > ( ) ;
if ( reader . IsEmptyElement )
{
reader . Read ( ) ;
return ;
}
string elementName = "BucketSyncInfoList" ;
reader . ReadStartElement ( elementName , String . Empty ) ;
while ( reader . Name = = "Bucket" )
{
reader . ReadStartElement ( "Bucket" , String . Empty ) ; // Bucket
string bucketName = "" ;
long timeStamp = 0 ;
string actorID = "" ;
while ( reader . NodeType ! = XmlNodeType . EndElement )
{
switch ( reader . Name )
{
case "Name" :
bucketName = reader . ReadElementContentAsString ( "Name" , String . Empty ) ;
break ;
case "TimeStamp" :
timeStamp = reader . ReadElementContentAsLong ( "TimeStamp" , String . Empty ) ;
break ;
case "ActorID" :
actorID = reader . ReadElementContentAsString ( "ActorID" , String . Empty ) ;
break ;
default :
reader . ReadOuterXml ( ) ;
break ;
}
}
reader . ReadEndElement ( ) ;
BucketSyncInfo bucketSyncInfo = new BucketSyncInfo ( timeStamp , actorID , bucketName ) ;
obj . BucketSyncInfoList . Add ( bucketName , bucketSyncInfo ) ;
}
if ( reader . NodeType = = XmlNodeType . EndElement )
reader . ReadEndElement ( ) ; // BucketSyncInfoList
}
2011-04-20 21:59:06 +00:00
//end of DSG SYNC
2010-12-27 20:15:39 +00:00
2010-10-13 15:16:41 +00:00
# endregion
#region TaskInventoryXmlProcessors
private static void ProcessTIAssetID ( TaskInventoryItem item , XmlTextReader reader )
{
2010-11-27 19:40:54 +00:00
item . AssetID = Util . ReadUUID ( reader , "AssetID" ) ;
2010-10-13 15:16:41 +00:00
}
private static void ProcessTIBasePermissions ( TaskInventoryItem item , XmlTextReader reader )
{
item . BasePermissions = ( uint ) reader . ReadElementContentAsInt ( "BasePermissions" , String . Empty ) ;
}
private static void ProcessTICreationDate ( TaskInventoryItem item , XmlTextReader reader )
{
item . CreationDate = ( uint ) reader . ReadElementContentAsInt ( "CreationDate" , String . Empty ) ;
}
private static void ProcessTICreatorID ( TaskInventoryItem item , XmlTextReader reader )
{
2010-11-27 19:40:54 +00:00
item . CreatorID = Util . ReadUUID ( reader , "CreatorID" ) ;
2010-10-13 15:16:41 +00:00
}
2010-11-22 01:19:24 +00:00
private static void ProcessTICreatorData ( TaskInventoryItem item , XmlTextReader reader )
{
item . CreatorData = reader . ReadElementContentAsString ( "CreatorData" , String . Empty ) ;
}
2010-10-13 15:16:41 +00:00
private static void ProcessTIDescription ( TaskInventoryItem item , XmlTextReader reader )
{
item . Description = reader . ReadElementContentAsString ( "Description" , String . Empty ) ;
}
private static void ProcessTIEveryonePermissions ( TaskInventoryItem item , XmlTextReader reader )
{
item . EveryonePermissions = ( uint ) reader . ReadElementContentAsInt ( "EveryonePermissions" , String . Empty ) ;
}
private static void ProcessTIFlags ( TaskInventoryItem item , XmlTextReader reader )
{
item . Flags = ( uint ) reader . ReadElementContentAsInt ( "Flags" , String . Empty ) ;
}
private static void ProcessTIGroupID ( TaskInventoryItem item , XmlTextReader reader )
{
2010-11-27 19:40:54 +00:00
item . GroupID = Util . ReadUUID ( reader , "GroupID" ) ;
2010-10-13 15:16:41 +00:00
}
private static void ProcessTIGroupPermissions ( TaskInventoryItem item , XmlTextReader reader )
{
item . GroupPermissions = ( uint ) reader . ReadElementContentAsInt ( "GroupPermissions" , String . Empty ) ;
}
private static void ProcessTIInvType ( TaskInventoryItem item , XmlTextReader reader )
{
item . InvType = reader . ReadElementContentAsInt ( "InvType" , String . Empty ) ;
}
private static void ProcessTIItemID ( TaskInventoryItem item , XmlTextReader reader )
{
2010-11-27 19:40:54 +00:00
item . ItemID = Util . ReadUUID ( reader , "ItemID" ) ;
2010-10-13 15:16:41 +00:00
}
private static void ProcessTIOldItemID ( TaskInventoryItem item , XmlTextReader reader )
{
2010-11-27 19:40:54 +00:00
Util . ReadUUID ( reader , "OldItemID" ) ;
2010-11-16 00:33:24 +00:00
// On deserialization, the old item id MUST BE UUID.Zero!!!!!
// Setting this to the saved value will BREAK script persistence!
2010-11-27 19:40:54 +00:00
// item.OldItemID = Util.ReadUUID(reader, "OldItemID");
2010-10-13 15:16:41 +00:00
}
private static void ProcessTILastOwnerID ( TaskInventoryItem item , XmlTextReader reader )
{
2010-11-27 19:40:54 +00:00
item . LastOwnerID = Util . ReadUUID ( reader , "LastOwnerID" ) ;
2010-10-13 15:16:41 +00:00
}
private static void ProcessTIName ( TaskInventoryItem item , XmlTextReader reader )
{
item . Name = reader . ReadElementContentAsString ( "Name" , String . Empty ) ;
}
private static void ProcessTINextPermissions ( TaskInventoryItem item , XmlTextReader reader )
{
item . NextPermissions = ( uint ) reader . ReadElementContentAsInt ( "NextPermissions" , String . Empty ) ;
}
private static void ProcessTIOwnerID ( TaskInventoryItem item , XmlTextReader reader )
{
2010-11-27 19:40:54 +00:00
item . OwnerID = Util . ReadUUID ( reader , "OwnerID" ) ;
2010-10-13 15:16:41 +00:00
}
private static void ProcessTICurrentPermissions ( TaskInventoryItem item , XmlTextReader reader )
{
item . CurrentPermissions = ( uint ) reader . ReadElementContentAsInt ( "CurrentPermissions" , String . Empty ) ;
}
private static void ProcessTIParentID ( TaskInventoryItem item , XmlTextReader reader )
{
2010-11-27 19:40:54 +00:00
item . ParentID = Util . ReadUUID ( reader , "ParentID" ) ;
2010-10-13 15:16:41 +00:00
}
private static void ProcessTIParentPartID ( TaskInventoryItem item , XmlTextReader reader )
{
2010-11-27 19:40:54 +00:00
item . ParentPartID = Util . ReadUUID ( reader , "ParentPartID" ) ;
2010-10-13 15:16:41 +00:00
}
private static void ProcessTIPermsGranter ( TaskInventoryItem item , XmlTextReader reader )
{
2010-11-27 19:40:54 +00:00
item . PermsGranter = Util . ReadUUID ( reader , "PermsGranter" ) ;
2010-10-13 15:16:41 +00:00
}
private static void ProcessTIPermsMask ( TaskInventoryItem item , XmlTextReader reader )
{
item . PermsMask = reader . ReadElementContentAsInt ( "PermsMask" , String . Empty ) ;
}
private static void ProcessTIType ( TaskInventoryItem item , XmlTextReader reader )
{
item . Type = reader . ReadElementContentAsInt ( "Type" , String . Empty ) ;
}
2010-10-17 17:35:38 +00:00
private static void ProcessTIOwnerChanged ( TaskInventoryItem item , XmlTextReader reader )
{
2010-11-29 16:43:33 +00:00
item . OwnerChanged = Util . ReadBoolean ( reader ) ;
2010-10-17 17:35:38 +00:00
}
2010-10-13 15:16:41 +00:00
# endregion
#region ShapeXmlProcessors
private static void ProcessShpProfileCurve ( PrimitiveBaseShape shp , XmlTextReader reader )
{
shp . ProfileCurve = ( byte ) reader . ReadElementContentAsInt ( "ProfileCurve" , String . Empty ) ;
}
private static void ProcessShpTextureEntry ( PrimitiveBaseShape shp , XmlTextReader reader )
{
byte [ ] teData = Convert . FromBase64String ( reader . ReadElementString ( "TextureEntry" ) ) ;
2010-10-27 04:01:03 +00:00
shp . Textures = new Primitive . TextureEntry ( teData , 0 , teData . Length ) ;
2010-10-13 15:16:41 +00:00
}
private static void ProcessShpExtraParams ( PrimitiveBaseShape shp , XmlTextReader reader )
{
shp . ExtraParams = Convert . FromBase64String ( reader . ReadElementString ( "ExtraParams" ) ) ;
}
private static void ProcessShpPathBegin ( PrimitiveBaseShape shp , XmlTextReader reader )
{
shp . PathBegin = ( ushort ) reader . ReadElementContentAsInt ( "PathBegin" , String . Empty ) ;
}
private static void ProcessShpPathCurve ( PrimitiveBaseShape shp , XmlTextReader reader )
{
shp . PathCurve = ( byte ) reader . ReadElementContentAsInt ( "PathCurve" , String . Empty ) ;
}
private static void ProcessShpPathEnd ( PrimitiveBaseShape shp , XmlTextReader reader )
{
shp . PathEnd = ( ushort ) reader . ReadElementContentAsInt ( "PathEnd" , String . Empty ) ;
}
private static void ProcessShpPathRadiusOffset ( PrimitiveBaseShape shp , XmlTextReader reader )
{
shp . PathRadiusOffset = ( sbyte ) reader . ReadElementContentAsInt ( "PathRadiusOffset" , String . Empty ) ;
}
private static void ProcessShpPathRevolutions ( PrimitiveBaseShape shp , XmlTextReader reader )
{
shp . PathRevolutions = ( byte ) reader . ReadElementContentAsInt ( "PathRevolutions" , String . Empty ) ;
}
private static void ProcessShpPathScaleX ( PrimitiveBaseShape shp , XmlTextReader reader )
{
shp . PathScaleX = ( byte ) reader . ReadElementContentAsInt ( "PathScaleX" , String . Empty ) ;
}
private static void ProcessShpPathScaleY ( PrimitiveBaseShape shp , XmlTextReader reader )
{
shp . PathScaleY = ( byte ) reader . ReadElementContentAsInt ( "PathScaleY" , String . Empty ) ;
}
private static void ProcessShpPathShearX ( PrimitiveBaseShape shp , XmlTextReader reader )
{
shp . PathShearX = ( byte ) reader . ReadElementContentAsInt ( "PathShearX" , String . Empty ) ;
}
private static void ProcessShpPathShearY ( PrimitiveBaseShape shp , XmlTextReader reader )
{
shp . PathShearY = ( byte ) reader . ReadElementContentAsInt ( "PathShearY" , String . Empty ) ;
}
private static void ProcessShpPathSkew ( PrimitiveBaseShape shp , XmlTextReader reader )
{
shp . PathSkew = ( sbyte ) reader . ReadElementContentAsInt ( "PathSkew" , String . Empty ) ;
}
private static void ProcessShpPathTaperX ( PrimitiveBaseShape shp , XmlTextReader reader )
{
shp . PathTaperX = ( sbyte ) reader . ReadElementContentAsInt ( "PathTaperX" , String . Empty ) ;
}
private static void ProcessShpPathTaperY ( PrimitiveBaseShape shp , XmlTextReader reader )
{
shp . PathTaperY = ( sbyte ) reader . ReadElementContentAsInt ( "PathTaperY" , String . Empty ) ;
}
private static void ProcessShpPathTwist ( PrimitiveBaseShape shp , XmlTextReader reader )
{
shp . PathTwist = ( sbyte ) reader . ReadElementContentAsInt ( "PathTwist" , String . Empty ) ;
}
private static void ProcessShpPathTwistBegin ( PrimitiveBaseShape shp , XmlTextReader reader )
{
shp . PathTwistBegin = ( sbyte ) reader . ReadElementContentAsInt ( "PathTwistBegin" , String . Empty ) ;
}
private static void ProcessShpPCode ( PrimitiveBaseShape shp , XmlTextReader reader )
{
shp . PCode = ( byte ) reader . ReadElementContentAsInt ( "PCode" , String . Empty ) ;
}
private static void ProcessShpProfileBegin ( PrimitiveBaseShape shp , XmlTextReader reader )
{
shp . ProfileBegin = ( ushort ) reader . ReadElementContentAsInt ( "ProfileBegin" , String . Empty ) ;
}
private static void ProcessShpProfileEnd ( PrimitiveBaseShape shp , XmlTextReader reader )
{
shp . ProfileEnd = ( ushort ) reader . ReadElementContentAsInt ( "ProfileEnd" , String . Empty ) ;
}
private static void ProcessShpProfileHollow ( PrimitiveBaseShape shp , XmlTextReader reader )
{
shp . ProfileHollow = ( ushort ) reader . ReadElementContentAsInt ( "ProfileHollow" , String . Empty ) ;
}
private static void ProcessShpScale ( PrimitiveBaseShape shp , XmlTextReader reader )
{
2010-11-27 19:40:54 +00:00
shp . Scale = Util . ReadVector ( reader , "Scale" ) ;
2010-10-13 15:16:41 +00:00
}
private static void ProcessShpState ( PrimitiveBaseShape shp , XmlTextReader reader )
{
shp . State = ( byte ) reader . ReadElementContentAsInt ( "State" , String . Empty ) ;
}
private static void ProcessShpProfileShape ( PrimitiveBaseShape shp , XmlTextReader reader )
{
2010-11-29 16:43:33 +00:00
shp . ProfileShape = Util . ReadEnum < ProfileShape > ( reader , "ProfileShape" ) ;
2010-10-13 15:16:41 +00:00
}
private static void ProcessShpHollowShape ( PrimitiveBaseShape shp , XmlTextReader reader )
{
2010-11-29 16:43:33 +00:00
shp . HollowShape = Util . ReadEnum < HollowShape > ( reader , "HollowShape" ) ;
2010-10-13 15:16:41 +00:00
}
private static void ProcessShpSculptTexture ( PrimitiveBaseShape shp , XmlTextReader reader )
{
2010-11-27 19:40:54 +00:00
shp . SculptTexture = Util . ReadUUID ( reader , "SculptTexture" ) ;
2010-10-13 15:16:41 +00:00
}
private static void ProcessShpSculptType ( PrimitiveBaseShape shp , XmlTextReader reader )
{
shp . SculptType = ( byte ) reader . ReadElementContentAsInt ( "SculptType" , String . Empty ) ;
}
private static void ProcessShpSculptData ( PrimitiveBaseShape shp , XmlTextReader reader )
{
shp . SculptData = Convert . FromBase64String ( reader . ReadElementString ( "SculptData" ) ) ;
}
private static void ProcessShpFlexiSoftness ( PrimitiveBaseShape shp , XmlTextReader reader )
{
shp . FlexiSoftness = reader . ReadElementContentAsInt ( "FlexiSoftness" , String . Empty ) ;
}
private static void ProcessShpFlexiTension ( PrimitiveBaseShape shp , XmlTextReader reader )
{
shp . FlexiTension = reader . ReadElementContentAsFloat ( "FlexiTension" , String . Empty ) ;
}
private static void ProcessShpFlexiDrag ( PrimitiveBaseShape shp , XmlTextReader reader )
{
shp . FlexiDrag = reader . ReadElementContentAsFloat ( "FlexiDrag" , String . Empty ) ;
}
private static void ProcessShpFlexiGravity ( PrimitiveBaseShape shp , XmlTextReader reader )
{
shp . FlexiGravity = reader . ReadElementContentAsFloat ( "FlexiGravity" , String . Empty ) ;
}
private static void ProcessShpFlexiWind ( PrimitiveBaseShape shp , XmlTextReader reader )
{
shp . FlexiWind = reader . ReadElementContentAsFloat ( "FlexiWind" , String . Empty ) ;
}
private static void ProcessShpFlexiForceX ( PrimitiveBaseShape shp , XmlTextReader reader )
{
shp . FlexiForceX = reader . ReadElementContentAsFloat ( "FlexiForceX" , String . Empty ) ;
}
private static void ProcessShpFlexiForceY ( PrimitiveBaseShape shp , XmlTextReader reader )
{
shp . FlexiForceY = reader . ReadElementContentAsFloat ( "FlexiForceY" , String . Empty ) ;
}
private static void ProcessShpFlexiForceZ ( PrimitiveBaseShape shp , XmlTextReader reader )
{
shp . FlexiForceZ = reader . ReadElementContentAsFloat ( "FlexiForceZ" , String . Empty ) ;
}
private static void ProcessShpLightColorR ( PrimitiveBaseShape shp , XmlTextReader reader )
{
shp . LightColorR = reader . ReadElementContentAsFloat ( "LightColorR" , String . Empty ) ;
}
private static void ProcessShpLightColorG ( PrimitiveBaseShape shp , XmlTextReader reader )
{
shp . LightColorG = reader . ReadElementContentAsFloat ( "LightColorG" , String . Empty ) ;
}
private static void ProcessShpLightColorB ( PrimitiveBaseShape shp , XmlTextReader reader )
{
shp . LightColorB = reader . ReadElementContentAsFloat ( "LightColorB" , String . Empty ) ;
}
private static void ProcessShpLightColorA ( PrimitiveBaseShape shp , XmlTextReader reader )
{
shp . LightColorA = reader . ReadElementContentAsFloat ( "LightColorA" , String . Empty ) ;
}
private static void ProcessShpLightRadius ( PrimitiveBaseShape shp , XmlTextReader reader )
{
shp . LightRadius = reader . ReadElementContentAsFloat ( "LightRadius" , String . Empty ) ;
}
private static void ProcessShpLightCutoff ( PrimitiveBaseShape shp , XmlTextReader reader )
{
shp . LightCutoff = reader . ReadElementContentAsFloat ( "LightCutoff" , String . Empty ) ;
}
private static void ProcessShpLightFalloff ( PrimitiveBaseShape shp , XmlTextReader reader )
{
shp . LightFalloff = reader . ReadElementContentAsFloat ( "LightFalloff" , String . Empty ) ;
}
private static void ProcessShpLightIntensity ( PrimitiveBaseShape shp , XmlTextReader reader )
{
shp . LightIntensity = reader . ReadElementContentAsFloat ( "LightIntensity" , String . Empty ) ;
}
private static void ProcessShpFlexiEntry ( PrimitiveBaseShape shp , XmlTextReader reader )
{
2010-11-29 16:43:33 +00:00
shp . FlexiEntry = Util . ReadBoolean ( reader ) ;
2010-10-13 15:16:41 +00:00
}
private static void ProcessShpLightEntry ( PrimitiveBaseShape shp , XmlTextReader reader )
{
2010-11-29 16:43:33 +00:00
shp . LightEntry = Util . ReadBoolean ( reader ) ;
2010-10-13 15:16:41 +00:00
}
private static void ProcessShpSculptEntry ( PrimitiveBaseShape shp , XmlTextReader reader )
{
2010-11-29 16:43:33 +00:00
shp . SculptEntry = Util . ReadBoolean ( reader ) ;
2010-10-13 15:16:41 +00:00
}
2010-10-13 22:44:25 +00:00
private static void ProcessShpMedia ( PrimitiveBaseShape shp , XmlTextReader reader )
{
string value = reader . ReadElementContentAsString ( "Media" , String . Empty ) ;
shp . Media = PrimitiveBaseShape . MediaList . FromXml ( value ) ;
}
2010-10-13 15:16:41 +00:00
# endregion
////////// Write /////////
2010-12-23 19:33:12 +00:00
public static void SOGToXml2 ( XmlTextWriter writer , SceneObjectGroup sog , Dictionary < string , object > options )
2010-10-13 15:16:41 +00:00
{
writer . WriteStartElement ( String . Empty , "SceneObjectGroup" , String . Empty ) ;
2010-10-17 17:35:38 +00:00
SOPToXml2 ( writer , sog . RootPart , options ) ;
2010-10-13 15:16:41 +00:00
writer . WriteStartElement ( String . Empty , "OtherParts" , String . Empty ) ;
sog . ForEachPart ( delegate ( SceneObjectPart sop )
{
2010-10-14 16:05:46 +00:00
if ( sop . UUID ! = sog . RootPart . UUID )
2010-10-17 17:35:38 +00:00
SOPToXml2 ( writer , sop , options ) ;
2010-10-13 15:16:41 +00:00
} ) ;
writer . WriteEndElement ( ) ;
writer . WriteEndElement ( ) ;
}
2010-10-17 17:35:38 +00:00
public static void SOPToXml2 ( XmlTextWriter writer , SceneObjectPart sop , Dictionary < string , object > options )
2010-10-13 15:16:41 +00:00
{
writer . WriteStartElement ( "SceneObjectPart" ) ;
writer . WriteAttributeString ( "xmlns:xsi" , "http://www.w3.org/2001/XMLSchema-instance" ) ;
writer . WriteAttributeString ( "xmlns:xsd" , "http://www.w3.org/2001/XMLSchema" ) ;
2010-10-14 16:05:46 +00:00
writer . WriteElementString ( "AllowedDrop" , sop . AllowedDrop . ToString ( ) . ToLower ( ) ) ;
2010-11-21 21:16:52 +00:00
2010-10-16 00:27:19 +00:00
WriteUUID ( writer , "CreatorID" , sop . CreatorID , options ) ;
2010-11-21 21:16:52 +00:00
if ( sop . CreatorData ! = null & & sop . CreatorData ! = string . Empty )
writer . WriteElementString ( "CreatorData" , sop . CreatorData ) ;
else if ( options . ContainsKey ( "profile" ) )
{
if ( m_UserManagement = = null )
m_UserManagement = sop . ParentGroup . Scene . RequestModuleInterface < IUserManagement > ( ) ;
string name = m_UserManagement . GetUserName ( sop . CreatorID ) ;
writer . WriteElementString ( "CreatorData" , ( string ) options [ "profile" ] + "/" + sop . CreatorID + ";" + name ) ;
}
2010-10-16 00:27:19 +00:00
WriteUUID ( writer , "FolderID" , sop . FolderID , options ) ;
2010-10-14 16:05:46 +00:00
writer . WriteElementString ( "InventorySerial" , sop . InventorySerial . ToString ( ) ) ;
2010-10-13 15:16:41 +00:00
2010-11-22 01:19:24 +00:00
WriteTaskInventory ( writer , sop . TaskInventory , options , sop . ParentGroup . Scene ) ;
2010-10-13 15:16:41 +00:00
2010-10-16 00:27:19 +00:00
WriteUUID ( writer , "UUID" , sop . UUID , options ) ;
2010-10-13 15:16:41 +00:00
writer . WriteElementString ( "LocalId" , sop . LocalId . ToString ( ) ) ;
writer . WriteElementString ( "Name" , sop . Name ) ;
2010-10-14 16:05:46 +00:00
writer . WriteElementString ( "Material" , sop . Material . ToString ( ) ) ;
writer . WriteElementString ( "PassTouches" , sop . PassTouches . ToString ( ) . ToLower ( ) ) ;
2010-10-13 15:16:41 +00:00
writer . WriteElementString ( "RegionHandle" , sop . RegionHandle . ToString ( ) ) ;
writer . WriteElementString ( "ScriptAccessPin" , sop . ScriptAccessPin . ToString ( ) ) ;
WriteVector ( writer , "GroupPosition" , sop . GroupPosition ) ;
WriteVector ( writer , "OffsetPosition" , sop . OffsetPosition ) ;
WriteQuaternion ( writer , "RotationOffset" , sop . RotationOffset ) ;
WriteVector ( writer , "Velocity" , sop . Velocity ) ;
WriteVector ( writer , "AngularVelocity" , sop . AngularVelocity ) ;
WriteVector ( writer , "Acceleration" , sop . Acceleration ) ;
writer . WriteElementString ( "Description" , sop . Description ) ;
2010-12-17 22:40:11 +00:00
writer . WriteStartElement ( "Color" ) ;
writer . WriteElementString ( "R" , sop . Color . R . ToString ( Utils . EnUsCulture ) ) ;
writer . WriteElementString ( "G" , sop . Color . G . ToString ( Utils . EnUsCulture ) ) ;
writer . WriteElementString ( "B" , sop . Color . B . ToString ( Utils . EnUsCulture ) ) ;
writer . WriteElementString ( "A" , sop . Color . G . ToString ( Utils . EnUsCulture ) ) ;
writer . WriteEndElement ( ) ;
2010-10-14 16:05:46 +00:00
2010-10-13 15:16:41 +00:00
writer . WriteElementString ( "Text" , sop . Text ) ;
writer . WriteElementString ( "SitName" , sop . SitName ) ;
writer . WriteElementString ( "TouchName" , sop . TouchName ) ;
writer . WriteElementString ( "LinkNum" , sop . LinkNum . ToString ( ) ) ;
writer . WriteElementString ( "ClickAction" , sop . ClickAction . ToString ( ) ) ;
2010-10-16 00:27:19 +00:00
WriteShape ( writer , sop . Shape , options ) ;
2010-10-13 15:16:41 +00:00
WriteVector ( writer , "Scale" , sop . Scale ) ;
2010-10-14 16:05:46 +00:00
writer . WriteElementString ( "UpdateFlag" , sop . UpdateFlag . ToString ( ) ) ;
2010-10-13 15:16:41 +00:00
WriteQuaternion ( writer , "SitTargetOrientation" , sop . SitTargetOrientation ) ;
WriteVector ( writer , "SitTargetPosition" , sop . SitTargetPosition ) ;
WriteVector ( writer , "SitTargetPositionLL" , sop . SitTargetPositionLL ) ;
WriteQuaternion ( writer , "SitTargetOrientationLL" , sop . SitTargetOrientationLL ) ;
writer . WriteElementString ( "ParentID" , sop . ParentID . ToString ( ) ) ;
writer . WriteElementString ( "CreationDate" , sop . CreationDate . ToString ( ) ) ;
2010-10-14 16:05:46 +00:00
writer . WriteElementString ( "Category" , sop . Category . ToString ( ) ) ;
2010-10-13 15:16:41 +00:00
writer . WriteElementString ( "SalePrice" , sop . SalePrice . ToString ( ) ) ;
2010-10-14 16:05:46 +00:00
writer . WriteElementString ( "ObjectSaleType" , sop . ObjectSaleType . ToString ( ) ) ;
writer . WriteElementString ( "OwnershipCost" , sop . OwnershipCost . ToString ( ) ) ;
2010-10-16 00:27:19 +00:00
WriteUUID ( writer , "GroupID" , sop . GroupID , options ) ;
WriteUUID ( writer , "OwnerID" , sop . OwnerID , options ) ;
WriteUUID ( writer , "LastOwnerID" , sop . LastOwnerID , options ) ;
2010-10-13 15:16:41 +00:00
writer . WriteElementString ( "BaseMask" , sop . BaseMask . ToString ( ) ) ;
writer . WriteElementString ( "OwnerMask" , sop . OwnerMask . ToString ( ) ) ;
writer . WriteElementString ( "GroupMask" , sop . GroupMask . ToString ( ) ) ;
writer . WriteElementString ( "EveryoneMask" , sop . EveryoneMask . ToString ( ) ) ;
writer . WriteElementString ( "NextOwnerMask" , sop . NextOwnerMask . ToString ( ) ) ;
2011-04-20 21:59:06 +00:00
//DSG SYNC: also serialize SceneObjectPart:LocalFlags, so that it can be propogated across actors
2011-02-08 23:55:00 +00:00
WriteFlags ( writer , "Flags" , sop . Flags . ToString ( ) , options ) ;
2011-03-07 23:51:59 +00:00
WriteFlags ( writer , "LocalFlags" , sop . LocalFlags . ToString ( ) , options ) ;
2011-04-20 21:59:06 +00:00
//end DSG SYNC
2010-10-16 00:27:19 +00:00
WriteUUID ( writer , "CollisionSound" , sop . CollisionSound , options ) ;
2010-10-13 15:16:41 +00:00
writer . WriteElementString ( "CollisionSoundVolume" , sop . CollisionSoundVolume . ToString ( ) ) ;
2010-10-14 16:05:46 +00:00
if ( sop . MediaUrl ! = null )
writer . WriteElementString ( "MediaUrl" , sop . MediaUrl . ToString ( ) ) ;
2010-10-19 07:04:02 +00:00
WriteBytes ( writer , "TextureAnimation" , sop . TextureAnimation ) ;
WriteBytes ( writer , "ParticleSystem" , sop . ParticleSystem ) ;
2010-10-13 15:16:41 +00:00
2011-04-20 21:59:06 +00:00
//DSG SYNC
2011-02-16 22:29:08 +00:00
//These properties are only meaningful for synchronization purpose. For saving oar files, they are not necessary.
//We may remove these if later we use a different method to encode object properties for synchronization.
2011-05-04 21:36:18 +00:00
/ *
2011-02-16 22:29:08 +00:00
WriteUUID ( writer , "AttachedAvatar" , sop . AttachedAvatar , options ) ;
WriteVector ( writer , "AttachedPos" , sop . AttachedPos ) ;
writer . WriteElementString ( "AttachmentPoint" , sop . AttachmentPoint . ToString ( ) ) ;
2011-02-17 00:57:47 +00:00
//writer.WriteElementString("IsAttachment", sop.IsAttachment.ToString().ToLower()); //IsAttachment is written last, so that on deserialization, it will be deserialized later than other Attachment properties
2011-02-16 22:29:08 +00:00
WriteFlags ( writer , "AggregateScriptEvents" , sop . AggregateScriptEvents . ToString ( ) , options ) ;
2011-02-03 20:01:08 +00:00
WriteBucketSyncInfo ( writer , sop . BucketSyncInfoList ) ;
2011-05-04 21:36:18 +00:00
* * /
2011-04-20 21:59:06 +00:00
//end of DSG SYNC
2010-12-27 20:15:39 +00:00
2010-10-13 15:16:41 +00:00
writer . WriteEndElement ( ) ;
}
2011-04-20 21:59:06 +00:00
//DSG SYNC
2011-02-03 20:01:08 +00:00
public static void WriteBucketSyncInfo ( XmlTextWriter writer , Dictionary < string , BucketSyncInfo > bucketSyncInfoList )
{
if ( bucketSyncInfoList ! = null | | bucketSyncInfoList . Count > 0 ) // otherwise skip this
{
writer . WriteStartElement ( "BucketSyncInfoList" ) ;
foreach ( KeyValuePair < string , BucketSyncInfo > pair in bucketSyncInfoList )
{
BucketSyncInfo bucketSyncInfo = pair . Value ;
writer . WriteStartElement ( "Bucket" ) ;
writer . WriteElementString ( "Name" , bucketSyncInfo . BucketName ) ;
writer . WriteElementString ( "TimeStamp" , bucketSyncInfo . LastUpdateTimeStamp . ToString ( ) ) ;
writer . WriteElementString ( "ActorID" , bucketSyncInfo . LastUpdateActorID ) ;
writer . WriteEndElement ( ) ; // Bucket
}
writer . WriteEndElement ( ) ; // BucketSyncInfo
}
}
2011-04-20 21:59:06 +00:00
//end of DSG SYNC
2011-02-03 20:01:08 +00:00
2010-10-16 00:27:19 +00:00
static void WriteUUID ( XmlTextWriter writer , string name , UUID id , Dictionary < string , object > options )
2010-10-13 15:16:41 +00:00
{
writer . WriteStartElement ( name ) ;
2010-10-16 00:27:19 +00:00
if ( options . ContainsKey ( "old-guids" ) )
writer . WriteElementString ( "Guid" , id . ToString ( ) ) ;
else
writer . WriteElementString ( "UUID" , id . ToString ( ) ) ;
2010-10-13 15:16:41 +00:00
writer . WriteEndElement ( ) ;
}
static void WriteVector ( XmlTextWriter writer , string name , Vector3 vec )
{
writer . WriteStartElement ( name ) ;
writer . WriteElementString ( "X" , vec . X . ToString ( Utils . EnUsCulture ) ) ;
writer . WriteElementString ( "Y" , vec . Y . ToString ( Utils . EnUsCulture ) ) ;
writer . WriteElementString ( "Z" , vec . Z . ToString ( Utils . EnUsCulture ) ) ;
writer . WriteEndElement ( ) ;
}
static void WriteQuaternion ( XmlTextWriter writer , string name , Quaternion quat )
{
writer . WriteStartElement ( name ) ;
writer . WriteElementString ( "X" , quat . X . ToString ( Utils . EnUsCulture ) ) ;
writer . WriteElementString ( "Y" , quat . Y . ToString ( Utils . EnUsCulture ) ) ;
writer . WriteElementString ( "Z" , quat . Z . ToString ( Utils . EnUsCulture ) ) ;
writer . WriteElementString ( "W" , quat . W . ToString ( Utils . EnUsCulture ) ) ;
writer . WriteEndElement ( ) ;
}
2010-10-19 07:04:02 +00:00
static void WriteBytes ( XmlTextWriter writer , string name , byte [ ] data )
{
writer . WriteStartElement ( name ) ;
byte [ ] d ;
if ( data ! = null )
d = data ;
else
d = Utils . EmptyBytes ;
writer . WriteBase64 ( d , 0 , d . Length ) ;
writer . WriteEndElement ( ) ; // name
}
2010-11-02 19:05:24 +00:00
static void WriteFlags ( XmlTextWriter writer , string name , string flagsStr , Dictionary < string , object > options )
{
2010-11-29 16:43:33 +00:00
// Older versions of serialization can't cope with commas, so we eliminate the commas
writer . WriteElementString ( name , flagsStr . Replace ( "," , "" ) ) ;
2010-11-02 19:05:24 +00:00
}
2011-04-08 22:08:56 +00:00
//DSG SYNC: make it a public function, so that we can call serialization of TaskInventory from other places
//static void WriteTaskInventory(XmlTextWriter writer, TaskInventoryDictionary tinv, Dictionary<string, object> options, Scene scene)
public static void WriteTaskInventory ( XmlTextWriter writer , TaskInventoryDictionary tinv , Dictionary < string , object > options , Scene scene )
2010-10-14 16:05:46 +00:00
{
if ( tinv . Count > 0 ) // otherwise skip this
{
writer . WriteStartElement ( "TaskInventory" ) ;
foreach ( TaskInventoryItem item in tinv . Values )
{
writer . WriteStartElement ( "TaskInventoryItem" ) ;
2010-10-16 00:27:19 +00:00
WriteUUID ( writer , "AssetID" , item . AssetID , options ) ;
2010-10-14 16:05:46 +00:00
writer . WriteElementString ( "BasePermissions" , item . BasePermissions . ToString ( ) ) ;
writer . WriteElementString ( "CreationDate" , item . CreationDate . ToString ( ) ) ;
2010-11-22 01:19:24 +00:00
2010-10-16 00:27:19 +00:00
WriteUUID ( writer , "CreatorID" , item . CreatorID , options ) ;
2010-11-22 01:19:24 +00:00
if ( item . CreatorData ! = null & & item . CreatorData ! = string . Empty )
writer . WriteElementString ( "CreatorData" , item . CreatorData ) ;
else if ( options . ContainsKey ( "profile" ) )
{
if ( m_UserManagement = = null )
m_UserManagement = scene . RequestModuleInterface < IUserManagement > ( ) ;
string name = m_UserManagement . GetUserName ( item . CreatorID ) ;
writer . WriteElementString ( "CreatorData" , ( string ) options [ "profile" ] + "/" + item . CreatorID + ";" + name ) ;
}
2010-10-14 16:05:46 +00:00
writer . WriteElementString ( "Description" , item . Description ) ;
writer . WriteElementString ( "EveryonePermissions" , item . EveryonePermissions . ToString ( ) ) ;
writer . WriteElementString ( "Flags" , item . Flags . ToString ( ) ) ;
2010-10-16 00:27:19 +00:00
WriteUUID ( writer , "GroupID" , item . GroupID , options ) ;
2010-10-14 16:05:46 +00:00
writer . WriteElementString ( "GroupPermissions" , item . GroupPermissions . ToString ( ) ) ;
writer . WriteElementString ( "InvType" , item . InvType . ToString ( ) ) ;
2010-10-16 00:27:19 +00:00
WriteUUID ( writer , "ItemID" , item . ItemID , options ) ;
WriteUUID ( writer , "OldItemID" , item . OldItemID , options ) ;
WriteUUID ( writer , "LastOwnerID" , item . LastOwnerID , options ) ;
2010-10-14 16:05:46 +00:00
writer . WriteElementString ( "Name" , item . Name ) ;
writer . WriteElementString ( "NextPermissions" , item . NextPermissions . ToString ( ) ) ;
2010-10-16 00:27:19 +00:00
WriteUUID ( writer , "OwnerID" , item . OwnerID , options ) ;
2010-10-14 16:05:46 +00:00
writer . WriteElementString ( "CurrentPermissions" , item . CurrentPermissions . ToString ( ) ) ;
2010-10-16 00:27:19 +00:00
WriteUUID ( writer , "ParentID" , item . ParentID , options ) ;
WriteUUID ( writer , "ParentPartID" , item . ParentPartID , options ) ;
WriteUUID ( writer , "PermsGranter" , item . PermsGranter , options ) ;
2010-10-14 16:05:46 +00:00
writer . WriteElementString ( "PermsMask" , item . PermsMask . ToString ( ) ) ;
writer . WriteElementString ( "Type" , item . Type . ToString ( ) ) ;
2010-10-17 17:35:38 +00:00
writer . WriteElementString ( "OwnerChanged" , item . OwnerChanged . ToString ( ) . ToLower ( ) ) ;
2010-10-14 16:05:46 +00:00
writer . WriteEndElement ( ) ; // TaskInventoryItem
}
writer . WriteEndElement ( ) ; // TaskInventory
}
}
2011-04-08 22:08:56 +00:00
//DSG SYNC: make it a public function, so that we can call serialization of Shape from other places
//static void WriteShape(XmlTextWriter writer, PrimitiveBaseShape shp, Dictionary<string, object> options)
public static void WriteShape ( XmlTextWriter writer , PrimitiveBaseShape shp , Dictionary < string , object > options )
2010-10-14 16:05:46 +00:00
{
if ( shp ! = null )
{
writer . WriteStartElement ( "Shape" ) ;
writer . WriteElementString ( "ProfileCurve" , shp . ProfileCurve . ToString ( ) ) ;
writer . WriteStartElement ( "TextureEntry" ) ;
byte [ ] te ;
if ( shp . TextureEntry ! = null )
te = shp . TextureEntry ;
else
te = Utils . EmptyBytes ;
writer . WriteBase64 ( te , 0 , te . Length ) ;
writer . WriteEndElement ( ) ; // TextureEntry
writer . WriteStartElement ( "ExtraParams" ) ;
byte [ ] ep ;
if ( shp . ExtraParams ! = null )
ep = shp . ExtraParams ;
else
ep = Utils . EmptyBytes ;
writer . WriteBase64 ( ep , 0 , ep . Length ) ;
writer . WriteEndElement ( ) ; // ExtraParams
writer . WriteElementString ( "PathBegin" , shp . PathBegin . ToString ( ) ) ;
writer . WriteElementString ( "PathCurve" , shp . PathCurve . ToString ( ) ) ;
writer . WriteElementString ( "PathEnd" , shp . PathEnd . ToString ( ) ) ;
writer . WriteElementString ( "PathRadiusOffset" , shp . PathRadiusOffset . ToString ( ) ) ;
writer . WriteElementString ( "PathRevolutions" , shp . PathRevolutions . ToString ( ) ) ;
writer . WriteElementString ( "PathScaleX" , shp . PathScaleX . ToString ( ) ) ;
writer . WriteElementString ( "PathScaleY" , shp . PathScaleY . ToString ( ) ) ;
writer . WriteElementString ( "PathShearX" , shp . PathShearX . ToString ( ) ) ;
writer . WriteElementString ( "PathShearY" , shp . PathShearY . ToString ( ) ) ;
writer . WriteElementString ( "PathSkew" , shp . PathSkew . ToString ( ) ) ;
writer . WriteElementString ( "PathTaperX" , shp . PathTaperX . ToString ( ) ) ;
writer . WriteElementString ( "PathTaperY" , shp . PathTaperY . ToString ( ) ) ;
writer . WriteElementString ( "PathTwist" , shp . PathTwist . ToString ( ) ) ;
writer . WriteElementString ( "PathTwistBegin" , shp . PathTwistBegin . ToString ( ) ) ;
writer . WriteElementString ( "PCode" , shp . PCode . ToString ( ) ) ;
writer . WriteElementString ( "ProfileBegin" , shp . ProfileBegin . ToString ( ) ) ;
writer . WriteElementString ( "ProfileEnd" , shp . ProfileEnd . ToString ( ) ) ;
writer . WriteElementString ( "ProfileHollow" , shp . ProfileHollow . ToString ( ) ) ;
2011-04-19 18:11:14 +00:00
//DSG SYNC: added serialization of Shape
WriteVector ( writer , "Scale" , shp . Scale ) ;
//end of DSG SYNC
2010-10-14 16:05:46 +00:00
writer . WriteElementString ( "State" , shp . State . ToString ( ) ) ;
2010-11-02 19:05:24 +00:00
WriteFlags ( writer , "ProfileShape" , shp . ProfileShape . ToString ( ) , options ) ;
WriteFlags ( writer , "HollowShape" , shp . HollowShape . ToString ( ) , options ) ;
2010-10-14 16:05:46 +00:00
2010-10-16 00:27:19 +00:00
WriteUUID ( writer , "SculptTexture" , shp . SculptTexture , options ) ;
2010-10-14 16:05:46 +00:00
writer . WriteElementString ( "SculptType" , shp . SculptType . ToString ( ) ) ;
writer . WriteStartElement ( "SculptData" ) ;
byte [ ] sd ;
if ( shp . SculptData ! = null )
2011-04-13 02:45:33 +00:00
sd = shp . SculptData ;
2010-10-14 16:05:46 +00:00
else
sd = Utils . EmptyBytes ;
writer . WriteBase64 ( sd , 0 , sd . Length ) ;
writer . WriteEndElement ( ) ; // SculptData
writer . WriteElementString ( "FlexiSoftness" , shp . FlexiSoftness . ToString ( ) ) ;
writer . WriteElementString ( "FlexiTension" , shp . FlexiTension . ToString ( ) ) ;
writer . WriteElementString ( "FlexiDrag" , shp . FlexiDrag . ToString ( ) ) ;
writer . WriteElementString ( "FlexiGravity" , shp . FlexiGravity . ToString ( ) ) ;
writer . WriteElementString ( "FlexiWind" , shp . FlexiWind . ToString ( ) ) ;
writer . WriteElementString ( "FlexiForceX" , shp . FlexiForceX . ToString ( ) ) ;
writer . WriteElementString ( "FlexiForceY" , shp . FlexiForceY . ToString ( ) ) ;
writer . WriteElementString ( "FlexiForceZ" , shp . FlexiForceZ . ToString ( ) ) ;
writer . WriteElementString ( "LightColorR" , shp . LightColorR . ToString ( ) ) ;
writer . WriteElementString ( "LightColorG" , shp . LightColorG . ToString ( ) ) ;
writer . WriteElementString ( "LightColorB" , shp . LightColorB . ToString ( ) ) ;
writer . WriteElementString ( "LightColorA" , shp . LightColorA . ToString ( ) ) ;
writer . WriteElementString ( "LightRadius" , shp . LightRadius . ToString ( ) ) ;
writer . WriteElementString ( "LightCutoff" , shp . LightCutoff . ToString ( ) ) ;
writer . WriteElementString ( "LightFalloff" , shp . LightFalloff . ToString ( ) ) ;
writer . WriteElementString ( "LightIntensity" , shp . LightIntensity . ToString ( ) ) ;
writer . WriteElementString ( "FlexiEntry" , shp . FlexiEntry . ToString ( ) . ToLower ( ) ) ;
writer . WriteElementString ( "LightEntry" , shp . LightEntry . ToString ( ) . ToLower ( ) ) ;
writer . WriteElementString ( "SculptEntry" , shp . SculptEntry . ToString ( ) . ToLower ( ) ) ;
if ( shp . Media ! = null )
writer . WriteElementString ( "Media" , shp . Media . ToXml ( ) ) ;
writer . WriteEndElement ( ) ; // Shape
}
}
2010-10-13 15:16:41 +00:00
//////// Read /////////
public static bool Xml2ToSOG ( XmlTextReader reader , SceneObjectGroup sog )
{
reader . Read ( ) ;
reader . ReadStartElement ( "SceneObjectGroup" ) ;
SceneObjectPart root = Xml2ToSOP ( reader ) ;
if ( root ! = null )
sog . SetRootPart ( root ) ;
else
{
return false ;
}
if ( sog . UUID = = UUID . Zero )
sog . UUID = sog . RootPart . UUID ;
reader . Read ( ) ; // OtherParts
while ( ! reader . EOF )
{
switch ( reader . NodeType )
{
case XmlNodeType . Element :
if ( reader . Name = = "SceneObjectPart" )
{
SceneObjectPart child = Xml2ToSOP ( reader ) ;
if ( child ! = null )
sog . AddPart ( child ) ;
}
else
{
//Logger.Log("Found unexpected prim XML element " + reader.Name, Helpers.LogLevel.Debug);
reader . Read ( ) ;
}
break ;
case XmlNodeType . EndElement :
default :
reader . Read ( ) ;
break ;
}
}
return true ;
}
public static SceneObjectPart Xml2ToSOP ( XmlTextReader reader )
{
SceneObjectPart obj = new SceneObjectPart ( ) ;
reader . ReadStartElement ( "SceneObjectPart" ) ;
string nodeName = string . Empty ;
while ( reader . NodeType ! = XmlNodeType . EndElement )
{
nodeName = reader . Name ;
SOPXmlProcessor p = null ;
if ( m_SOPXmlProcessors . TryGetValue ( reader . Name , out p ) )
{
2010-10-14 16:05:46 +00:00
//m_log.DebugFormat("[XXX] Processing: {0}", reader.Name);
2010-10-13 15:16:41 +00:00
try
{
p ( obj , reader ) ;
}
catch ( Exception e )
{
2010-10-14 16:05:46 +00:00
m_log . DebugFormat ( "[SceneObjectSerializer]: exception while parsing {0}: {1}" , nodeName , e ) ;
if ( reader . NodeType = = XmlNodeType . EndElement )
reader . Read ( ) ;
2010-10-13 15:16:41 +00:00
}
}
else
{
2010-10-19 00:22:31 +00:00
// m_log.DebugFormat("[SceneObjectSerializer]: caught unknown element {0}", nodeName);
2010-10-13 15:16:41 +00:00
reader . ReadOuterXml ( ) ; // ignore
}
}
reader . ReadEndElement ( ) ; // SceneObjectPart
//m_log.DebugFormat("[XXX]: parsed SOP {0} - {1}", obj.Name, obj.UUID);
return obj ;
}
2011-04-08 22:55:40 +00:00
//DSG SYNC: make it public to be called outside
//static TaskInventoryDictionary ReadTaskInventory(XmlTextReader reader, string name)
public static TaskInventoryDictionary ReadTaskInventory ( XmlTextReader reader , string name )
2010-10-13 15:16:41 +00:00
{
TaskInventoryDictionary tinv = new TaskInventoryDictionary ( ) ;
2011-01-08 23:49:51 +00:00
if ( reader . IsEmptyElement )
{
reader . Read ( ) ;
return tinv ;
}
2010-10-13 15:16:41 +00:00
reader . ReadStartElement ( name , String . Empty ) ;
while ( reader . Name = = "TaskInventoryItem" )
{
reader . ReadStartElement ( "TaskInventoryItem" , String . Empty ) ; // TaskInventory
TaskInventoryItem item = new TaskInventoryItem ( ) ;
while ( reader . NodeType ! = XmlNodeType . EndElement )
{
TaskInventoryXmlProcessor p = null ;
if ( m_TaskInventoryXmlProcessors . TryGetValue ( reader . Name , out p ) )
p ( item , reader ) ;
else
{
2010-10-18 23:51:04 +00:00
// m_log.DebugFormat("[SceneObjectSerializer]: caught unknown element in TaskInventory {0}, {1}", reader.Name, reader.Value);
2010-10-13 15:16:41 +00:00
reader . ReadOuterXml ( ) ;
}
}
reader . ReadEndElement ( ) ; // TaskInventoryItem
tinv . Add ( item . ItemID , item ) ;
}
if ( reader . NodeType = = XmlNodeType . EndElement )
reader . ReadEndElement ( ) ; // TaskInventory
return tinv ;
}
2011-04-08 22:55:40 +00:00
//DSG SYNC: make it public to be called outside
//static PrimitiveBaseShape ReadShape(XmlTextReader reader, string name)
public static PrimitiveBaseShape ReadShape ( XmlTextReader reader , string name )
2010-10-13 15:16:41 +00:00
{
PrimitiveBaseShape shape = new PrimitiveBaseShape ( ) ;
2011-01-08 23:49:51 +00:00
if ( reader . IsEmptyElement )
{
reader . Read ( ) ;
return shape ;
}
2010-10-13 15:16:41 +00:00
reader . ReadStartElement ( name , String . Empty ) ; // Shape
2010-10-24 03:39:41 +00:00
string nodeName = string . Empty ;
2010-10-13 15:16:41 +00:00
while ( reader . NodeType ! = XmlNodeType . EndElement )
{
2010-10-24 03:39:41 +00:00
nodeName = reader . Name ;
2010-10-14 16:05:46 +00:00
//m_log.DebugFormat("[XXX] Processing: {0}", reader.Name);
2010-10-13 15:16:41 +00:00
ShapeXmlProcessor p = null ;
if ( m_ShapeXmlProcessors . TryGetValue ( reader . Name , out p ) )
2010-10-24 03:39:41 +00:00
{
try
{
p ( shape , reader ) ;
}
catch ( Exception e )
{
m_log . DebugFormat ( "[SceneObjectSerializer]: exception while parsing Shape {0}: {1}" , nodeName , e ) ;
if ( reader . NodeType = = XmlNodeType . EndElement )
reader . Read ( ) ;
}
}
2010-10-13 15:16:41 +00:00
else
{
2010-10-24 03:39:41 +00:00
// m_log.DebugFormat("[SceneObjectSerializer]: caught unknown element in Shape {0}", reader.Name);
2010-10-13 15:16:41 +00:00
reader . ReadOuterXml ( ) ;
}
}
reader . ReadEndElement ( ) ; // Shape
return shape ;
}
# endregion
2009-05-08 15:47:59 +00:00
}
}