Merge branch 'master' of git://opensimulator.org/git/opensim

viewer-2-initial-appearance
Jonathan Freedman 2010-10-17 18:45:25 -04:00
commit 4e4fb93fae
40 changed files with 30430 additions and 28237 deletions

View File

@ -1,4 +1,4 @@
=== Building OpenSim ===
==== Building OpenSim ====
=== Building on Windows ===

View File

@ -2284,7 +2284,7 @@ namespace OpenSim.ApplicationPlugins.RemoteController
if (archiver != null)
{
scene.EventManager.OnOarFileSaved += RemoteAdminOarSaveCompleted;
archiver.ArchiveRegion(filename);
archiver.ArchiveRegion(filename, new Dictionary<string, object>());
lock (m_saveOarLock) Monitor.Wait(m_saveOarLock,5000);
scene.EventManager.OnOarFileSaved -= RemoteAdminOarSaveCompleted;
}

View File

@ -78,9 +78,12 @@ namespace OpenSim.Data.MySQL
if (pd.Length == 0)
return false;
if (regionID == UUID.Zero)
return false;
MySqlCommand cmd = new MySqlCommand();
cmd.CommandText = String.Format("update {0} set RegionID=?RegionID where `SessionID`=?SessionID", m_Realm);
cmd.CommandText = String.Format("update {0} set RegionID=?RegionID, LastSeen=NOW() where `SessionID`=?SessionID", m_Realm);
cmd.Parameters.AddWithValue("?SessionID", sessionID.ToString());
cmd.Parameters.AddWithValue("?RegionID", regionID.ToString());
@ -90,6 +93,5 @@ namespace OpenSim.Data.MySQL
return true;
}
}
}

View File

@ -424,6 +424,7 @@ namespace OpenSim.Data.MySQL
cmd.CommandText =
"SELECT * FROM prims LEFT JOIN primshapes ON prims.UUID = primshapes.UUID WHERE RegionUUID = ?RegionUUID";
cmd.Parameters.AddWithValue("RegionUUID", regionID.ToString());
cmd.CommandTimeout = 3600;
using (IDataReader reader = ExecuteReader(cmd))
{

View File

@ -13,3 +13,11 @@ CREATE UNIQUE INDEX SessionID ON Presence(SessionID);
CREATE INDEX UserID ON Presence(UserID);
COMMIT;
:VERSION 1 # --------------------------
BEGIN;
ALTER TABLE `Presence` ADD COLUMN LastSeen timestamp;
COMMIT;

View File

@ -962,10 +962,10 @@ namespace OpenSim.Framework.Capabilities
item.AssetType = assType;
item.InvType = inType;
item.Folder = parentFolder;
item.CurrentPermissions = 2147483647;
item.BasePermissions = 2147483647;
item.CurrentPermissions = (uint)PermissionMask.All;
item.BasePermissions = (uint)PermissionMask.All;
item.EveryOnePermissions = 0;
item.NextPermissions = 2147483647;
item.NextPermissions = (uint)(PermissionMask.Move | PermissionMask.Modify | PermissionMask.Transfer);
item.CreationDate = Util.UnixTimeSinceEpoch();
if (AddNewInventoryItem != null)

View File

@ -39,4 +39,18 @@ namespace OpenSim.Framework.Capabilities
{
}
}
[OSDMap]
public class LLSDNewFileAngentInventoryVariablePriceReplyResponse
{
public int resource_cost;
public string state;
public int upload_price;
public string rsvp;
public LLSDNewFileAngentInventoryVariablePriceReplyResponse()
{
state = "confirm_upload";
}
}
}

View File

@ -136,6 +136,13 @@ namespace OpenSim.Framework
[XmlIgnore] private bool _lightEntry;
[XmlIgnore] private bool _sculptEntry;
// Light Projection Filter
[XmlIgnore] private bool _projectionEntry;
[XmlIgnore] private UUID _projectionTextureID;
[XmlIgnore] private float _projectionFOV;
[XmlIgnore] private float _projectionFocus;
[XmlIgnore] private float _projectionAmb;
public byte ProfileCurve
{
get { return (byte)((byte)HollowShape | (byte)ProfileShape); }
@ -795,11 +802,57 @@ namespace OpenSim.Framework
}
}
public bool ProjectionEntry {
get {
return _projectionEntry;
}
set {
_projectionEntry = value;
}
}
public UUID ProjectionTextureUUID {
get {
return _projectionTextureID;
}
set {
_projectionTextureID = value;
}
}
public float ProjectionFOV {
get {
return _projectionFOV;
}
set {
_projectionFOV = value;
}
}
public float ProjectionFocus {
get {
return _projectionFocus;
}
set {
_projectionFocus = value;
}
}
public float ProjectionAmbiance {
get {
return _projectionAmb;
}
set {
_projectionAmb = value;
}
}
public byte[] ExtraParamsToBytes()
{
ushort FlexiEP = 0x10;
ushort LightEP = 0x20;
ushort SculptEP = 0x30;
ushort ProjectionEP = 0x40;
int i = 0;
uint TotalBytesLength = 1; // ExtraParamsNum
@ -823,6 +876,12 @@ namespace OpenSim.Framework
TotalBytesLength += 17;// data
TotalBytesLength += 2 + 4; // type
}
if (_projectionEntry)
{
ExtraParamsNum++;
TotalBytesLength += 28;// data
TotalBytesLength += 2 + 4;// type
}
byte[] returnbytes = new byte[TotalBytesLength];
@ -874,8 +933,20 @@ namespace OpenSim.Framework
Array.Copy(SculptData, 0, returnbytes, i, SculptData.Length);
i += SculptData.Length;
}
if (_projectionEntry)
{
byte[] ProjectionData = GetProjectionBytes();
if (!_flexiEntry && !_lightEntry && !_sculptEntry)
returnbytes[i++] = (byte)(ProjectionEP % 256);
returnbytes[i++] = (byte)((ProjectionEP >> 8) % 256);
returnbytes[i++] = (byte)((ProjectionData.Length) % 256);
returnbytes[i++] = (byte)((ProjectionData.Length >> 16) % 256);
returnbytes[i++] = (byte)((ProjectionData.Length >> 20) % 256);
returnbytes[i++] = (byte)((ProjectionData.Length >> 24) % 256);
Array.Copy(ProjectionData, 0, returnbytes, i, ProjectionData.Length);
i += ProjectionData.Length;
}
if (!_flexiEntry && !_lightEntry && !_sculptEntry && !_projectionEntry)
{
byte[] returnbyte = new byte[1];
returnbyte[0] = 0;
@ -893,6 +964,7 @@ namespace OpenSim.Framework
const ushort FlexiEP = 0x10;
const ushort LightEP = 0x20;
const ushort SculptEP = 0x30;
const ushort ProjectionEP = 0x40;
switch (type)
{
@ -922,6 +994,14 @@ namespace OpenSim.Framework
}
ReadSculptData(data, 0);
break;
case ProjectionEP:
if (!inUse)
{
_projectionEntry = false;
return;
}
ReadProjectionData(data, 0);
break;
}
}
@ -933,10 +1013,12 @@ namespace OpenSim.Framework
const ushort FlexiEP = 0x10;
const ushort LightEP = 0x20;
const ushort SculptEP = 0x30;
const ushort ProjectionEP = 0x40;
bool lGotFlexi = false;
bool lGotLight = false;
bool lGotSculpt = false;
bool lGotFilter = false;
int i = 0;
byte extraParamCount = 0;
@ -973,6 +1055,11 @@ namespace OpenSim.Framework
i += 17;
lGotSculpt = true;
break;
case ProjectionEP:
ReadProjectionData(data, i);
i += 28;
lGotFilter = true;
break;
}
}
@ -982,6 +1069,8 @@ namespace OpenSim.Framework
_lightEntry = false;
if (!lGotSculpt)
_sculptEntry = false;
if (!lGotFilter)
_projectionEntry = false;
}
@ -1121,6 +1210,42 @@ namespace OpenSim.Framework
return data;
}
public void ReadProjectionData(byte[] data, int pos)
{
byte[] ProjectionTextureUUID = new byte[16];
if (data.Length - pos >= 28)
{
_projectionEntry = true;
Array.Copy(data, pos, ProjectionTextureUUID,0, 16);
_projectionTextureID = new UUID(ProjectionTextureUUID, 0);
_projectionFOV = Utils.BytesToFloat(data, pos + 16);
_projectionFocus = Utils.BytesToFloat(data, pos + 20);
_projectionAmb = Utils.BytesToFloat(data, pos + 24);
}
else
{
_projectionEntry = false;
_projectionTextureID = UUID.Zero;
_projectionFOV = 0f;
_projectionFocus = 0f;
_projectionAmb = 0f;
}
}
public byte[] GetProjectionBytes()
{
byte[] data = new byte[28];
_projectionTextureID.GetBytes().CopyTo(data, 0);
Utils.FloatToBytes(_projectionFOV).CopyTo(data, 16);
Utils.FloatToBytes(_projectionFocus).CopyTo(data, 20);
Utils.FloatToBytes(_projectionAmb).CopyTo(data, 24);
return data;
}
/// <summary>
/// Creates a OpenMetaverse.Primitive and populates it with converted PrimitiveBaseShape values

View File

@ -1474,7 +1474,8 @@ namespace OpenSim.Framework.Servers.HttpServer
if (!(contentType.Contains("image")
|| contentType.Contains("x-shockwave-flash")
|| contentType.Contains("application/x-oar")))
|| contentType.Contains("application/x-oar")
|| contentType.Contains("application/vnd.ll.mesh")))
{
// Text
buffer = Encoding.UTF8.GetBytes(responseString);

View File

@ -0,0 +1,202 @@
/*
* Copyright (c) Contributors, http://opensimulator.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSimulator Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
using System;
using System.Collections;
using System.Collections.Specialized;
using System.Reflection;
using System.IO;
using System.Web;
using Mono.Addins;
using log4net;
using Nini.Config;
using OpenMetaverse;
using OpenMetaverse.StructuredData;
using OpenSim.Framework;
using OpenSim.Framework.Servers;
using OpenSim.Framework.Servers.HttpServer;
using OpenSim.Region.Framework.Interfaces;
using OpenSim.Region.Framework.Scenes;
using OpenSim.Services.Interfaces;
using Caps = OpenSim.Framework.Capabilities.Caps;
namespace OpenSim.Region.CoreModules.Avatar.Assets
{
[Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule")]
public class GetMeshModule : INonSharedRegionModule
{
private static readonly ILog m_log =
LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
private Scene m_scene;
private IAssetService m_assetService;
#region IRegionModuleBase Members
public Type ReplaceableInterface
{
get { return null; }
}
public void Initialise(IConfigSource source)
{
}
public void AddRegion(Scene pScene)
{
m_scene = pScene;
}
public void RemoveRegion(Scene scene)
{
m_scene.EventManager.OnRegisterCaps -= RegisterCaps;
m_scene = null;
}
public void RegionLoaded(Scene scene)
{
m_assetService = m_scene.RequestModuleInterface<IAssetService>();
m_scene.EventManager.OnRegisterCaps += RegisterCaps;
}
#endregion
#region IRegionModule Members
public void Close() { }
public string Name { get { return "GetMeshModule"; } }
public void RegisterCaps(UUID agentID, Caps caps)
{
UUID capID = UUID.Random();
m_log.Info("[GETMESH]: /CAPS/" + capID);
caps.RegisterHandler("GetMesh",
new RestHTTPHandler("GET", "/CAPS/" + capID,
delegate(Hashtable m_dhttpMethod)
{
return ProcessGetMesh(m_dhttpMethod, agentID, caps);
}));
}
#endregion
public Hashtable ProcessGetMesh(Hashtable request, UUID AgentId, Caps cap)
{
Hashtable responsedata = new Hashtable();
responsedata["int_response_code"] = 400; //501; //410; //404;
responsedata["content_type"] = "text/plain";
responsedata["keepalive"] = false;
responsedata["str_response_string"] = "Request wasn't what was expected";
string meshStr = string.Empty;
if (request.ContainsKey("mesh_id"))
meshStr = request["mesh_id"].ToString();
UUID meshID = UUID.Zero;
if (!String.IsNullOrEmpty(meshStr) && UUID.TryParse(meshStr, out meshID))
{
if (m_assetService == null)
{
responsedata["int_response_code"] = 404; //501; //410; //404;
responsedata["content_type"] = "text/plain";
responsedata["keepalive"] = false;
responsedata["str_response_string"] = "The asset service is unavailable. So is your mesh.";
return responsedata;
}
AssetBase mesh;
// Only try to fetch locally cached textures. Misses are redirected
mesh = m_assetService.GetCached(meshID.ToString());
if (mesh != null)
{
if (mesh.Type == (SByte)AssetType.Mesh)
{
responsedata["str_response_string"] = Convert.ToBase64String(mesh.Data);
responsedata["content_type"] = "application/vnd.ll.mesh";
responsedata["int_response_code"] = 200;
}
// Optionally add additional mesh types here
else
{
responsedata["int_response_code"] = 404; //501; //410; //404;
responsedata["content_type"] = "text/plain";
responsedata["keepalive"] = false;
responsedata["str_response_string"] = "Unfortunately, this asset isn't a mesh.";
return responsedata;
}
}
else
{
mesh = m_assetService.Get(meshID.ToString());
if (mesh != null)
{
if (mesh.Type == (SByte)AssetType.Mesh)
{
responsedata["str_response_string"] = Convert.ToBase64String(mesh.Data);
responsedata["content_type"] = "application/vnd.ll.mesh";
responsedata["int_response_code"] = 200;
}
// Optionally add additional mesh types here
else
{
responsedata["int_response_code"] = 404; //501; //410; //404;
responsedata["content_type"] = "text/plain";
responsedata["keepalive"] = false;
responsedata["str_response_string"] = "Unfortunately, this asset isn't a mesh.";
return responsedata;
}
}
else
{
responsedata["int_response_code"] = 404; //501; //410; //404;
responsedata["content_type"] = "text/plain";
responsedata["keepalive"] = false;
responsedata["str_response_string"] = "Your Mesh wasn't found. Sorry!";
return responsedata;
}
}
}
return responsedata;
}
}
}

View File

@ -0,0 +1,266 @@
/*
* Copyright (c) Contributors, http://opensimulator.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSimulator Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
using System;
using System.Collections;
using System.Collections.Specialized;
using System.Reflection;
using System.IO;
using System.Web;
using Mono.Addins;
using log4net;
using Nini.Config;
using OpenMetaverse;
using OpenMetaverse.StructuredData;
using OpenSim.Framework;
using OpenSim.Framework.Servers;
using OpenSim.Framework.Servers.HttpServer;
using OpenSim.Region.Framework.Interfaces;
using OpenSim.Region.Framework.Scenes;
using OpenSim.Services.Interfaces;
using Caps = OpenSim.Framework.Capabilities.Caps;
using OpenSim.Framework.Capabilities;
namespace OpenSim.Region.CoreModules.Avatar.Assets
{
[Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule")]
public class NewFileAgentInventoryVariablePriceModule : INonSharedRegionModule
{
private static readonly ILog m_log =
LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
private Scene m_scene;
private IAssetService m_assetService;
private bool m_dumpAssetsToFile = false;
#region IRegionModuleBase Members
public Type ReplaceableInterface
{
get { return null; }
}
public void Initialise(IConfigSource source)
{
}
public void AddRegion(Scene pScene)
{
m_scene = pScene;
}
public void RemoveRegion(Scene scene)
{
m_scene.EventManager.OnRegisterCaps -= RegisterCaps;
m_scene = null;
}
public void RegionLoaded(Scene scene)
{
m_assetService = m_scene.RequestModuleInterface<IAssetService>();
m_scene.EventManager.OnRegisterCaps += RegisterCaps;
}
#endregion
#region IRegionModule Members
public void Close() { }
public string Name { get { return "NewFileAgentInventoryVariablePriceModule"; } }
public void RegisterCaps(UUID agentID, Caps caps)
{
UUID capID = UUID.Random();
m_log.Info("[GETMESH]: /CAPS/" + capID);
caps.RegisterHandler("NewFileAgentInventoryVariablePrice",
new LLSDStreamhandler<LLSDAssetUploadRequest, LLSDNewFileAngentInventoryVariablePriceReplyResponse>("POST",
"/CAPS/" + capID.ToString(),
delegate(LLSDAssetUploadRequest req)
{
return NewAgentInventoryRequest(req,agentID);
}));
}
#endregion
public LLSDNewFileAngentInventoryVariablePriceReplyResponse NewAgentInventoryRequest(LLSDAssetUploadRequest llsdRequest, UUID agentID)
{
//TODO: The Mesh uploader uploads many types of content. If you're going to implement a Money based limit
// You need to be aware of this and
//if (llsdRequest.asset_type == "texture" ||
// llsdRequest.asset_type == "animation" ||
// llsdRequest.asset_type == "sound")
// {
IClientAPI client = null;
IMoneyModule mm = m_scene.RequestModuleInterface<IMoneyModule>();
if (mm != null)
{
if (m_scene.TryGetClient(agentID, out client))
{
if (!mm.UploadCovered(client, mm.UploadCharge))
{
if (client != null)
client.SendAgentAlertMessage("Unable to upload asset. Insufficient funds.", false);
LLSDNewFileAngentInventoryVariablePriceReplyResponse errorResponse = new LLSDNewFileAngentInventoryVariablePriceReplyResponse();
errorResponse.rsvp = "";
errorResponse.state = "error";
return errorResponse;
}
}
}
// }
string assetName = llsdRequest.name;
string assetDes = llsdRequest.description;
string capsBase = "/CAPS/NewFileAgentInventoryVariablePrice/";
UUID newAsset = UUID.Random();
UUID newInvItem = UUID.Random();
UUID parentFolder = llsdRequest.folder_id;
string uploaderPath = Util.RandomClass.Next(5000, 8000).ToString("0000") + "/";
Caps.AssetUploader uploader =
new Caps.AssetUploader(assetName, assetDes, newAsset, newInvItem, parentFolder, llsdRequest.inventory_type,
llsdRequest.asset_type, capsBase + uploaderPath, MainServer.Instance, m_dumpAssetsToFile);
MainServer.Instance.AddStreamHandler(
new BinaryStreamHandler("POST", capsBase + uploaderPath, uploader.uploaderCaps));
string protocol = "http://";
if (MainServer.Instance.UseSSL)
protocol = "https://";
string uploaderURL = protocol + m_scene.RegionInfo.ExternalHostName + ":" + MainServer.Instance.Port.ToString() + capsBase +
uploaderPath;
LLSDNewFileAngentInventoryVariablePriceReplyResponse uploadResponse = new LLSDNewFileAngentInventoryVariablePriceReplyResponse();
uploadResponse.rsvp = uploaderURL;
uploadResponse.state = "upload";
uploadResponse.resource_cost = 0;
uploadResponse.upload_price = 0;
uploader.OnUpLoad += //UploadCompleteHandler;
delegate(
string passetName, string passetDescription, UUID passetID,
UUID pinventoryItem, UUID pparentFolder, byte[] pdata, string pinventoryType,
string passetType)
{
UploadCompleteHandler(passetName, passetDescription, passetID,
pinventoryItem, pparentFolder, pdata, pinventoryType,
passetType,agentID);
};
return uploadResponse;
}
public void UploadCompleteHandler(string assetName, string assetDescription, UUID assetID,
UUID inventoryItem, UUID parentFolder, byte[] data, string inventoryType,
string assetType,UUID AgentID)
{
sbyte assType = 0;
sbyte inType = 0;
if (inventoryType == "sound")
{
inType = 1;
assType = 1;
}
else if (inventoryType == "animation")
{
inType = 19;
assType = 20;
}
else if (inventoryType == "wearable")
{
inType = 18;
switch (assetType)
{
case "bodypart":
assType = 13;
break;
case "clothing":
assType = 5;
break;
}
}
else if (inventoryType == "mesh")
{
inType = (sbyte)InventoryType.Mesh;
assType = (sbyte)AssetType.Mesh;
}
AssetBase asset;
asset = new AssetBase(assetID, assetName, assType, AgentID.ToString());
asset.Data = data;
if (m_scene.AssetService != null)
m_scene.AssetService.Store(asset);
InventoryItemBase item = new InventoryItemBase();
item.Owner = AgentID;
item.CreatorId = AgentID.ToString();
item.ID = inventoryItem;
item.AssetID = asset.FullID;
item.Description = assetDescription;
item.Name = assetName;
item.AssetType = assType;
item.InvType = inType;
item.Folder = parentFolder;
item.CurrentPermissions = (uint)PermissionMask.All;
item.BasePermissions = (uint)PermissionMask.All;
item.EveryOnePermissions = 0;
item.NextPermissions = (uint)(PermissionMask.Move | PermissionMask.Modify | PermissionMask.Transfer);
item.CreationDate = Util.UnixTimeSinceEpoch();
m_scene.AddInventoryItem(item);
}
}
}

View File

@ -113,6 +113,10 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
if (!m_scene.Permissions.CanTakeObject(part.UUID, remoteClient.AgentId))
return;
// TODO: this short circuits multiple attachments functionality in LL viewer 2.1+ and should
// be removed when that functionality is implemented in opensim
AttachmentPt &= 0x7f;
// Calls attach with a Zero position
if (AttachObject(remoteClient, part.ParentGroup, AttachmentPt, false))
{
@ -142,6 +146,10 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
if (m_scene.Permissions.CanTakeObject(group.UUID, remoteClient.AgentId))
{
// TODO: this short circuits multiple attachments functionality in LL viewer 2.1+ and should
// be removed when that functionality is implemented in opensim
AttachmentPt &= 0x7f;
// If the attachment point isn't the same as the one previously used
// set it's offset position = 0 so that it appears on the attachment point
// and not in a weird location somewhere unknown.
@ -228,6 +236,10 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
"[ATTACHMENTS MODULE]: Rezzing attachment to point {0} from item {1} for {2}",
(AttachmentPoint)AttachmentPt, itemID, remoteClient.Name);
// TODO: this short circuits multiple attachments functionality in LL viewer 2.1+ and should
// be removed when that functionality is implemented in opensim
AttachmentPt &= 0x7f;
SceneObjectGroup att = RezSingleAttachmentFromInventoryInternal(remoteClient, itemID, AttachmentPt);
if (updateInventoryStatus)

View File

@ -52,6 +52,12 @@ namespace OpenSim.Region.CoreModules.World.Archiver
{
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
/// <summary>
/// The maximum major version of OAR that we can read. Minor versions shouldn't need a number since version
/// bumps here should be compatible.
/// </summary>
public static int MAX_MAJOR_VERSION = 0;
protected Scene m_scene;
protected Stream m_loadStream;
protected Guid m_requestId;
@ -497,6 +503,22 @@ namespace OpenSim.Region.CoreModules.World.Archiver
{
if (xtr.NodeType == XmlNodeType.Element)
{
if (xtr.Name.ToString() == "archive")
{
int majorVersion = int.Parse(xtr["major_version"]);
int minorVersion = int.Parse(xtr["minor_version"]);
string version = string.Format("{0}.{1}", majorVersion, minorVersion);
if (majorVersion > MAX_MAJOR_VERSION)
{
throw new Exception(
string.Format(
"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",
majorVersion, MAX_MAJOR_VERSION));
}
m_log.InfoFormat("[ARCHIVER]: Loading OAR with version {0}", version);
}
if (xtr.Name.ToString() == "datetime")
{
int value;

View File

@ -60,6 +60,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver
protected Scene m_scene;
protected TarArchiveWriter m_archiveWriter;
protected Guid m_requestId;
protected Dictionary<string, object> m_options;
public ArchiveWriteRequestExecution(
List<SceneObjectGroup> sceneObjects,
@ -67,7 +68,8 @@ namespace OpenSim.Region.CoreModules.World.Archiver
IRegionSerialiserModule serialiser,
Scene scene,
TarArchiveWriter archiveWriter,
Guid requestId)
Guid requestId,
Dictionary<string, object> options)
{
m_sceneObjects = sceneObjects;
m_terrainModule = terrainModule;
@ -75,6 +77,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver
m_scene = scene;
m_archiveWriter = archiveWriter;
m_requestId = requestId;
m_options = options;
}
protected internal void ReceivedAllAssets(
@ -105,12 +108,6 @@ namespace OpenSim.Region.CoreModules.World.Archiver
// "[ARCHIVER]: Received {0} of {1} assets requested",
// assetsFoundUuids.Count, assetsFoundUuids.Count + assetsNotFoundUuids.Count);
m_log.InfoFormat("[ARCHIVER]: Creating archive file. This may take some time.");
// Write out control file
m_archiveWriter.WriteFile(ArchiveConstants.CONTROL_FILE_PATH, Create0p2ControlFile());
m_log.InfoFormat("[ARCHIVER]: Added control file to archive.");
// Write out region settings
string settingsPath
= String.Format("{0}{1}.xml", ArchiveConstants.SETTINGS_PATH, m_scene.RegionInfo.RegionName);
@ -140,47 +137,22 @@ namespace OpenSim.Region.CoreModules.World.Archiver
m_log.InfoFormat("[ARCHIVER]: Added terrain information to archive.");
Dictionary<string, object> serializationOptions = new Dictionary<string, object>();
// if (m_options.ContainsKey("version") && (string)m_options["version"] == "0")
// serializationOptions["old-guids"] = true;
// Write out scene object metadata
foreach (SceneObjectGroup sceneObject in m_sceneObjects)
{
//m_log.DebugFormat("[ARCHIVER]: Saving {0} {1}, {2}", entity.Name, entity.UUID, entity.GetType());
string serializedObject = m_serialiser.SerializeGroupToXml2(sceneObject);
string serializedObject = m_serialiser.SerializeGroupToXml2(sceneObject, serializationOptions);
m_archiveWriter.WriteFile(ArchiveHelpers.CreateObjectPath(sceneObject), serializedObject);
}
m_log.InfoFormat("[ARCHIVER]: Added scene objects to archive.");
}
/// <summary>
/// Create the control file for a 0.2 version archive
/// </summary>
/// <returns></returns>
public static string Create0p2ControlFile()
{
StringWriter sw = new StringWriter();
XmlTextWriter xtw = new XmlTextWriter(sw);
xtw.Formatting = Formatting.Indented;
xtw.WriteStartDocument();
xtw.WriteStartElement("archive");
xtw.WriteAttributeString("major_version", "0");
xtw.WriteAttributeString("minor_version", "3");
xtw.WriteStartElement("creation_info");
DateTime now = DateTime.UtcNow;
TimeSpan t = now - new DateTime(1970, 1, 1);
xtw.WriteElementString("datetime", ((int)t.TotalSeconds).ToString());
xtw.WriteElementString("id", UUID.Random().ToString());
xtw.WriteEndElement();
xtw.WriteEndElement();
xtw.Flush();
xtw.Close();
String s = sw.ToString();
sw.Close();
return s;
}
}
}

View File

@ -32,6 +32,7 @@ using System.IO.Compression;
using System.Reflection;
using System.Text.RegularExpressions;
using System.Threading;
using System.Xml;
using log4net;
using OpenMetaverse;
using OpenSim.Framework;
@ -98,7 +99,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver
/// Archive the region requested.
/// </summary>
/// <exception cref="System.IO.IOException">if there was an io problem with creating the file</exception>
public void ArchiveRegion()
public void ArchiveRegion(Dictionary<string, object> options)
{
Dictionary<UUID, AssetType> assetUuids = new Dictionary<UUID, AssetType>();
@ -165,11 +166,71 @@ namespace OpenSim.Region.CoreModules.World.Archiver
m_scene.RequestModuleInterface<IRegionSerialiserModule>(),
m_scene,
archiveWriter,
m_requestId);
m_requestId,
options);
m_log.InfoFormat("[ARCHIVER]: Creating archive file. This may take some time.");
// Write out control file
archiveWriter.WriteFile(ArchiveConstants.CONTROL_FILE_PATH, Create0p2ControlFile(options));
m_log.InfoFormat("[ARCHIVER]: Added control file to archive.");
new AssetsRequest(
new AssetsArchiver(archiveWriter), assetUuids,
m_scene.AssetService, awre.ReceivedAllAssets).Execute();
}
/// <summary>
/// Create the control file for the most up to date archive
/// </summary>
/// <returns></returns>
public static string Create0p2ControlFile(Dictionary<string, object> options)
{
int majorVersion = 0, minorVersion = 4;
/*
if (options.ContainsKey("version") && (string)options["version"] == "0")
{
majorVersion = 0;
minorVersion = 3;
}
else
{
majorVersion = 1;
minorVersion = 0;
}
*/
m_log.InfoFormat("[ARCHIVER]: Creating version {0}.{1} OAR", majorVersion, minorVersion);
// if (majorVersion == 1)
// {
// 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");
// }
StringWriter sw = new StringWriter();
XmlTextWriter xtw = new XmlTextWriter(sw);
xtw.Formatting = Formatting.Indented;
xtw.WriteStartDocument();
xtw.WriteStartElement("archive");
xtw.WriteAttributeString("major_version", majorVersion.ToString());
xtw.WriteAttributeString("minor_version", minorVersion.ToString());
xtw.WriteStartElement("creation_info");
DateTime now = DateTime.UtcNow;
TimeSpan t = now - new DateTime(1970, 1, 1);
xtw.WriteElementString("datetime", ((int)t.TotalSeconds).ToString());
xtw.WriteElementString("id", UUID.Random().ToString());
xtw.WriteEndElement();
xtw.WriteEndElement();
xtw.Flush();
xtw.Close();
String s = sw.ToString();
sw.Close();
return s;
}
}
}

View File

@ -122,27 +122,34 @@ namespace OpenSim.Region.CoreModules.World.Archiver
/// <param name="cmdparams"></param>
public void HandleSaveOarConsoleCommand(string module, string[] cmdparams)
{
Dictionary<string, object> options = new Dictionary<string, object>();
OptionSet ops = new OptionSet();
ops.Add("v|version=", delegate(string v) { options["version"] = v; });
List<string> mainParams = ops.Parse(cmdparams);
if (cmdparams.Length > 2)
{
ArchiveRegion(cmdparams[2]);
ArchiveRegion(mainParams[2], options);
}
else
{
ArchiveRegion(DEFAULT_OAR_BACKUP_FILENAME);
ArchiveRegion(DEFAULT_OAR_BACKUP_FILENAME, options);
}
}
public void ArchiveRegion(string savePath)
public void ArchiveRegion(string savePath, Dictionary<string, object> options)
{
ArchiveRegion(savePath, Guid.Empty);
ArchiveRegion(savePath, Guid.Empty, options);
}
public void ArchiveRegion(string savePath, Guid requestId)
public void ArchiveRegion(string savePath, Guid requestId, Dictionary<string, object> options)
{
m_log.InfoFormat(
"[ARCHIVER]: Writing archive for region {0} to {1}", m_scene.RegionInfo.RegionName, savePath);
new ArchiveWriteRequestPreparation(m_scene, savePath, requestId).ArchiveRegion();
new ArchiveWriteRequestPreparation(m_scene, savePath, requestId).ArchiveRegion(options);
}
public void ArchiveRegion(Stream saveStream)
@ -152,7 +159,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver
public void ArchiveRegion(Stream saveStream, Guid requestId)
{
new ArchiveWriteRequestPreparation(m_scene, saveStream, requestId).ArchiveRegion();
new ArchiveWriteRequestPreparation(m_scene, saveStream, requestId).ArchiveRegion(new Dictionary<string, object>());
}
public void DearchiveRegion(string loadPath)

View File

@ -230,7 +230,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver.Tests
// upset load
tar.WriteDir(ArchiveConstants.TERRAINS_PATH);
tar.WriteFile(ArchiveConstants.CONTROL_FILE_PATH, ArchiveWriteRequestExecution.Create0p2ControlFile());
tar.WriteFile(ArchiveConstants.CONTROL_FILE_PATH, ArchiveWriteRequestPreparation.Create0p2ControlFile(new Dictionary<string, Object>()));
SceneObjectPart part1 = CreateSceneObjectPart1();
SceneObjectGroup object1 = new SceneObjectGroup(part1);
@ -329,7 +329,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver.Tests
TarArchiveWriter tar = new TarArchiveWriter(archiveWriteStream);
tar.WriteDir(ArchiveConstants.TERRAINS_PATH);
tar.WriteFile(ArchiveConstants.CONTROL_FILE_PATH, ArchiveWriteRequestExecution.Create0p2ControlFile());
tar.WriteFile(ArchiveConstants.CONTROL_FILE_PATH, ArchiveWriteRequestPreparation.Create0p2ControlFile(new Dictionary<string, Object>()));
RegionSettings rs = new RegionSettings();
rs.AgentLimit = 17;

View File

@ -160,9 +160,9 @@ namespace OpenSim.Region.CoreModules.World.Serialiser
return SceneXmlLoader.DeserializeGroupFromXml2(xmlString);
}
public string SerializeGroupToXml2(SceneObjectGroup grp)
public string SerializeGroupToXml2(SceneObjectGroup grp, Dictionary<string, object> options)
{
return SceneXmlLoader.SaveGroupToXml2(grp);
return SceneXmlLoader.SaveGroupToXml2(grp, options);
}
public void SavePrimListToXml2(EntityBase[] entityList, string fileName)

View File

@ -25,6 +25,9 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
using System.Collections.Generic;
using System.IO;
using System.Xml;
using log4net.Config;
using NUnit.Framework;
using NUnit.Framework.SyntaxHelpers;
@ -34,8 +37,6 @@ using OpenSim.Region.Framework.Scenes;
using OpenSim.Region.Framework.Scenes.Serialization;
using OpenSim.Tests.Common;
using OpenSim.Tests.Common.Setup;
using System.IO;
using System.Xml;
namespace OpenSim.Region.CoreModules.World.Serialiser.Tests
{
@ -302,15 +303,19 @@ namespace OpenSim.Region.CoreModules.World.Serialiser.Tests
{
case "UUID":
xtr.ReadStartElement("UUID");
uuid = UUID.Parse(xtr.ReadElementString("Guid"));
try
{
uuid = UUID.Parse(xtr.ReadElementString("UUID"));
xtr.ReadEndElement();
}
catch { } // ignore everything but <UUID><UUID>...</UUID></UUID>
break;
case "Name":
name = xtr.ReadElementContentAsString();
break;
case "CreatorID":
xtr.ReadStartElement("CreatorID");
creatorId = UUID.Parse(xtr.ReadElementString("Guid"));
creatorId = UUID.Parse(xtr.ReadElementString("UUID"));
xtr.ReadEndElement();
break;
}
@ -369,7 +374,9 @@ namespace OpenSim.Region.CoreModules.World.Serialiser.Tests
// Need to add the object to the scene so that the request to get script state succeeds
m_scene.AddSceneObject(so);
string xml2 = m_serialiserModule.SerializeGroupToXml2(so);
Dictionary<string, object> options = new Dictionary<string, object>();
options["old-guids"] = true;
string xml2 = m_serialiserModule.SerializeGroupToXml2(so, options);
XmlTextReader xtr = new XmlTextReader(new StringReader(xml2));
xtr.ReadStartElement("SceneObjectGroup");

View File

@ -26,6 +26,7 @@
*/
using System;
using System.Collections.Generic;
using System.IO;
namespace OpenSim.Region.Framework.Interfaces
@ -46,7 +47,7 @@ namespace OpenSim.Region.Framework.Interfaces
/// the EventManager.OnOarFileSaved event.
///
/// <param name="savePath"></param>
void ArchiveRegion(string savePath);
void ArchiveRegion(string savePath, Dictionary<string, object> options);
/// <summary>
/// Archive the region to the given path
@ -57,7 +58,7 @@ namespace OpenSim.Region.Framework.Interfaces
///
/// <param name="savePath"></param>
/// <param name="requestId">If supplied, this request Id is later returned in the saved event</param>
void ArchiveRegion(string savePath, Guid requestId);
void ArchiveRegion(string savePath, Guid requestId, Dictionary<string, object> options);
/// <summary>
/// Archive the region to a stream.

View File

@ -117,6 +117,6 @@ namespace OpenSim.Region.Framework.Interfaces
/// </summary>
/// <param name="grp"></param>
/// <returns></returns>
string SerializeGroupToXml2(SceneObjectGroup grp);
string SerializeGroupToXml2(SceneObjectGroup grp, Dictionary<string, object> options);
}
}

View File

@ -39,6 +39,7 @@ using OpenMetaverse.Packets;
using OpenSim.Framework;
using OpenSim.Region.Framework.Interfaces;
using OpenSim.Region.Framework.Scenes.Scripting;
using OpenSim.Region.Framework.Scenes.Serialization;
using OpenSim.Region.Physics.Manager;
namespace OpenSim.Region.Framework.Scenes
@ -118,40 +119,36 @@ namespace OpenSim.Region.Framework.Scenes
/// <value>
/// Is this sop a root part?
/// </value>
[XmlIgnore]
public bool IsRoot
{
get { return ParentGroup.RootPart == this; }
}
// use only one serializer to give the runtime a chance to optimize it (it won't do that if you
// use a new instance every time)
private static XmlSerializer serializer = new XmlSerializer(typeof (SceneObjectPart));
#region Fields
public bool AllowedDrop;
[XmlIgnore]
public bool DIE_AT_EDGE;
[XmlIgnore]
public bool RETURN_AT_EDGE;
[XmlIgnore]
public bool BlockGrab;
[XmlIgnore]
public bool StatusSandbox;
[XmlIgnore]
public Vector3 StatusSandboxPos;
// TODO: This needs to be persisted in next XML version update!
[XmlIgnore]
public readonly int[] PayPrice = {-2,-2,-2,-2,-2};
[XmlIgnore]
public PhysicsActor PhysActor
{
get { return m_physActor; }
@ -166,43 +163,43 @@ namespace OpenSim.Region.Framework.Scenes
// Note: This isn't persisted in the database right now, as the fields for that aren't just there yet.
// Not a big problem as long as the script that sets it remains in the prim on startup.
// for SL compatibility it should be persisted though (set sound / displaytext / particlesystem, kill script)
[XmlIgnore]
public UUID Sound;
[XmlIgnore]
public byte SoundFlags;
[XmlIgnore]
public double SoundGain;
[XmlIgnore]
public double SoundRadius;
[XmlIgnore]
public uint TimeStampFull;
[XmlIgnore]
public uint TimeStampLastActivity; // Will be used for AutoReturn
[XmlIgnore]
public uint TimeStampTerse;
[XmlIgnore]
public UUID FromItemID;
[XmlIgnore]
public UUID FromFolderID;
[XmlIgnore]
public int STATUS_ROTATE_X;
[XmlIgnore]
public int STATUS_ROTATE_Y;
[XmlIgnore]
public int STATUS_ROTATE_Z;
[XmlIgnore]
private Dictionary<int, string> m_CollisionFilter = new Dictionary<int, string>();
/// <value>
@ -211,68 +208,68 @@ namespace OpenSim.Region.Framework.Scenes
/// </value>
private UUID m_fromUserInventoryItemID;
[XmlIgnore]
public UUID FromUserInventoryItemID
{
get { return m_fromUserInventoryItemID; }
}
[XmlIgnore]
public bool IsAttachment;
[XmlIgnore]
public scriptEvents AggregateScriptEvents;
[XmlIgnore]
public UUID AttachedAvatar;
[XmlIgnore]
public Vector3 AttachedPos;
[XmlIgnore]
public uint AttachmentPoint;
[XmlIgnore]
public Vector3 RotationAxis = Vector3.One;
[XmlIgnore]
public bool VolumeDetectActive; // XmlIgnore set to avoid problems with persistance until I come to care for this
// Certainly this must be a persistant setting finally
[XmlIgnore]
public bool IsWaitingForFirstSpinUpdatePacket;
[XmlIgnore]
public Quaternion SpinOldOrientation = Quaternion.Identity;
[XmlIgnore]
public Quaternion m_APIDTarget = Quaternion.Identity;
[XmlIgnore]
public float m_APIDDamp = 0;
[XmlIgnore]
public float m_APIDStrength = 0;
/// <summary>
/// This part's inventory
/// </summary>
[XmlIgnore]
public IEntityInventory Inventory
{
get { return m_inventory; }
}
protected SceneObjectPartInventory m_inventory;
[XmlIgnore]
public bool Undoing;
[XmlIgnore]
public bool IgnoreUndoUpdate = false;
[XmlIgnore]
private PrimFlags LocalFlags;
[XmlIgnore]
private float m_damage = -1.0f;
private byte[] m_TextureAnimation;
private byte m_clickAction;
@ -280,9 +277,9 @@ namespace OpenSim.Region.Framework.Scenes
private string m_description = String.Empty;
private readonly List<uint> m_lastColliders = new List<uint>();
private int m_linkNum;
[XmlIgnore]
private int m_scriptAccessPin;
[XmlIgnore]
private readonly Dictionary<UUID, scriptEvents> m_scriptEvents = new Dictionary<UUID, scriptEvents>();
private string m_sitName = String.Empty;
private Quaternion m_sitTargetOrientation = Quaternion.Identity;
@ -548,7 +545,7 @@ namespace OpenSim.Region.Framework.Scenes
}
[XmlIgnore]
public Dictionary<int, string> CollisionFilter
{
get { return m_CollisionFilter; }
@ -558,21 +555,21 @@ namespace OpenSim.Region.Framework.Scenes
}
}
[XmlIgnore]
public Quaternion APIDTarget
{
get { return m_APIDTarget; }
set { m_APIDTarget = value; }
}
[XmlIgnore]
public float APIDDamp
{
get { return m_APIDDamp; }
set { m_APIDDamp = value; }
}
[XmlIgnore]
public float APIDStrength
{
get { return m_APIDStrength; }
@ -618,35 +615,35 @@ namespace OpenSim.Region.Framework.Scenes
set { m_LoopSoundSlavePrims = value; }
}
[XmlIgnore]
public Byte[] TextureAnimation
{
get { return m_TextureAnimation; }
set { m_TextureAnimation = value; }
}
[XmlIgnore]
public Byte[] ParticleSystem
{
get { return m_particleSystem; }
set { m_particleSystem = value; }
}
[XmlIgnore]
public DateTime Expires
{
get { return m_expires; }
set { m_expires = value; }
}
[XmlIgnore]
public DateTime Rezzed
{
get { return m_rezzed; }
set { m_rezzed = value; }
}
[XmlIgnore]
public float Damage
{
get { return m_damage; }
@ -1019,7 +1016,7 @@ namespace OpenSim.Region.Framework.Scenes
}
}
[XmlIgnore]
public bool CreateSelected
{
get { return m_createSelected; }
@ -1201,14 +1198,14 @@ namespace OpenSim.Region.Framework.Scenes
}
}
[XmlIgnore]
public UUID SitTargetAvatar
{
get { return m_sitTargetAvatar; }
set { m_sitTargetAvatar = value; }
}
[XmlIgnore]
public virtual UUID RegionID
{
get
@ -1222,7 +1219,7 @@ namespace OpenSim.Region.Framework.Scenes
}
private UUID _parentUUID = UUID.Zero;
[XmlIgnore]
public UUID ParentUUID
{
get
@ -1236,7 +1233,7 @@ namespace OpenSim.Region.Framework.Scenes
set { _parentUUID = value; }
}
[XmlIgnore]
public string SitAnimation
{
get { return m_sitAnimation; }
@ -1850,7 +1847,7 @@ namespace OpenSim.Region.Framework.Scenes
/// </summary>
/// <param name="xmlReader"></param>
/// <returns></returns>
public static SceneObjectPart FromXml(XmlReader xmlReader)
public static SceneObjectPart FromXml(XmlTextReader xmlReader)
{
return FromXml(UUID.Zero, xmlReader);
}
@ -1861,9 +1858,9 @@ namespace OpenSim.Region.Framework.Scenes
/// <param name="fromUserInventoryItemId">The inventory id from which this part came, if applicable</param>
/// <param name="xmlReader"></param>
/// <returns></returns>
public static SceneObjectPart FromXml(UUID fromUserInventoryItemId, XmlReader xmlReader)
public static SceneObjectPart FromXml(UUID fromUserInventoryItemId, XmlTextReader xmlReader)
{
SceneObjectPart part = (SceneObjectPart)serializer.Deserialize(xmlReader);
SceneObjectPart part = SceneObjectSerializer.Xml2ToSOP(xmlReader);
part.m_fromUserInventoryItemID = fromUserInventoryItemId;
// for tempOnRez objects, we have to fix the Expire date.
@ -4058,9 +4055,9 @@ namespace OpenSim.Region.Framework.Scenes
/// Serialize this part to xml.
/// </summary>
/// <param name="xmlWriter"></param>
public void ToXml(XmlWriter xmlWriter)
public void ToXml(XmlTextWriter xmlWriter)
{
serializer.Serialize(xmlWriter, this);
SceneObjectSerializer.SOPToXml2(xmlWriter, this, new Dictionary<string, object>());
}
public void TriggerScriptChangedEvent(Changed val)

View File

@ -45,6 +45,7 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
{
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
#region old xml format
public static void LoadPrimsFromXml(Scene scene, string fileName, bool newIDS, Vector3 loadOffset)
{
XmlDocument doc = new XmlDocument();
@ -98,10 +99,127 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
file.Close();
}
public static string SaveGroupToXml2(SceneObjectGroup grp)
#endregion
#region XML2 serialization
// Called by archives (save oar)
public static string SaveGroupToXml2(SceneObjectGroup grp, Dictionary<string, object> options)
{
return SceneObjectSerializer.ToXml2Format(grp);
//return SceneObjectSerializer.ToXml2Format(grp);
using (MemoryStream mem = new MemoryStream())
{
using (XmlTextWriter writer = new XmlTextWriter(mem, System.Text.Encoding.UTF8))
{
SceneObjectSerializer.SOGToXml2(writer, grp, options);
writer.Flush();
using (StreamReader reader = new StreamReader(mem))
{
mem.Seek(0, SeekOrigin.Begin);
return reader.ReadToEnd();
}
}
}
}
// Called by scene serializer (save xml2)
public static void SavePrimsToXml2(Scene scene, string fileName)
{
EntityBase[] entityList = scene.GetEntities();
SavePrimListToXml2(entityList, fileName);
}
// Called by scene serializer (save xml2)
public static void SaveNamedPrimsToXml2(Scene scene, string primName, string fileName)
{
m_log.InfoFormat(
"[SERIALISER]: Saving prims with name {0} in xml2 format for region {1} to {2}",
primName, scene.RegionInfo.RegionName, fileName);
EntityBase[] entityList = scene.GetEntities();
List<EntityBase> primList = new List<EntityBase>();
foreach (EntityBase ent in entityList)
{
if (ent is SceneObjectGroup)
{
if (ent.Name == primName)
{
primList.Add(ent);
}
}
}
SavePrimListToXml2(primList.ToArray(), fileName);
}
// Called by REST Application plugin
public static void SavePrimsToXml2(Scene scene, TextWriter stream, Vector3 min, Vector3 max)
{
EntityBase[] entityList = scene.GetEntities();
SavePrimListToXml2(entityList, stream, min, max);
}
// Called here only. Should be private?
public static void SavePrimListToXml2(EntityBase[] entityList, string fileName)
{
FileStream file = new FileStream(fileName, FileMode.Create);
try
{
StreamWriter stream = new StreamWriter(file);
try
{
SavePrimListToXml2(entityList, stream, Vector3.Zero, Vector3.Zero);
}
finally
{
stream.Close();
}
}
finally
{
file.Close();
}
}
// Called here only. Should be private?
public static void SavePrimListToXml2(EntityBase[] entityList, TextWriter stream, Vector3 min, Vector3 max)
{
XmlTextWriter writer = new XmlTextWriter(stream);
int primCount = 0;
stream.WriteLine("<scene>\n");
foreach (EntityBase ent in entityList)
{
if (ent is SceneObjectGroup)
{
SceneObjectGroup g = (SceneObjectGroup)ent;
if (!min.Equals(Vector3.Zero) || !max.Equals(Vector3.Zero))
{
Vector3 pos = g.RootPart.GetWorldPosition();
if (min.X > pos.X || min.Y > pos.Y || min.Z > pos.Z)
continue;
if (max.X < pos.X || max.Y < pos.Y || max.Z < pos.Z)
continue;
}
//stream.WriteLine(SceneObjectSerializer.ToXml2Format(g));
SceneObjectSerializer.SOGToXml2(writer, (SceneObjectGroup)ent, new Dictionary<string,object>());
stream.WriteLine();
primCount++;
}
}
stream.WriteLine("</scene>\n");
stream.Flush();
}
#endregion
#region XML2 deserialization
public static SceneObjectGroup DeserializeGroupFromXml2(string xmlString)
{
@ -124,14 +242,30 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
foreach (XmlNode aPrimNode in rootNode.ChildNodes)
{
// There is only ever one prim. This oddity should be removeable post 0.5.9
return SceneObjectSerializer.FromXml2Format(aPrimNode.OuterXml);
//return SceneObjectSerializer.FromXml2Format(aPrimNode.OuterXml);
using (reader = new XmlTextReader(new StringReader(aPrimNode.OuterXml)))
{
SceneObjectGroup obj = new SceneObjectGroup();
if (SceneObjectSerializer.Xml2ToSOG(reader, obj))
return obj;
return null;
}
}
return null;
}
else
{
return SceneObjectSerializer.FromXml2Format(rootNode.OuterXml);
//return SceneObjectSerializer.FromXml2Format(rootNode.OuterXml);
using (reader = new XmlTextReader(new StringReader(rootNode.OuterXml)))
{
SceneObjectGroup obj = new SceneObjectGroup();
if (SceneObjectSerializer.Xml2ToSOG(reader, obj))
return obj;
return null;
}
}
}
@ -193,96 +327,19 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
/// <returns>The scene object created. null if the scene object already existed</returns>
protected static SceneObjectGroup CreatePrimFromXml2(Scene scene, string xmlData)
{
SceneObjectGroup obj = SceneObjectSerializer.FromXml2Format(xmlData);
//SceneObjectGroup obj = SceneObjectSerializer.FromXml2Format(xmlData);
using (XmlTextReader reader = new XmlTextReader(new StringReader(xmlData)))
{
SceneObjectGroup obj = new SceneObjectGroup();
SceneObjectSerializer.Xml2ToSOG(reader, obj);
if (scene.AddRestoredSceneObject(obj, true, false))
return obj;
else
return null;
}
public static void SavePrimsToXml2(Scene scene, string fileName)
{
EntityBase[] entityList = scene.GetEntities();
SavePrimListToXml2(entityList, fileName);
}
public static void SavePrimsToXml2(Scene scene, TextWriter stream, Vector3 min, Vector3 max)
{
EntityBase[] entityList = scene.GetEntities();
SavePrimListToXml2(entityList, stream, min, max);
}
public static void SaveNamedPrimsToXml2(Scene scene, string primName, string fileName)
{
m_log.InfoFormat(
"[SERIALISER]: Saving prims with name {0} in xml2 format for region {1} to {2}",
primName, scene.RegionInfo.RegionName, fileName);
EntityBase[] entityList = scene.GetEntities();
List<EntityBase> primList = new List<EntityBase>();
foreach (EntityBase ent in entityList)
{
if (ent is SceneObjectGroup)
{
if (ent.Name == primName)
{
primList.Add(ent);
}
}
}
SavePrimListToXml2(primList.ToArray(), fileName);
}
public static void SavePrimListToXml2(EntityBase[] entityList, string fileName)
{
FileStream file = new FileStream(fileName, FileMode.Create);
try
{
StreamWriter stream = new StreamWriter(file);
try
{
SavePrimListToXml2(entityList, stream, Vector3.Zero, Vector3.Zero);
}
finally
{
stream.Close();
}
}
finally
{
file.Close();
}
}
public static void SavePrimListToXml2(EntityBase[] entityList, TextWriter stream, Vector3 min, Vector3 max)
{
int primCount = 0;
stream.WriteLine("<scene>\n");
foreach (EntityBase ent in entityList)
{
if (ent is SceneObjectGroup)
{
SceneObjectGroup g = (SceneObjectGroup)ent;
if (!min.Equals(Vector3.Zero) || !max.Equals(Vector3.Zero))
{
Vector3 pos = g.RootPart.GetWorldPosition();
if (min.X > pos.X || min.Y > pos.Y || min.Z > pos.Z)
continue;
if (max.X < pos.X || max.Y < pos.Y || max.Z < pos.Z)
continue;
}
stream.WriteLine(SceneObjectSerializer.ToXml2Format(g));
primCount++;
}
}
stream.WriteLine("</scene>\n");
stream.Flush();
}
#endregion
}
}

View File

@ -31,8 +31,10 @@ using System.Collections.Generic;
using OpenSim.Framework;
using OpenSim.Region.Physics.Manager;
using OpenMetaverse;
using OpenMetaverse.StructuredData;
using System.Drawing;
using System.Drawing.Imaging;
using System.IO.Compression;
using PrimMesher;
using log4net;
using Nini.Config;
@ -256,13 +258,85 @@ namespace OpenSim.Region.Physics.Meshing
PrimMesh primMesh;
PrimMesher.SculptMesh sculptMesh;
List<Coord> coords;
List<Face> faces;
List<Coord> coords = new List<Coord>();
List<Face> faces = new List<Face>();
Image idata = null;
string decodedSculptFileName = "";
if (primShape.SculptEntry)
{
if (((OpenMetaverse.SculptType)primShape.SculptType) == SculptType.Mesh)
{
// add code for mesh physics proxy generation here
m_log.Debug("[MESH]: mesh proxy generation not implemented yet ");
OSD meshOsd;
if (primShape.SculptData.Length > 0)
{
m_log.Debug("[MESH]: asset data length: " + primShape.SculptData.Length.ToString());
byte[] header = Util.StringToBytes256("<? LLSD/Binary ?>");
////dump to debugging file
//string filename = System.IO.Path.Combine(decodedSculptMapPath, "mesh_" + primShape.SculptTexture.ToString());
//BinaryWriter writer = new BinaryWriter(File.Open(filename, FileMode.Create));
//writer.Write(primShape.SculptData);
//writer.Close();
}
else
{
m_log.Error("[MESH]: asset data is zero length");
return null;
}
try
{
meshOsd = OSDParser.DeserializeLLSDBinary(primShape.SculptData, true);
}
catch (Exception e)
{
m_log.Error("[MESH]: exception decoding mesh asset: " + e.ToString());
return null;
}
if (meshOsd is OSDMap)
{
OSDMap map = (OSDMap)meshOsd;
//foreach (string name in map.Keys)
// m_log.Debug("[MESH]: key:" + name + " value:" + map[name].AsString());
OSDMap physicsParms = (OSDMap)map["physics_shape"];
int physOffset = physicsParms["offset"].AsInteger();
int physSize = physicsParms["size"].AsInteger();
if (physOffset < 0 || physSize == 0)
return null; // no mesh data in asset
m_log.Debug("[MESH]: physOffset:" + physOffset.ToString() + " physSize:" + physSize.ToString());
//MemoryStream ms = new MemoryStream(primShape.SculptData, physOffset, physSize);
//GZipStream gzStream = new GZipStream(ms, CompressionMode.Decompress);
//int maxSize = physSize * 5; // arbitrary guess
//byte[] readBuffer = new byte[maxSize];
//int bytesRead = gzStream.Read(readBuffer, 0, maxSize);
//OSD physMeshOsd = OSDParser.DeserializeLLSDBinary(readBuffer);
}
//just bail out for now until mesh code is finished
return null;
}
else
{
if (cacheSculptMaps && primShape.SculptTexture != UUID.Zero)
{
@ -353,6 +427,7 @@ namespace OpenSim.Region.Physics.Meshing
coords = sculptMesh.coords;
faces = sculptMesh.faces;
}
}
else
{
float pathShearX = primShape.PathShearX < 128 ? (float)primShape.PathShearX * 0.01f : (float)(primShape.PathShearX - 256) * 0.01f;

View File

@ -2201,6 +2201,48 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
m_LSL_Api.SetPrimitiveParamsEx(prim, rules);
}
/// <summary>
/// Set parameters for light projection in host prim
/// </summary>
public void osSetProjectionParams(bool projection, LSL_Key texture, double fov, double focus, double amb)
{
CheckThreatLevel(ThreatLevel.High, "osSetProjectionParams");
osSetProjectionParams(UUID.Zero.ToString(), projection, texture, fov, focus, amb);
}
/// <summary>
/// Set parameters for light projection with uuid of target prim
/// </summary>
public void osSetProjectionParams(LSL_Key prim, bool projection, LSL_Key texture, double fov, double focus, double amb)
{
CheckThreatLevel(ThreatLevel.High, "osSetProjectionParams");
m_host.AddScriptLPS(1);
SceneObjectPart obj = null;
if (prim == UUID.Zero.ToString())
{
obj = m_host;
}
else
{
obj = World.GetSceneObjectPart(new UUID(prim));
if (obj == null)
return;
}
obj.Shape.ProjectionEntry = projection;
obj.Shape.ProjectionTextureUUID = new UUID(texture);
obj.Shape.ProjectionFOV = (float)fov;
obj.Shape.ProjectionFocus = (float)focus;
obj.Shape.ProjectionAmbiance = (float)amb;
obj.ParentGroup.HasGroupChanged = true;
obj.ScheduleFullUpdate();
}
/// <summary>
/// Like osGetAgents but returns enough info for a radar
/// </summary>

View File

@ -176,6 +176,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces
void osCauseDamage(string avatar, double damage);
LSL_List osGetPrimitiveParams(LSL_Key prim, LSL_List rules);
void osSetPrimitiveParams(LSL_Key prim, LSL_List rules);
void osSetProjectionParams(bool projection, LSL_Key texture, double fov, double focus, double amb);
void osSetProjectionParams(LSL_Key prim, bool projection, LSL_Key texture, double fov, double focus, double amb);
LSL_List osGetAvatarList();
}

View File

@ -688,6 +688,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
m_OSSL_Functions.osSetPrimitiveParams(prim, rules);
}
public void osSetProjectionParams(bool projection, LSL_Key texture, double fov, double focus, double amb)
{
m_OSSL_Functions.osSetProjectionParams(projection, texture, fov, focus, amb);
}
public void osSetProjectionParams(LSL_Key prim, bool projection, LSL_Key texture, double fov, double focus, double amb)
{
m_OSSL_Functions.osSetProjectionParams(prim, projection, texture, fov, focus, amb);
}
public LSL_List osGetAvatarList()
{
return m_OSSL_Functions.osGetAvatarList();

View File

@ -1,8 +1,8 @@
Welcome to OpenSim!
================
=== OVERVIEW ===
================
==================
==== OVERVIEW ====
==================
OpenSim is a BSD Licensed Open Source project to develop a functioning
virtual worlds server platform capable of supporting multiple clients

Binary file not shown.

View File

@ -175,7 +175,7 @@
<param name="toFind"></param>
<returns></returns>
</member>
<member name="M:OpenMetaverse.StructuredData.OSDParser.FindByteArray(System.IO.Stream,System.Byte[])">
<member name="M:OpenMetaverse.StructuredData.OSDParser.FindString(System.IO.Stream,System.String)">
<summary>
</summary>

Binary file not shown.

File diff suppressed because it is too large Load Diff

Binary file not shown.

File diff suppressed because it is too large Load Diff

Binary file not shown.

View File

@ -136,16 +136,15 @@
meshing = Meshmerizer
;meshing = ZeroMesher
;; Path to decoded sculpty maps
;; Defaults to "j2kDecodeCache
; Path to decoded sculpty maps
; Defaults to "j2kDecodeCache
;DecodedSculptMapPath = "j2kDecodeCache"
;# {CacheSculptMaps} {Cache decoded sculpt maps?} {true false} true
;; if you use Meshmerizer and want sculpt map collisions, setting this to
;; to true will store decoded sculpt maps in a special folder in your bin
;; folder, which can reduce startup times by reducing asset requests. Some
;; versions of mono dont work well when reading the cache files, so set this
;; to false if you have compatability problems.
; if you use Meshmerizer and want sculpt map collisions, setting this to
; to true will store decoded sculpt maps in a special folder in your bin
; folder, which can reduce startup times by reducing asset requests. Some
; versions of mono dont work well when reading the cache files, so set this
; to false if you have compatibility problems.
;CacheSculptMaps = true
; Choose one of the physics engines below

View File

@ -587,9 +587,11 @@
<ReferencePath>../../../../bin/</ReferencePath>
<Reference name="System"/>
<Reference name="System.Drawing"/>
<Reference name="System.IO.Compression;"/>
<Reference name="CSJ2K" path="../../../../bin/"/>
<Reference name="OpenMetaverseTypes" path="../../../../bin/"/>
<Reference name="OpenMetaverse" path="../../../../bin/"/>
<Reference name="OpenMetaverse.StructuredData" path="../../../../bin/"/>
<Reference name="Nini" path="../../../../bin/"/>
<Reference name="OpenSim.Framework"/>
<Reference name="OpenSim.Framework.Console"/>
@ -679,6 +681,7 @@
<Reference name="OpenSim.Framework.Servers.HttpServer"/>
<Reference name="OpenSim.Framework.Statistics"/>
<Reference name="OpenSim.Services.Interfaces"/>
<Reference name="OpenMetaverse" path="../../../bin/"/>
<Reference name="OpenMetaverseTypes" path="../../../bin/"/>
<!-- FIXME: The OpenMetaverse.dll reference can be dropped when the TransferRequestPacket reference is removed from the code -->
<Reference name="Nini" path="../../../bin/"/>