aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region
diff options
context:
space:
mode:
authorMelanie2010-10-16 02:27:51 +0100
committerMelanie2010-10-16 02:27:51 +0100
commit455a2ba7ded01ffce92bf54cb3e11e73ae086e22 (patch)
tree9d695e2b8108b3b626ade78c3e65b654076e2074 /OpenSim/Region
parentAdd a setter to OldItemID so it can be deserialized (diff)
parentAdding projected light filters to prim propeties (diff)
downloadopensim-SC-455a2ba7ded01ffce92bf54cb3e11e73ae086e22.zip
opensim-SC-455a2ba7ded01ffce92bf54cb3e11e73ae086e22.tar.gz
opensim-SC-455a2ba7ded01ffce92bf54cb3e11e73ae086e22.tar.bz2
opensim-SC-455a2ba7ded01ffce92bf54cb3e11e73ae086e22.tar.xz
Merge branch 'master' into careminster-presence-refactor
Diffstat (limited to 'OpenSim/Region')
-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/Framework/Scenes/Serialization/SceneObjectSerializer.cs479
-rw-r--r--OpenSim/Region/Framework/Scenes/Serialization/SceneXmlLoader.cs8
-rw-r--r--OpenSim/Region/Physics/Meshing/Meshmerizer.cs207
6 files changed, 799 insertions, 375 deletions
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 6ff0ffc..bf71c07 100644
--- a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
@@ -114,6 +114,10 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
114 if (!m_scene.Permissions.CanTakeObject(part.UUID, remoteClient.AgentId)) 114 if (!m_scene.Permissions.CanTakeObject(part.UUID, remoteClient.AgentId))
115 return; 115 return;
116 116
117 // TODO: this short circuits multiple attachments functionality in LL viewer 2.1+ and should
118 // be removed when that functionality is implemented in opensim
119 AttachmentPt &= 0x7f;
120
117 // Calls attach with a Zero position 121 // Calls attach with a Zero position
118 if (AttachObject(remoteClient, part.ParentGroup, AttachmentPt, false)) 122 if (AttachObject(remoteClient, part.ParentGroup, AttachmentPt, false))
119 { 123 {
@@ -143,6 +147,10 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
143 147
144 if (m_scene.Permissions.CanTakeObject(group.UUID, remoteClient.AgentId)) 148 if (m_scene.Permissions.CanTakeObject(group.UUID, remoteClient.AgentId))
145 { 149 {
150 // TODO: this short circuits multiple attachments functionality in LL viewer 2.1+ and should
151 // be removed when that functionality is implemented in opensim
152 AttachmentPt &= 0x7f;
153
146 // If the attachment point isn't the same as the one previously used 154 // If the attachment point isn't the same as the one previously used
147 // set it's offset position = 0 so that it appears on the attachment point 155 // set it's offset position = 0 so that it appears on the attachment point
148 // and not in a weird location somewhere unknown. 156 // and not in a weird location somewhere unknown.
@@ -231,6 +239,10 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
231 public UUID RezSingleAttachmentFromInventory( 239 public UUID RezSingleAttachmentFromInventory(
232 IClientAPI remoteClient, UUID itemID, uint AttachmentPt, bool updateInventoryStatus, XmlDocument doc) 240 IClientAPI remoteClient, UUID itemID, uint AttachmentPt, bool updateInventoryStatus, XmlDocument doc)
233 { 241 {
242 // TODO: this short circuits multiple attachments functionality in LL viewer 2.1+ and should
243 // be removed when that functionality is implemented in opensim
244 AttachmentPt &= 0x7f;
245
234 SceneObjectGroup att = RezSingleAttachmentFromInventoryInternal(remoteClient, itemID, AttachmentPt, doc); 246 SceneObjectGroup att = RezSingleAttachmentFromInventoryInternal(remoteClient, itemID, AttachmentPt, doc);
235 247
236 if (updateInventoryStatus) 248 if (updateInventoryStatus)
diff --git a/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs b/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs
index 0c21fd9..cd7a1ca 100644
--- a/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs
+++ b/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs
@@ -316,7 +316,6 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
316 m_SOPXmlProcessors.Add("FolderID", ProcessFolderID); 316 m_SOPXmlProcessors.Add("FolderID", ProcessFolderID);
317 m_SOPXmlProcessors.Add("InventorySerial", ProcessInventorySerial); 317 m_SOPXmlProcessors.Add("InventorySerial", ProcessInventorySerial);
318 m_SOPXmlProcessors.Add("TaskInventory", ProcessTaskInventory); 318 m_SOPXmlProcessors.Add("TaskInventory", ProcessTaskInventory);
319 m_SOPXmlProcessors.Add("ObjectFlags", ProcessObjectFlags);
320 m_SOPXmlProcessors.Add("UUID", ProcessUUID); 319 m_SOPXmlProcessors.Add("UUID", ProcessUUID);
321 m_SOPXmlProcessors.Add("LocalId", ProcessLocalId); 320 m_SOPXmlProcessors.Add("LocalId", ProcessLocalId);
322 m_SOPXmlProcessors.Add("Name", ProcessName); 321 m_SOPXmlProcessors.Add("Name", ProcessName);
@@ -361,6 +360,7 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
361 m_SOPXmlProcessors.Add("Flags", ProcessFlags); 360 m_SOPXmlProcessors.Add("Flags", ProcessFlags);
362 m_SOPXmlProcessors.Add("CollisionSound", ProcessCollisionSound); 361 m_SOPXmlProcessors.Add("CollisionSound", ProcessCollisionSound);
363 m_SOPXmlProcessors.Add("CollisionSoundVolume", ProcessCollisionSoundVolume); 362 m_SOPXmlProcessors.Add("CollisionSoundVolume", ProcessCollisionSoundVolume);
363 m_SOPXmlProcessors.Add("MediaUrl", ProcessMediaUrl);
364 #endregion 364 #endregion
365 365
366 #region TaskInventoryXmlProcessors initialization 366 #region TaskInventoryXmlProcessors initialization
@@ -436,6 +436,7 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
436 m_ShapeXmlProcessors.Add("FlexiEntry", ProcessShpFlexiEntry); 436 m_ShapeXmlProcessors.Add("FlexiEntry", ProcessShpFlexiEntry);
437 m_ShapeXmlProcessors.Add("LightEntry", ProcessShpLightEntry); 437 m_ShapeXmlProcessors.Add("LightEntry", ProcessShpLightEntry);
438 m_ShapeXmlProcessors.Add("SculptEntry", ProcessShpSculptEntry); 438 m_ShapeXmlProcessors.Add("SculptEntry", ProcessShpSculptEntry);
439 m_ShapeXmlProcessors.Add("Media", ProcessShpMedia);
439 #endregion 440 #endregion
440 } 441 }
441 442
@@ -465,11 +466,6 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
465 obj.TaskInventory = ReadTaskInventory(reader, "TaskInventory"); 466 obj.TaskInventory = ReadTaskInventory(reader, "TaskInventory");
466 } 467 }
467 468
468 private static void ProcessObjectFlags(SceneObjectPart obj, XmlTextReader reader)
469 {
470 obj.Flags = (PrimFlags)reader.ReadElementContentAsInt("ObjectFlags", String.Empty);
471 }
472
473 private static void ProcessUUID(SceneObjectPart obj, XmlTextReader reader) 469 private static void ProcessUUID(SceneObjectPart obj, XmlTextReader reader)
474 { 470 {
475 obj.UUID = ReadUUID(reader, "UUID"); 471 obj.UUID = ReadUUID(reader, "UUID");
@@ -703,6 +699,11 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
703 { 699 {
704 obj.CollisionSoundVolume = reader.ReadElementContentAsFloat("CollisionSoundVolume", String.Empty); 700 obj.CollisionSoundVolume = reader.ReadElementContentAsFloat("CollisionSoundVolume", String.Empty);
705 } 701 }
702
703 private static void ProcessMediaUrl(SceneObjectPart obj, XmlTextReader reader)
704 {
705 obj.MediaUrl = reader.ReadElementContentAsString("MediaUrl", String.Empty);
706 }
706 #endregion 707 #endregion
707 708
708 #region TaskInventoryXmlProcessors 709 #region TaskInventoryXmlProcessors
@@ -1063,6 +1064,13 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
1063 shp.SculptEntry = reader.ReadElementContentAsBoolean("SculptEntry", String.Empty); 1064 shp.SculptEntry = reader.ReadElementContentAsBoolean("SculptEntry", String.Empty);
1064 } 1065 }
1065 1066
1067 private static void ProcessShpMedia(PrimitiveBaseShape shp, XmlTextReader reader)
1068 {
1069 string value = reader.ReadElementContentAsString("Media", String.Empty);
1070 shp.Media = PrimitiveBaseShape.MediaList.FromXml(value);
1071 }
1072
1073
1066 #endregion 1074 #endregion
1067 1075
1068 ////////// Write ///////// 1076 ////////// Write /////////
@@ -1075,7 +1083,8 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
1075 1083
1076 sog.ForEachPart(delegate(SceneObjectPart sop) 1084 sog.ForEachPart(delegate(SceneObjectPart sop)
1077 { 1085 {
1078 SOPToXml2(writer, sop, sog.RootPart); 1086 if (sop.UUID != sog.RootPart.UUID)
1087 SOPToXml2(writer, sop, sog.RootPart);
1079 }); 1088 });
1080 1089
1081 writer.WriteEndElement(); 1090 writer.WriteEndElement();
@@ -1088,19 +1097,18 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
1088 writer.WriteAttributeString("xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance"); 1097 writer.WriteAttributeString("xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance");
1089 writer.WriteAttributeString("xmlns:xsd", "http://www.w3.org/2001/XMLSchema"); 1098 writer.WriteAttributeString("xmlns:xsd", "http://www.w3.org/2001/XMLSchema");
1090 1099
1100 writer.WriteElementString("AllowedDrop", sop.AllowedDrop.ToString().ToLower());
1091 WriteUUID(writer, "CreatorID", sop.CreatorID); 1101 WriteUUID(writer, "CreatorID", sop.CreatorID);
1092 WriteUUID(writer, "FolderID", sop.FolderID); 1102 WriteUUID(writer, "FolderID", sop.FolderID);
1093 writer.WriteElementString("InventorySerial", (sop.Inventory != null) ? sop.InventorySerial.ToString() : "0"); 1103 writer.WriteElementString("InventorySerial", sop.InventorySerial.ToString());
1094
1095 // FIXME: Task inventory
1096 writer.WriteStartElement("TaskInventory"); writer.WriteEndElement();
1097 1104
1098 writer.WriteElementString("ObjectFlags", ((int)sop.Flags).ToString()); 1105 WriteTaskInventory(writer, sop.TaskInventory);
1099 1106
1100 WriteUUID(writer, "UUID", sop.UUID); 1107 WriteUUID(writer, "UUID", sop.UUID);
1101 writer.WriteElementString("LocalId", sop.LocalId.ToString()); 1108 writer.WriteElementString("LocalId", sop.LocalId.ToString());
1102 writer.WriteElementString("Name", sop.Name); 1109 writer.WriteElementString("Name", sop.Name);
1103 writer.WriteElementString("Material", ((int)sop.Material).ToString()); 1110 writer.WriteElementString("Material", sop.Material.ToString());
1111 writer.WriteElementString("PassTouches", sop.PassTouches.ToString().ToLower());
1104 writer.WriteElementString("RegionHandle", sop.RegionHandle.ToString()); 1112 writer.WriteElementString("RegionHandle", sop.RegionHandle.ToString());
1105 writer.WriteElementString("ScriptAccessPin", sop.ScriptAccessPin.ToString()); 1113 writer.WriteElementString("ScriptAccessPin", sop.ScriptAccessPin.ToString());
1106 1114
@@ -1109,115 +1117,40 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
1109 1117
1110 WriteQuaternion(writer, "RotationOffset", sop.RotationOffset); 1118 WriteQuaternion(writer, "RotationOffset", sop.RotationOffset);
1111 WriteVector(writer, "Velocity", sop.Velocity); 1119 WriteVector(writer, "Velocity", sop.Velocity);
1112 WriteVector(writer, "RotationalVelocity", Vector3.Zero);
1113 WriteVector(writer, "AngularVelocity", sop.AngularVelocity); 1120 WriteVector(writer, "AngularVelocity", sop.AngularVelocity);
1114 WriteVector(writer, "Acceleration", sop.Acceleration); 1121 WriteVector(writer, "Acceleration", sop.Acceleration);
1115 writer.WriteElementString("Description", sop.Description); 1122 writer.WriteElementString("Description", sop.Description);
1116 writer.WriteStartElement("Color"); 1123 if (sop.Color != null)
1117 writer.WriteElementString("R", sop.Color.R.ToString(Utils.EnUsCulture)); 1124 {
1118 writer.WriteElementString("G", sop.Color.G.ToString(Utils.EnUsCulture)); 1125 writer.WriteStartElement("Color");
1119 writer.WriteElementString("B", sop.Color.B.ToString(Utils.EnUsCulture)); 1126 writer.WriteElementString("R", sop.Color.R.ToString(Utils.EnUsCulture));
1120 writer.WriteElementString("A", sop.Color.G.ToString(Utils.EnUsCulture)); 1127 writer.WriteElementString("G", sop.Color.G.ToString(Utils.EnUsCulture));
1121 writer.WriteEndElement(); 1128 writer.WriteElementString("B", sop.Color.B.ToString(Utils.EnUsCulture));
1129 writer.WriteElementString("A", sop.Color.G.ToString(Utils.EnUsCulture));
1130 writer.WriteEndElement();
1131 }
1132
1122 writer.WriteElementString("Text", sop.Text); 1133 writer.WriteElementString("Text", sop.Text);
1123 writer.WriteElementString("SitName", sop.SitName); 1134 writer.WriteElementString("SitName", sop.SitName);
1124 writer.WriteElementString("TouchName", sop.TouchName); 1135 writer.WriteElementString("TouchName", sop.TouchName);
1125 1136
1126 writer.WriteElementString("LinkNum", sop.LinkNum.ToString()); 1137 writer.WriteElementString("LinkNum", sop.LinkNum.ToString());
1127 writer.WriteElementString("ClickAction", sop.ClickAction.ToString()); 1138 writer.WriteElementString("ClickAction", sop.ClickAction.ToString());
1128 writer.WriteStartElement("Shape");
1129 1139
1130 writer.WriteElementString("ProfileCurve", sop.Shape.ProfileCurve.ToString()); 1140 WriteShape(writer, sop.Shape);
1131 1141
1132 writer.WriteStartElement("TextureEntry");
1133 byte[] te;
1134 if (sop.Shape.TextureEntry != null)
1135 te = sop.Shape.TextureEntry;
1136 else
1137 te = Utils.EmptyBytes;
1138 writer.WriteBase64(te, 0, te.Length);
1139 writer.WriteEndElement(); // TextureEntry
1140
1141 writer.WriteStartElement("ExtraParams");
1142 byte[] ep;
1143 if (sop.Shape.ExtraParams != null)
1144 ep = sop.Shape.ExtraParams;
1145 else
1146 ep = Utils.EmptyBytes;
1147 writer.WriteBase64(ep, 0, ep.Length);
1148 writer.WriteEndElement(); // ExtraParams
1149
1150 writer.WriteElementString("PathBegin", Primitive.PackBeginCut(sop.Shape.PathBegin).ToString());
1151 writer.WriteElementString("PathCurve", sop.Shape.PathCurve.ToString());
1152 writer.WriteElementString("PathEnd", Primitive.PackEndCut(sop.Shape.PathEnd).ToString());
1153 writer.WriteElementString("PathRadiusOffset", Primitive.PackPathTwist(sop.Shape.PathRadiusOffset).ToString());
1154 writer.WriteElementString("PathRevolutions", Primitive.PackPathRevolutions(sop.Shape.PathRevolutions).ToString());
1155 writer.WriteElementString("PathScaleX", Primitive.PackPathScale(sop.Shape.PathScaleX).ToString());
1156 writer.WriteElementString("PathScaleY", Primitive.PackPathScale(sop.Shape.PathScaleY).ToString());
1157 writer.WriteElementString("PathShearX", ((byte)Primitive.PackPathShear(sop.Shape.PathShearX)).ToString());
1158 writer.WriteElementString("PathShearY", ((byte)Primitive.PackPathShear(sop.Shape.PathShearY)).ToString());
1159 writer.WriteElementString("PathSkew", Primitive.PackPathTwist(sop.Shape.PathSkew).ToString());
1160 writer.WriteElementString("PathTaperX", Primitive.PackPathTaper(sop.Shape.PathTaperX).ToString());
1161 writer.WriteElementString("PathTaperY", Primitive.PackPathTaper(sop.Shape.PathTaperY).ToString());
1162 writer.WriteElementString("PathTwist", Primitive.PackPathTwist(sop.Shape.PathTwist).ToString());
1163 writer.WriteElementString("PathTwistBegin", Primitive.PackPathTwist(sop.Shape.PathTwistBegin).ToString());
1164 writer.WriteElementString("PCode", sop.Shape.PCode.ToString());
1165 writer.WriteElementString("ProfileBegin", Primitive.PackBeginCut(sop.Shape.ProfileBegin).ToString());
1166 writer.WriteElementString("ProfileEnd", Primitive.PackEndCut(sop.Shape.ProfileEnd).ToString());
1167 writer.WriteElementString("ProfileHollow", Primitive.PackProfileHollow(sop.Shape.ProfileHollow).ToString());
1168 WriteVector(writer, "Scale", sop.Scale); 1142 WriteVector(writer, "Scale", sop.Scale);
1169 writer.WriteElementString("State", sop.Shape.State.ToString()); 1143 writer.WriteElementString("UpdateFlag", sop.UpdateFlag.ToString());
1170
1171 writer.WriteElementString("ProfileShape", sop.Shape.ProfileShape.ToString());
1172 writer.WriteElementString("HollowShape", sop.Shape.HollowShape.ToString());
1173
1174 writer.WriteElementString("SculptTexture", sop.Shape.SculptTexture.ToString());
1175 writer.WriteElementString("SculptType", sop.Shape.SculptType.ToString());
1176 writer.WriteStartElement("SculptData");
1177 byte[] sd;
1178 if (sop.Shape.SculptData != null)
1179 sd = sop.Shape.ExtraParams;
1180 else
1181 sd = Utils.EmptyBytes;
1182 writer.WriteBase64(sd, 0, sd.Length);
1183 writer.WriteEndElement(); // SculptData
1184
1185 writer.WriteElementString("FlexiSoftness", sop.Shape.FlexiSoftness.ToString());
1186 writer.WriteElementString("FlexiTension", sop.Shape.FlexiTension.ToString());
1187 writer.WriteElementString("FlexiDrag", sop.Shape.FlexiDrag.ToString());
1188 writer.WriteElementString("FlexiGravity", sop.Shape.FlexiGravity.ToString());
1189 writer.WriteElementString("FlexiWind", sop.Shape.FlexiWind.ToString());
1190 writer.WriteElementString("FlexiForceX", sop.Shape.FlexiForceX.ToString());
1191 writer.WriteElementString("FlexiForceY", sop.Shape.FlexiForceY.ToString());
1192 writer.WriteElementString("FlexiForceZ", sop.Shape.FlexiForceZ.ToString());
1193
1194 writer.WriteElementString("LightColorR", sop.Shape.LightColorR.ToString());
1195 writer.WriteElementString("LightColorG", sop.Shape.LightColorG.ToString());
1196 writer.WriteElementString("LightColorB", sop.Shape.LightColorB.ToString());
1197 writer.WriteElementString("LightColorA", sop.Shape.LightColorA.ToString());
1198 writer.WriteElementString("LightRadius", sop.Shape.LightRadius.ToString());
1199 writer.WriteElementString("LightCutoff", sop.Shape.LightCutoff.ToString());
1200 writer.WriteElementString("LightFalloff", sop.Shape.LightFalloff.ToString());
1201 writer.WriteElementString("LightIntensity", sop.Shape.LightIntensity.ToString());
1202
1203 writer.WriteElementString("FlexyEntry", sop.Shape.FlexiEntry.ToString());
1204 writer.WriteElementString("LightEntry", sop.Shape.LightEntry.ToString());
1205 writer.WriteElementString("SculptEntry", sop.Shape.SculptEntry.ToString());
1206
1207 writer.WriteEndElement(); // Shape
1208
1209 WriteVector(writer, "Scale", sop.Scale);
1210 writer.WriteElementString("UpdateFlag", "0");
1211 WriteQuaternion(writer, "SitTargetOrientation", sop.SitTargetOrientation); 1144 WriteQuaternion(writer, "SitTargetOrientation", sop.SitTargetOrientation);
1212 WriteVector(writer, "SitTargetPosition", sop.SitTargetPosition); 1145 WriteVector(writer, "SitTargetPosition", sop.SitTargetPosition);
1213 WriteVector(writer, "SitTargetPositionLL", sop.SitTargetPositionLL); 1146 WriteVector(writer, "SitTargetPositionLL", sop.SitTargetPositionLL);
1214 WriteQuaternion(writer, "SitTargetOrientationLL", sop.SitTargetOrientationLL); 1147 WriteQuaternion(writer, "SitTargetOrientationLL", sop.SitTargetOrientationLL);
1215 writer.WriteElementString("ParentID", sop.ParentID.ToString()); 1148 writer.WriteElementString("ParentID", sop.ParentID.ToString());
1216 writer.WriteElementString("CreationDate", sop.CreationDate.ToString()); 1149 writer.WriteElementString("CreationDate", sop.CreationDate.ToString());
1217 writer.WriteElementString("Category", "0"); 1150 writer.WriteElementString("Category", sop.Category.ToString());
1218 writer.WriteElementString("SalePrice", sop.SalePrice.ToString()); 1151 writer.WriteElementString("SalePrice", sop.SalePrice.ToString());
1219 writer.WriteElementString("ObjectSaleType", ((int)sop.ObjectSaleType).ToString()); 1152 writer.WriteElementString("ObjectSaleType", sop.ObjectSaleType.ToString());
1220 writer.WriteElementString("OwnershipCost", "0"); 1153 writer.WriteElementString("OwnershipCost", sop.OwnershipCost.ToString());
1221 WriteUUID(writer, "GroupID", sop.GroupID); 1154 WriteUUID(writer, "GroupID", sop.GroupID);
1222 WriteUUID(writer, "OwnerID", sop.OwnerID); 1155 WriteUUID(writer, "OwnerID", sop.OwnerID);
1223 WriteUUID(writer, "LastOwnerID", sop.LastOwnerID); 1156 WriteUUID(writer, "LastOwnerID", sop.LastOwnerID);
@@ -1229,6 +1162,8 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
1229 writer.WriteElementString("Flags", sop.Flags.ToString()); 1162 writer.WriteElementString("Flags", sop.Flags.ToString());
1230 WriteUUID(writer, "CollisionSound", sop.CollisionSound); 1163 WriteUUID(writer, "CollisionSound", sop.CollisionSound);
1231 writer.WriteElementString("CollisionSoundVolume", sop.CollisionSoundVolume.ToString()); 1164 writer.WriteElementString("CollisionSoundVolume", sop.CollisionSoundVolume.ToString());
1165 if (sop.MediaUrl != null)
1166 writer.WriteElementString("MediaUrl", sop.MediaUrl.ToString());
1232 1167
1233 writer.WriteEndElement(); 1168 writer.WriteEndElement();
1234 } 1169 }
@@ -1259,6 +1194,134 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
1259 writer.WriteEndElement(); 1194 writer.WriteEndElement();
1260 } 1195 }
1261 1196
1197 static void WriteTaskInventory(XmlTextWriter writer, TaskInventoryDictionary tinv)
1198 {
1199 if (tinv.Count > 0) // otherwise skip this
1200 {
1201 writer.WriteStartElement("TaskInventory");
1202
1203 foreach (TaskInventoryItem item in tinv.Values)
1204 {
1205 writer.WriteStartElement("TaskInventoryItem");
1206
1207 WriteUUID(writer, "AssetID", item.AssetID);
1208 writer.WriteElementString("BasePermissions", item.BasePermissions.ToString());
1209 writer.WriteElementString("CreationDate", item.CreationDate.ToString());
1210 WriteUUID(writer, "CreatorID", item.CreatorID);
1211 writer.WriteElementString("Description", item.Description);
1212 writer.WriteElementString("EveryonePermissions", item.EveryonePermissions.ToString());
1213 writer.WriteElementString("Flags", item.Flags.ToString());
1214 WriteUUID(writer, "GroupID", item.GroupID);
1215 writer.WriteElementString("GroupPermissions", item.GroupPermissions.ToString());
1216 writer.WriteElementString("InvType", item.InvType.ToString());
1217 WriteUUID(writer, "ItemID", item.ItemID);
1218 WriteUUID(writer, "OldItemID", item.OldItemID);
1219 WriteUUID(writer, "LastOwnerID", item.LastOwnerID);
1220 writer.WriteElementString("Name", item.Name);
1221 writer.WriteElementString("NextPermissions", item.NextPermissions.ToString());
1222 WriteUUID(writer, "OwnerID", item.OwnerID);
1223 writer.WriteElementString("CurrentPermissions", item.CurrentPermissions.ToString());
1224 WriteUUID(writer, "ParentID", item.ParentID);
1225 WriteUUID(writer, "ParentPartID", item.ParentPartID);
1226 WriteUUID(writer, "PermsGranter", item.PermsGranter);
1227 writer.WriteElementString("PermsMask", item.PermsMask.ToString());
1228 writer.WriteElementString("Type", item.Type.ToString());
1229
1230 writer.WriteEndElement(); // TaskInventoryItem
1231 }
1232
1233 writer.WriteEndElement(); // TaskInventory
1234 }
1235 }
1236
1237 static void WriteShape(XmlTextWriter writer, PrimitiveBaseShape shp)
1238 {
1239 if (shp != null)
1240 {
1241 writer.WriteStartElement("Shape");
1242
1243 writer.WriteElementString("ProfileCurve", shp.ProfileCurve.ToString());
1244
1245 writer.WriteStartElement("TextureEntry");
1246 byte[] te;
1247 if (shp.TextureEntry != null)
1248 te = shp.TextureEntry;
1249 else
1250 te = Utils.EmptyBytes;
1251 writer.WriteBase64(te, 0, te.Length);
1252 writer.WriteEndElement(); // TextureEntry
1253
1254 writer.WriteStartElement("ExtraParams");
1255 byte[] ep;
1256 if (shp.ExtraParams != null)
1257 ep = shp.ExtraParams;
1258 else
1259 ep = Utils.EmptyBytes;
1260 writer.WriteBase64(ep, 0, ep.Length);
1261 writer.WriteEndElement(); // ExtraParams
1262
1263 writer.WriteElementString("PathBegin", shp.PathBegin.ToString());
1264 writer.WriteElementString("PathCurve", shp.PathCurve.ToString());
1265 writer.WriteElementString("PathEnd", shp.PathEnd.ToString());
1266 writer.WriteElementString("PathRadiusOffset", shp.PathRadiusOffset.ToString());
1267 writer.WriteElementString("PathRevolutions", shp.PathRevolutions.ToString());
1268 writer.WriteElementString("PathScaleX", shp.PathScaleX.ToString());
1269 writer.WriteElementString("PathScaleY", shp.PathScaleY.ToString());
1270 writer.WriteElementString("PathShearX", shp.PathShearX.ToString());
1271 writer.WriteElementString("PathShearY", shp.PathShearY.ToString());
1272 writer.WriteElementString("PathSkew", shp.PathSkew.ToString());
1273 writer.WriteElementString("PathTaperX", shp.PathTaperX.ToString());
1274 writer.WriteElementString("PathTaperY", shp.PathTaperY.ToString());
1275 writer.WriteElementString("PathTwist", shp.PathTwist.ToString());
1276 writer.WriteElementString("PathTwistBegin", shp.PathTwistBegin.ToString());
1277 writer.WriteElementString("PCode", shp.PCode.ToString());
1278 writer.WriteElementString("ProfileBegin", shp.ProfileBegin.ToString());
1279 writer.WriteElementString("ProfileEnd", shp.ProfileEnd.ToString());
1280 writer.WriteElementString("ProfileHollow", shp.ProfileHollow.ToString());
1281 writer.WriteElementString("State", shp.State.ToString());
1282
1283 writer.WriteElementString("ProfileShape", shp.ProfileShape.ToString());
1284 writer.WriteElementString("HollowShape", shp.HollowShape.ToString());
1285
1286 WriteUUID(writer, "SculptTexture", shp.SculptTexture);
1287 writer.WriteElementString("SculptType", shp.SculptType.ToString());
1288 writer.WriteStartElement("SculptData");
1289 byte[] sd;
1290 if (shp.SculptData != null)
1291 sd = shp.ExtraParams;
1292 else
1293 sd = Utils.EmptyBytes;
1294 writer.WriteBase64(sd, 0, sd.Length);
1295 writer.WriteEndElement(); // SculptData
1296
1297 writer.WriteElementString("FlexiSoftness", shp.FlexiSoftness.ToString());
1298 writer.WriteElementString("FlexiTension", shp.FlexiTension.ToString());
1299 writer.WriteElementString("FlexiDrag", shp.FlexiDrag.ToString());
1300 writer.WriteElementString("FlexiGravity", shp.FlexiGravity.ToString());
1301 writer.WriteElementString("FlexiWind", shp.FlexiWind.ToString());
1302 writer.WriteElementString("FlexiForceX", shp.FlexiForceX.ToString());
1303 writer.WriteElementString("FlexiForceY", shp.FlexiForceY.ToString());
1304 writer.WriteElementString("FlexiForceZ", shp.FlexiForceZ.ToString());
1305
1306 writer.WriteElementString("LightColorR", shp.LightColorR.ToString());
1307 writer.WriteElementString("LightColorG", shp.LightColorG.ToString());
1308 writer.WriteElementString("LightColorB", shp.LightColorB.ToString());
1309 writer.WriteElementString("LightColorA", shp.LightColorA.ToString());
1310 writer.WriteElementString("LightRadius", shp.LightRadius.ToString());
1311 writer.WriteElementString("LightCutoff", shp.LightCutoff.ToString());
1312 writer.WriteElementString("LightFalloff", shp.LightFalloff.ToString());
1313 writer.WriteElementString("LightIntensity", shp.LightIntensity.ToString());
1314
1315 writer.WriteElementString("FlexiEntry", shp.FlexiEntry.ToString().ToLower());
1316 writer.WriteElementString("LightEntry", shp.LightEntry.ToString().ToLower());
1317 writer.WriteElementString("SculptEntry", shp.SculptEntry.ToString().ToLower());
1318
1319 if (shp.Media != null)
1320 writer.WriteElementString("Media", shp.Media.ToXml());
1321
1322 writer.WriteEndElement(); // Shape
1323 }
1324 }
1262 1325
1263 //////// Read ///////// 1326 //////// Read /////////
1264 public static bool Xml2ToSOG(XmlTextReader reader, SceneObjectGroup sog) 1327 public static bool Xml2ToSOG(XmlTextReader reader, SceneObjectGroup sog)
@@ -1305,210 +1368,6 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
1305 return true; 1368 return true;
1306 } 1369 }
1307 1370
1308 public static SceneObjectPart Xml2ToSOPPull(XmlTextReader reader)
1309 {
1310 SceneObjectPart obj = new SceneObjectPart();
1311
1312 reader.ReadStartElement("SceneObjectPart");
1313
1314 if (reader.Name == "AllowedDrop")
1315 obj.AllowedDrop = reader.ReadElementContentAsBoolean("AllowedDrop", String.Empty);
1316 else
1317 obj.AllowedDrop = true;
1318
1319 obj.CreatorID = ReadUUID(reader, "CreatorID");
1320 obj.FolderID = ReadUUID(reader, "FolderID");
1321 obj.InventorySerial = (uint)reader.ReadElementContentAsInt("InventorySerial", String.Empty);
1322
1323 #region Task Inventory
1324
1325 obj.TaskInventory = new TaskInventoryDictionary();
1326 //List<PrimObject.InventoryBlock.ItemBlock> invItems = new List<PrimObject.InventoryBlock.ItemBlock>();
1327
1328 reader.ReadStartElement("TaskInventory", String.Empty);
1329 while (reader.Name == "TaskInventoryItem")
1330 {
1331 TaskInventoryItem item = new TaskInventoryItem();
1332 reader.ReadStartElement("TaskInventoryItem", String.Empty);
1333
1334 item.AssetID = ReadUUID(reader, "AssetID");
1335 item.BasePermissions = (uint)reader.ReadElementContentAsInt("BasePermissions", String.Empty);
1336 item.CreationDate = (uint)reader.ReadElementContentAsInt("CreationDate", String.Empty);
1337 item.CreatorID = ReadUUID(reader, "CreatorID");
1338 item.Description = reader.ReadElementContentAsString("Description", String.Empty);
1339 item.EveryonePermissions = (uint)reader.ReadElementContentAsInt("EveryonePermissions", String.Empty);
1340 item.Flags = (uint)reader.ReadElementContentAsInt("Flags", String.Empty);
1341 item.GroupID = ReadUUID(reader, "GroupID");
1342 item.GroupPermissions = (uint)reader.ReadElementContentAsInt("GroupPermissions", String.Empty);
1343 item.InvType = reader.ReadElementContentAsInt("InvType", String.Empty);
1344 item.ItemID = ReadUUID(reader, "ItemID");
1345 UUID oldItemID = ReadUUID(reader, "OldItemID"); // TODO: Is this useful?
1346 item.LastOwnerID = ReadUUID(reader, "LastOwnerID");
1347 item.Name = reader.ReadElementContentAsString("Name", String.Empty);
1348 item.NextPermissions = (uint)reader.ReadElementContentAsInt("NextPermissions", String.Empty);
1349 item.OwnerID = ReadUUID(reader, "OwnerID");
1350 item.CurrentPermissions = (uint)reader.ReadElementContentAsInt("CurrentPermissions", String.Empty);
1351 UUID parentID = ReadUUID(reader, "ParentID");
1352 UUID parentPartID = ReadUUID(reader, "ParentPartID");
1353 item.PermsGranter = ReadUUID(reader, "PermsGranter");
1354 item.PermsMask = reader.ReadElementContentAsInt("PermsMask", String.Empty);
1355 item.Type = reader.ReadElementContentAsInt("Type", String.Empty);
1356
1357 reader.ReadEndElement();
1358 obj.TaskInventory.Add(item.ItemID, item);
1359 }
1360 if (reader.NodeType == XmlNodeType.EndElement)
1361 reader.ReadEndElement();
1362
1363 #endregion Task Inventory
1364
1365 obj.Flags = (PrimFlags)reader.ReadElementContentAsInt("ObjectFlags", String.Empty);
1366
1367 obj.UUID = ReadUUID(reader, "UUID");
1368 obj.LocalId = (uint)reader.ReadElementContentAsLong("LocalId", String.Empty);
1369 obj.Name = reader.ReadElementString("Name");
1370 obj.Material = (byte)reader.ReadElementContentAsInt("Material", String.Empty);
1371
1372 if (reader.Name == "PassTouches")
1373 obj.PassTouches = reader.ReadElementContentAsBoolean("PassTouches", String.Empty);
1374 else
1375 obj.PassTouches = false;
1376
1377 obj.RegionHandle = (ulong)reader.ReadElementContentAsLong("RegionHandle", String.Empty);
1378 obj.ScriptAccessPin = reader.ReadElementContentAsInt("ScriptAccessPin", String.Empty);
1379
1380 if (reader.Name == "PlaySoundSlavePrims")
1381 reader.ReadInnerXml();
1382 if (reader.Name == "LoopSoundSlavePrims")
1383 reader.ReadInnerXml();
1384
1385 Vector3 groupPosition = ReadVector(reader, "GroupPosition");
1386 Vector3 offsetPosition = ReadVector(reader, "OffsetPosition");
1387 obj.RotationOffset = ReadQuaternion(reader, "RotationOffset");
1388 obj.Velocity = ReadVector(reader, "Velocity");
1389 if (reader.Name == "RotationalVelocity")
1390 ReadVector(reader, "RotationalVelocity");
1391 obj.AngularVelocity = ReadVector(reader, "AngularVelocity");
1392 obj.Acceleration = ReadVector(reader, "Acceleration");
1393 obj.Description = reader.ReadElementString("Description");
1394 reader.ReadStartElement("Color");
1395 if (reader.Name == "R")
1396 {
1397 obj.Color = Color.FromArgb((int)reader.ReadElementContentAsFloat("A", String.Empty),
1398 (int)reader.ReadElementContentAsFloat("R", String.Empty),
1399 (int)reader.ReadElementContentAsFloat("G", String.Empty),
1400 (int)reader.ReadElementContentAsFloat("B", String.Empty));
1401 reader.ReadEndElement();
1402 }
1403 obj.Text = reader.ReadElementString("Text", String.Empty);
1404 obj.SitName = reader.ReadElementString("SitName", String.Empty);
1405 obj.TouchName = reader.ReadElementString("TouchName", String.Empty);
1406
1407 obj.LinkNum = reader.ReadElementContentAsInt("LinkNum", String.Empty);
1408 obj.ClickAction = (byte)reader.ReadElementContentAsInt("ClickAction", String.Empty);
1409
1410 reader.ReadStartElement("Shape");
1411 obj.Shape.ProfileCurve = (byte)reader.ReadElementContentAsInt("ProfileCurve", String.Empty);
1412
1413 byte[] teData = Convert.FromBase64String(reader.ReadElementString("TextureEntry"));
1414 obj.Shape.Textures = new Primitive.TextureEntry(teData, 0, teData.Length);
1415
1416 reader.ReadInnerXml(); // ExtraParams
1417
1418 obj.Shape.PathBegin = (ushort)reader.ReadElementContentAsInt("PathBegin", String.Empty);
1419 obj.Shape.PathCurve = (byte)reader.ReadElementContentAsInt("PathCurve", String.Empty);
1420 obj.Shape.PathEnd = (ushort)reader.ReadElementContentAsInt("PathEnd", String.Empty);
1421 obj.Shape.PathRadiusOffset = (sbyte)reader.ReadElementContentAsInt("PathRadiusOffset", String.Empty);
1422 obj.Shape.PathRevolutions = (byte)reader.ReadElementContentAsInt("PathRevolutions", String.Empty);
1423 obj.Shape.PathScaleX = (byte)reader.ReadElementContentAsInt("PathScaleX", String.Empty);
1424 obj.Shape.PathScaleY = (byte)reader.ReadElementContentAsInt("PathScaleY", String.Empty);
1425 obj.Shape.PathShearX = (byte)reader.ReadElementContentAsInt("PathShearX", String.Empty);
1426 obj.Shape.PathShearY = (byte)reader.ReadElementContentAsInt("PathShearY", String.Empty);
1427 obj.Shape.PathSkew = (sbyte)reader.ReadElementContentAsInt("PathSkew", String.Empty);
1428 obj.Shape.PathTaperX = (sbyte)reader.ReadElementContentAsInt("PathTaperX", String.Empty);
1429 obj.Shape.PathTaperY = (sbyte)reader.ReadElementContentAsInt("PathTaperY", String.Empty);
1430 obj.Shape.PathTwist = (sbyte)reader.ReadElementContentAsInt("PathTwist", String.Empty);
1431 obj.Shape.PathTwistBegin = (sbyte)reader.ReadElementContentAsInt("PathTwistBegin", String.Empty);
1432 obj.Shape.PCode = (byte)reader.ReadElementContentAsInt("PCode", String.Empty);
1433 obj.Shape.ProfileBegin = (ushort)reader.ReadElementContentAsInt("ProfileBegin", String.Empty);
1434 obj.Shape.ProfileEnd = (ushort)reader.ReadElementContentAsInt("ProfileEnd", String.Empty);
1435 obj.Shape.ProfileHollow = (ushort)reader.ReadElementContentAsInt("ProfileHollow", String.Empty);
1436 obj.Scale = ReadVector(reader, "Scale");
1437 obj.Shape.State = (byte)reader.ReadElementContentAsInt("State", String.Empty);
1438
1439 obj.Shape.ProfileCurve = (byte)reader.ReadElementContentAsInt("ProfileCurve", String.Empty);
1440 obj.Shape.ProfileShape = (ProfileShape)reader.ReadElementContentAsInt("ProfileShape", String.Empty);
1441 obj.Shape.HollowShape = (HollowShape)reader.ReadElementContentAsInt("HollowShape", String.Empty);
1442
1443 UUID sculptTexture = ReadUUID(reader, "SculptTexture");
1444 SculptType sculptType = (SculptType)reader.ReadElementContentAsInt("SculptType", String.Empty);
1445 if (sculptTexture != UUID.Zero)
1446 {
1447 obj.Shape.SculptTexture = sculptTexture;
1448 obj.Shape.SculptType = (byte)sculptType;
1449 }
1450
1451 reader.ReadInnerXml(); // SculptData
1452
1453 obj.Shape.FlexiSoftness = reader.ReadElementContentAsInt("FlexiSoftness", String.Empty);
1454 obj.Shape.FlexiTension = reader.ReadElementContentAsFloat("FlexiTension", String.Empty);
1455 obj.Shape.FlexiDrag = reader.ReadElementContentAsFloat("FlexiDrag", String.Empty);
1456 obj.Shape.FlexiGravity = reader.ReadElementContentAsFloat("FlexiGravity", String.Empty);
1457 obj.Shape.FlexiWind = reader.ReadElementContentAsFloat("FlexiWind", String.Empty);
1458 obj.Shape.FlexiForceX = reader.ReadElementContentAsFloat("FlexiForceX", String.Empty);
1459 obj.Shape.FlexiForceY = reader.ReadElementContentAsFloat("FlexiForceY", String.Empty);
1460 obj.Shape.FlexiForceZ = reader.ReadElementContentAsFloat("FlexiForceZ", String.Empty);
1461
1462 obj.Shape.LightColorR = reader.ReadElementContentAsFloat("LightColorR", String.Empty);
1463 obj.Shape.LightColorG = reader.ReadElementContentAsFloat("LightColorG", String.Empty);
1464 obj.Shape.LightColorB = reader.ReadElementContentAsFloat("LightColorB", String.Empty);
1465 obj.Shape.LightColorA = reader.ReadElementContentAsFloat("LightColorA", String.Empty);
1466 obj.Shape.LightRadius = reader.ReadElementContentAsFloat("LightRadius", String.Empty);
1467 obj.Shape.LightCutoff = reader.ReadElementContentAsFloat("LightCutoff", String.Empty);
1468 obj.Shape.LightFalloff = reader.ReadElementContentAsFloat("LightFalloff", String.Empty);
1469 obj.Shape.LightIntensity = reader.ReadElementContentAsFloat("LightIntensity", String.Empty);
1470
1471 bool hasFlexi = reader.ReadElementContentAsBoolean("FlexiEntry", String.Empty);
1472 bool hasLight = reader.ReadElementContentAsBoolean("LightEntry", String.Empty);
1473 reader.ReadInnerXml(); // SculptEntry
1474
1475 reader.ReadEndElement();
1476
1477 obj.Scale = ReadVector(reader, "Scale"); // Yes, again
1478 obj.UpdateFlag = (byte)reader.ReadElementContentAsInt("UpdateFlag", String.Empty); // UpdateFlag
1479
1480 obj.SitTargetOrientation = ReadQuaternion(reader, "SitTargetOrientation");
1481 obj.SitTargetPosition = ReadVector(reader, "SitTargetPosition");
1482 obj.SitTargetPositionLL = ReadVector(reader, "SitTargetPositionLL");
1483 obj.SitTargetOrientationLL = ReadQuaternion(reader, "SitTargetOrientationLL");
1484 obj.ParentID = (uint)reader.ReadElementContentAsLong("ParentID", String.Empty);
1485 obj.CreationDate = reader.ReadElementContentAsInt("CreationDate", String.Empty);
1486 int category = reader.ReadElementContentAsInt("Category", String.Empty);
1487 obj.SalePrice = reader.ReadElementContentAsInt("SalePrice", String.Empty);
1488 obj.ObjectSaleType = (byte)reader.ReadElementContentAsInt("ObjectSaleType", String.Empty);
1489 int ownershipCost = reader.ReadElementContentAsInt("OwnershipCost", String.Empty);
1490 obj.GroupID = ReadUUID(reader, "GroupID");
1491 obj.OwnerID = ReadUUID(reader, "OwnerID");
1492 obj.LastOwnerID = ReadUUID(reader, "LastOwnerID");
1493 obj.BaseMask = (uint)reader.ReadElementContentAsInt("BaseMask", String.Empty);
1494 obj.OwnerMask = (uint)reader.ReadElementContentAsInt("OwnerMask", String.Empty);
1495 obj.GroupMask = (uint)reader.ReadElementContentAsInt("GroupMask", String.Empty);
1496 obj.EveryoneMask = (uint)reader.ReadElementContentAsInt("EveryoneMask", String.Empty);
1497 obj.NextOwnerMask = (uint)reader.ReadElementContentAsInt("NextOwnerMask", String.Empty);
1498
1499 obj.Flags = (PrimFlags)reader.ReadElementContentAsInt("Flags", String.Empty);
1500
1501 obj.CollisionSound = ReadUUID(reader, "CollisionSound");
1502 obj.CollisionSoundVolume = reader.ReadElementContentAsFloat("CollisionSoundVolume", String.Empty);
1503
1504 reader.ReadEndElement();
1505
1506 obj.GroupPosition = groupPosition;
1507 obj.OffsetPosition = offsetPosition;
1508
1509 return obj;
1510 }
1511
1512 public static SceneObjectPart Xml2ToSOP(XmlTextReader reader) 1371 public static SceneObjectPart Xml2ToSOP(XmlTextReader reader)
1513 { 1372 {
1514 SceneObjectPart obj = new SceneObjectPart(); 1373 SceneObjectPart obj = new SceneObjectPart();
@@ -1522,13 +1381,16 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
1522 SOPXmlProcessor p = null; 1381 SOPXmlProcessor p = null;
1523 if (m_SOPXmlProcessors.TryGetValue(reader.Name, out p)) 1382 if (m_SOPXmlProcessors.TryGetValue(reader.Name, out p))
1524 { 1383 {
1384 //m_log.DebugFormat("[XXX] Processing: {0}", reader.Name);
1525 try 1385 try
1526 { 1386 {
1527 p(obj, reader); 1387 p(obj, reader);
1528 } 1388 }
1529 catch (Exception e) 1389 catch (Exception e)
1530 { 1390 {
1531 m_log.DebugFormat("[SceneObjectSerializer]: exception while parsing {0} in {1}-{2}: {3}", nodeName, obj.Name, obj.UUID, e); 1391 m_log.DebugFormat("[SceneObjectSerializer]: exception while parsing {0}: {1}", nodeName, e);
1392 if (reader.NodeType == XmlNodeType.EndElement)
1393 reader.Read();
1532 } 1394 }
1533 } 1395 }
1534 else 1396 else
@@ -1631,6 +1493,7 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
1631 1493
1632 while (reader.NodeType != XmlNodeType.EndElement) 1494 while (reader.NodeType != XmlNodeType.EndElement)
1633 { 1495 {
1496 //m_log.DebugFormat("[XXX] Processing: {0}", reader.Name);
1634 ShapeXmlProcessor p = null; 1497 ShapeXmlProcessor p = null;
1635 if (m_ShapeXmlProcessors.TryGetValue(reader.Name, out p)) 1498 if (m_ShapeXmlProcessors.TryGetValue(reader.Name, out p))
1636 p(shape, reader); 1499 p(shape, reader);
diff --git a/OpenSim/Region/Framework/Scenes/Serialization/SceneXmlLoader.cs b/OpenSim/Region/Framework/Scenes/Serialization/SceneXmlLoader.cs
index bb67ca0..c6d4e55 100644
--- a/OpenSim/Region/Framework/Scenes/Serialization/SceneXmlLoader.cs
+++ b/OpenSim/Region/Framework/Scenes/Serialization/SceneXmlLoader.cs
@@ -280,6 +280,8 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
280 280
281 public static void SavePrimListToXml2(EntityBase[] entityList, TextWriter stream, Vector3 min, Vector3 max) 281 public static void SavePrimListToXml2(EntityBase[] entityList, TextWriter stream, Vector3 min, Vector3 max)
282 { 282 {
283 XmlTextWriter writer = new XmlTextWriter(stream);
284
283 int primCount = 0; 285 int primCount = 0;
284 stream.WriteLine("<scene>\n"); 286 stream.WriteLine("<scene>\n");
285 287
@@ -297,10 +299,14 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
297 continue; 299 continue;
298 } 300 }
299 301
300 stream.WriteLine(SceneObjectSerializer.ToXml2Format(g)); 302 //stream.WriteLine(SceneObjectSerializer.ToXml2Format(g));
303 SceneObjectSerializer.SOGToXml2(writer, (SceneObjectGroup)ent);
304 stream.WriteLine();
305
301 primCount++; 306 primCount++;
302 } 307 }
303 } 308 }
309
304 stream.WriteLine("</scene>\n"); 310 stream.WriteLine("</scene>\n");
305 stream.Flush(); 311 stream.Flush();
306 } 312 }
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 {