aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs2
-rw-r--r--OpenSim/Data/MySQL/MySQLPresenceData.cs6
-rw-r--r--OpenSim/Data/MySQL/MySQLSimulationData.cs1
-rw-r--r--OpenSim/Data/MySQL/Resources/Presence.migrations8
-rw-r--r--OpenSim/Framework/Capabilities/Caps.cs6
-rw-r--r--OpenSim/Framework/Capabilities/LLSDAssetUploadResponse.cs14
-rw-r--r--OpenSim/Framework/PrimitiveBaseShape.cs129
-rw-r--r--OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs3
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Assets/GetMeshModule.cs202
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Assets/NewFileAgentInventoryVariablePriceModule.cs266
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs12
-rw-r--r--OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs22
-rw-r--r--OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequestExecution.cs48
-rw-r--r--OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequestPreparation.cs65
-rw-r--r--OpenSim/Region/CoreModules/World/Archiver/ArchiverModule.cs27
-rw-r--r--OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs4
-rw-r--r--OpenSim/Region/CoreModules/World/Serialiser/SerialiserModule.cs4
-rw-r--r--OpenSim/Region/CoreModules/World/Serialiser/Tests/SerialiserTests.cs19
-rw-r--r--OpenSim/Region/Framework/Interfaces/IRegionArchiverModule.cs5
-rw-r--r--OpenSim/Region/Framework/Interfaces/IRegionSerialiserModule.cs2
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectPart.cs125
-rw-r--r--OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs1262
-rw-r--r--OpenSim/Region/Framework/Scenes/Serialization/SceneXmlLoader.cs237
-rw-r--r--OpenSim/Region/Physics/Meshing/Meshmerizer.cs207
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs42
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs3
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs10
27 files changed, 2400 insertions, 331 deletions
diff --git a/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs b/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs
index bb0a5b5..aeed467 100644
--- a/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs
+++ b/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs
@@ -2284,7 +2284,7 @@ namespace OpenSim.ApplicationPlugins.RemoteController
2284 if (archiver != null) 2284 if (archiver != null)
2285 { 2285 {
2286 scene.EventManager.OnOarFileSaved += RemoteAdminOarSaveCompleted; 2286 scene.EventManager.OnOarFileSaved += RemoteAdminOarSaveCompleted;
2287 archiver.ArchiveRegion(filename); 2287 archiver.ArchiveRegion(filename, new Dictionary<string, object>());
2288 lock (m_saveOarLock) Monitor.Wait(m_saveOarLock,5000); 2288 lock (m_saveOarLock) Monitor.Wait(m_saveOarLock,5000);
2289 scene.EventManager.OnOarFileSaved -= RemoteAdminOarSaveCompleted; 2289 scene.EventManager.OnOarFileSaved -= RemoteAdminOarSaveCompleted;
2290 } 2290 }
diff --git a/OpenSim/Data/MySQL/MySQLPresenceData.cs b/OpenSim/Data/MySQL/MySQLPresenceData.cs
index 71caa1a..2390feb 100644
--- a/OpenSim/Data/MySQL/MySQLPresenceData.cs
+++ b/OpenSim/Data/MySQL/MySQLPresenceData.cs
@@ -78,9 +78,12 @@ namespace OpenSim.Data.MySQL
78 if (pd.Length == 0) 78 if (pd.Length == 0)
79 return false; 79 return false;
80 80
81 if (regionID == UUID.Zero)
82 return false;
83
81 MySqlCommand cmd = new MySqlCommand(); 84 MySqlCommand cmd = new MySqlCommand();
82 85
83 cmd.CommandText = String.Format("update {0} set RegionID=?RegionID where `SessionID`=?SessionID", m_Realm); 86 cmd.CommandText = String.Format("update {0} set RegionID=?RegionID, LastSeen=NOW() where `SessionID`=?SessionID", m_Realm);
84 87
85 cmd.Parameters.AddWithValue("?SessionID", sessionID.ToString()); 88 cmd.Parameters.AddWithValue("?SessionID", sessionID.ToString());
86 cmd.Parameters.AddWithValue("?RegionID", regionID.ToString()); 89 cmd.Parameters.AddWithValue("?RegionID", regionID.ToString());
@@ -90,6 +93,5 @@ namespace OpenSim.Data.MySQL
90 93
91 return true; 94 return true;
92 } 95 }
93
94 } 96 }
95} 97}
diff --git a/OpenSim/Data/MySQL/MySQLSimulationData.cs b/OpenSim/Data/MySQL/MySQLSimulationData.cs
index 3450e2f..e2b6953 100644
--- a/OpenSim/Data/MySQL/MySQLSimulationData.cs
+++ b/OpenSim/Data/MySQL/MySQLSimulationData.cs
@@ -424,6 +424,7 @@ namespace OpenSim.Data.MySQL
424 cmd.CommandText = 424 cmd.CommandText =
425 "SELECT * FROM prims LEFT JOIN primshapes ON prims.UUID = primshapes.UUID WHERE RegionUUID = ?RegionUUID"; 425 "SELECT * FROM prims LEFT JOIN primshapes ON prims.UUID = primshapes.UUID WHERE RegionUUID = ?RegionUUID";
426 cmd.Parameters.AddWithValue("RegionUUID", regionID.ToString()); 426 cmd.Parameters.AddWithValue("RegionUUID", regionID.ToString());
427 cmd.CommandTimeout = 3600;
427 428
428 using (IDataReader reader = ExecuteReader(cmd)) 429 using (IDataReader reader = ExecuteReader(cmd))
429 { 430 {
diff --git a/OpenSim/Data/MySQL/Resources/Presence.migrations b/OpenSim/Data/MySQL/Resources/Presence.migrations
index 91f7de5..1075a15 100644
--- a/OpenSim/Data/MySQL/Resources/Presence.migrations
+++ b/OpenSim/Data/MySQL/Resources/Presence.migrations
@@ -13,3 +13,11 @@ CREATE UNIQUE INDEX SessionID ON Presence(SessionID);
13CREATE INDEX UserID ON Presence(UserID); 13CREATE INDEX UserID ON Presence(UserID);
14 14
15COMMIT; 15COMMIT;
16
17:VERSION 1 # --------------------------
18
19BEGIN;
20
21ALTER TABLE `Presence` ADD COLUMN LastSeen timestamp;
22
23COMMIT;
diff --git a/OpenSim/Framework/Capabilities/Caps.cs b/OpenSim/Framework/Capabilities/Caps.cs
index 6f32adf..72283de 100644
--- a/OpenSim/Framework/Capabilities/Caps.cs
+++ b/OpenSim/Framework/Capabilities/Caps.cs
@@ -962,10 +962,10 @@ namespace OpenSim.Framework.Capabilities
962 item.AssetType = assType; 962 item.AssetType = assType;
963 item.InvType = inType; 963 item.InvType = inType;
964 item.Folder = parentFolder; 964 item.Folder = parentFolder;
965 item.CurrentPermissions = 2147483647; 965 item.CurrentPermissions = (uint)PermissionMask.All;
966 item.BasePermissions = 2147483647; 966 item.BasePermissions = (uint)PermissionMask.All;
967 item.EveryOnePermissions = 0; 967 item.EveryOnePermissions = 0;
968 item.NextPermissions = 2147483647; 968 item.NextPermissions = (uint)(PermissionMask.Move | PermissionMask.Modify | PermissionMask.Transfer);
969 item.CreationDate = Util.UnixTimeSinceEpoch(); 969 item.CreationDate = Util.UnixTimeSinceEpoch();
970 970
971 if (AddNewInventoryItem != null) 971 if (AddNewInventoryItem != null)
diff --git a/OpenSim/Framework/Capabilities/LLSDAssetUploadResponse.cs b/OpenSim/Framework/Capabilities/LLSDAssetUploadResponse.cs
index 08f14e3..0d6f7f9 100644
--- a/OpenSim/Framework/Capabilities/LLSDAssetUploadResponse.cs
+++ b/OpenSim/Framework/Capabilities/LLSDAssetUploadResponse.cs
@@ -39,4 +39,18 @@ namespace OpenSim.Framework.Capabilities
39 { 39 {
40 } 40 }
41 } 41 }
42
43 [OSDMap]
44 public class LLSDNewFileAngentInventoryVariablePriceReplyResponse
45 {
46 public int resource_cost;
47 public string state;
48 public int upload_price;
49 public string rsvp;
50
51 public LLSDNewFileAngentInventoryVariablePriceReplyResponse()
52 {
53 state = "confirm_upload";
54 }
55 }
42} \ No newline at end of file 56} \ No newline at end of file
diff --git a/OpenSim/Framework/PrimitiveBaseShape.cs b/OpenSim/Framework/PrimitiveBaseShape.cs
index 0a81363..927415e 100644
--- a/OpenSim/Framework/PrimitiveBaseShape.cs
+++ b/OpenSim/Framework/PrimitiveBaseShape.cs
@@ -136,6 +136,13 @@ namespace OpenSim.Framework
136 [XmlIgnore] private bool _lightEntry; 136 [XmlIgnore] private bool _lightEntry;
137 [XmlIgnore] private bool _sculptEntry; 137 [XmlIgnore] private bool _sculptEntry;
138 138
139 // Light Projection Filter
140 [XmlIgnore] private bool _projectionEntry;
141 [XmlIgnore] private UUID _projectionTextureID;
142 [XmlIgnore] private float _projectionFOV;
143 [XmlIgnore] private float _projectionFocus;
144 [XmlIgnore] private float _projectionAmb;
145
139 public byte ProfileCurve 146 public byte ProfileCurve
140 { 147 {
141 get { return (byte)((byte)HollowShape | (byte)ProfileShape); } 148 get { return (byte)((byte)HollowShape | (byte)ProfileShape); }
@@ -795,11 +802,57 @@ namespace OpenSim.Framework
795 } 802 }
796 } 803 }
797 804
805 public bool ProjectionEntry {
806 get {
807 return _projectionEntry;
808 }
809 set {
810 _projectionEntry = value;
811 }
812 }
813
814 public UUID ProjectionTextureUUID {
815 get {
816 return _projectionTextureID;
817 }
818 set {
819 _projectionTextureID = value;
820 }
821 }
822
823 public float ProjectionFOV {
824 get {
825 return _projectionFOV;
826 }
827 set {
828 _projectionFOV = value;
829 }
830 }
831
832 public float ProjectionFocus {
833 get {
834 return _projectionFocus;
835 }
836 set {
837 _projectionFocus = value;
838 }
839 }
840
841 public float ProjectionAmbiance {
842 get {
843 return _projectionAmb;
844 }
845 set {
846 _projectionAmb = value;
847 }
848 }
849
798 public byte[] ExtraParamsToBytes() 850 public byte[] ExtraParamsToBytes()
799 { 851 {
800 ushort FlexiEP = 0x10; 852 ushort FlexiEP = 0x10;
801 ushort LightEP = 0x20; 853 ushort LightEP = 0x20;
802 ushort SculptEP = 0x30; 854 ushort SculptEP = 0x30;
855 ushort ProjectionEP = 0x40;
803 856
804 int i = 0; 857 int i = 0;
805 uint TotalBytesLength = 1; // ExtraParamsNum 858 uint TotalBytesLength = 1; // ExtraParamsNum
@@ -823,6 +876,12 @@ namespace OpenSim.Framework
823 TotalBytesLength += 17;// data 876 TotalBytesLength += 17;// data
824 TotalBytesLength += 2 + 4; // type 877 TotalBytesLength += 2 + 4; // type
825 } 878 }
879 if (_projectionEntry)
880 {
881 ExtraParamsNum++;
882 TotalBytesLength += 28;// data
883 TotalBytesLength += 2 + 4;// type
884 }
826 885
827 byte[] returnbytes = new byte[TotalBytesLength]; 886 byte[] returnbytes = new byte[TotalBytesLength];
828 887
@@ -874,8 +933,20 @@ namespace OpenSim.Framework
874 Array.Copy(SculptData, 0, returnbytes, i, SculptData.Length); 933 Array.Copy(SculptData, 0, returnbytes, i, SculptData.Length);
875 i += SculptData.Length; 934 i += SculptData.Length;
876 } 935 }
877 936 if (_projectionEntry)
878 if (!_flexiEntry && !_lightEntry && !_sculptEntry) 937 {
938 byte[] ProjectionData = GetProjectionBytes();
939
940 returnbytes[i++] = (byte)(ProjectionEP % 256);
941 returnbytes[i++] = (byte)((ProjectionEP >> 8) % 256);
942 returnbytes[i++] = (byte)((ProjectionData.Length) % 256);
943 returnbytes[i++] = (byte)((ProjectionData.Length >> 16) % 256);
944 returnbytes[i++] = (byte)((ProjectionData.Length >> 20) % 256);
945 returnbytes[i++] = (byte)((ProjectionData.Length >> 24) % 256);
946 Array.Copy(ProjectionData, 0, returnbytes, i, ProjectionData.Length);
947 i += ProjectionData.Length;
948 }
949 if (!_flexiEntry && !_lightEntry && !_sculptEntry && !_projectionEntry)
879 { 950 {
880 byte[] returnbyte = new byte[1]; 951 byte[] returnbyte = new byte[1];
881 returnbyte[0] = 0; 952 returnbyte[0] = 0;
@@ -893,6 +964,7 @@ namespace OpenSim.Framework
893 const ushort FlexiEP = 0x10; 964 const ushort FlexiEP = 0x10;
894 const ushort LightEP = 0x20; 965 const ushort LightEP = 0x20;
895 const ushort SculptEP = 0x30; 966 const ushort SculptEP = 0x30;
967 const ushort ProjectionEP = 0x40;
896 968
897 switch (type) 969 switch (type)
898 { 970 {
@@ -922,6 +994,14 @@ namespace OpenSim.Framework
922 } 994 }
923 ReadSculptData(data, 0); 995 ReadSculptData(data, 0);
924 break; 996 break;
997 case ProjectionEP:
998 if (!inUse)
999 {
1000 _projectionEntry = false;
1001 return;
1002 }
1003 ReadProjectionData(data, 0);
1004 break;
925 } 1005 }
926 } 1006 }
927 1007
@@ -933,10 +1013,12 @@ namespace OpenSim.Framework
933 const ushort FlexiEP = 0x10; 1013 const ushort FlexiEP = 0x10;
934 const ushort LightEP = 0x20; 1014 const ushort LightEP = 0x20;
935 const ushort SculptEP = 0x30; 1015 const ushort SculptEP = 0x30;
1016 const ushort ProjectionEP = 0x40;
936 1017
937 bool lGotFlexi = false; 1018 bool lGotFlexi = false;
938 bool lGotLight = false; 1019 bool lGotLight = false;
939 bool lGotSculpt = false; 1020 bool lGotSculpt = false;
1021 bool lGotFilter = false;
940 1022
941 int i = 0; 1023 int i = 0;
942 byte extraParamCount = 0; 1024 byte extraParamCount = 0;
@@ -973,6 +1055,11 @@ namespace OpenSim.Framework
973 i += 17; 1055 i += 17;
974 lGotSculpt = true; 1056 lGotSculpt = true;
975 break; 1057 break;
1058 case ProjectionEP:
1059 ReadProjectionData(data, i);
1060 i += 28;
1061 lGotFilter = true;
1062 break;
976 } 1063 }
977 } 1064 }
978 1065
@@ -982,6 +1069,8 @@ namespace OpenSim.Framework
982 _lightEntry = false; 1069 _lightEntry = false;
983 if (!lGotSculpt) 1070 if (!lGotSculpt)
984 _sculptEntry = false; 1071 _sculptEntry = false;
1072 if (!lGotFilter)
1073 _projectionEntry = false;
985 1074
986 } 1075 }
987 1076
@@ -1121,6 +1210,42 @@ namespace OpenSim.Framework
1121 return data; 1210 return data;
1122 } 1211 }
1123 1212
1213 public void ReadProjectionData(byte[] data, int pos)
1214 {
1215 byte[] ProjectionTextureUUID = new byte[16];
1216
1217 if (data.Length - pos >= 28)
1218 {
1219 _projectionEntry = true;
1220 Array.Copy(data, pos, ProjectionTextureUUID,0, 16);
1221 _projectionTextureID = new UUID(ProjectionTextureUUID, 0);
1222
1223 _projectionFOV = Utils.BytesToFloat(data, pos + 16);
1224 _projectionFocus = Utils.BytesToFloat(data, pos + 20);
1225 _projectionAmb = Utils.BytesToFloat(data, pos + 24);
1226 }
1227 else
1228 {
1229 _projectionEntry = false;
1230 _projectionTextureID = UUID.Zero;
1231 _projectionFOV = 0f;
1232 _projectionFocus = 0f;
1233 _projectionAmb = 0f;
1234 }
1235 }
1236
1237 public byte[] GetProjectionBytes()
1238 {
1239 byte[] data = new byte[28];
1240
1241 _projectionTextureID.GetBytes().CopyTo(data, 0);
1242 Utils.FloatToBytes(_projectionFOV).CopyTo(data, 16);
1243 Utils.FloatToBytes(_projectionFocus).CopyTo(data, 20);
1244 Utils.FloatToBytes(_projectionAmb).CopyTo(data, 24);
1245
1246 return data;
1247 }
1248
1124 1249
1125 /// <summary> 1250 /// <summary>
1126 /// Creates a OpenMetaverse.Primitive and populates it with converted PrimitiveBaseShape values 1251 /// Creates a OpenMetaverse.Primitive and populates it with converted PrimitiveBaseShape values
diff --git a/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs b/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs
index 54e4a46..47e86ad 100644
--- a/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs
+++ b/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs
@@ -1474,7 +1474,8 @@ namespace OpenSim.Framework.Servers.HttpServer
1474 1474
1475 if (!(contentType.Contains("image") 1475 if (!(contentType.Contains("image")
1476 || contentType.Contains("x-shockwave-flash") 1476 || contentType.Contains("x-shockwave-flash")
1477 || contentType.Contains("application/x-oar"))) 1477 || contentType.Contains("application/x-oar")
1478 || contentType.Contains("application/vnd.ll.mesh")))
1478 { 1479 {
1479 // Text 1480 // Text
1480 buffer = Encoding.UTF8.GetBytes(responseString); 1481 buffer = Encoding.UTF8.GetBytes(responseString);
diff --git a/OpenSim/Region/CoreModules/Avatar/Assets/GetMeshModule.cs b/OpenSim/Region/CoreModules/Avatar/Assets/GetMeshModule.cs
new file mode 100644
index 0000000..36aaab3
--- /dev/null
+++ b/OpenSim/Region/CoreModules/Avatar/Assets/GetMeshModule.cs
@@ -0,0 +1,202 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using System.Collections;
30using System.Collections.Specialized;
31using System.Reflection;
32using System.IO;
33using System.Web;
34using Mono.Addins;
35using log4net;
36using Nini.Config;
37using OpenMetaverse;
38using OpenMetaverse.StructuredData;
39using OpenSim.Framework;
40using OpenSim.Framework.Servers;
41using OpenSim.Framework.Servers.HttpServer;
42using OpenSim.Region.Framework.Interfaces;
43using OpenSim.Region.Framework.Scenes;
44using OpenSim.Services.Interfaces;
45using Caps = OpenSim.Framework.Capabilities.Caps;
46
47namespace OpenSim.Region.CoreModules.Avatar.Assets
48{
49 [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule")]
50 public class GetMeshModule : INonSharedRegionModule
51 {
52 private static readonly ILog m_log =
53 LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
54 private Scene m_scene;
55 private IAssetService m_assetService;
56
57 #region IRegionModuleBase Members
58
59
60 public Type ReplaceableInterface
61 {
62 get { return null; }
63 }
64
65 public void Initialise(IConfigSource source)
66 {
67
68 }
69
70 public void AddRegion(Scene pScene)
71 {
72 m_scene = pScene;
73 }
74
75 public void RemoveRegion(Scene scene)
76 {
77
78 m_scene.EventManager.OnRegisterCaps -= RegisterCaps;
79 m_scene = null;
80 }
81
82 public void RegionLoaded(Scene scene)
83 {
84
85 m_assetService = m_scene.RequestModuleInterface<IAssetService>();
86 m_scene.EventManager.OnRegisterCaps += RegisterCaps;
87 }
88
89 #endregion
90
91
92 #region IRegionModule Members
93
94
95
96 public void Close() { }
97
98 public string Name { get { return "GetMeshModule"; } }
99
100
101 public void RegisterCaps(UUID agentID, Caps caps)
102 {
103 UUID capID = UUID.Random();
104
105 m_log.Info("[GETMESH]: /CAPS/" + capID);
106 caps.RegisterHandler("GetMesh",
107 new RestHTTPHandler("GET", "/CAPS/" + capID,
108 delegate(Hashtable m_dhttpMethod)
109 {
110 return ProcessGetMesh(m_dhttpMethod, agentID, caps);
111 }));
112
113 }
114
115 #endregion
116
117 public Hashtable ProcessGetMesh(Hashtable request, UUID AgentId, Caps cap)
118 {
119
120 Hashtable responsedata = new Hashtable();
121 responsedata["int_response_code"] = 400; //501; //410; //404;
122 responsedata["content_type"] = "text/plain";
123 responsedata["keepalive"] = false;
124 responsedata["str_response_string"] = "Request wasn't what was expected";
125
126 string meshStr = string.Empty;
127
128 if (request.ContainsKey("mesh_id"))
129 meshStr = request["mesh_id"].ToString();
130
131
132 UUID meshID = UUID.Zero;
133 if (!String.IsNullOrEmpty(meshStr) && UUID.TryParse(meshStr, out meshID))
134 {
135 if (m_assetService == null)
136 {
137 responsedata["int_response_code"] = 404; //501; //410; //404;
138 responsedata["content_type"] = "text/plain";
139 responsedata["keepalive"] = false;
140 responsedata["str_response_string"] = "The asset service is unavailable. So is your mesh.";
141 return responsedata;
142 }
143
144 AssetBase mesh;
145 // Only try to fetch locally cached textures. Misses are redirected
146 mesh = m_assetService.GetCached(meshID.ToString());
147 if (mesh != null)
148 {
149 if (mesh.Type == (SByte)AssetType.Mesh)
150 {
151 responsedata["str_response_string"] = Convert.ToBase64String(mesh.Data);
152 responsedata["content_type"] = "application/vnd.ll.mesh";
153 responsedata["int_response_code"] = 200;
154 }
155 // Optionally add additional mesh types here
156 else
157 {
158 responsedata["int_response_code"] = 404; //501; //410; //404;
159 responsedata["content_type"] = "text/plain";
160 responsedata["keepalive"] = false;
161 responsedata["str_response_string"] = "Unfortunately, this asset isn't a mesh.";
162 return responsedata;
163 }
164 }
165 else
166 {
167 mesh = m_assetService.Get(meshID.ToString());
168 if (mesh != null)
169 {
170 if (mesh.Type == (SByte)AssetType.Mesh)
171 {
172 responsedata["str_response_string"] = Convert.ToBase64String(mesh.Data);
173 responsedata["content_type"] = "application/vnd.ll.mesh";
174 responsedata["int_response_code"] = 200;
175 }
176 // Optionally add additional mesh types here
177 else
178 {
179 responsedata["int_response_code"] = 404; //501; //410; //404;
180 responsedata["content_type"] = "text/plain";
181 responsedata["keepalive"] = false;
182 responsedata["str_response_string"] = "Unfortunately, this asset isn't a mesh.";
183 return responsedata;
184 }
185 }
186
187 else
188 {
189 responsedata["int_response_code"] = 404; //501; //410; //404;
190 responsedata["content_type"] = "text/plain";
191 responsedata["keepalive"] = false;
192 responsedata["str_response_string"] = "Your Mesh wasn't found. Sorry!";
193 return responsedata;
194 }
195 }
196
197 }
198
199 return responsedata;
200 }
201 }
202}
diff --git a/OpenSim/Region/CoreModules/Avatar/Assets/NewFileAgentInventoryVariablePriceModule.cs b/OpenSim/Region/CoreModules/Avatar/Assets/NewFileAgentInventoryVariablePriceModule.cs
new file mode 100644
index 0000000..af26b2b
--- /dev/null
+++ b/OpenSim/Region/CoreModules/Avatar/Assets/NewFileAgentInventoryVariablePriceModule.cs
@@ -0,0 +1,266 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using System.Collections;
30using System.Collections.Specialized;
31using System.Reflection;
32using System.IO;
33using System.Web;
34using Mono.Addins;
35using log4net;
36using Nini.Config;
37using OpenMetaverse;
38using OpenMetaverse.StructuredData;
39using OpenSim.Framework;
40using OpenSim.Framework.Servers;
41using OpenSim.Framework.Servers.HttpServer;
42using OpenSim.Region.Framework.Interfaces;
43using OpenSim.Region.Framework.Scenes;
44using OpenSim.Services.Interfaces;
45using Caps = OpenSim.Framework.Capabilities.Caps;
46using OpenSim.Framework.Capabilities;
47
48namespace OpenSim.Region.CoreModules.Avatar.Assets
49{
50 [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule")]
51 public class NewFileAgentInventoryVariablePriceModule : INonSharedRegionModule
52 {
53 private static readonly ILog m_log =
54 LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
55 private Scene m_scene;
56 private IAssetService m_assetService;
57 private bool m_dumpAssetsToFile = false;
58
59 #region IRegionModuleBase Members
60
61
62 public Type ReplaceableInterface
63 {
64 get { return null; }
65 }
66
67 public void Initialise(IConfigSource source)
68 {
69
70 }
71
72 public void AddRegion(Scene pScene)
73 {
74 m_scene = pScene;
75 }
76
77 public void RemoveRegion(Scene scene)
78 {
79
80 m_scene.EventManager.OnRegisterCaps -= RegisterCaps;
81 m_scene = null;
82 }
83
84 public void RegionLoaded(Scene scene)
85 {
86
87 m_assetService = m_scene.RequestModuleInterface<IAssetService>();
88 m_scene.EventManager.OnRegisterCaps += RegisterCaps;
89 }
90
91 #endregion
92
93
94 #region IRegionModule Members
95
96
97
98 public void Close() { }
99
100 public string Name { get { return "NewFileAgentInventoryVariablePriceModule"; } }
101
102
103 public void RegisterCaps(UUID agentID, Caps caps)
104 {
105 UUID capID = UUID.Random();
106
107 m_log.Info("[GETMESH]: /CAPS/" + capID);
108 caps.RegisterHandler("NewFileAgentInventoryVariablePrice",
109
110 new LLSDStreamhandler<LLSDAssetUploadRequest, LLSDNewFileAngentInventoryVariablePriceReplyResponse>("POST",
111 "/CAPS/" + capID.ToString(),
112 delegate(LLSDAssetUploadRequest req)
113 {
114 return NewAgentInventoryRequest(req,agentID);
115 }));
116
117 }
118
119 #endregion
120
121 public LLSDNewFileAngentInventoryVariablePriceReplyResponse NewAgentInventoryRequest(LLSDAssetUploadRequest llsdRequest, UUID agentID)
122 {
123
124 //TODO: The Mesh uploader uploads many types of content. If you're going to implement a Money based limit
125 // You need to be aware of this and
126
127
128 //if (llsdRequest.asset_type == "texture" ||
129 // llsdRequest.asset_type == "animation" ||
130 // llsdRequest.asset_type == "sound")
131 // {
132 IClientAPI client = null;
133
134
135 IMoneyModule mm = m_scene.RequestModuleInterface<IMoneyModule>();
136
137 if (mm != null)
138 {
139 if (m_scene.TryGetClient(agentID, out client))
140 {
141 if (!mm.UploadCovered(client, mm.UploadCharge))
142 {
143 if (client != null)
144 client.SendAgentAlertMessage("Unable to upload asset. Insufficient funds.", false);
145
146 LLSDNewFileAngentInventoryVariablePriceReplyResponse errorResponse = new LLSDNewFileAngentInventoryVariablePriceReplyResponse();
147 errorResponse.rsvp = "";
148 errorResponse.state = "error";
149 return errorResponse;
150 }
151 }
152 }
153 // }
154
155
156
157 string assetName = llsdRequest.name;
158 string assetDes = llsdRequest.description;
159 string capsBase = "/CAPS/NewFileAgentInventoryVariablePrice/";
160 UUID newAsset = UUID.Random();
161 UUID newInvItem = UUID.Random();
162 UUID parentFolder = llsdRequest.folder_id;
163 string uploaderPath = Util.RandomClass.Next(5000, 8000).ToString("0000") + "/";
164
165 Caps.AssetUploader uploader =
166 new Caps.AssetUploader(assetName, assetDes, newAsset, newInvItem, parentFolder, llsdRequest.inventory_type,
167 llsdRequest.asset_type, capsBase + uploaderPath, MainServer.Instance, m_dumpAssetsToFile);
168 MainServer.Instance.AddStreamHandler(
169 new BinaryStreamHandler("POST", capsBase + uploaderPath, uploader.uploaderCaps));
170
171 string protocol = "http://";
172
173 if (MainServer.Instance.UseSSL)
174 protocol = "https://";
175
176 string uploaderURL = protocol + m_scene.RegionInfo.ExternalHostName + ":" + MainServer.Instance.Port.ToString() + capsBase +
177 uploaderPath;
178
179
180 LLSDNewFileAngentInventoryVariablePriceReplyResponse uploadResponse = new LLSDNewFileAngentInventoryVariablePriceReplyResponse();
181
182
183 uploadResponse.rsvp = uploaderURL;
184 uploadResponse.state = "upload";
185 uploadResponse.resource_cost = 0;
186 uploadResponse.upload_price = 0;
187
188 uploader.OnUpLoad += //UploadCompleteHandler;
189
190 delegate(
191 string passetName, string passetDescription, UUID passetID,
192 UUID pinventoryItem, UUID pparentFolder, byte[] pdata, string pinventoryType,
193 string passetType)
194 {
195 UploadCompleteHandler(passetName, passetDescription, passetID,
196 pinventoryItem, pparentFolder, pdata, pinventoryType,
197 passetType,agentID);
198 };
199 return uploadResponse;
200 }
201
202
203 public void UploadCompleteHandler(string assetName, string assetDescription, UUID assetID,
204 UUID inventoryItem, UUID parentFolder, byte[] data, string inventoryType,
205 string assetType,UUID AgentID)
206 {
207
208 sbyte assType = 0;
209 sbyte inType = 0;
210
211 if (inventoryType == "sound")
212 {
213 inType = 1;
214 assType = 1;
215 }
216 else if (inventoryType == "animation")
217 {
218 inType = 19;
219 assType = 20;
220 }
221 else if (inventoryType == "wearable")
222 {
223 inType = 18;
224 switch (assetType)
225 {
226 case "bodypart":
227 assType = 13;
228 break;
229 case "clothing":
230 assType = 5;
231 break;
232 }
233 }
234 else if (inventoryType == "mesh")
235 {
236 inType = (sbyte)InventoryType.Mesh;
237 assType = (sbyte)AssetType.Mesh;
238 }
239
240 AssetBase asset;
241 asset = new AssetBase(assetID, assetName, assType, AgentID.ToString());
242 asset.Data = data;
243
244 if (m_scene.AssetService != null)
245 m_scene.AssetService.Store(asset);
246
247 InventoryItemBase item = new InventoryItemBase();
248 item.Owner = AgentID;
249 item.CreatorId = AgentID.ToString();
250 item.ID = inventoryItem;
251 item.AssetID = asset.FullID;
252 item.Description = assetDescription;
253 item.Name = assetName;
254 item.AssetType = assType;
255 item.InvType = inType;
256 item.Folder = parentFolder;
257 item.CurrentPermissions = (uint)PermissionMask.All;
258 item.BasePermissions = (uint)PermissionMask.All;
259 item.EveryOnePermissions = 0;
260 item.NextPermissions = (uint)(PermissionMask.Move | PermissionMask.Modify | PermissionMask.Transfer);
261 item.CreationDate = Util.UnixTimeSinceEpoch();
262 m_scene.AddInventoryItem(item);
263
264 }
265 }
266}
diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
index 457e0bb..2a0c0b1 100644
--- a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
@@ -113,6 +113,10 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
113 if (!m_scene.Permissions.CanTakeObject(part.UUID, remoteClient.AgentId)) 113 if (!m_scene.Permissions.CanTakeObject(part.UUID, remoteClient.AgentId))
114 return; 114 return;
115 115
116 // TODO: this short circuits multiple attachments functionality in LL viewer 2.1+ and should
117 // be removed when that functionality is implemented in opensim
118 AttachmentPt &= 0x7f;
119
116 // Calls attach with a Zero position 120 // Calls attach with a Zero position
117 if (AttachObject(remoteClient, part.ParentGroup, AttachmentPt, false)) 121 if (AttachObject(remoteClient, part.ParentGroup, AttachmentPt, false))
118 { 122 {
@@ -142,6 +146,10 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
142 146
143 if (m_scene.Permissions.CanTakeObject(group.UUID, remoteClient.AgentId)) 147 if (m_scene.Permissions.CanTakeObject(group.UUID, remoteClient.AgentId))
144 { 148 {
149 // TODO: this short circuits multiple attachments functionality in LL viewer 2.1+ and should
150 // be removed when that functionality is implemented in opensim
151 AttachmentPt &= 0x7f;
152
145 // If the attachment point isn't the same as the one previously used 153 // If the attachment point isn't the same as the one previously used
146 // set it's offset position = 0 so that it appears on the attachment point 154 // set it's offset position = 0 so that it appears on the attachment point
147 // and not in a weird location somewhere unknown. 155 // and not in a weird location somewhere unknown.
@@ -228,6 +236,10 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
228 "[ATTACHMENTS MODULE]: Rezzing attachment to point {0} from item {1} for {2}", 236 "[ATTACHMENTS MODULE]: Rezzing attachment to point {0} from item {1} for {2}",
229 (AttachmentPoint)AttachmentPt, itemID, remoteClient.Name); 237 (AttachmentPoint)AttachmentPt, itemID, remoteClient.Name);
230 238
239 // TODO: this short circuits multiple attachments functionality in LL viewer 2.1+ and should
240 // be removed when that functionality is implemented in opensim
241 AttachmentPt &= 0x7f;
242
231 SceneObjectGroup att = RezSingleAttachmentFromInventoryInternal(remoteClient, itemID, AttachmentPt); 243 SceneObjectGroup att = RezSingleAttachmentFromInventoryInternal(remoteClient, itemID, AttachmentPt);
232 244
233 if (updateInventoryStatus) 245 if (updateInventoryStatus)
diff --git a/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs b/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs
index 6b538f6..f1f5258 100644
--- a/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs
+++ b/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs
@@ -51,6 +51,12 @@ namespace OpenSim.Region.CoreModules.World.Archiver
51 public class ArchiveReadRequest 51 public class ArchiveReadRequest
52 { 52 {
53 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 53 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
54
55 /// <summary>
56 /// The maximum major version of OAR that we can read. Minor versions shouldn't need a number since version
57 /// bumps here should be compatible.
58 /// </summary>
59 public static int MAX_MAJOR_VERSION = 0;
54 60
55 protected Scene m_scene; 61 protected Scene m_scene;
56 protected Stream m_loadStream; 62 protected Stream m_loadStream;
@@ -497,6 +503,22 @@ namespace OpenSim.Region.CoreModules.World.Archiver
497 { 503 {
498 if (xtr.NodeType == XmlNodeType.Element) 504 if (xtr.NodeType == XmlNodeType.Element)
499 { 505 {
506 if (xtr.Name.ToString() == "archive")
507 {
508 int majorVersion = int.Parse(xtr["major_version"]);
509 int minorVersion = int.Parse(xtr["minor_version"]);
510 string version = string.Format("{0}.{1}", majorVersion, minorVersion);
511
512 if (majorVersion > MAX_MAJOR_VERSION)
513 {
514 throw new Exception(
515 string.Format(
516 "The OAR you are trying to load has major version number of {0} but this version of OpenSim can only load OARs with major version number {1} and below",
517 majorVersion, MAX_MAJOR_VERSION));
518 }
519
520 m_log.InfoFormat("[ARCHIVER]: Loading OAR with version {0}", version);
521 }
500 if (xtr.Name.ToString() == "datetime") 522 if (xtr.Name.ToString() == "datetime")
501 { 523 {
502 int value; 524 int value;
diff --git a/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequestExecution.cs b/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequestExecution.cs
index 586d98e..c062833 100644
--- a/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequestExecution.cs
+++ b/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequestExecution.cs
@@ -60,6 +60,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver
60 protected Scene m_scene; 60 protected Scene m_scene;
61 protected TarArchiveWriter m_archiveWriter; 61 protected TarArchiveWriter m_archiveWriter;
62 protected Guid m_requestId; 62 protected Guid m_requestId;
63 protected Dictionary<string, object> m_options;
63 64
64 public ArchiveWriteRequestExecution( 65 public ArchiveWriteRequestExecution(
65 List<SceneObjectGroup> sceneObjects, 66 List<SceneObjectGroup> sceneObjects,
@@ -67,7 +68,8 @@ namespace OpenSim.Region.CoreModules.World.Archiver
67 IRegionSerialiserModule serialiser, 68 IRegionSerialiserModule serialiser,
68 Scene scene, 69 Scene scene,
69 TarArchiveWriter archiveWriter, 70 TarArchiveWriter archiveWriter,
70 Guid requestId) 71 Guid requestId,
72 Dictionary<string, object> options)
71 { 73 {
72 m_sceneObjects = sceneObjects; 74 m_sceneObjects = sceneObjects;
73 m_terrainModule = terrainModule; 75 m_terrainModule = terrainModule;
@@ -75,6 +77,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver
75 m_scene = scene; 77 m_scene = scene;
76 m_archiveWriter = archiveWriter; 78 m_archiveWriter = archiveWriter;
77 m_requestId = requestId; 79 m_requestId = requestId;
80 m_options = options;
78 } 81 }
79 82
80 protected internal void ReceivedAllAssets( 83 protected internal void ReceivedAllAssets(
@@ -105,12 +108,6 @@ namespace OpenSim.Region.CoreModules.World.Archiver
105// "[ARCHIVER]: Received {0} of {1} assets requested", 108// "[ARCHIVER]: Received {0} of {1} assets requested",
106// assetsFoundUuids.Count, assetsFoundUuids.Count + assetsNotFoundUuids.Count); 109// assetsFoundUuids.Count, assetsFoundUuids.Count + assetsNotFoundUuids.Count);
107 110
108 m_log.InfoFormat("[ARCHIVER]: Creating archive file. This may take some time.");
109
110 // Write out control file
111 m_archiveWriter.WriteFile(ArchiveConstants.CONTROL_FILE_PATH, Create0p2ControlFile());
112 m_log.InfoFormat("[ARCHIVER]: Added control file to archive.");
113
114 // Write out region settings 111 // Write out region settings
115 string settingsPath 112 string settingsPath
116 = String.Format("{0}{1}.xml", ArchiveConstants.SETTINGS_PATH, m_scene.RegionInfo.RegionName); 113 = String.Format("{0}{1}.xml", ArchiveConstants.SETTINGS_PATH, m_scene.RegionInfo.RegionName);
@@ -140,47 +137,22 @@ namespace OpenSim.Region.CoreModules.World.Archiver
140 137
141 m_log.InfoFormat("[ARCHIVER]: Added terrain information to archive."); 138 m_log.InfoFormat("[ARCHIVER]: Added terrain information to archive.");
142 139
140 Dictionary<string, object> serializationOptions = new Dictionary<string, object>();
141// if (m_options.ContainsKey("version") && (string)m_options["version"] == "0")
142// serializationOptions["old-guids"] = true;
143
143 // Write out scene object metadata 144 // Write out scene object metadata
144 foreach (SceneObjectGroup sceneObject in m_sceneObjects) 145 foreach (SceneObjectGroup sceneObject in m_sceneObjects)
145 { 146 {
146 //m_log.DebugFormat("[ARCHIVER]: Saving {0} {1}, {2}", entity.Name, entity.UUID, entity.GetType()); 147 //m_log.DebugFormat("[ARCHIVER]: Saving {0} {1}, {2}", entity.Name, entity.UUID, entity.GetType());
147 148
148 string serializedObject = m_serialiser.SerializeGroupToXml2(sceneObject); 149 string serializedObject = m_serialiser.SerializeGroupToXml2(sceneObject, serializationOptions);
149 m_archiveWriter.WriteFile(ArchiveHelpers.CreateObjectPath(sceneObject), serializedObject); 150 m_archiveWriter.WriteFile(ArchiveHelpers.CreateObjectPath(sceneObject), serializedObject);
150 } 151 }
151 152
152 m_log.InfoFormat("[ARCHIVER]: Added scene objects to archive."); 153 m_log.InfoFormat("[ARCHIVER]: Added scene objects to archive.");
153 } 154 }
154 155
155 /// <summary> 156
156 /// Create the control file for a 0.2 version archive
157 /// </summary>
158 /// <returns></returns>
159 public static string Create0p2ControlFile()
160 {
161 StringWriter sw = new StringWriter();
162 XmlTextWriter xtw = new XmlTextWriter(sw);
163 xtw.Formatting = Formatting.Indented;
164 xtw.WriteStartDocument();
165 xtw.WriteStartElement("archive");
166 xtw.WriteAttributeString("major_version", "0");
167 xtw.WriteAttributeString("minor_version", "3");
168
169 xtw.WriteStartElement("creation_info");
170 DateTime now = DateTime.UtcNow;
171 TimeSpan t = now - new DateTime(1970, 1, 1);
172 xtw.WriteElementString("datetime", ((int)t.TotalSeconds).ToString());
173 xtw.WriteElementString("id", UUID.Random().ToString());
174 xtw.WriteEndElement();
175 xtw.WriteEndElement();
176
177 xtw.Flush();
178 xtw.Close();
179
180 String s = sw.ToString();
181 sw.Close();
182
183 return s;
184 }
185 } 157 }
186} 158}
diff --git a/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequestPreparation.cs b/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequestPreparation.cs
index 283b33b..43789af 100644
--- a/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequestPreparation.cs
+++ b/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequestPreparation.cs
@@ -32,6 +32,7 @@ using System.IO.Compression;
32using System.Reflection; 32using System.Reflection;
33using System.Text.RegularExpressions; 33using System.Text.RegularExpressions;
34using System.Threading; 34using System.Threading;
35using System.Xml;
35using log4net; 36using log4net;
36using OpenMetaverse; 37using OpenMetaverse;
37using OpenSim.Framework; 38using OpenSim.Framework;
@@ -98,7 +99,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver
98 /// Archive the region requested. 99 /// Archive the region requested.
99 /// </summary> 100 /// </summary>
100 /// <exception cref="System.IO.IOException">if there was an io problem with creating the file</exception> 101 /// <exception cref="System.IO.IOException">if there was an io problem with creating the file</exception>
101 public void ArchiveRegion() 102 public void ArchiveRegion(Dictionary<string, object> options)
102 { 103 {
103 Dictionary<UUID, AssetType> assetUuids = new Dictionary<UUID, AssetType>(); 104 Dictionary<UUID, AssetType> assetUuids = new Dictionary<UUID, AssetType>();
104 105
@@ -165,11 +166,71 @@ namespace OpenSim.Region.CoreModules.World.Archiver
165 m_scene.RequestModuleInterface<IRegionSerialiserModule>(), 166 m_scene.RequestModuleInterface<IRegionSerialiserModule>(),
166 m_scene, 167 m_scene,
167 archiveWriter, 168 archiveWriter,
168 m_requestId); 169 m_requestId,
170 options);
171
172 m_log.InfoFormat("[ARCHIVER]: Creating archive file. This may take some time.");
173
174 // Write out control file
175 archiveWriter.WriteFile(ArchiveConstants.CONTROL_FILE_PATH, Create0p2ControlFile(options));
176 m_log.InfoFormat("[ARCHIVER]: Added control file to archive.");
169 177
170 new AssetsRequest( 178 new AssetsRequest(
171 new AssetsArchiver(archiveWriter), assetUuids, 179 new AssetsArchiver(archiveWriter), assetUuids,
172 m_scene.AssetService, awre.ReceivedAllAssets).Execute(); 180 m_scene.AssetService, awre.ReceivedAllAssets).Execute();
173 } 181 }
182
183 /// <summary>
184 /// Create the control file for the most up to date archive
185 /// </summary>
186 /// <returns></returns>
187 public static string Create0p2ControlFile(Dictionary<string, object> options)
188 {
189 int majorVersion = 0, minorVersion = 4;
190
191 /*
192 if (options.ContainsKey("version") && (string)options["version"] == "0")
193 {
194 majorVersion = 0;
195 minorVersion = 3;
196 }
197 else
198 {
199 majorVersion = 1;
200 minorVersion = 0;
201 }
202 */
203
204 m_log.InfoFormat("[ARCHIVER]: Creating version {0}.{1} OAR", majorVersion, minorVersion);
205// if (majorVersion == 1)
206// {
207// m_log.WarnFormat("[ARCHIVER]: Please be aware that version 1.0 OARs are not compatible with OpenSim 0.7.0.2 and earlier. Please use the --version=0 option if you want to produce a compatible OAR");
208// }
209
210
211 StringWriter sw = new StringWriter();
212 XmlTextWriter xtw = new XmlTextWriter(sw);
213 xtw.Formatting = Formatting.Indented;
214 xtw.WriteStartDocument();
215 xtw.WriteStartElement("archive");
216 xtw.WriteAttributeString("major_version", majorVersion.ToString());
217 xtw.WriteAttributeString("minor_version", minorVersion.ToString());
218
219 xtw.WriteStartElement("creation_info");
220 DateTime now = DateTime.UtcNow;
221 TimeSpan t = now - new DateTime(1970, 1, 1);
222 xtw.WriteElementString("datetime", ((int)t.TotalSeconds).ToString());
223 xtw.WriteElementString("id", UUID.Random().ToString());
224 xtw.WriteEndElement();
225 xtw.WriteEndElement();
226
227 xtw.Flush();
228 xtw.Close();
229
230 String s = sw.ToString();
231 sw.Close();
232
233 return s;
234 }
174 } 235 }
175} 236}
diff --git a/OpenSim/Region/CoreModules/World/Archiver/ArchiverModule.cs b/OpenSim/Region/CoreModules/World/Archiver/ArchiverModule.cs
index 82ede01..e0ad71e 100644
--- a/OpenSim/Region/CoreModules/World/Archiver/ArchiverModule.cs
+++ b/OpenSim/Region/CoreModules/World/Archiver/ArchiverModule.cs
@@ -122,37 +122,44 @@ namespace OpenSim.Region.CoreModules.World.Archiver
122 /// <param name="cmdparams"></param> 122 /// <param name="cmdparams"></param>
123 public void HandleSaveOarConsoleCommand(string module, string[] cmdparams) 123 public void HandleSaveOarConsoleCommand(string module, string[] cmdparams)
124 { 124 {
125 Dictionary<string, object> options = new Dictionary<string, object>();
126
127 OptionSet ops = new OptionSet();
128 ops.Add("v|version=", delegate(string v) { options["version"] = v; });
129
130 List<string> mainParams = ops.Parse(cmdparams);
131
125 if (cmdparams.Length > 2) 132 if (cmdparams.Length > 2)
126 { 133 {
127 ArchiveRegion(cmdparams[2]); 134 ArchiveRegion(mainParams[2], options);
128 } 135 }
129 else 136 else
130 { 137 {
131 ArchiveRegion(DEFAULT_OAR_BACKUP_FILENAME); 138 ArchiveRegion(DEFAULT_OAR_BACKUP_FILENAME, options);
132 } 139 }
133 } 140 }
134 141
135 public void ArchiveRegion(string savePath) 142 public void ArchiveRegion(string savePath, Dictionary<string, object> options)
136 { 143 {
137 ArchiveRegion(savePath, Guid.Empty); 144 ArchiveRegion(savePath, Guid.Empty, options);
138 } 145 }
139 146
140 public void ArchiveRegion(string savePath, Guid requestId) 147 public void ArchiveRegion(string savePath, Guid requestId, Dictionary<string, object> options)
141 { 148 {
142 m_log.InfoFormat( 149 m_log.InfoFormat(
143 "[ARCHIVER]: Writing archive for region {0} to {1}", m_scene.RegionInfo.RegionName, savePath); 150 "[ARCHIVER]: Writing archive for region {0} to {1}", m_scene.RegionInfo.RegionName, savePath);
144 151
145 new ArchiveWriteRequestPreparation(m_scene, savePath, requestId).ArchiveRegion(); 152 new ArchiveWriteRequestPreparation(m_scene, savePath, requestId).ArchiveRegion(options);
146 } 153 }
147 154
148 public void ArchiveRegion(Stream saveStream) 155 public void ArchiveRegion(Stream saveStream)
149 { 156 {
150 ArchiveRegion(saveStream, Guid.Empty); 157 ArchiveRegion(saveStream, Guid.Empty);
151 } 158 }
152 159
153 public void ArchiveRegion(Stream saveStream, Guid requestId) 160 public void ArchiveRegion(Stream saveStream, Guid requestId)
154 { 161 {
155 new ArchiveWriteRequestPreparation(m_scene, saveStream, requestId).ArchiveRegion(); 162 new ArchiveWriteRequestPreparation(m_scene, saveStream, requestId).ArchiveRegion(new Dictionary<string, object>());
156 } 163 }
157 164
158 public void DearchiveRegion(string loadPath) 165 public void DearchiveRegion(string loadPath)
diff --git a/OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs b/OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs
index 3342164..04bdc4f 100644
--- a/OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs
+++ b/OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs
@@ -230,7 +230,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver.Tests
230 // upset load 230 // upset load
231 tar.WriteDir(ArchiveConstants.TERRAINS_PATH); 231 tar.WriteDir(ArchiveConstants.TERRAINS_PATH);
232 232
233 tar.WriteFile(ArchiveConstants.CONTROL_FILE_PATH, ArchiveWriteRequestExecution.Create0p2ControlFile()); 233 tar.WriteFile(ArchiveConstants.CONTROL_FILE_PATH, ArchiveWriteRequestPreparation.Create0p2ControlFile(new Dictionary<string, Object>()));
234 234
235 SceneObjectPart part1 = CreateSceneObjectPart1(); 235 SceneObjectPart part1 = CreateSceneObjectPart1();
236 SceneObjectGroup object1 = new SceneObjectGroup(part1); 236 SceneObjectGroup object1 = new SceneObjectGroup(part1);
@@ -329,7 +329,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver.Tests
329 TarArchiveWriter tar = new TarArchiveWriter(archiveWriteStream); 329 TarArchiveWriter tar = new TarArchiveWriter(archiveWriteStream);
330 330
331 tar.WriteDir(ArchiveConstants.TERRAINS_PATH); 331 tar.WriteDir(ArchiveConstants.TERRAINS_PATH);
332 tar.WriteFile(ArchiveConstants.CONTROL_FILE_PATH, ArchiveWriteRequestExecution.Create0p2ControlFile()); 332 tar.WriteFile(ArchiveConstants.CONTROL_FILE_PATH, ArchiveWriteRequestPreparation.Create0p2ControlFile(new Dictionary<string, Object>()));
333 333
334 RegionSettings rs = new RegionSettings(); 334 RegionSettings rs = new RegionSettings();
335 rs.AgentLimit = 17; 335 rs.AgentLimit = 17;
diff --git a/OpenSim/Region/CoreModules/World/Serialiser/SerialiserModule.cs b/OpenSim/Region/CoreModules/World/Serialiser/SerialiserModule.cs
index 04062b0..ec97acd 100644
--- a/OpenSim/Region/CoreModules/World/Serialiser/SerialiserModule.cs
+++ b/OpenSim/Region/CoreModules/World/Serialiser/SerialiserModule.cs
@@ -160,9 +160,9 @@ namespace OpenSim.Region.CoreModules.World.Serialiser
160 return SceneXmlLoader.DeserializeGroupFromXml2(xmlString); 160 return SceneXmlLoader.DeserializeGroupFromXml2(xmlString);
161 } 161 }
162 162
163 public string SerializeGroupToXml2(SceneObjectGroup grp) 163 public string SerializeGroupToXml2(SceneObjectGroup grp, Dictionary<string, object> options)
164 { 164 {
165 return SceneXmlLoader.SaveGroupToXml2(grp); 165 return SceneXmlLoader.SaveGroupToXml2(grp, options);
166 } 166 }
167 167
168 public void SavePrimListToXml2(EntityBase[] entityList, string fileName) 168 public void SavePrimListToXml2(EntityBase[] entityList, string fileName)
diff --git a/OpenSim/Region/CoreModules/World/Serialiser/Tests/SerialiserTests.cs b/OpenSim/Region/CoreModules/World/Serialiser/Tests/SerialiserTests.cs
index 799a448..f10e848 100644
--- a/OpenSim/Region/CoreModules/World/Serialiser/Tests/SerialiserTests.cs
+++ b/OpenSim/Region/CoreModules/World/Serialiser/Tests/SerialiserTests.cs
@@ -25,6 +25,9 @@
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */ 26 */
27 27
28using System.Collections.Generic;
29using System.IO;
30using System.Xml;
28using log4net.Config; 31using log4net.Config;
29using NUnit.Framework; 32using NUnit.Framework;
30using NUnit.Framework.SyntaxHelpers; 33using NUnit.Framework.SyntaxHelpers;
@@ -34,8 +37,6 @@ using OpenSim.Region.Framework.Scenes;
34using OpenSim.Region.Framework.Scenes.Serialization; 37using OpenSim.Region.Framework.Scenes.Serialization;
35using OpenSim.Tests.Common; 38using OpenSim.Tests.Common;
36using OpenSim.Tests.Common.Setup; 39using OpenSim.Tests.Common.Setup;
37using System.IO;
38using System.Xml;
39 40
40namespace OpenSim.Region.CoreModules.World.Serialiser.Tests 41namespace OpenSim.Region.CoreModules.World.Serialiser.Tests
41{ 42{
@@ -302,15 +303,19 @@ namespace OpenSim.Region.CoreModules.World.Serialiser.Tests
302 { 303 {
303 case "UUID": 304 case "UUID":
304 xtr.ReadStartElement("UUID"); 305 xtr.ReadStartElement("UUID");
305 uuid = UUID.Parse(xtr.ReadElementString("Guid")); 306 try
306 xtr.ReadEndElement(); 307 {
308 uuid = UUID.Parse(xtr.ReadElementString("UUID"));
309 xtr.ReadEndElement();
310 }
311 catch { } // ignore everything but <UUID><UUID>...</UUID></UUID>
307 break; 312 break;
308 case "Name": 313 case "Name":
309 name = xtr.ReadElementContentAsString(); 314 name = xtr.ReadElementContentAsString();
310 break; 315 break;
311 case "CreatorID": 316 case "CreatorID":
312 xtr.ReadStartElement("CreatorID"); 317 xtr.ReadStartElement("CreatorID");
313 creatorId = UUID.Parse(xtr.ReadElementString("Guid")); 318 creatorId = UUID.Parse(xtr.ReadElementString("UUID"));
314 xtr.ReadEndElement(); 319 xtr.ReadEndElement();
315 break; 320 break;
316 } 321 }
@@ -369,7 +374,9 @@ namespace OpenSim.Region.CoreModules.World.Serialiser.Tests
369 // Need to add the object to the scene so that the request to get script state succeeds 374 // Need to add the object to the scene so that the request to get script state succeeds
370 m_scene.AddSceneObject(so); 375 m_scene.AddSceneObject(so);
371 376
372 string xml2 = m_serialiserModule.SerializeGroupToXml2(so); 377 Dictionary<string, object> options = new Dictionary<string, object>();
378 options["old-guids"] = true;
379 string xml2 = m_serialiserModule.SerializeGroupToXml2(so, options);
373 380
374 XmlTextReader xtr = new XmlTextReader(new StringReader(xml2)); 381 XmlTextReader xtr = new XmlTextReader(new StringReader(xml2));
375 xtr.ReadStartElement("SceneObjectGroup"); 382 xtr.ReadStartElement("SceneObjectGroup");
diff --git a/OpenSim/Region/Framework/Interfaces/IRegionArchiverModule.cs b/OpenSim/Region/Framework/Interfaces/IRegionArchiverModule.cs
index 89e59d0..d8229de 100644
--- a/OpenSim/Region/Framework/Interfaces/IRegionArchiverModule.cs
+++ b/OpenSim/Region/Framework/Interfaces/IRegionArchiverModule.cs
@@ -26,6 +26,7 @@
26 */ 26 */
27 27
28using System; 28using System;
29using System.Collections.Generic;
29using System.IO; 30using System.IO;
30 31
31namespace OpenSim.Region.Framework.Interfaces 32namespace OpenSim.Region.Framework.Interfaces
@@ -46,7 +47,7 @@ namespace OpenSim.Region.Framework.Interfaces
46 /// the EventManager.OnOarFileSaved event. 47 /// the EventManager.OnOarFileSaved event.
47 /// 48 ///
48 /// <param name="savePath"></param> 49 /// <param name="savePath"></param>
49 void ArchiveRegion(string savePath); 50 void ArchiveRegion(string savePath, Dictionary<string, object> options);
50 51
51 /// <summary> 52 /// <summary>
52 /// Archive the region to the given path 53 /// Archive the region to the given path
@@ -57,7 +58,7 @@ namespace OpenSim.Region.Framework.Interfaces
57 /// 58 ///
58 /// <param name="savePath"></param> 59 /// <param name="savePath"></param>
59 /// <param name="requestId">If supplied, this request Id is later returned in the saved event</param> 60 /// <param name="requestId">If supplied, this request Id is later returned in the saved event</param>
60 void ArchiveRegion(string savePath, Guid requestId); 61 void ArchiveRegion(string savePath, Guid requestId, Dictionary<string, object> options);
61 62
62 /// <summary> 63 /// <summary>
63 /// Archive the region to a stream. 64 /// Archive the region to a stream.
diff --git a/OpenSim/Region/Framework/Interfaces/IRegionSerialiserModule.cs b/OpenSim/Region/Framework/Interfaces/IRegionSerialiserModule.cs
index 18758c8..c5b21a8 100644
--- a/OpenSim/Region/Framework/Interfaces/IRegionSerialiserModule.cs
+++ b/OpenSim/Region/Framework/Interfaces/IRegionSerialiserModule.cs
@@ -117,6 +117,6 @@ namespace OpenSim.Region.Framework.Interfaces
117 /// </summary> 117 /// </summary>
118 /// <param name="grp"></param> 118 /// <param name="grp"></param>
119 /// <returns></returns> 119 /// <returns></returns>
120 string SerializeGroupToXml2(SceneObjectGroup grp); 120 string SerializeGroupToXml2(SceneObjectGroup grp, Dictionary<string, object> options);
121 } 121 }
122} 122}
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
index 39b109b..7a6449d 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
@@ -39,6 +39,7 @@ using OpenMetaverse.Packets;
39using OpenSim.Framework; 39using OpenSim.Framework;
40using OpenSim.Region.Framework.Interfaces; 40using OpenSim.Region.Framework.Interfaces;
41using OpenSim.Region.Framework.Scenes.Scripting; 41using OpenSim.Region.Framework.Scenes.Scripting;
42using OpenSim.Region.Framework.Scenes.Serialization;
42using OpenSim.Region.Physics.Manager; 43using OpenSim.Region.Physics.Manager;
43 44
44namespace OpenSim.Region.Framework.Scenes 45namespace OpenSim.Region.Framework.Scenes
@@ -118,40 +119,36 @@ namespace OpenSim.Region.Framework.Scenes
118 /// <value> 119 /// <value>
119 /// Is this sop a root part? 120 /// Is this sop a root part?
120 /// </value> 121 /// </value>
121 [XmlIgnore] 122
122 public bool IsRoot 123 public bool IsRoot
123 { 124 {
124 get { return ParentGroup.RootPart == this; } 125 get { return ParentGroup.RootPart == this; }
125 } 126 }
126 127
127 // use only one serializer to give the runtime a chance to optimize it (it won't do that if you
128 // use a new instance every time)
129 private static XmlSerializer serializer = new XmlSerializer(typeof (SceneObjectPart));
130
131 #region Fields 128 #region Fields
132 129
133 public bool AllowedDrop; 130 public bool AllowedDrop;
134 131
135 [XmlIgnore] 132
136 public bool DIE_AT_EDGE; 133 public bool DIE_AT_EDGE;
137 134
138 [XmlIgnore] 135
139 public bool RETURN_AT_EDGE; 136 public bool RETURN_AT_EDGE;
140 137
141 [XmlIgnore] 138
142 public bool BlockGrab; 139 public bool BlockGrab;
143 140
144 [XmlIgnore] 141
145 public bool StatusSandbox; 142 public bool StatusSandbox;
146 143
147 [XmlIgnore] 144
148 public Vector3 StatusSandboxPos; 145 public Vector3 StatusSandboxPos;
149 146
150 // TODO: This needs to be persisted in next XML version update! 147 // TODO: This needs to be persisted in next XML version update!
151 [XmlIgnore] 148
152 public readonly int[] PayPrice = {-2,-2,-2,-2,-2}; 149 public readonly int[] PayPrice = {-2,-2,-2,-2,-2};
153 150
154 [XmlIgnore] 151
155 public PhysicsActor PhysActor 152 public PhysicsActor PhysActor
156 { 153 {
157 get { return m_physActor; } 154 get { return m_physActor; }
@@ -166,43 +163,43 @@ namespace OpenSim.Region.Framework.Scenes
166 // Note: This isn't persisted in the database right now, as the fields for that aren't just there yet. 163 // Note: This isn't persisted in the database right now, as the fields for that aren't just there yet.
167 // Not a big problem as long as the script that sets it remains in the prim on startup. 164 // Not a big problem as long as the script that sets it remains in the prim on startup.
168 // for SL compatibility it should be persisted though (set sound / displaytext / particlesystem, kill script) 165 // for SL compatibility it should be persisted though (set sound / displaytext / particlesystem, kill script)
169 [XmlIgnore] 166
170 public UUID Sound; 167 public UUID Sound;
171 168
172 [XmlIgnore] 169
173 public byte SoundFlags; 170 public byte SoundFlags;
174 171
175 [XmlIgnore] 172
176 public double SoundGain; 173 public double SoundGain;
177 174
178 [XmlIgnore] 175
179 public double SoundRadius; 176 public double SoundRadius;
180 177
181 [XmlIgnore] 178
182 public uint TimeStampFull; 179 public uint TimeStampFull;
183 180
184 [XmlIgnore] 181
185 public uint TimeStampLastActivity; // Will be used for AutoReturn 182 public uint TimeStampLastActivity; // Will be used for AutoReturn
186 183
187 [XmlIgnore] 184
188 public uint TimeStampTerse; 185 public uint TimeStampTerse;
189 186
190 [XmlIgnore] 187
191 public UUID FromItemID; 188 public UUID FromItemID;
192 189
193 [XmlIgnore] 190
194 public UUID FromFolderID; 191 public UUID FromFolderID;
195 192
196 [XmlIgnore] 193
197 public int STATUS_ROTATE_X; 194 public int STATUS_ROTATE_X;
198 195
199 [XmlIgnore] 196
200 public int STATUS_ROTATE_Y; 197 public int STATUS_ROTATE_Y;
201 198
202 [XmlIgnore] 199
203 public int STATUS_ROTATE_Z; 200 public int STATUS_ROTATE_Z;
204 201
205 [XmlIgnore] 202
206 private Dictionary<int, string> m_CollisionFilter = new Dictionary<int, string>(); 203 private Dictionary<int, string> m_CollisionFilter = new Dictionary<int, string>();
207 204
208 /// <value> 205 /// <value>
@@ -211,68 +208,68 @@ namespace OpenSim.Region.Framework.Scenes
211 /// </value> 208 /// </value>
212 private UUID m_fromUserInventoryItemID; 209 private UUID m_fromUserInventoryItemID;
213 210
214 [XmlIgnore] 211
215 public UUID FromUserInventoryItemID 212 public UUID FromUserInventoryItemID
216 { 213 {
217 get { return m_fromUserInventoryItemID; } 214 get { return m_fromUserInventoryItemID; }
218 } 215 }
219 216
220 [XmlIgnore] 217
221 public bool IsAttachment; 218 public bool IsAttachment;
222 219
223 [XmlIgnore] 220
224 public scriptEvents AggregateScriptEvents; 221 public scriptEvents AggregateScriptEvents;
225 222
226 [XmlIgnore] 223
227 public UUID AttachedAvatar; 224 public UUID AttachedAvatar;
228 225
229 [XmlIgnore] 226
230 public Vector3 AttachedPos; 227 public Vector3 AttachedPos;
231 228
232 [XmlIgnore] 229
233 public uint AttachmentPoint; 230 public uint AttachmentPoint;
234 231
235 [XmlIgnore] 232
236 public Vector3 RotationAxis = Vector3.One; 233 public Vector3 RotationAxis = Vector3.One;
237 234
238 [XmlIgnore] 235
239 public bool VolumeDetectActive; // XmlIgnore set to avoid problems with persistance until I come to care for this 236 public bool VolumeDetectActive; // XmlIgnore set to avoid problems with persistance until I come to care for this
240 // Certainly this must be a persistant setting finally 237 // Certainly this must be a persistant setting finally
241 238
242 [XmlIgnore] 239
243 public bool IsWaitingForFirstSpinUpdatePacket; 240 public bool IsWaitingForFirstSpinUpdatePacket;
244 241
245 [XmlIgnore] 242
246 public Quaternion SpinOldOrientation = Quaternion.Identity; 243 public Quaternion SpinOldOrientation = Quaternion.Identity;
247 244
248 [XmlIgnore] 245
249 public Quaternion m_APIDTarget = Quaternion.Identity; 246 public Quaternion m_APIDTarget = Quaternion.Identity;
250 247
251 [XmlIgnore] 248
252 public float m_APIDDamp = 0; 249 public float m_APIDDamp = 0;
253 250
254 [XmlIgnore] 251
255 public float m_APIDStrength = 0; 252 public float m_APIDStrength = 0;
256 253
257 /// <summary> 254 /// <summary>
258 /// This part's inventory 255 /// This part's inventory
259 /// </summary> 256 /// </summary>
260 [XmlIgnore] 257
261 public IEntityInventory Inventory 258 public IEntityInventory Inventory
262 { 259 {
263 get { return m_inventory; } 260 get { return m_inventory; }
264 } 261 }
265 protected SceneObjectPartInventory m_inventory; 262 protected SceneObjectPartInventory m_inventory;
266 263
267 [XmlIgnore] 264
268 public bool Undoing; 265 public bool Undoing;
269 266
270 [XmlIgnore] 267
271 public bool IgnoreUndoUpdate = false; 268 public bool IgnoreUndoUpdate = false;
272 269
273 [XmlIgnore] 270
274 private PrimFlags LocalFlags; 271 private PrimFlags LocalFlags;
275 [XmlIgnore] 272
276 private float m_damage = -1.0f; 273 private float m_damage = -1.0f;
277 private byte[] m_TextureAnimation; 274 private byte[] m_TextureAnimation;
278 private byte m_clickAction; 275 private byte m_clickAction;
@@ -280,9 +277,9 @@ namespace OpenSim.Region.Framework.Scenes
280 private string m_description = String.Empty; 277 private string m_description = String.Empty;
281 private readonly List<uint> m_lastColliders = new List<uint>(); 278 private readonly List<uint> m_lastColliders = new List<uint>();
282 private int m_linkNum; 279 private int m_linkNum;
283 [XmlIgnore] 280
284 private int m_scriptAccessPin; 281 private int m_scriptAccessPin;
285 [XmlIgnore] 282
286 private readonly Dictionary<UUID, scriptEvents> m_scriptEvents = new Dictionary<UUID, scriptEvents>(); 283 private readonly Dictionary<UUID, scriptEvents> m_scriptEvents = new Dictionary<UUID, scriptEvents>();
287 private string m_sitName = String.Empty; 284 private string m_sitName = String.Empty;
288 private Quaternion m_sitTargetOrientation = Quaternion.Identity; 285 private Quaternion m_sitTargetOrientation = Quaternion.Identity;
@@ -548,7 +545,7 @@ namespace OpenSim.Region.Framework.Scenes
548 } 545 }
549 546
550 547
551 [XmlIgnore] 548
552 public Dictionary<int, string> CollisionFilter 549 public Dictionary<int, string> CollisionFilter
553 { 550 {
554 get { return m_CollisionFilter; } 551 get { return m_CollisionFilter; }
@@ -558,21 +555,21 @@ namespace OpenSim.Region.Framework.Scenes
558 } 555 }
559 } 556 }
560 557
561 [XmlIgnore] 558
562 public Quaternion APIDTarget 559 public Quaternion APIDTarget
563 { 560 {
564 get { return m_APIDTarget; } 561 get { return m_APIDTarget; }
565 set { m_APIDTarget = value; } 562 set { m_APIDTarget = value; }
566 } 563 }
567 564
568 [XmlIgnore] 565
569 public float APIDDamp 566 public float APIDDamp
570 { 567 {
571 get { return m_APIDDamp; } 568 get { return m_APIDDamp; }
572 set { m_APIDDamp = value; } 569 set { m_APIDDamp = value; }
573 } 570 }
574 571
575 [XmlIgnore] 572
576 public float APIDStrength 573 public float APIDStrength
577 { 574 {
578 get { return m_APIDStrength; } 575 get { return m_APIDStrength; }
@@ -618,35 +615,35 @@ namespace OpenSim.Region.Framework.Scenes
618 set { m_LoopSoundSlavePrims = value; } 615 set { m_LoopSoundSlavePrims = value; }
619 } 616 }
620 617
621 [XmlIgnore] 618
622 public Byte[] TextureAnimation 619 public Byte[] TextureAnimation
623 { 620 {
624 get { return m_TextureAnimation; } 621 get { return m_TextureAnimation; }
625 set { m_TextureAnimation = value; } 622 set { m_TextureAnimation = value; }
626 } 623 }
627 624
628 [XmlIgnore] 625
629 public Byte[] ParticleSystem 626 public Byte[] ParticleSystem
630 { 627 {
631 get { return m_particleSystem; } 628 get { return m_particleSystem; }
632 set { m_particleSystem = value; } 629 set { m_particleSystem = value; }
633 } 630 }
634 631
635 [XmlIgnore] 632
636 public DateTime Expires 633 public DateTime Expires
637 { 634 {
638 get { return m_expires; } 635 get { return m_expires; }
639 set { m_expires = value; } 636 set { m_expires = value; }
640 } 637 }
641 638
642 [XmlIgnore] 639
643 public DateTime Rezzed 640 public DateTime Rezzed
644 { 641 {
645 get { return m_rezzed; } 642 get { return m_rezzed; }
646 set { m_rezzed = value; } 643 set { m_rezzed = value; }
647 } 644 }
648 645
649 [XmlIgnore] 646
650 public float Damage 647 public float Damage
651 { 648 {
652 get { return m_damage; } 649 get { return m_damage; }
@@ -1019,7 +1016,7 @@ namespace OpenSim.Region.Framework.Scenes
1019 } 1016 }
1020 } 1017 }
1021 1018
1022 [XmlIgnore] 1019
1023 public bool CreateSelected 1020 public bool CreateSelected
1024 { 1021 {
1025 get { return m_createSelected; } 1022 get { return m_createSelected; }
@@ -1201,14 +1198,14 @@ namespace OpenSim.Region.Framework.Scenes
1201 } 1198 }
1202 } 1199 }
1203 1200
1204 [XmlIgnore] 1201
1205 public UUID SitTargetAvatar 1202 public UUID SitTargetAvatar
1206 { 1203 {
1207 get { return m_sitTargetAvatar; } 1204 get { return m_sitTargetAvatar; }
1208 set { m_sitTargetAvatar = value; } 1205 set { m_sitTargetAvatar = value; }
1209 } 1206 }
1210 1207
1211 [XmlIgnore] 1208
1212 public virtual UUID RegionID 1209 public virtual UUID RegionID
1213 { 1210 {
1214 get 1211 get
@@ -1222,7 +1219,7 @@ namespace OpenSim.Region.Framework.Scenes
1222 } 1219 }
1223 1220
1224 private UUID _parentUUID = UUID.Zero; 1221 private UUID _parentUUID = UUID.Zero;
1225 [XmlIgnore] 1222
1226 public UUID ParentUUID 1223 public UUID ParentUUID
1227 { 1224 {
1228 get 1225 get
@@ -1236,7 +1233,7 @@ namespace OpenSim.Region.Framework.Scenes
1236 set { _parentUUID = value; } 1233 set { _parentUUID = value; }
1237 } 1234 }
1238 1235
1239 [XmlIgnore] 1236
1240 public string SitAnimation 1237 public string SitAnimation
1241 { 1238 {
1242 get { return m_sitAnimation; } 1239 get { return m_sitAnimation; }
@@ -1850,7 +1847,7 @@ namespace OpenSim.Region.Framework.Scenes
1850 /// </summary> 1847 /// </summary>
1851 /// <param name="xmlReader"></param> 1848 /// <param name="xmlReader"></param>
1852 /// <returns></returns> 1849 /// <returns></returns>
1853 public static SceneObjectPart FromXml(XmlReader xmlReader) 1850 public static SceneObjectPart FromXml(XmlTextReader xmlReader)
1854 { 1851 {
1855 return FromXml(UUID.Zero, xmlReader); 1852 return FromXml(UUID.Zero, xmlReader);
1856 } 1853 }
@@ -1861,9 +1858,9 @@ namespace OpenSim.Region.Framework.Scenes
1861 /// <param name="fromUserInventoryItemId">The inventory id from which this part came, if applicable</param> 1858 /// <param name="fromUserInventoryItemId">The inventory id from which this part came, if applicable</param>
1862 /// <param name="xmlReader"></param> 1859 /// <param name="xmlReader"></param>
1863 /// <returns></returns> 1860 /// <returns></returns>
1864 public static SceneObjectPart FromXml(UUID fromUserInventoryItemId, XmlReader xmlReader) 1861 public static SceneObjectPart FromXml(UUID fromUserInventoryItemId, XmlTextReader xmlReader)
1865 { 1862 {
1866 SceneObjectPart part = (SceneObjectPart)serializer.Deserialize(xmlReader); 1863 SceneObjectPart part = SceneObjectSerializer.Xml2ToSOP(xmlReader);
1867 part.m_fromUserInventoryItemID = fromUserInventoryItemId; 1864 part.m_fromUserInventoryItemID = fromUserInventoryItemId;
1868 1865
1869 // for tempOnRez objects, we have to fix the Expire date. 1866 // for tempOnRez objects, we have to fix the Expire date.
@@ -4058,9 +4055,9 @@ namespace OpenSim.Region.Framework.Scenes
4058 /// Serialize this part to xml. 4055 /// Serialize this part to xml.
4059 /// </summary> 4056 /// </summary>
4060 /// <param name="xmlWriter"></param> 4057 /// <param name="xmlWriter"></param>
4061 public void ToXml(XmlWriter xmlWriter) 4058 public void ToXml(XmlTextWriter xmlWriter)
4062 { 4059 {
4063 serializer.Serialize(xmlWriter, this); 4060 SceneObjectSerializer.SOPToXml2(xmlWriter, this, new Dictionary<string, object>());
4064 } 4061 }
4065 4062
4066 public void TriggerScriptChangedEvent(Changed val) 4063 public void TriggerScriptChangedEvent(Changed val)
diff --git a/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs b/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs
index f5f6b90..252304b 100644
--- a/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs
+++ b/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs
@@ -26,6 +26,8 @@
26 */ 26 */
27 27
28using System; 28using System;
29using System.Collections.Generic;
30using System.Drawing;
29using System.IO; 31using System.IO;
30using System.Reflection; 32using System.Reflection;
31using System.Xml; 33using System.Xml;
@@ -65,14 +67,6 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
65 //m_log.DebugFormat("[SOG]: Starting deserialization of SOG"); 67 //m_log.DebugFormat("[SOG]: Starting deserialization of SOG");
66 //int time = System.Environment.TickCount; 68 //int time = System.Environment.TickCount;
67 69
68 // libomv.types changes UUID to Guid
69 xmlData = xmlData.Replace("<UUID>", "<Guid>");
70 xmlData = xmlData.Replace("</UUID>", "</Guid>");
71
72 // Handle Nested <UUID><UUID> property
73 xmlData = xmlData.Replace("<Guid><Guid>", "<UUID><Guid>");
74 xmlData = xmlData.Replace("</Guid></Guid>", "</Guid></UUID>");
75
76 try 70 try
77 { 71 {
78 StringReader sr; 72 StringReader sr;
@@ -124,6 +118,7 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
124 } 118 }
125 } 119 }
126 120
121
127 /// <summary> 122 /// <summary>
128 /// Serialize a scene object to the original xml format 123 /// Serialize a scene object to the original xml format
129 /// </summary> 124 /// </summary>
@@ -154,7 +149,7 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
154 149
155 writer.WriteStartElement(String.Empty, "SceneObjectGroup", String.Empty); 150 writer.WriteStartElement(String.Empty, "SceneObjectGroup", String.Empty);
156 writer.WriteStartElement(String.Empty, "RootPart", String.Empty); 151 writer.WriteStartElement(String.Empty, "RootPart", String.Empty);
157 ToOriginalXmlFormat(sceneObject.RootPart, writer); 152 ToXmlFormat(sceneObject.RootPart, writer);
158 writer.WriteEndElement(); 153 writer.WriteEndElement();
159 writer.WriteStartElement(String.Empty, "OtherParts", String.Empty); 154 writer.WriteStartElement(String.Empty, "OtherParts", String.Empty);
160 155
@@ -165,7 +160,7 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
165 if (part.UUID != sceneObject.RootPart.UUID) 160 if (part.UUID != sceneObject.RootPart.UUID)
166 { 161 {
167 writer.WriteStartElement(String.Empty, "Part", String.Empty); 162 writer.WriteStartElement(String.Empty, "Part", String.Empty);
168 ToOriginalXmlFormat(part, writer); 163 ToXmlFormat(part, writer);
169 writer.WriteEndElement(); 164 writer.WriteEndElement();
170 } 165 }
171 } 166 }
@@ -177,9 +172,9 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
177 //m_log.DebugFormat("[SERIALIZER]: Finished serialization of SOG {0}, {1}ms", Name, System.Environment.TickCount - time); 172 //m_log.DebugFormat("[SERIALIZER]: Finished serialization of SOG {0}, {1}ms", Name, System.Environment.TickCount - time);
178 } 173 }
179 174
180 protected static void ToOriginalXmlFormat(SceneObjectPart part, XmlTextWriter writer) 175 protected static void ToXmlFormat(SceneObjectPart part, XmlTextWriter writer)
181 { 176 {
182 part.ToXml(writer); 177 SOPToXml2(writer, part, new Dictionary<string, object>());
183 } 178 }
184 179
185 public static SceneObjectGroup FromXml2Format(string xmlData) 180 public static SceneObjectGroup FromXml2Format(string xmlData)
@@ -187,14 +182,6 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
187 //m_log.DebugFormat("[SOG]: Starting deserialization of SOG"); 182 //m_log.DebugFormat("[SOG]: Starting deserialization of SOG");
188 //int time = System.Environment.TickCount; 183 //int time = System.Environment.TickCount;
189 184
190 // libomv.types changes UUID to Guid
191 xmlData = xmlData.Replace("<UUID>", "<Guid>");
192 xmlData = xmlData.Replace("</UUID>", "</Guid>");
193
194 // Handle Nested <UUID><UUID> property
195 xmlData = xmlData.Replace("<Guid><Guid>", "<UUID><Guid>");
196 xmlData = xmlData.Replace("</Guid></Guid>", "</Guid></UUID>");
197
198 try 185 try
199 { 186 {
200 XmlDocument doc = new XmlDocument(); 187 XmlDocument doc = new XmlDocument();
@@ -259,40 +246,1237 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
259 { 246 {
260 using (XmlTextWriter writer = new XmlTextWriter(sw)) 247 using (XmlTextWriter writer = new XmlTextWriter(sw))
261 { 248 {
262 ToXml2Format(sceneObject, writer); 249 SOGToXml2(writer, sceneObject, new Dictionary<string,object>());
263 } 250 }
264 251
265 return sw.ToString(); 252 return sw.ToString();
266 } 253 }
267 } 254 }
268 255
269 /// <summary> 256
270 /// Serialize a scene object to the 'xml2' format. 257 #region manual serialization
271 /// </summary> 258
272 /// <param name="sceneObject"></param> 259 private delegate void SOPXmlProcessor(SceneObjectPart sop, XmlTextReader reader);
273 /// <returns></returns> 260 private static Dictionary<string, SOPXmlProcessor> m_SOPXmlProcessors = new Dictionary<string, SOPXmlProcessor>();
274 public static void ToXml2Format(SceneObjectGroup sceneObject, XmlTextWriter writer) 261
262 private delegate void TaskInventoryXmlProcessor(TaskInventoryItem item, XmlTextReader reader);
263 private static Dictionary<string, TaskInventoryXmlProcessor> m_TaskInventoryXmlProcessors = new Dictionary<string, TaskInventoryXmlProcessor>();
264
265 private delegate void ShapeXmlProcessor(PrimitiveBaseShape shape, XmlTextReader reader);
266 private static Dictionary<string, ShapeXmlProcessor> m_ShapeXmlProcessors = new Dictionary<string, ShapeXmlProcessor>();
267
268 static SceneObjectSerializer()
275 { 269 {
276 //m_log.DebugFormat("[SERIALIZER]: Starting serialization of SOG {0} to XML2", Name); 270 #region SOPXmlProcessors initialization
277 //int time = System.Environment.TickCount; 271 m_SOPXmlProcessors.Add("AllowedDrop", ProcessAllowedDrop);
272 m_SOPXmlProcessors.Add("CreatorID", ProcessCreatorID);
273 m_SOPXmlProcessors.Add("FolderID", ProcessFolderID);
274 m_SOPXmlProcessors.Add("InventorySerial", ProcessInventorySerial);
275 m_SOPXmlProcessors.Add("TaskInventory", ProcessTaskInventory);
276 m_SOPXmlProcessors.Add("UUID", ProcessUUID);
277 m_SOPXmlProcessors.Add("LocalId", ProcessLocalId);
278 m_SOPXmlProcessors.Add("Name", ProcessName);
279 m_SOPXmlProcessors.Add("Material", ProcessMaterial);
280 m_SOPXmlProcessors.Add("PassTouches", ProcessPassTouches);
281 m_SOPXmlProcessors.Add("RegionHandle", ProcessRegionHandle);
282 m_SOPXmlProcessors.Add("ScriptAccessPin", ProcessScriptAccessPin);
283 m_SOPXmlProcessors.Add("GroupPosition", ProcessGroupPosition);
284 m_SOPXmlProcessors.Add("OffsetPosition", ProcessOffsetPosition);
285 m_SOPXmlProcessors.Add("RotationOffset", ProcessRotationOffset);
286 m_SOPXmlProcessors.Add("Velocity", ProcessVelocity);
287 m_SOPXmlProcessors.Add("AngularVelocity", ProcessAngularVelocity);
288 m_SOPXmlProcessors.Add("Acceleration", ProcessAcceleration);
289 m_SOPXmlProcessors.Add("Description", ProcessDescription);
290 m_SOPXmlProcessors.Add("Color", ProcessColor);
291 m_SOPXmlProcessors.Add("Text", ProcessText);
292 m_SOPXmlProcessors.Add("SitName", ProcessSitName);
293 m_SOPXmlProcessors.Add("TouchName", ProcessTouchName);
294 m_SOPXmlProcessors.Add("LinkNum", ProcessLinkNum);
295 m_SOPXmlProcessors.Add("ClickAction", ProcessClickAction);
296 m_SOPXmlProcessors.Add("Shape", ProcessShape);
297 m_SOPXmlProcessors.Add("Scale", ProcessScale);
298 m_SOPXmlProcessors.Add("UpdateFlag", ProcessUpdateFlag);
299 m_SOPXmlProcessors.Add("SitTargetOrientation", ProcessSitTargetOrientation);
300 m_SOPXmlProcessors.Add("SitTargetPosition", ProcessSitTargetPosition);
301 m_SOPXmlProcessors.Add("SitTargetPositionLL", ProcessSitTargetPositionLL);
302 m_SOPXmlProcessors.Add("SitTargetOrientationLL", ProcessSitTargetOrientationLL);
303 m_SOPXmlProcessors.Add("ParentID", ProcessParentID);
304 m_SOPXmlProcessors.Add("CreationDate", ProcessCreationDate);
305 m_SOPXmlProcessors.Add("Category", ProcessCategory);
306 m_SOPXmlProcessors.Add("SalePrice", ProcessSalePrice);
307 m_SOPXmlProcessors.Add("ObjectSaleType", ProcessObjectSaleType);
308 m_SOPXmlProcessors.Add("OwnershipCost", ProcessOwnershipCost);
309 m_SOPXmlProcessors.Add("GroupID", ProcessGroupID);
310 m_SOPXmlProcessors.Add("OwnerID", ProcessOwnerID);
311 m_SOPXmlProcessors.Add("LastOwnerID", ProcessLastOwnerID);
312 m_SOPXmlProcessors.Add("BaseMask", ProcessBaseMask);
313 m_SOPXmlProcessors.Add("OwnerMask", ProcessOwnerMask);
314 m_SOPXmlProcessors.Add("GroupMask", ProcessGroupMask);
315 m_SOPXmlProcessors.Add("EveryoneMask", ProcessEveryoneMask);
316 m_SOPXmlProcessors.Add("NextOwnerMask", ProcessNextOwnerMask);
317 m_SOPXmlProcessors.Add("Flags", ProcessFlags);
318 m_SOPXmlProcessors.Add("CollisionSound", ProcessCollisionSound);
319 m_SOPXmlProcessors.Add("CollisionSoundVolume", ProcessCollisionSoundVolume);
320 m_SOPXmlProcessors.Add("MediaUrl", ProcessMediaUrl);
321 #endregion
322
323 #region TaskInventoryXmlProcessors initialization
324 m_TaskInventoryXmlProcessors.Add("AssetID", ProcessTIAssetID);
325 m_TaskInventoryXmlProcessors.Add("BasePermissions", ProcessTIBasePermissions);
326 m_TaskInventoryXmlProcessors.Add("CreationDate", ProcessTICreationDate);
327 m_TaskInventoryXmlProcessors.Add("CreatorID", ProcessTICreatorID);
328 m_TaskInventoryXmlProcessors.Add("Description", ProcessTIDescription);
329 m_TaskInventoryXmlProcessors.Add("EveryonePermissions", ProcessTIEveryonePermissions);
330 m_TaskInventoryXmlProcessors.Add("Flags", ProcessTIFlags);
331 m_TaskInventoryXmlProcessors.Add("GroupID", ProcessTIGroupID);
332 m_TaskInventoryXmlProcessors.Add("GroupPermissions", ProcessTIGroupPermissions);
333 m_TaskInventoryXmlProcessors.Add("InvType", ProcessTIInvType);
334 m_TaskInventoryXmlProcessors.Add("ItemID", ProcessTIItemID);
335 m_TaskInventoryXmlProcessors.Add("OldItemID", ProcessTIOldItemID);
336 m_TaskInventoryXmlProcessors.Add("LastOwnerID", ProcessTILastOwnerID);
337 m_TaskInventoryXmlProcessors.Add("Name", ProcessTIName);
338 m_TaskInventoryXmlProcessors.Add("NextPermissions", ProcessTINextPermissions);
339 m_TaskInventoryXmlProcessors.Add("OwnerID", ProcessTIOwnerID);
340 m_TaskInventoryXmlProcessors.Add("CurrentPermissions", ProcessTICurrentPermissions);
341 m_TaskInventoryXmlProcessors.Add("ParentID", ProcessTIParentID);
342 m_TaskInventoryXmlProcessors.Add("ParentPartID", ProcessTIParentPartID);
343 m_TaskInventoryXmlProcessors.Add("PermsGranter", ProcessTIPermsGranter);
344 m_TaskInventoryXmlProcessors.Add("PermsMask", ProcessTIPermsMask);
345 m_TaskInventoryXmlProcessors.Add("Type", ProcessTIType);
346 m_TaskInventoryXmlProcessors.Add("OwnerChanged", ProcessTIOwnerChanged);
347
348 #endregion
349
350 #region ShapeXmlProcessors initialization
351 m_ShapeXmlProcessors.Add("ProfileCurve", ProcessShpProfileCurve);
352 m_ShapeXmlProcessors.Add("TextureEntry", ProcessShpTextureEntry);
353 m_ShapeXmlProcessors.Add("ExtraParams", ProcessShpExtraParams);
354 m_ShapeXmlProcessors.Add("PathBegin", ProcessShpPathBegin);
355 m_ShapeXmlProcessors.Add("PathCurve", ProcessShpPathCurve);
356 m_ShapeXmlProcessors.Add("PathEnd", ProcessShpPathEnd);
357 m_ShapeXmlProcessors.Add("PathRadiusOffset", ProcessShpPathRadiusOffset);
358 m_ShapeXmlProcessors.Add("PathRevolutions", ProcessShpPathRevolutions);
359 m_ShapeXmlProcessors.Add("PathScaleX", ProcessShpPathScaleX);
360 m_ShapeXmlProcessors.Add("PathScaleY", ProcessShpPathScaleY);
361 m_ShapeXmlProcessors.Add("PathShearX", ProcessShpPathShearX);
362 m_ShapeXmlProcessors.Add("PathShearY", ProcessShpPathShearY);
363 m_ShapeXmlProcessors.Add("PathSkew", ProcessShpPathSkew);
364 m_ShapeXmlProcessors.Add("PathTaperX", ProcessShpPathTaperX);
365 m_ShapeXmlProcessors.Add("PathTaperY", ProcessShpPathTaperY);
366 m_ShapeXmlProcessors.Add("PathTwist", ProcessShpPathTwist);
367 m_ShapeXmlProcessors.Add("PathTwistBegin", ProcessShpPathTwistBegin);
368 m_ShapeXmlProcessors.Add("PCode", ProcessShpPCode);
369 m_ShapeXmlProcessors.Add("ProfileBegin", ProcessShpProfileBegin);
370 m_ShapeXmlProcessors.Add("ProfileEnd", ProcessShpProfileEnd);
371 m_ShapeXmlProcessors.Add("ProfileHollow", ProcessShpProfileHollow);
372 m_ShapeXmlProcessors.Add("Scale", ProcessShpScale);
373 m_ShapeXmlProcessors.Add("State", ProcessShpState);
374 m_ShapeXmlProcessors.Add("ProfileShape", ProcessShpProfileShape);
375 m_ShapeXmlProcessors.Add("HollowShape", ProcessShpHollowShape);
376 m_ShapeXmlProcessors.Add("SculptTexture", ProcessShpSculptTexture);
377 m_ShapeXmlProcessors.Add("SculptType", ProcessShpSculptType);
378 m_ShapeXmlProcessors.Add("SculptData", ProcessShpSculptData);
379 m_ShapeXmlProcessors.Add("FlexiSoftness", ProcessShpFlexiSoftness);
380 m_ShapeXmlProcessors.Add("FlexiTension", ProcessShpFlexiTension);
381 m_ShapeXmlProcessors.Add("FlexiDrag", ProcessShpFlexiDrag);
382 m_ShapeXmlProcessors.Add("FlexiGravity", ProcessShpFlexiGravity);
383 m_ShapeXmlProcessors.Add("FlexiWind", ProcessShpFlexiWind);
384 m_ShapeXmlProcessors.Add("FlexiForceX", ProcessShpFlexiForceX);
385 m_ShapeXmlProcessors.Add("FlexiForceY", ProcessShpFlexiForceY);
386 m_ShapeXmlProcessors.Add("FlexiForceZ", ProcessShpFlexiForceZ);
387 m_ShapeXmlProcessors.Add("LightColorR", ProcessShpLightColorR);
388 m_ShapeXmlProcessors.Add("LightColorG", ProcessShpLightColorG);
389 m_ShapeXmlProcessors.Add("LightColorB", ProcessShpLightColorB);
390 m_ShapeXmlProcessors.Add("LightColorA", ProcessShpLightColorA);
391 m_ShapeXmlProcessors.Add("LightRadius", ProcessShpLightRadius);
392 m_ShapeXmlProcessors.Add("LightCutoff", ProcessShpLightCutoff);
393 m_ShapeXmlProcessors.Add("LightFalloff", ProcessShpLightFalloff);
394 m_ShapeXmlProcessors.Add("LightIntensity", ProcessShpLightIntensity);
395 m_ShapeXmlProcessors.Add("FlexiEntry", ProcessShpFlexiEntry);
396 m_ShapeXmlProcessors.Add("LightEntry", ProcessShpLightEntry);
397 m_ShapeXmlProcessors.Add("SculptEntry", ProcessShpSculptEntry);
398 m_ShapeXmlProcessors.Add("Media", ProcessShpMedia);
399 #endregion
400 }
401
402 #region SOPXmlProcessors
403 private static void ProcessAllowedDrop(SceneObjectPart obj, XmlTextReader reader)
404 {
405 obj.AllowedDrop = reader.ReadElementContentAsBoolean("AllowedDrop", String.Empty);
406 }
407
408 private static void ProcessCreatorID(SceneObjectPart obj, XmlTextReader reader)
409 {
410 obj.CreatorID = ReadUUID(reader, "CreatorID");
411 }
412
413 private static void ProcessFolderID(SceneObjectPart obj, XmlTextReader reader)
414 {
415 obj.FolderID = ReadUUID(reader, "FolderID");
416 }
417
418 private static void ProcessInventorySerial(SceneObjectPart obj, XmlTextReader reader)
419 {
420 obj.InventorySerial = (uint)reader.ReadElementContentAsInt("InventorySerial", String.Empty);
421 }
422
423 private static void ProcessTaskInventory(SceneObjectPart obj, XmlTextReader reader)
424 {
425 obj.TaskInventory = ReadTaskInventory(reader, "TaskInventory");
426 }
427
428 private static void ProcessUUID(SceneObjectPart obj, XmlTextReader reader)
429 {
430 obj.UUID = ReadUUID(reader, "UUID");
431 }
432
433 private static void ProcessLocalId(SceneObjectPart obj, XmlTextReader reader)
434 {
435 obj.LocalId = (uint)reader.ReadElementContentAsLong("LocalId", String.Empty);
436 }
437
438 private static void ProcessName(SceneObjectPart obj, XmlTextReader reader)
439 {
440 obj.Name = reader.ReadElementString("Name");
441 }
442
443 private static void ProcessMaterial(SceneObjectPart obj, XmlTextReader reader)
444 {
445 obj.Material = (byte)reader.ReadElementContentAsInt("Material", String.Empty);
446 }
447
448 private static void ProcessPassTouches(SceneObjectPart obj, XmlTextReader reader)
449 {
450 obj.PassTouches = reader.ReadElementContentAsBoolean("PassTouches", String.Empty);
451 }
452
453 private static void ProcessRegionHandle(SceneObjectPart obj, XmlTextReader reader)
454 {
455 obj.RegionHandle = (ulong)reader.ReadElementContentAsLong("RegionHandle", String.Empty);
456 }
457
458 private static void ProcessScriptAccessPin(SceneObjectPart obj, XmlTextReader reader)
459 {
460 obj.ScriptAccessPin = reader.ReadElementContentAsInt("ScriptAccessPin", String.Empty);
461 }
462
463 private static void ProcessGroupPosition(SceneObjectPart obj, XmlTextReader reader)
464 {
465 obj.GroupPosition = ReadVector(reader, "GroupPosition");
466 }
467
468 private static void ProcessOffsetPosition(SceneObjectPart obj, XmlTextReader reader)
469 {
470 obj.OffsetPosition = ReadVector(reader, "OffsetPosition"); ;
471 }
472
473 private static void ProcessRotationOffset(SceneObjectPart obj, XmlTextReader reader)
474 {
475 obj.RotationOffset = ReadQuaternion(reader, "RotationOffset");
476 }
477
478 private static void ProcessVelocity(SceneObjectPart obj, XmlTextReader reader)
479 {
480 obj.Velocity = ReadVector(reader, "Velocity");
481 }
482
483 private static void ProcessAngularVelocity(SceneObjectPart obj, XmlTextReader reader)
484 {
485 obj.AngularVelocity = ReadVector(reader, "AngularVelocity");
486 }
487
488 private static void ProcessAcceleration(SceneObjectPart obj, XmlTextReader reader)
489 {
490 obj.Acceleration = ReadVector(reader, "Acceleration");
491 }
492
493 private static void ProcessDescription(SceneObjectPart obj, XmlTextReader reader)
494 {
495 obj.Description = reader.ReadElementString("Description");
496 }
497
498 private static void ProcessColor(SceneObjectPart obj, XmlTextReader reader)
499 {
500 reader.ReadStartElement("Color");
501 if (reader.Name == "R")
502 {
503 float r = reader.ReadElementContentAsFloat("R", String.Empty);
504 float g = reader.ReadElementContentAsFloat("G", String.Empty);
505 float b = reader.ReadElementContentAsFloat("B", String.Empty);
506 float a = reader.ReadElementContentAsFloat("A", String.Empty);
507 obj.Color = Color.FromArgb((int)a, (int)r, (int)g, (int)b);
508 reader.ReadEndElement();
509 }
510 }
511
512 private static void ProcessText(SceneObjectPart obj, XmlTextReader reader)
513 {
514 obj.Text = reader.ReadElementString("Text", String.Empty);
515 }
516
517 private static void ProcessSitName(SceneObjectPart obj, XmlTextReader reader)
518 {
519 obj.SitName = reader.ReadElementString("SitName", String.Empty);
520 }
521
522 private static void ProcessTouchName(SceneObjectPart obj, XmlTextReader reader)
523 {
524 obj.TouchName = reader.ReadElementString("TouchName", String.Empty);
525 }
526
527 private static void ProcessLinkNum(SceneObjectPart obj, XmlTextReader reader)
528 {
529 obj.LinkNum = reader.ReadElementContentAsInt("LinkNum", String.Empty);
530 }
531
532 private static void ProcessClickAction(SceneObjectPart obj, XmlTextReader reader)
533 {
534 obj.ClickAction = (byte)reader.ReadElementContentAsInt("ClickAction", String.Empty);
535 }
536
537 private static void ProcessShape(SceneObjectPart obj, XmlTextReader reader)
538 {
539 obj.Shape = ReadShape(reader, "Shape");
540 }
541
542 private static void ProcessScale(SceneObjectPart obj, XmlTextReader reader)
543 {
544 obj.Scale = ReadVector(reader, "Scale");
545 }
546
547 private static void ProcessUpdateFlag(SceneObjectPart obj, XmlTextReader reader)
548 {
549 obj.UpdateFlag = (byte)reader.ReadElementContentAsInt("UpdateFlag", String.Empty);
550 }
551
552 private static void ProcessSitTargetOrientation(SceneObjectPart obj, XmlTextReader reader)
553 {
554 obj.SitTargetOrientation = ReadQuaternion(reader, "SitTargetOrientation");
555 }
556
557 private static void ProcessSitTargetPosition(SceneObjectPart obj, XmlTextReader reader)
558 {
559 obj.SitTargetPosition = ReadVector(reader, "SitTargetPosition");
560 }
561
562 private static void ProcessSitTargetPositionLL(SceneObjectPart obj, XmlTextReader reader)
563 {
564 obj.SitTargetPositionLL = ReadVector(reader, "SitTargetPositionLL");
565 }
566
567 private static void ProcessSitTargetOrientationLL(SceneObjectPart obj, XmlTextReader reader)
568 {
569 obj.SitTargetOrientationLL = ReadQuaternion(reader, "SitTargetOrientationLL");
570 }
571
572 private static void ProcessParentID(SceneObjectPart obj, XmlTextReader reader)
573 {
574 string str = reader.ReadElementContentAsString("ParentID", String.Empty);
575 obj.ParentID = Convert.ToUInt32(str);
576 }
577
578 private static void ProcessCreationDate(SceneObjectPart obj, XmlTextReader reader)
579 {
580 obj.CreationDate = reader.ReadElementContentAsInt("CreationDate", String.Empty);
581 }
582
583 private static void ProcessCategory(SceneObjectPart obj, XmlTextReader reader)
584 {
585 obj.Category = (uint)reader.ReadElementContentAsInt("Category", String.Empty);
586 }
587
588 private static void ProcessSalePrice(SceneObjectPart obj, XmlTextReader reader)
589 {
590 obj.SalePrice = reader.ReadElementContentAsInt("SalePrice", String.Empty);
591 }
592
593 private static void ProcessObjectSaleType(SceneObjectPart obj, XmlTextReader reader)
594 {
595 obj.ObjectSaleType = (byte)reader.ReadElementContentAsInt("ObjectSaleType", String.Empty);
596 }
597
598 private static void ProcessOwnershipCost(SceneObjectPart obj, XmlTextReader reader)
599 {
600 obj.OwnershipCost = reader.ReadElementContentAsInt("OwnershipCost", String.Empty);
601 }
602
603 private static void ProcessGroupID(SceneObjectPart obj, XmlTextReader reader)
604 {
605 obj.GroupID = ReadUUID(reader, "GroupID");
606 }
607
608 private static void ProcessOwnerID(SceneObjectPart obj, XmlTextReader reader)
609 {
610 obj.OwnerID = ReadUUID(reader, "OwnerID");
611 }
612
613 private static void ProcessLastOwnerID(SceneObjectPart obj, XmlTextReader reader)
614 {
615 obj.LastOwnerID = ReadUUID(reader, "LastOwnerID");
616 }
617
618 private static void ProcessBaseMask(SceneObjectPart obj, XmlTextReader reader)
619 {
620 obj.BaseMask = (uint)reader.ReadElementContentAsInt("BaseMask", String.Empty);
621 }
622
623 private static void ProcessOwnerMask(SceneObjectPart obj, XmlTextReader reader)
624 {
625 obj.OwnerMask = (uint)reader.ReadElementContentAsInt("OwnerMask", String.Empty);
626 }
627
628 private static void ProcessGroupMask(SceneObjectPart obj, XmlTextReader reader)
629 {
630 obj.GroupMask = (uint)reader.ReadElementContentAsInt("GroupMask", String.Empty);
631 }
632
633 private static void ProcessEveryoneMask(SceneObjectPart obj, XmlTextReader reader)
634 {
635 obj.EveryoneMask = (uint)reader.ReadElementContentAsInt("EveryoneMask", String.Empty);
636 }
637
638 private static void ProcessNextOwnerMask(SceneObjectPart obj, XmlTextReader reader)
639 {
640 obj.NextOwnerMask = (uint)reader.ReadElementContentAsInt("NextOwnerMask", String.Empty);
641 }
642
643 private static void ProcessFlags(SceneObjectPart obj, XmlTextReader reader)
644 {
645 string value = reader.ReadElementContentAsString("Flags", String.Empty);
646 // !!!!! to deal with flags without commas
647 if (value.Contains(" ") && !value.Contains(","))
648 value = value.Replace(" ", ", ");
649 obj.Flags = (PrimFlags)Enum.Parse(typeof(PrimFlags), value);
650 }
651
652 private static void ProcessCollisionSound(SceneObjectPart obj, XmlTextReader reader)
653 {
654 obj.CollisionSound = ReadUUID(reader, "CollisionSound");
655 }
656
657 private static void ProcessCollisionSoundVolume(SceneObjectPart obj, XmlTextReader reader)
658 {
659 obj.CollisionSoundVolume = reader.ReadElementContentAsFloat("CollisionSoundVolume", String.Empty);
660 }
661
662 private static void ProcessMediaUrl(SceneObjectPart obj, XmlTextReader reader)
663 {
664 obj.MediaUrl = reader.ReadElementContentAsString("MediaUrl", String.Empty);
665 }
666 #endregion
667
668 #region TaskInventoryXmlProcessors
669 private static void ProcessTIAssetID(TaskInventoryItem item, XmlTextReader reader)
670 {
671 item.AssetID = ReadUUID(reader, "AssetID");
672 }
673
674 private static void ProcessTIBasePermissions(TaskInventoryItem item, XmlTextReader reader)
675 {
676 item.BasePermissions = (uint)reader.ReadElementContentAsInt("BasePermissions", String.Empty);
677 }
678
679 private static void ProcessTICreationDate(TaskInventoryItem item, XmlTextReader reader)
680 {
681 item.CreationDate = (uint)reader.ReadElementContentAsInt("CreationDate", String.Empty);
682 }
683
684 private static void ProcessTICreatorID(TaskInventoryItem item, XmlTextReader reader)
685 {
686 item.CreatorID = ReadUUID(reader, "CreatorID");
687 }
688
689 private static void ProcessTIDescription(TaskInventoryItem item, XmlTextReader reader)
690 {
691 item.Description = reader.ReadElementContentAsString("Description", String.Empty);
692 }
693
694 private static void ProcessTIEveryonePermissions(TaskInventoryItem item, XmlTextReader reader)
695 {
696 item.EveryonePermissions = (uint)reader.ReadElementContentAsInt("EveryonePermissions", String.Empty);
697 }
698
699 private static void ProcessTIFlags(TaskInventoryItem item, XmlTextReader reader)
700 {
701 item.Flags = (uint)reader.ReadElementContentAsInt("Flags", String.Empty);
702 }
703
704 private static void ProcessTIGroupID(TaskInventoryItem item, XmlTextReader reader)
705 {
706 item.GroupID = ReadUUID(reader, "GroupID");
707 }
708
709 private static void ProcessTIGroupPermissions(TaskInventoryItem item, XmlTextReader reader)
710 {
711 item.GroupPermissions = (uint)reader.ReadElementContentAsInt("GroupPermissions", String.Empty);
712 }
713
714 private static void ProcessTIInvType(TaskInventoryItem item, XmlTextReader reader)
715 {
716 item.InvType = reader.ReadElementContentAsInt("InvType", String.Empty);
717 }
718
719 private static void ProcessTIItemID(TaskInventoryItem item, XmlTextReader reader)
720 {
721 item.ItemID = ReadUUID(reader, "ItemID");
722 }
723
724 private static void ProcessTIOldItemID(TaskInventoryItem item, XmlTextReader reader)
725 {
726 item.OldItemID = ReadUUID(reader, "OldItemID");
727 }
728
729 private static void ProcessTILastOwnerID(TaskInventoryItem item, XmlTextReader reader)
730 {
731 item.LastOwnerID = ReadUUID(reader, "LastOwnerID");
732 }
733
734 private static void ProcessTIName(TaskInventoryItem item, XmlTextReader reader)
735 {
736 item.Name = reader.ReadElementContentAsString("Name", String.Empty);
737 }
738
739 private static void ProcessTINextPermissions(TaskInventoryItem item, XmlTextReader reader)
740 {
741 item.NextPermissions = (uint)reader.ReadElementContentAsInt("NextPermissions", String.Empty);
742 }
743
744 private static void ProcessTIOwnerID(TaskInventoryItem item, XmlTextReader reader)
745 {
746 item.OwnerID = ReadUUID(reader, "OwnerID");
747 }
748
749 private static void ProcessTICurrentPermissions(TaskInventoryItem item, XmlTextReader reader)
750 {
751 item.CurrentPermissions = (uint)reader.ReadElementContentAsInt("CurrentPermissions", String.Empty);
752 }
753
754 private static void ProcessTIParentID(TaskInventoryItem item, XmlTextReader reader)
755 {
756 item.ParentID = ReadUUID(reader, "ParentID");
757 }
758
759 private static void ProcessTIParentPartID(TaskInventoryItem item, XmlTextReader reader)
760 {
761 item.ParentPartID = ReadUUID(reader, "ParentPartID");
762 }
763
764 private static void ProcessTIPermsGranter(TaskInventoryItem item, XmlTextReader reader)
765 {
766 item.PermsGranter = ReadUUID(reader, "PermsGranter");
767 }
768
769 private static void ProcessTIPermsMask(TaskInventoryItem item, XmlTextReader reader)
770 {
771 item.PermsMask = reader.ReadElementContentAsInt("PermsMask", String.Empty);
772 }
773
774 private static void ProcessTIType(TaskInventoryItem item, XmlTextReader reader)
775 {
776 item.Type = reader.ReadElementContentAsInt("Type", String.Empty);
777 }
778
779 private static void ProcessTIOwnerChanged(TaskInventoryItem item, XmlTextReader reader)
780 {
781 item.OwnerChanged = reader.ReadElementContentAsBoolean("OwnerChanged", String.Empty);
782 }
783
784 #endregion
785
786 #region ShapeXmlProcessors
787 private static void ProcessShpProfileCurve(PrimitiveBaseShape shp, XmlTextReader reader)
788 {
789 shp.ProfileCurve = (byte)reader.ReadElementContentAsInt("ProfileCurve", String.Empty);
790 }
791
792 private static void ProcessShpTextureEntry(PrimitiveBaseShape shp, XmlTextReader reader)
793 {
794 byte[] teData = Convert.FromBase64String(reader.ReadElementString("TextureEntry"));
795 shp.Textures = new Primitive.TextureEntry(teData, 0, teData.Length);
796 }
797
798 private static void ProcessShpExtraParams(PrimitiveBaseShape shp, XmlTextReader reader)
799 {
800 shp.ExtraParams = Convert.FromBase64String(reader.ReadElementString("ExtraParams"));
801 }
802
803 private static void ProcessShpPathBegin(PrimitiveBaseShape shp, XmlTextReader reader)
804 {
805 shp.PathBegin = (ushort)reader.ReadElementContentAsInt("PathBegin", String.Empty);
806 }
807
808 private static void ProcessShpPathCurve(PrimitiveBaseShape shp, XmlTextReader reader)
809 {
810 shp.PathCurve = (byte)reader.ReadElementContentAsInt("PathCurve", String.Empty);
811 }
812
813 private static void ProcessShpPathEnd(PrimitiveBaseShape shp, XmlTextReader reader)
814 {
815 shp.PathEnd = (ushort)reader.ReadElementContentAsInt("PathEnd", String.Empty);
816 }
278 817
818 private static void ProcessShpPathRadiusOffset(PrimitiveBaseShape shp, XmlTextReader reader)
819 {
820 shp.PathRadiusOffset = (sbyte)reader.ReadElementContentAsInt("PathRadiusOffset", String.Empty);
821 }
822
823 private static void ProcessShpPathRevolutions(PrimitiveBaseShape shp, XmlTextReader reader)
824 {
825 shp.PathRevolutions = (byte)reader.ReadElementContentAsInt("PathRevolutions", String.Empty);
826 }
827
828 private static void ProcessShpPathScaleX(PrimitiveBaseShape shp, XmlTextReader reader)
829 {
830 shp.PathScaleX = (byte)reader.ReadElementContentAsInt("PathScaleX", String.Empty);
831 }
832
833 private static void ProcessShpPathScaleY(PrimitiveBaseShape shp, XmlTextReader reader)
834 {
835 shp.PathScaleY = (byte)reader.ReadElementContentAsInt("PathScaleY", String.Empty);
836 }
837
838 private static void ProcessShpPathShearX(PrimitiveBaseShape shp, XmlTextReader reader)
839 {
840 shp.PathShearX = (byte)reader.ReadElementContentAsInt("PathShearX", String.Empty);
841 }
842
843 private static void ProcessShpPathShearY(PrimitiveBaseShape shp, XmlTextReader reader)
844 {
845 shp.PathShearY = (byte)reader.ReadElementContentAsInt("PathShearY", String.Empty);
846 }
847
848 private static void ProcessShpPathSkew(PrimitiveBaseShape shp, XmlTextReader reader)
849 {
850 shp.PathSkew = (sbyte)reader.ReadElementContentAsInt("PathSkew", String.Empty);
851 }
852
853 private static void ProcessShpPathTaperX(PrimitiveBaseShape shp, XmlTextReader reader)
854 {
855 shp.PathTaperX = (sbyte)reader.ReadElementContentAsInt("PathTaperX", String.Empty);
856 }
857
858 private static void ProcessShpPathTaperY(PrimitiveBaseShape shp, XmlTextReader reader)
859 {
860 shp.PathTaperY = (sbyte)reader.ReadElementContentAsInt("PathTaperY", String.Empty);
861 }
862
863 private static void ProcessShpPathTwist(PrimitiveBaseShape shp, XmlTextReader reader)
864 {
865 shp.PathTwist = (sbyte)reader.ReadElementContentAsInt("PathTwist", String.Empty);
866 }
867
868 private static void ProcessShpPathTwistBegin(PrimitiveBaseShape shp, XmlTextReader reader)
869 {
870 shp.PathTwistBegin = (sbyte)reader.ReadElementContentAsInt("PathTwistBegin", String.Empty);
871 }
872
873 private static void ProcessShpPCode(PrimitiveBaseShape shp, XmlTextReader reader)
874 {
875 shp.PCode = (byte)reader.ReadElementContentAsInt("PCode", String.Empty);
876 }
877
878 private static void ProcessShpProfileBegin(PrimitiveBaseShape shp, XmlTextReader reader)
879 {
880 shp.ProfileBegin = (ushort)reader.ReadElementContentAsInt("ProfileBegin", String.Empty);
881 }
882
883 private static void ProcessShpProfileEnd(PrimitiveBaseShape shp, XmlTextReader reader)
884 {
885 shp.ProfileEnd = (ushort)reader.ReadElementContentAsInt("ProfileEnd", String.Empty);
886 }
887
888 private static void ProcessShpProfileHollow(PrimitiveBaseShape shp, XmlTextReader reader)
889 {
890 shp.ProfileHollow = (ushort)reader.ReadElementContentAsInt("ProfileHollow", String.Empty);
891 }
892
893 private static void ProcessShpScale(PrimitiveBaseShape shp, XmlTextReader reader)
894 {
895 shp.Scale = ReadVector(reader, "Scale");
896 }
897
898 private static void ProcessShpState(PrimitiveBaseShape shp, XmlTextReader reader)
899 {
900 shp.State = (byte)reader.ReadElementContentAsInt("State", String.Empty);
901 }
902
903 private static void ProcessShpProfileShape(PrimitiveBaseShape shp, XmlTextReader reader)
904 {
905 string value = reader.ReadElementContentAsString("ProfileShape", String.Empty);
906 // !!!!! to deal with flags without commas
907 if (value.Contains(" ") && !value.Contains(","))
908 value = value.Replace(" ", ", ");
909 shp.ProfileShape = (ProfileShape)Enum.Parse(typeof(ProfileShape), value);
910 }
911
912 private static void ProcessShpHollowShape(PrimitiveBaseShape shp, XmlTextReader reader)
913 {
914 string value = reader.ReadElementContentAsString("HollowShape", String.Empty);
915 // !!!!! to deal with flags without commas
916 if (value.Contains(" ") && !value.Contains(","))
917 value = value.Replace(" ", ", ");
918 shp.HollowShape = (HollowShape)Enum.Parse(typeof(HollowShape), value);
919 }
920
921 private static void ProcessShpSculptTexture(PrimitiveBaseShape shp, XmlTextReader reader)
922 {
923 shp.SculptTexture = ReadUUID(reader, "SculptTexture");
924 }
925
926 private static void ProcessShpSculptType(PrimitiveBaseShape shp, XmlTextReader reader)
927 {
928 shp.SculptType = (byte)reader.ReadElementContentAsInt("SculptType", String.Empty);
929 }
930
931 private static void ProcessShpSculptData(PrimitiveBaseShape shp, XmlTextReader reader)
932 {
933 shp.SculptData = Convert.FromBase64String(reader.ReadElementString("SculptData"));
934 }
935
936 private static void ProcessShpFlexiSoftness(PrimitiveBaseShape shp, XmlTextReader reader)
937 {
938 shp.FlexiSoftness = reader.ReadElementContentAsInt("FlexiSoftness", String.Empty);
939 }
940
941 private static void ProcessShpFlexiTension(PrimitiveBaseShape shp, XmlTextReader reader)
942 {
943 shp.FlexiTension = reader.ReadElementContentAsFloat("FlexiTension", String.Empty);
944 }
945
946 private static void ProcessShpFlexiDrag(PrimitiveBaseShape shp, XmlTextReader reader)
947 {
948 shp.FlexiDrag = reader.ReadElementContentAsFloat("FlexiDrag", String.Empty);
949 }
950
951 private static void ProcessShpFlexiGravity(PrimitiveBaseShape shp, XmlTextReader reader)
952 {
953 shp.FlexiGravity = reader.ReadElementContentAsFloat("FlexiGravity", String.Empty);
954 }
955
956 private static void ProcessShpFlexiWind(PrimitiveBaseShape shp, XmlTextReader reader)
957 {
958 shp.FlexiWind = reader.ReadElementContentAsFloat("FlexiWind", String.Empty);
959 }
960
961 private static void ProcessShpFlexiForceX(PrimitiveBaseShape shp, XmlTextReader reader)
962 {
963 shp.FlexiForceX = reader.ReadElementContentAsFloat("FlexiForceX", String.Empty);
964 }
965
966 private static void ProcessShpFlexiForceY(PrimitiveBaseShape shp, XmlTextReader reader)
967 {
968 shp.FlexiForceY = reader.ReadElementContentAsFloat("FlexiForceY", String.Empty);
969 }
970
971 private static void ProcessShpFlexiForceZ(PrimitiveBaseShape shp, XmlTextReader reader)
972 {
973 shp.FlexiForceZ = reader.ReadElementContentAsFloat("FlexiForceZ", String.Empty);
974 }
975
976 private static void ProcessShpLightColorR(PrimitiveBaseShape shp, XmlTextReader reader)
977 {
978 shp.LightColorR = reader.ReadElementContentAsFloat("LightColorR", String.Empty);
979 }
980
981 private static void ProcessShpLightColorG(PrimitiveBaseShape shp, XmlTextReader reader)
982 {
983 shp.LightColorG = reader.ReadElementContentAsFloat("LightColorG", String.Empty);
984 }
985
986 private static void ProcessShpLightColorB(PrimitiveBaseShape shp, XmlTextReader reader)
987 {
988 shp.LightColorB = reader.ReadElementContentAsFloat("LightColorB", String.Empty);
989 }
990
991 private static void ProcessShpLightColorA(PrimitiveBaseShape shp, XmlTextReader reader)
992 {
993 shp.LightColorA = reader.ReadElementContentAsFloat("LightColorA", String.Empty);
994 }
995
996 private static void ProcessShpLightRadius(PrimitiveBaseShape shp, XmlTextReader reader)
997 {
998 shp.LightRadius = reader.ReadElementContentAsFloat("LightRadius", String.Empty);
999 }
1000
1001 private static void ProcessShpLightCutoff(PrimitiveBaseShape shp, XmlTextReader reader)
1002 {
1003 shp.LightCutoff = reader.ReadElementContentAsFloat("LightCutoff", String.Empty);
1004 }
1005
1006 private static void ProcessShpLightFalloff(PrimitiveBaseShape shp, XmlTextReader reader)
1007 {
1008 shp.LightFalloff = reader.ReadElementContentAsFloat("LightFalloff", String.Empty);
1009 }
1010
1011 private static void ProcessShpLightIntensity(PrimitiveBaseShape shp, XmlTextReader reader)
1012 {
1013 shp.LightIntensity = reader.ReadElementContentAsFloat("LightIntensity", String.Empty);
1014 }
1015
1016 private static void ProcessShpFlexiEntry(PrimitiveBaseShape shp, XmlTextReader reader)
1017 {
1018 shp.FlexiEntry = reader.ReadElementContentAsBoolean("FlexiEntry", String.Empty);
1019 }
1020
1021 private static void ProcessShpLightEntry(PrimitiveBaseShape shp, XmlTextReader reader)
1022 {
1023 shp.LightEntry = reader.ReadElementContentAsBoolean("LightEntry", String.Empty);
1024 }
1025
1026 private static void ProcessShpSculptEntry(PrimitiveBaseShape shp, XmlTextReader reader)
1027 {
1028 shp.SculptEntry = reader.ReadElementContentAsBoolean("SculptEntry", String.Empty);
1029 }
1030
1031 private static void ProcessShpMedia(PrimitiveBaseShape shp, XmlTextReader reader)
1032 {
1033 string value = reader.ReadElementContentAsString("Media", String.Empty);
1034 shp.Media = PrimitiveBaseShape.MediaList.FromXml(value);
1035 }
1036
1037
1038 #endregion
1039
1040 ////////// Write /////////
1041
1042 public static void SOGToXml2(XmlTextWriter writer, SceneObjectGroup sog, Dictionary<string, object>options)
1043 {
279 writer.WriteStartElement(String.Empty, "SceneObjectGroup", String.Empty); 1044 writer.WriteStartElement(String.Empty, "SceneObjectGroup", String.Empty);
280 sceneObject.RootPart.ToXml(writer); 1045 SOPToXml2(writer, sog.RootPart, options);
281 writer.WriteStartElement(String.Empty, "OtherParts", String.Empty); 1046 writer.WriteStartElement(String.Empty, "OtherParts", String.Empty);
282 1047
283 SceneObjectPart[] parts = sceneObject.Parts; 1048 sog.ForEachPart(delegate(SceneObjectPart sop)
284 for (int i = 0; i < parts.Length; i++)
285 { 1049 {
286 SceneObjectPart part = parts[i]; 1050 if (sop.UUID != sog.RootPart.UUID)
287 if (part.UUID != sceneObject.RootPart.UUID) 1051 SOPToXml2(writer, sop, options);
288 part.ToXml(writer); 1052 });
1053
1054 writer.WriteEndElement();
1055 writer.WriteEndElement();
1056 }
1057
1058 public static void SOPToXml2(XmlTextWriter writer, SceneObjectPart sop, Dictionary<string, object> options)
1059 {
1060 writer.WriteStartElement("SceneObjectPart");
1061 writer.WriteAttributeString("xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance");
1062 writer.WriteAttributeString("xmlns:xsd", "http://www.w3.org/2001/XMLSchema");
1063
1064 writer.WriteElementString("AllowedDrop", sop.AllowedDrop.ToString().ToLower());
1065 WriteUUID(writer, "CreatorID", sop.CreatorID, options);
1066 WriteUUID(writer, "FolderID", sop.FolderID, options);
1067 writer.WriteElementString("InventorySerial", sop.InventorySerial.ToString());
1068
1069 WriteTaskInventory(writer, sop.TaskInventory, options);
1070
1071 WriteUUID(writer, "UUID", sop.UUID, options);
1072 writer.WriteElementString("LocalId", sop.LocalId.ToString());
1073 writer.WriteElementString("Name", sop.Name);
1074 writer.WriteElementString("Material", sop.Material.ToString());
1075 writer.WriteElementString("PassTouches", sop.PassTouches.ToString().ToLower());
1076 writer.WriteElementString("RegionHandle", sop.RegionHandle.ToString());
1077 writer.WriteElementString("ScriptAccessPin", sop.ScriptAccessPin.ToString());
1078
1079 WriteVector(writer, "GroupPosition", sop.GroupPosition);
1080 WriteVector(writer, "OffsetPosition", sop.OffsetPosition);
1081
1082 WriteQuaternion(writer, "RotationOffset", sop.RotationOffset);
1083 WriteVector(writer, "Velocity", sop.Velocity);
1084 WriteVector(writer, "AngularVelocity", sop.AngularVelocity);
1085 WriteVector(writer, "Acceleration", sop.Acceleration);
1086 writer.WriteElementString("Description", sop.Description);
1087 if (sop.Color != null)
1088 {
1089 writer.WriteStartElement("Color");
1090 writer.WriteElementString("R", sop.Color.R.ToString(Utils.EnUsCulture));
1091 writer.WriteElementString("G", sop.Color.G.ToString(Utils.EnUsCulture));
1092 writer.WriteElementString("B", sop.Color.B.ToString(Utils.EnUsCulture));
1093 writer.WriteElementString("A", sop.Color.G.ToString(Utils.EnUsCulture));
1094 writer.WriteEndElement();
289 } 1095 }
290 1096
291 writer.WriteEndElement(); // End of OtherParts 1097 writer.WriteElementString("Text", sop.Text);
292 sceneObject.SaveScriptedState(writer); 1098 writer.WriteElementString("SitName", sop.SitName);
293 writer.WriteEndElement(); // End of SceneObjectGroup 1099 writer.WriteElementString("TouchName", sop.TouchName);
294 1100
295 //m_log.DebugFormat("[SERIALIZER]: Finished serialization of SOG {0} to XML2, {1}ms", Name, System.Environment.TickCount - time); 1101 writer.WriteElementString("LinkNum", sop.LinkNum.ToString());
1102 writer.WriteElementString("ClickAction", sop.ClickAction.ToString());
1103
1104 WriteShape(writer, sop.Shape, options);
1105
1106 WriteVector(writer, "Scale", sop.Scale);
1107 writer.WriteElementString("UpdateFlag", sop.UpdateFlag.ToString());
1108 WriteQuaternion(writer, "SitTargetOrientation", sop.SitTargetOrientation);
1109 WriteVector(writer, "SitTargetPosition", sop.SitTargetPosition);
1110 WriteVector(writer, "SitTargetPositionLL", sop.SitTargetPositionLL);
1111 WriteQuaternion(writer, "SitTargetOrientationLL", sop.SitTargetOrientationLL);
1112 writer.WriteElementString("ParentID", sop.ParentID.ToString());
1113 writer.WriteElementString("CreationDate", sop.CreationDate.ToString());
1114 writer.WriteElementString("Category", sop.Category.ToString());
1115 writer.WriteElementString("SalePrice", sop.SalePrice.ToString());
1116 writer.WriteElementString("ObjectSaleType", sop.ObjectSaleType.ToString());
1117 writer.WriteElementString("OwnershipCost", sop.OwnershipCost.ToString());
1118 WriteUUID(writer, "GroupID", sop.GroupID, options);
1119 WriteUUID(writer, "OwnerID", sop.OwnerID, options);
1120 WriteUUID(writer, "LastOwnerID", sop.LastOwnerID, options);
1121 writer.WriteElementString("BaseMask", sop.BaseMask.ToString());
1122 writer.WriteElementString("OwnerMask", sop.OwnerMask.ToString());
1123 writer.WriteElementString("GroupMask", sop.GroupMask.ToString());
1124 writer.WriteElementString("EveryoneMask", sop.EveryoneMask.ToString());
1125 writer.WriteElementString("NextOwnerMask", sop.NextOwnerMask.ToString());
1126 writer.WriteElementString("Flags", sop.Flags.ToString());
1127 WriteUUID(writer, "CollisionSound", sop.CollisionSound, options);
1128 writer.WriteElementString("CollisionSoundVolume", sop.CollisionSoundVolume.ToString());
1129 if (sop.MediaUrl != null)
1130 writer.WriteElementString("MediaUrl", sop.MediaUrl.ToString());
1131
1132 writer.WriteEndElement();
1133 }
1134
1135 static void WriteUUID(XmlTextWriter writer, string name, UUID id, Dictionary<string, object> options)
1136 {
1137 writer.WriteStartElement(name);
1138 if (options.ContainsKey("old-guids"))
1139 writer.WriteElementString("Guid", id.ToString());
1140 else
1141 writer.WriteElementString("UUID", id.ToString());
1142 writer.WriteEndElement();
1143 }
1144
1145 static void WriteVector(XmlTextWriter writer, string name, Vector3 vec)
1146 {
1147 writer.WriteStartElement(name);
1148 writer.WriteElementString("X", vec.X.ToString(Utils.EnUsCulture));
1149 writer.WriteElementString("Y", vec.Y.ToString(Utils.EnUsCulture));
1150 writer.WriteElementString("Z", vec.Z.ToString(Utils.EnUsCulture));
1151 writer.WriteEndElement();
1152 }
1153
1154 static void WriteQuaternion(XmlTextWriter writer, string name, Quaternion quat)
1155 {
1156 writer.WriteStartElement(name);
1157 writer.WriteElementString("X", quat.X.ToString(Utils.EnUsCulture));
1158 writer.WriteElementString("Y", quat.Y.ToString(Utils.EnUsCulture));
1159 writer.WriteElementString("Z", quat.Z.ToString(Utils.EnUsCulture));
1160 writer.WriteElementString("W", quat.W.ToString(Utils.EnUsCulture));
1161 writer.WriteEndElement();
296 } 1162 }
1163
1164 static void WriteTaskInventory(XmlTextWriter writer, TaskInventoryDictionary tinv, Dictionary<string, object> options)
1165 {
1166 if (tinv.Count > 0) // otherwise skip this
1167 {
1168 writer.WriteStartElement("TaskInventory");
1169
1170 foreach (TaskInventoryItem item in tinv.Values)
1171 {
1172 writer.WriteStartElement("TaskInventoryItem");
1173
1174 WriteUUID(writer, "AssetID", item.AssetID, options);
1175 writer.WriteElementString("BasePermissions", item.BasePermissions.ToString());
1176 writer.WriteElementString("CreationDate", item.CreationDate.ToString());
1177 WriteUUID(writer, "CreatorID", item.CreatorID, options);
1178 writer.WriteElementString("Description", item.Description);
1179 writer.WriteElementString("EveryonePermissions", item.EveryonePermissions.ToString());
1180 writer.WriteElementString("Flags", item.Flags.ToString());
1181 WriteUUID(writer, "GroupID", item.GroupID, options);
1182 writer.WriteElementString("GroupPermissions", item.GroupPermissions.ToString());
1183 writer.WriteElementString("InvType", item.InvType.ToString());
1184 WriteUUID(writer, "ItemID", item.ItemID, options);
1185 WriteUUID(writer, "OldItemID", item.OldItemID, options);
1186 WriteUUID(writer, "LastOwnerID", item.LastOwnerID, options);
1187 writer.WriteElementString("Name", item.Name);
1188 writer.WriteElementString("NextPermissions", item.NextPermissions.ToString());
1189 WriteUUID(writer, "OwnerID", item.OwnerID, options);
1190 writer.WriteElementString("CurrentPermissions", item.CurrentPermissions.ToString());
1191 WriteUUID(writer, "ParentID", item.ParentID, options);
1192 WriteUUID(writer, "ParentPartID", item.ParentPartID, options);
1193 WriteUUID(writer, "PermsGranter", item.PermsGranter, options);
1194 writer.WriteElementString("PermsMask", item.PermsMask.ToString());
1195 writer.WriteElementString("Type", item.Type.ToString());
1196 writer.WriteElementString("OwnerChanged", item.OwnerChanged.ToString().ToLower());
1197
1198 writer.WriteEndElement(); // TaskInventoryItem
1199 }
1200
1201 writer.WriteEndElement(); // TaskInventory
1202 }
1203 }
1204
1205 static void WriteShape(XmlTextWriter writer, PrimitiveBaseShape shp, Dictionary<string, object> options)
1206 {
1207 if (shp != null)
1208 {
1209 writer.WriteStartElement("Shape");
1210
1211 writer.WriteElementString("ProfileCurve", shp.ProfileCurve.ToString());
1212
1213 writer.WriteStartElement("TextureEntry");
1214 byte[] te;
1215 if (shp.TextureEntry != null)
1216 te = shp.TextureEntry;
1217 else
1218 te = Utils.EmptyBytes;
1219 writer.WriteBase64(te, 0, te.Length);
1220 writer.WriteEndElement(); // TextureEntry
1221
1222 writer.WriteStartElement("ExtraParams");
1223 byte[] ep;
1224 if (shp.ExtraParams != null)
1225 ep = shp.ExtraParams;
1226 else
1227 ep = Utils.EmptyBytes;
1228 writer.WriteBase64(ep, 0, ep.Length);
1229 writer.WriteEndElement(); // ExtraParams
1230
1231 writer.WriteElementString("PathBegin", shp.PathBegin.ToString());
1232 writer.WriteElementString("PathCurve", shp.PathCurve.ToString());
1233 writer.WriteElementString("PathEnd", shp.PathEnd.ToString());
1234 writer.WriteElementString("PathRadiusOffset", shp.PathRadiusOffset.ToString());
1235 writer.WriteElementString("PathRevolutions", shp.PathRevolutions.ToString());
1236 writer.WriteElementString("PathScaleX", shp.PathScaleX.ToString());
1237 writer.WriteElementString("PathScaleY", shp.PathScaleY.ToString());
1238 writer.WriteElementString("PathShearX", shp.PathShearX.ToString());
1239 writer.WriteElementString("PathShearY", shp.PathShearY.ToString());
1240 writer.WriteElementString("PathSkew", shp.PathSkew.ToString());
1241 writer.WriteElementString("PathTaperX", shp.PathTaperX.ToString());
1242 writer.WriteElementString("PathTaperY", shp.PathTaperY.ToString());
1243 writer.WriteElementString("PathTwist", shp.PathTwist.ToString());
1244 writer.WriteElementString("PathTwistBegin", shp.PathTwistBegin.ToString());
1245 writer.WriteElementString("PCode", shp.PCode.ToString());
1246 writer.WriteElementString("ProfileBegin", shp.ProfileBegin.ToString());
1247 writer.WriteElementString("ProfileEnd", shp.ProfileEnd.ToString());
1248 writer.WriteElementString("ProfileHollow", shp.ProfileHollow.ToString());
1249 writer.WriteElementString("State", shp.State.ToString());
1250
1251 writer.WriteElementString("ProfileShape", shp.ProfileShape.ToString());
1252 writer.WriteElementString("HollowShape", shp.HollowShape.ToString());
1253
1254 WriteUUID(writer, "SculptTexture", shp.SculptTexture, options);
1255 writer.WriteElementString("SculptType", shp.SculptType.ToString());
1256 writer.WriteStartElement("SculptData");
1257 byte[] sd;
1258 if (shp.SculptData != null)
1259 sd = shp.ExtraParams;
1260 else
1261 sd = Utils.EmptyBytes;
1262 writer.WriteBase64(sd, 0, sd.Length);
1263 writer.WriteEndElement(); // SculptData
1264
1265 writer.WriteElementString("FlexiSoftness", shp.FlexiSoftness.ToString());
1266 writer.WriteElementString("FlexiTension", shp.FlexiTension.ToString());
1267 writer.WriteElementString("FlexiDrag", shp.FlexiDrag.ToString());
1268 writer.WriteElementString("FlexiGravity", shp.FlexiGravity.ToString());
1269 writer.WriteElementString("FlexiWind", shp.FlexiWind.ToString());
1270 writer.WriteElementString("FlexiForceX", shp.FlexiForceX.ToString());
1271 writer.WriteElementString("FlexiForceY", shp.FlexiForceY.ToString());
1272 writer.WriteElementString("FlexiForceZ", shp.FlexiForceZ.ToString());
1273
1274 writer.WriteElementString("LightColorR", shp.LightColorR.ToString());
1275 writer.WriteElementString("LightColorG", shp.LightColorG.ToString());
1276 writer.WriteElementString("LightColorB", shp.LightColorB.ToString());
1277 writer.WriteElementString("LightColorA", shp.LightColorA.ToString());
1278 writer.WriteElementString("LightRadius", shp.LightRadius.ToString());
1279 writer.WriteElementString("LightCutoff", shp.LightCutoff.ToString());
1280 writer.WriteElementString("LightFalloff", shp.LightFalloff.ToString());
1281 writer.WriteElementString("LightIntensity", shp.LightIntensity.ToString());
1282
1283 writer.WriteElementString("FlexiEntry", shp.FlexiEntry.ToString().ToLower());
1284 writer.WriteElementString("LightEntry", shp.LightEntry.ToString().ToLower());
1285 writer.WriteElementString("SculptEntry", shp.SculptEntry.ToString().ToLower());
1286
1287 if (shp.Media != null)
1288 writer.WriteElementString("Media", shp.Media.ToXml());
1289
1290 writer.WriteEndElement(); // Shape
1291 }
1292 }
1293
1294 //////// Read /////////
1295 public static bool Xml2ToSOG(XmlTextReader reader, SceneObjectGroup sog)
1296 {
1297 reader.Read();
1298 reader.ReadStartElement("SceneObjectGroup");
1299 SceneObjectPart root = Xml2ToSOP(reader);
1300 if (root != null)
1301 sog.SetRootPart(root);
1302 else
1303 {
1304 return false;
1305 }
1306
1307 if (sog.UUID == UUID.Zero)
1308 sog.UUID = sog.RootPart.UUID;
1309
1310 reader.Read(); // OtherParts
1311
1312 while (!reader.EOF)
1313 {
1314 switch (reader.NodeType)
1315 {
1316 case XmlNodeType.Element:
1317 if (reader.Name == "SceneObjectPart")
1318 {
1319 SceneObjectPart child = Xml2ToSOP(reader);
1320 if (child != null)
1321 sog.AddPart(child);
1322 }
1323 else
1324 {
1325 //Logger.Log("Found unexpected prim XML element " + reader.Name, Helpers.LogLevel.Debug);
1326 reader.Read();
1327 }
1328 break;
1329 case XmlNodeType.EndElement:
1330 default:
1331 reader.Read();
1332 break;
1333 }
1334
1335 }
1336 return true;
1337 }
1338
1339 public static SceneObjectPart Xml2ToSOP(XmlTextReader reader)
1340 {
1341 SceneObjectPart obj = new SceneObjectPart();
1342
1343 reader.ReadStartElement("SceneObjectPart");
1344
1345 string nodeName = string.Empty;
1346 while (reader.NodeType != XmlNodeType.EndElement)
1347 {
1348 nodeName = reader.Name;
1349 SOPXmlProcessor p = null;
1350 if (m_SOPXmlProcessors.TryGetValue(reader.Name, out p))
1351 {
1352 //m_log.DebugFormat("[XXX] Processing: {0}", reader.Name);
1353 try
1354 {
1355 p(obj, reader);
1356 }
1357 catch (Exception e)
1358 {
1359 m_log.DebugFormat("[SceneObjectSerializer]: exception while parsing {0}: {1}", nodeName, e);
1360 if (reader.NodeType == XmlNodeType.EndElement)
1361 reader.Read();
1362 }
1363 }
1364 else
1365 {
1366 m_log.DebugFormat("[SceneObjectSerializer]: caught unknown element {0}", nodeName);
1367 reader.ReadOuterXml(); // ignore
1368 }
1369
1370 }
1371
1372 reader.ReadEndElement(); // SceneObjectPart
1373
1374 //m_log.DebugFormat("[XXX]: parsed SOP {0} - {1}", obj.Name, obj.UUID);
1375 return obj;
1376 }
1377
1378 static UUID ReadUUID(XmlTextReader reader, string name)
1379 {
1380 UUID id;
1381 string idStr;
1382
1383 reader.ReadStartElement(name);
1384
1385 if (reader.Name == "Guid")
1386 idStr = reader.ReadElementString("Guid");
1387 else // UUID
1388 idStr = reader.ReadElementString("UUID");
1389
1390 UUID.TryParse(idStr, out id);
1391 reader.ReadEndElement();
1392
1393 return id;
1394 }
1395
1396 static Vector3 ReadVector(XmlTextReader reader, string name)
1397 {
1398 Vector3 vec;
1399
1400 reader.ReadStartElement(name);
1401 vec.X = reader.ReadElementContentAsFloat("X", String.Empty);
1402 vec.Y = reader.ReadElementContentAsFloat("Y", String.Empty);
1403 vec.Z = reader.ReadElementContentAsFloat("Z", String.Empty);
1404 reader.ReadEndElement();
1405
1406 return vec;
1407 }
1408
1409 static Quaternion ReadQuaternion(XmlTextReader reader, string name)
1410 {
1411 Quaternion quat;
1412
1413 reader.ReadStartElement(name);
1414 quat.X = reader.ReadElementContentAsFloat("X", String.Empty);
1415 quat.Y = reader.ReadElementContentAsFloat("Y", String.Empty);
1416 quat.Z = reader.ReadElementContentAsFloat("Z", String.Empty);
1417 quat.W = reader.ReadElementContentAsFloat("W", String.Empty);
1418 reader.ReadEndElement();
1419
1420 return quat;
1421 }
1422
1423 static TaskInventoryDictionary ReadTaskInventory(XmlTextReader reader, string name)
1424 {
1425 TaskInventoryDictionary tinv = new TaskInventoryDictionary();
1426
1427 reader.ReadStartElement(name, String.Empty);
1428
1429 while (reader.Name == "TaskInventoryItem")
1430 {
1431 reader.ReadStartElement("TaskInventoryItem", String.Empty); // TaskInventory
1432
1433 TaskInventoryItem item = new TaskInventoryItem();
1434 while (reader.NodeType != XmlNodeType.EndElement)
1435 {
1436 TaskInventoryXmlProcessor p = null;
1437 if (m_TaskInventoryXmlProcessors.TryGetValue(reader.Name, out p))
1438 p(item, reader);
1439 else
1440 {
1441 m_log.DebugFormat("[SceneObjectSerializer]: caught unknown element in TaskInventory {0}, {1}", reader.Name, reader.Value);
1442 reader.ReadOuterXml();
1443 }
1444 }
1445 reader.ReadEndElement(); // TaskInventoryItem
1446 tinv.Add(item.ItemID, item);
1447
1448 }
1449
1450 if (reader.NodeType == XmlNodeType.EndElement)
1451 reader.ReadEndElement(); // TaskInventory
1452
1453 return tinv;
1454 }
1455
1456 static PrimitiveBaseShape ReadShape(XmlTextReader reader, string name)
1457 {
1458 PrimitiveBaseShape shape = new PrimitiveBaseShape();
1459
1460 reader.ReadStartElement(name, String.Empty); // Shape
1461
1462 while (reader.NodeType != XmlNodeType.EndElement)
1463 {
1464 //m_log.DebugFormat("[XXX] Processing: {0}", reader.Name);
1465 ShapeXmlProcessor p = null;
1466 if (m_ShapeXmlProcessors.TryGetValue(reader.Name, out p))
1467 p(shape, reader);
1468 else
1469 {
1470 m_log.DebugFormat("[SceneObjectSerializer]: caught unknown element in Shape {0}", reader.Name);
1471 reader.ReadOuterXml();
1472 }
1473 }
1474
1475 reader.ReadEndElement(); // Shape
1476
1477 return shape;
1478 }
1479
1480 #endregion
297 } 1481 }
298} 1482}
diff --git a/OpenSim/Region/Framework/Scenes/Serialization/SceneXmlLoader.cs b/OpenSim/Region/Framework/Scenes/Serialization/SceneXmlLoader.cs
index 5494549..d214eba 100644
--- a/OpenSim/Region/Framework/Scenes/Serialization/SceneXmlLoader.cs
+++ b/OpenSim/Region/Framework/Scenes/Serialization/SceneXmlLoader.cs
@@ -45,6 +45,7 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
45 { 45 {
46 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 46 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
47 47
48 #region old xml format
48 public static void LoadPrimsFromXml(Scene scene, string fileName, bool newIDS, Vector3 loadOffset) 49 public static void LoadPrimsFromXml(Scene scene, string fileName, bool newIDS, Vector3 loadOffset)
49 { 50 {
50 XmlDocument doc = new XmlDocument(); 51 XmlDocument doc = new XmlDocument();
@@ -98,11 +99,128 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
98 file.Close(); 99 file.Close();
99 } 100 }
100 101
101 public static string SaveGroupToXml2(SceneObjectGroup grp) 102 #endregion
103
104 #region XML2 serialization
105
106 // Called by archives (save oar)
107 public static string SaveGroupToXml2(SceneObjectGroup grp, Dictionary<string, object> options)
108 {
109 //return SceneObjectSerializer.ToXml2Format(grp);
110 using (MemoryStream mem = new MemoryStream())
111 {
112 using (XmlTextWriter writer = new XmlTextWriter(mem, System.Text.Encoding.UTF8))
113 {
114 SceneObjectSerializer.SOGToXml2(writer, grp, options);
115 writer.Flush();
116
117 using (StreamReader reader = new StreamReader(mem))
118 {
119 mem.Seek(0, SeekOrigin.Begin);
120 return reader.ReadToEnd();
121 }
122 }
123 }
124 }
125
126 // Called by scene serializer (save xml2)
127 public static void SavePrimsToXml2(Scene scene, string fileName)
128 {
129 EntityBase[] entityList = scene.GetEntities();
130 SavePrimListToXml2(entityList, fileName);
131 }
132
133 // Called by scene serializer (save xml2)
134 public static void SaveNamedPrimsToXml2(Scene scene, string primName, string fileName)
135 {
136 m_log.InfoFormat(
137 "[SERIALISER]: Saving prims with name {0} in xml2 format for region {1} to {2}",
138 primName, scene.RegionInfo.RegionName, fileName);
139
140 EntityBase[] entityList = scene.GetEntities();
141 List<EntityBase> primList = new List<EntityBase>();
142
143 foreach (EntityBase ent in entityList)
144 {
145 if (ent is SceneObjectGroup)
146 {
147 if (ent.Name == primName)
148 {
149 primList.Add(ent);
150 }
151 }
152 }
153
154 SavePrimListToXml2(primList.ToArray(), fileName);
155 }
156
157 // Called by REST Application plugin
158 public static void SavePrimsToXml2(Scene scene, TextWriter stream, Vector3 min, Vector3 max)
102 { 159 {
103 return SceneObjectSerializer.ToXml2Format(grp); 160 EntityBase[] entityList = scene.GetEntities();
161 SavePrimListToXml2(entityList, stream, min, max);
104 } 162 }
105 163
164 // Called here only. Should be private?
165 public static void SavePrimListToXml2(EntityBase[] entityList, string fileName)
166 {
167 FileStream file = new FileStream(fileName, FileMode.Create);
168 try
169 {
170 StreamWriter stream = new StreamWriter(file);
171 try
172 {
173 SavePrimListToXml2(entityList, stream, Vector3.Zero, Vector3.Zero);
174 }
175 finally
176 {
177 stream.Close();
178 }
179 }
180 finally
181 {
182 file.Close();
183 }
184 }
185
186 // Called here only. Should be private?
187 public static void SavePrimListToXml2(EntityBase[] entityList, TextWriter stream, Vector3 min, Vector3 max)
188 {
189 XmlTextWriter writer = new XmlTextWriter(stream);
190
191 int primCount = 0;
192 stream.WriteLine("<scene>\n");
193
194 foreach (EntityBase ent in entityList)
195 {
196 if (ent is SceneObjectGroup)
197 {
198 SceneObjectGroup g = (SceneObjectGroup)ent;
199 if (!min.Equals(Vector3.Zero) || !max.Equals(Vector3.Zero))
200 {
201 Vector3 pos = g.RootPart.GetWorldPosition();
202 if (min.X > pos.X || min.Y > pos.Y || min.Z > pos.Z)
203 continue;
204 if (max.X < pos.X || max.Y < pos.Y || max.Z < pos.Z)
205 continue;
206 }
207
208 //stream.WriteLine(SceneObjectSerializer.ToXml2Format(g));
209 SceneObjectSerializer.SOGToXml2(writer, (SceneObjectGroup)ent, new Dictionary<string,object>());
210 stream.WriteLine();
211
212 primCount++;
213 }
214 }
215
216 stream.WriteLine("</scene>\n");
217 stream.Flush();
218 }
219
220 #endregion
221
222 #region XML2 deserialization
223
106 public static SceneObjectGroup DeserializeGroupFromXml2(string xmlString) 224 public static SceneObjectGroup DeserializeGroupFromXml2(string xmlString)
107 { 225 {
108 XmlDocument doc = new XmlDocument(); 226 XmlDocument doc = new XmlDocument();
@@ -124,14 +242,30 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
124 foreach (XmlNode aPrimNode in rootNode.ChildNodes) 242 foreach (XmlNode aPrimNode in rootNode.ChildNodes)
125 { 243 {
126 // There is only ever one prim. This oddity should be removeable post 0.5.9 244 // There is only ever one prim. This oddity should be removeable post 0.5.9
127 return SceneObjectSerializer.FromXml2Format(aPrimNode.OuterXml); 245 //return SceneObjectSerializer.FromXml2Format(aPrimNode.OuterXml);
246 using (reader = new XmlTextReader(new StringReader(aPrimNode.OuterXml)))
247 {
248 SceneObjectGroup obj = new SceneObjectGroup();
249 if (SceneObjectSerializer.Xml2ToSOG(reader, obj))
250 return obj;
251
252 return null;
253 }
128 } 254 }
129 255
130 return null; 256 return null;
131 } 257 }
132 else 258 else
133 { 259 {
134 return SceneObjectSerializer.FromXml2Format(rootNode.OuterXml); 260 //return SceneObjectSerializer.FromXml2Format(rootNode.OuterXml);
261 using (reader = new XmlTextReader(new StringReader(rootNode.OuterXml)))
262 {
263 SceneObjectGroup obj = new SceneObjectGroup();
264 if (SceneObjectSerializer.Xml2ToSOG(reader, obj))
265 return obj;
266
267 return null;
268 }
135 } 269 }
136 } 270 }
137 271
@@ -193,96 +327,19 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
193 /// <returns>The scene object created. null if the scene object already existed</returns> 327 /// <returns>The scene object created. null if the scene object already existed</returns>
194 protected static SceneObjectGroup CreatePrimFromXml2(Scene scene, string xmlData) 328 protected static SceneObjectGroup CreatePrimFromXml2(Scene scene, string xmlData)
195 { 329 {
196 SceneObjectGroup obj = SceneObjectSerializer.FromXml2Format(xmlData); 330 //SceneObjectGroup obj = SceneObjectSerializer.FromXml2Format(xmlData);
197 331 using (XmlTextReader reader = new XmlTextReader(new StringReader(xmlData)))
198 if (scene.AddRestoredSceneObject(obj, true, false))
199 return obj;
200 else
201 return null;
202 }
203
204 public static void SavePrimsToXml2(Scene scene, string fileName)
205 {
206 EntityBase[] entityList = scene.GetEntities();
207 SavePrimListToXml2(entityList, fileName);
208 }
209
210 public static void SavePrimsToXml2(Scene scene, TextWriter stream, Vector3 min, Vector3 max)
211 {
212 EntityBase[] entityList = scene.GetEntities();
213 SavePrimListToXml2(entityList, stream, min, max);
214 }
215
216 public static void SaveNamedPrimsToXml2(Scene scene, string primName, string fileName)
217 {
218 m_log.InfoFormat(
219 "[SERIALISER]: Saving prims with name {0} in xml2 format for region {1} to {2}",
220 primName, scene.RegionInfo.RegionName, fileName);
221
222 EntityBase[] entityList = scene.GetEntities();
223 List<EntityBase> primList = new List<EntityBase>();
224
225 foreach (EntityBase ent in entityList)
226 {
227 if (ent is SceneObjectGroup)
228 {
229 if (ent.Name == primName)
230 {
231 primList.Add(ent);
232 }
233 }
234 }
235
236 SavePrimListToXml2(primList.ToArray(), fileName);
237 }
238
239 public static void SavePrimListToXml2(EntityBase[] entityList, string fileName)
240 {
241 FileStream file = new FileStream(fileName, FileMode.Create);
242 try
243 { 332 {
244 StreamWriter stream = new StreamWriter(file); 333 SceneObjectGroup obj = new SceneObjectGroup();
245 try 334 SceneObjectSerializer.Xml2ToSOG(reader, obj);
246 {
247 SavePrimListToXml2(entityList, stream, Vector3.Zero, Vector3.Zero);
248 }
249 finally
250 {
251 stream.Close();
252 }
253 }
254 finally
255 {
256 file.Close();
257 }
258 }
259 335
260 public static void SavePrimListToXml2(EntityBase[] entityList, TextWriter stream, Vector3 min, Vector3 max) 336 if (scene.AddRestoredSceneObject(obj, true, false))
261 { 337 return obj;
262 int primCount = 0; 338 else
263 stream.WriteLine("<scene>\n"); 339 return null;
264
265 foreach (EntityBase ent in entityList)
266 {
267 if (ent is SceneObjectGroup)
268 {
269 SceneObjectGroup g = (SceneObjectGroup)ent;
270 if (!min.Equals(Vector3.Zero) || !max.Equals(Vector3.Zero))
271 {
272 Vector3 pos = g.RootPart.GetWorldPosition();
273 if (min.X > pos.X || min.Y > pos.Y || min.Z > pos.Z)
274 continue;
275 if (max.X < pos.X || max.Y < pos.Y || max.Z < pos.Z)
276 continue;
277 }
278
279 stream.WriteLine(SceneObjectSerializer.ToXml2Format(g));
280 primCount++;
281 }
282 } 340 }
283 stream.WriteLine("</scene>\n");
284 stream.Flush();
285 } 341 }
286 342
343 #endregion
287 } 344 }
288} 345}
diff --git a/OpenSim/Region/Physics/Meshing/Meshmerizer.cs b/OpenSim/Region/Physics/Meshing/Meshmerizer.cs
index cf57c0a..3e3a0f0 100644
--- a/OpenSim/Region/Physics/Meshing/Meshmerizer.cs
+++ b/OpenSim/Region/Physics/Meshing/Meshmerizer.cs
@@ -31,8 +31,10 @@ using System.Collections.Generic;
31using OpenSim.Framework; 31using OpenSim.Framework;
32using OpenSim.Region.Physics.Manager; 32using OpenSim.Region.Physics.Manager;
33using OpenMetaverse; 33using OpenMetaverse;
34using OpenMetaverse.StructuredData;
34using System.Drawing; 35using System.Drawing;
35using System.Drawing.Imaging; 36using System.Drawing.Imaging;
37using System.IO.Compression;
36using PrimMesher; 38using PrimMesher;
37using log4net; 39using log4net;
38using Nini.Config; 40using Nini.Config;
@@ -256,102 +258,175 @@ namespace OpenSim.Region.Physics.Meshing
256 PrimMesh primMesh; 258 PrimMesh primMesh;
257 PrimMesher.SculptMesh sculptMesh; 259 PrimMesher.SculptMesh sculptMesh;
258 260
259 List<Coord> coords; 261 List<Coord> coords = new List<Coord>();
260 List<Face> faces; 262 List<Face> faces = new List<Face>();
261 263
262 Image idata = null; 264 Image idata = null;
263 string decodedSculptFileName = ""; 265 string decodedSculptFileName = "";
264 266
265 if (primShape.SculptEntry) 267 if (primShape.SculptEntry)
266 { 268 {
267 if (cacheSculptMaps && primShape.SculptTexture != UUID.Zero) 269 if (((OpenMetaverse.SculptType)primShape.SculptType) == SculptType.Mesh)
268 { 270 {
269 decodedSculptFileName = System.IO.Path.Combine(decodedSculptMapPath, "smap_" + primShape.SculptTexture.ToString()); 271 // add code for mesh physics proxy generation here
272 m_log.Debug("[MESH]: mesh proxy generation not implemented yet ");
273
274 OSD meshOsd;
275
276 if (primShape.SculptData.Length > 0)
277 {
278
279
280 m_log.Debug("[MESH]: asset data length: " + primShape.SculptData.Length.ToString());
281 byte[] header = Util.StringToBytes256("<? LLSD/Binary ?>");
282
283 ////dump to debugging file
284 //string filename = System.IO.Path.Combine(decodedSculptMapPath, "mesh_" + primShape.SculptTexture.ToString());
285 //BinaryWriter writer = new BinaryWriter(File.Open(filename, FileMode.Create));
286 //writer.Write(primShape.SculptData);
287 //writer.Close();
288
289 }
290 else
291 {
292 m_log.Error("[MESH]: asset data is zero length");
293 return null;
294 }
295
270 try 296 try
271 { 297 {
272 if (File.Exists(decodedSculptFileName)) 298 meshOsd = OSDParser.DeserializeLLSDBinary(primShape.SculptData, true);
273 {
274 idata = Image.FromFile(decodedSculptFileName);
275 }
276 } 299 }
277 catch (Exception e) 300 catch (Exception e)
278 { 301 {
279 m_log.Error("[SCULPT]: unable to load cached sculpt map " + decodedSculptFileName + " " + e.Message); 302 m_log.Error("[MESH]: exception decoding mesh asset: " + e.ToString());
303 return null;
304 }
305
306 if (meshOsd is OSDMap)
307 {
308 OSDMap map = (OSDMap)meshOsd;
309 //foreach (string name in map.Keys)
310 // m_log.Debug("[MESH]: key:" + name + " value:" + map[name].AsString());
311 OSDMap physicsParms = (OSDMap)map["physics_shape"];
312 int physOffset = physicsParms["offset"].AsInteger();
313 int physSize = physicsParms["size"].AsInteger();
314
315 if (physOffset < 0 || physSize == 0)
316 return null; // no mesh data in asset
317
318 m_log.Debug("[MESH]: physOffset:" + physOffset.ToString() + " physSize:" + physSize.ToString());
319 //MemoryStream ms = new MemoryStream(primShape.SculptData, physOffset, physSize);
320 //GZipStream gzStream = new GZipStream(ms, CompressionMode.Decompress);
321
322 //int maxSize = physSize * 5; // arbitrary guess
323 //byte[] readBuffer = new byte[maxSize];
324
325 //int bytesRead = gzStream.Read(readBuffer, 0, maxSize);
326
327 //OSD physMeshOsd = OSDParser.DeserializeLLSDBinary(readBuffer);
328
329
330
331
280 332
281 } 333 }
282 //if (idata != null)
283 // m_log.Debug("[SCULPT]: loaded cached map asset for map ID: " + primShape.SculptTexture.ToString());
284 }
285 334
286 if (idata == null) 335 //just bail out for now until mesh code is finished
336 return null;
337
338 }
339 else
287 { 340 {
288 if (primShape.SculptData == null || primShape.SculptData.Length == 0) 341 if (cacheSculptMaps && primShape.SculptTexture != UUID.Zero)
289 return null; 342 {
343 decodedSculptFileName = System.IO.Path.Combine(decodedSculptMapPath, "smap_" + primShape.SculptTexture.ToString());
344 try
345 {
346 if (File.Exists(decodedSculptFileName))
347 {
348 idata = Image.FromFile(decodedSculptFileName);
349 }
350 }
351 catch (Exception e)
352 {
353 m_log.Error("[SCULPT]: unable to load cached sculpt map " + decodedSculptFileName + " " + e.Message);
290 354
291 try 355 }
356 //if (idata != null)
357 // m_log.Debug("[SCULPT]: loaded cached map asset for map ID: " + primShape.SculptTexture.ToString());
358 }
359
360 if (idata == null)
292 { 361 {
293 OpenMetaverse.Imaging.ManagedImage unusedData; 362 if (primShape.SculptData == null || primShape.SculptData.Length == 0)
294 OpenMetaverse.Imaging.OpenJPEG.DecodeToImage(primShape.SculptData, out unusedData, out idata); 363 return null;
295 unusedData = null;
296 364
297 //idata = CSJ2K.J2kImage.FromBytes(primShape.SculptData); 365 try
366 {
367 OpenMetaverse.Imaging.ManagedImage unusedData;
368 OpenMetaverse.Imaging.OpenJPEG.DecodeToImage(primShape.SculptData, out unusedData, out idata);
369 unusedData = null;
370
371 //idata = CSJ2K.J2kImage.FromBytes(primShape.SculptData);
298 372
299 if (cacheSculptMaps && idata != null) 373 if (cacheSculptMaps && idata != null)
374 {
375 try { idata.Save(decodedSculptFileName, ImageFormat.MemoryBmp); }
376 catch (Exception e) { m_log.Error("[SCULPT]: unable to cache sculpt map " + decodedSculptFileName + " " + e.Message); }
377 }
378 }
379 catch (DllNotFoundException)
300 { 380 {
301 try { idata.Save(decodedSculptFileName, ImageFormat.MemoryBmp); } 381 m_log.Error("[PHYSICS]: OpenJpeg is not installed correctly on this system. Physics Proxy generation failed. Often times this is because of an old version of GLIBC. You must have version 2.4 or above!");
302 catch (Exception e) { m_log.Error("[SCULPT]: unable to cache sculpt map " + decodedSculptFileName + " " + e.Message); } 382 return null;
383 }
384 catch (IndexOutOfRangeException)
385 {
386 m_log.Error("[PHYSICS]: OpenJpeg was unable to decode this. Physics Proxy generation failed");
387 return null;
388 }
389 catch (Exception ex)
390 {
391 m_log.Error("[PHYSICS]: Unable to generate a Sculpty physics proxy. Sculpty texture decode failed: " + ex.Message);
392 return null;
303 } 393 }
304 } 394 }
305 catch (DllNotFoundException) 395
306 { 396 PrimMesher.SculptMesh.SculptType sculptType;
307 m_log.Error("[PHYSICS]: OpenJpeg is not installed correctly on this system. Physics Proxy generation failed. Often times this is because of an old version of GLIBC. You must have version 2.4 or above!"); 397 switch ((OpenMetaverse.SculptType)primShape.SculptType)
308 return null;
309 }
310 catch (IndexOutOfRangeException)
311 {
312 m_log.Error("[PHYSICS]: OpenJpeg was unable to decode this. Physics Proxy generation failed");
313 return null;
314 }
315 catch (Exception ex)
316 { 398 {
317 m_log.Error("[PHYSICS]: Unable to generate a Sculpty physics proxy. Sculpty texture decode failed: " + ex.Message); 399 case OpenMetaverse.SculptType.Cylinder:
318 return null; 400 sculptType = PrimMesher.SculptMesh.SculptType.cylinder;
401 break;
402 case OpenMetaverse.SculptType.Plane:
403 sculptType = PrimMesher.SculptMesh.SculptType.plane;
404 break;
405 case OpenMetaverse.SculptType.Torus:
406 sculptType = PrimMesher.SculptMesh.SculptType.torus;
407 break;
408 case OpenMetaverse.SculptType.Sphere:
409 sculptType = PrimMesher.SculptMesh.SculptType.sphere;
410 break;
411 default:
412 sculptType = PrimMesher.SculptMesh.SculptType.plane;
413 break;
319 } 414 }
320 }
321 415
322 PrimMesher.SculptMesh.SculptType sculptType; 416 bool mirror = ((primShape.SculptType & 128) != 0);
323 switch ((OpenMetaverse.SculptType)primShape.SculptType) 417 bool invert = ((primShape.SculptType & 64) != 0);
324 {
325 case OpenMetaverse.SculptType.Cylinder:
326 sculptType = PrimMesher.SculptMesh.SculptType.cylinder;
327 break;
328 case OpenMetaverse.SculptType.Plane:
329 sculptType = PrimMesher.SculptMesh.SculptType.plane;
330 break;
331 case OpenMetaverse.SculptType.Torus:
332 sculptType = PrimMesher.SculptMesh.SculptType.torus;
333 break;
334 case OpenMetaverse.SculptType.Sphere:
335 sculptType = PrimMesher.SculptMesh.SculptType.sphere;
336 break;
337 default:
338 sculptType = PrimMesher.SculptMesh.SculptType.plane;
339 break;
340 }
341
342 bool mirror = ((primShape.SculptType & 128) != 0);
343 bool invert = ((primShape.SculptType & 64) != 0);
344 418
345 sculptMesh = new PrimMesher.SculptMesh((Bitmap)idata, sculptType, (int)lod, false, mirror, invert); 419 sculptMesh = new PrimMesher.SculptMesh((Bitmap)idata, sculptType, (int)lod, false, mirror, invert);
346 420
347 idata.Dispose(); 421 idata.Dispose();
348 422
349 sculptMesh.DumpRaw(baseDir, primName, "primMesh"); 423 sculptMesh.DumpRaw(baseDir, primName, "primMesh");
350 424
351 sculptMesh.Scale(size.X, size.Y, size.Z); 425 sculptMesh.Scale(size.X, size.Y, size.Z);
352 426
353 coords = sculptMesh.coords; 427 coords = sculptMesh.coords;
354 faces = sculptMesh.faces; 428 faces = sculptMesh.faces;
429 }
355 } 430 }
356 else 431 else
357 { 432 {
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
index 477c52d..8a98be7 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
@@ -2200,6 +2200,48 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2200 2200
2201 m_LSL_Api.SetPrimitiveParamsEx(prim, rules); 2201 m_LSL_Api.SetPrimitiveParamsEx(prim, rules);
2202 } 2202 }
2203
2204 /// <summary>
2205 /// Set parameters for light projection in host prim
2206 /// </summary>
2207 public void osSetProjectionParams(bool projection, LSL_Key texture, double fov, double focus, double amb)
2208 {
2209 CheckThreatLevel(ThreatLevel.High, "osSetProjectionParams");
2210
2211 osSetProjectionParams(UUID.Zero.ToString(), projection, texture, fov, focus, amb);
2212 }
2213
2214 /// <summary>
2215 /// Set parameters for light projection with uuid of target prim
2216 /// </summary>
2217 public void osSetProjectionParams(LSL_Key prim, bool projection, LSL_Key texture, double fov, double focus, double amb)
2218 {
2219 CheckThreatLevel(ThreatLevel.High, "osSetProjectionParams");
2220 m_host.AddScriptLPS(1);
2221
2222 SceneObjectPart obj = null;
2223 if (prim == UUID.Zero.ToString())
2224 {
2225 obj = m_host;
2226 }
2227 else
2228 {
2229 obj = World.GetSceneObjectPart(new UUID(prim));
2230 if (obj == null)
2231 return;
2232 }
2233
2234 obj.Shape.ProjectionEntry = projection;
2235 obj.Shape.ProjectionTextureUUID = new UUID(texture);
2236 obj.Shape.ProjectionFOV = (float)fov;
2237 obj.Shape.ProjectionFocus = (float)focus;
2238 obj.Shape.ProjectionAmbiance = (float)amb;
2239
2240
2241 obj.ParentGroup.HasGroupChanged = true;
2242 obj.ScheduleFullUpdate();
2243
2244 }
2203 2245
2204 /// <summary> 2246 /// <summary>
2205 /// Like osGetAgents but returns enough info for a radar 2247 /// Like osGetAgents but returns enough info for a radar
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs
index 78ee43c..630821b 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs
@@ -176,6 +176,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces
176 void osCauseDamage(string avatar, double damage); 176 void osCauseDamage(string avatar, double damage);
177 LSL_List osGetPrimitiveParams(LSL_Key prim, LSL_List rules); 177 LSL_List osGetPrimitiveParams(LSL_Key prim, LSL_List rules);
178 void osSetPrimitiveParams(LSL_Key prim, LSL_List rules); 178 void osSetPrimitiveParams(LSL_Key prim, LSL_List rules);
179 void osSetProjectionParams(bool projection, LSL_Key texture, double fov, double focus, double amb);
180 void osSetProjectionParams(LSL_Key prim, bool projection, LSL_Key texture, double fov, double focus, double amb);
181
179 LSL_List osGetAvatarList(); 182 LSL_List osGetAvatarList();
180 183
181 } 184 }
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs
index 6cc5f51..e289554 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs
@@ -688,6 +688,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
688 m_OSSL_Functions.osSetPrimitiveParams(prim, rules); 688 m_OSSL_Functions.osSetPrimitiveParams(prim, rules);
689 } 689 }
690 690
691 public void osSetProjectionParams(bool projection, LSL_Key texture, double fov, double focus, double amb)
692 {
693 m_OSSL_Functions.osSetProjectionParams(projection, texture, fov, focus, amb);
694 }
695
696 public void osSetProjectionParams(LSL_Key prim, bool projection, LSL_Key texture, double fov, double focus, double amb)
697 {
698 m_OSSL_Functions.osSetProjectionParams(prim, projection, texture, fov, focus, amb);
699 }
700
691 public LSL_List osGetAvatarList() 701 public LSL_List osGetAvatarList()
692 { 702 {
693 return m_OSSL_Functions.osGetAvatarList(); 703 return m_OSSL_Functions.osGetAvatarList();