mirror of
https://github.com/opensim/opensim.git
synced 2026-08-07 17:55:48 +08:00
Major refactoring of appearance handling.
AvatarService -- add two new methods, GetAppearance and SetAppearance to get around the lossy encoding in AvatarData. Preseve the old functions to avoid changing the behavior for ROBUST services. AvatarAppearance -- major refactor, moved the various encoding methods used by AgentCircuitData, ClientAgentUpdate and ScenePresence into one location. Changed initialization. AvatarAttachments -- added a class specifically to handle attachments in preparation for additional functionality that will be needed for viewer 2. AvatarFactory -- removed a number of unused or methods duplicated in other locations. Moved in all appearance event handling from ScenePresence. Required a change to IClientAPI that propogated throughout all the IClientAPI implementations.
This commit is contained in:
@@ -26,7 +26,9 @@
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.Reflection;
|
||||
using System.Collections.Generic;
|
||||
using log4net;
|
||||
using OpenMetaverse;
|
||||
using OpenMetaverse.StructuredData;
|
||||
|
||||
@@ -38,6 +40,12 @@ namespace OpenSim.Framework
|
||||
/// </summary>
|
||||
public class AgentCircuitData
|
||||
{
|
||||
// DEBUG ON
|
||||
private static readonly ILog m_log =
|
||||
LogManager.GetLogger(
|
||||
MethodBase.GetCurrentMethod().DeclaringType);
|
||||
// DEBUG OFF
|
||||
|
||||
/// <summary>
|
||||
/// Avatar Unique Agent Identifier
|
||||
/// </summary>
|
||||
@@ -205,6 +213,7 @@ namespace OpenSim.Framework
|
||||
args["mac"] = OSD.FromString(Mac);
|
||||
args["id0"] = OSD.FromString(Id0);
|
||||
|
||||
/*
|
||||
if (Appearance != null)
|
||||
{
|
||||
//System.Console.WriteLine("XXX Before packing Wearables");
|
||||
@@ -221,20 +230,26 @@ namespace OpenSim.Framework
|
||||
}
|
||||
|
||||
//System.Console.WriteLine("XXX Before packing Attachments");
|
||||
Dictionary<int, UUID[]> attachments = Appearance.GetAttachmentDictionary();
|
||||
Dictionary<int, AvatarAttachment> attachments = Appearance.Attachments;
|
||||
if ((attachments != null) && (attachments.Count > 0))
|
||||
{
|
||||
OSDArray attachs = new OSDArray(attachments.Count);
|
||||
foreach (KeyValuePair<int, UUID[]> kvp in attachments)
|
||||
foreach (KeyValuePair<int, AvatarAttachment> kvp in attachments)
|
||||
{
|
||||
AttachmentData adata = new AttachmentData(kvp.Key, kvp.Value[0], kvp.Value[1]);
|
||||
attachs.Add(adata.PackUpdateMessage());
|
||||
AvatarAttachment adata = new AvatarAttachment(kvp.Value);
|
||||
attachs.Add(adata.Pack());
|
||||
//System.Console.WriteLine("XXX att.pt=" + kvp.Key + "; itemID=" + kvp.Value[0] + "; assetID=" + kvp.Value[1]);
|
||||
}
|
||||
args["attachments"] = attachs;
|
||||
}
|
||||
}
|
||||
|
||||
*/
|
||||
if (Appearance != null)
|
||||
{
|
||||
OSDMap appmap = Appearance.Pack();
|
||||
args["packed_appearance"] = appmap;
|
||||
}
|
||||
|
||||
if (ServiceURLs != null && ServiceURLs.Count > 0)
|
||||
{
|
||||
OSDArray urls = new OSDArray(ServiceURLs.Count * 2);
|
||||
@@ -317,9 +332,37 @@ namespace OpenSim.Framework
|
||||
if (args["start_pos"] != null)
|
||||
Vector3.TryParse(args["start_pos"].AsString(), out startpos);
|
||||
|
||||
// DEBUG ON
|
||||
m_log.WarnFormat("[AGENTCIRCUITDATA] agentid={0}, child={1}, startpos={2}",AgentID,child,startpos.ToString());
|
||||
// DEBUG OFF
|
||||
|
||||
try {
|
||||
// Unpack various appearance elements
|
||||
Appearance = new AvatarAppearance(AgentID);
|
||||
if (args["packed_appearance"] != null)
|
||||
{
|
||||
if (args["packed_appearance"].Type == OSDType.Map)
|
||||
{
|
||||
Appearance.Unpack((OSDMap)args["packed_appearance"]);
|
||||
m_log.WarnFormat("[AGENTCIRCUITDATA] unpacked appearance");
|
||||
}
|
||||
else
|
||||
m_log.WarnFormat("[AGENTCIRCUITDATA] packed_appearance is not a map:\n{0}",args["packed_appearance"].ToString());
|
||||
}
|
||||
// DEBUG ON
|
||||
else
|
||||
m_log.Warn("[AGENTCIRCUITDATA] failed to find a valid packed_appearance");
|
||||
// DEBUG OFF
|
||||
} catch (Exception e)
|
||||
{
|
||||
m_log.ErrorFormat("[AGENTCIRCUITDATA] failed to unpack appearance; {0}",e.Message);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
if (args["appearance_serial"] != null)
|
||||
Appearance.Serial = args["appearance_serial"].AsInteger();
|
||||
|
||||
if ((args["wearables"] != null) && (args["wearables"]).Type == OSDType.Array)
|
||||
{
|
||||
OSDArray wears = (OSDArray)(args["wearables"]);
|
||||
@@ -328,23 +371,23 @@ namespace OpenSim.Framework
|
||||
Appearance.Wearables[i].ItemID = wears[i*2].AsUUID();
|
||||
Appearance.Wearables[i].AssetID = wears[(i*2)+1].AsUUID();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ((args["attachments"] != null) && (args["attachments"]).Type == OSDType.Array)
|
||||
{
|
||||
OSDArray attachs = (OSDArray)(args["attachments"]);
|
||||
AttachmentData[] attachments = new AttachmentData[attachs.Count];
|
||||
AvatarAttachment[] attachments = new AvatarAttachment[attachs.Count];
|
||||
int i = 0;
|
||||
foreach (OSD o in attachs)
|
||||
{
|
||||
if (o.Type == OSDType.Map)
|
||||
{
|
||||
attachments[i++] = new AttachmentData((OSDMap)o);
|
||||
attachments[i++] = new AvatarAttachment((OSDMap)o);
|
||||
}
|
||||
}
|
||||
Appearance.SetAttachments(attachments);
|
||||
}
|
||||
|
||||
*/
|
||||
ServiceURLs = new Dictionary<string, object>();
|
||||
if (args.ContainsKey("service_urls") && args["service_urls"] != null && (args["service_urls"]).Type == OSDType.Array)
|
||||
{
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
78
OpenSim/Framework/AvatarAttachment.cs
Normal file
78
OpenSim/Framework/AvatarAttachment.cs
Normal file
@@ -0,0 +1,78 @@
|
||||
/*
|
||||
* 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 OpenMetaverse;
|
||||
using OpenMetaverse.StructuredData;
|
||||
|
||||
namespace OpenSim.Framework
|
||||
{
|
||||
public class AvatarAttachment
|
||||
{
|
||||
public int AttachPoint;
|
||||
public UUID ItemID;
|
||||
public UUID AssetID;
|
||||
|
||||
public AvatarAttachment(AvatarAttachment attach)
|
||||
{
|
||||
AttachPoint = attach.AttachPoint;
|
||||
ItemID = attach.ItemID;
|
||||
AssetID = attach.AssetID;
|
||||
}
|
||||
|
||||
public AvatarAttachment(int point, UUID item, UUID asset)
|
||||
{
|
||||
AttachPoint = point;
|
||||
ItemID = item;
|
||||
AssetID = asset;
|
||||
}
|
||||
|
||||
public AvatarAttachment(OSDMap args)
|
||||
{
|
||||
Unpack(args);
|
||||
}
|
||||
|
||||
public OSDMap Pack()
|
||||
{
|
||||
OSDMap attachdata = new OSDMap();
|
||||
attachdata["point"] = OSD.FromInteger(AttachPoint);
|
||||
attachdata["item"] = OSD.FromUUID(ItemID);
|
||||
attachdata["asset"] = OSD.FromUUID(AssetID);
|
||||
|
||||
return attachdata;
|
||||
}
|
||||
|
||||
|
||||
public void Unpack(OSDMap args)
|
||||
{
|
||||
if (args["point"] != null)
|
||||
AttachPoint = args["point"].AsInteger();
|
||||
ItemID = (args["item"] != null) ? args["item"].AsUUID() : UUID.Zero;
|
||||
AssetID = (args["asset"] != null) ? args["asset"].AsUUID() : UUID.Zero;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -26,14 +26,32 @@
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.Runtime.Serialization;
|
||||
using System.Security.Permissions;
|
||||
using OpenMetaverse;
|
||||
using OpenMetaverse.StructuredData;
|
||||
|
||||
namespace OpenSim.Framework
|
||||
{
|
||||
public class AvatarWearable
|
||||
{
|
||||
// these are guessed at by the list here -
|
||||
// http://wiki.secondlife.com/wiki/Avatar_Appearance. We'll
|
||||
// correct them over time for when were are wrong.
|
||||
public static readonly int BODY = 0;
|
||||
public static readonly int SKIN = 1;
|
||||
public static readonly int HAIR = 2;
|
||||
public static readonly int EYES = 3;
|
||||
public static readonly int SHIRT = 4;
|
||||
public static readonly int PANTS = 5;
|
||||
public static readonly int SHOES = 6;
|
||||
public static readonly int SOCKS = 7;
|
||||
public static readonly int JACKET = 8;
|
||||
public static readonly int GLOVES = 9;
|
||||
public static readonly int UNDERSHIRT = 10;
|
||||
public static readonly int UNDERPANTS = 11;
|
||||
public static readonly int SKIRT = 12;
|
||||
|
||||
public static readonly int MAX_WEARABLES = 13;
|
||||
|
||||
public static readonly UUID DEFAULT_BODY_ITEM = new UUID("66c41e39-38f9-f75a-024e-585989bfaba9");
|
||||
public static readonly UUID DEFAULT_BODY_ASSET = new UUID("66c41e39-38f9-f75a-024e-585989bfab73");
|
||||
|
||||
@@ -62,12 +80,32 @@ namespace OpenSim.Framework
|
||||
ItemID = itemId;
|
||||
}
|
||||
|
||||
public AvatarWearable(OSDMap args)
|
||||
{
|
||||
Unpack(args);
|
||||
}
|
||||
|
||||
public OSDMap Pack()
|
||||
{
|
||||
OSDMap weardata = new OSDMap();
|
||||
weardata["item"] = OSD.FromUUID(ItemID);
|
||||
weardata["asset"] = OSD.FromUUID(AssetID);
|
||||
|
||||
return weardata;
|
||||
}
|
||||
|
||||
public void Unpack(OSDMap args)
|
||||
{
|
||||
ItemID = (args["item"] != null) ? args["item"].AsUUID() : UUID.Zero;
|
||||
AssetID = (args["asset"] != null) ? args["asset"].AsUUID() : UUID.Zero;
|
||||
}
|
||||
|
||||
public static AvatarWearable[] DefaultWearables
|
||||
{
|
||||
get
|
||||
{
|
||||
AvatarWearable[] defaultWearables = new AvatarWearable[13]; //should be 13 of these
|
||||
for (int i = 0; i < 13; i++)
|
||||
AvatarWearable[] defaultWearables = new AvatarWearable[MAX_WEARABLES]; //should be 13 of these
|
||||
for (int i = 0; i < MAX_WEARABLES; i++)
|
||||
{
|
||||
defaultWearables[i] = new AvatarWearable();
|
||||
}
|
||||
|
||||
@@ -976,7 +976,9 @@ namespace OpenSim.Framework.Capabilities
|
||||
|
||||
public void BakedTextureUploaded(UUID assetID, byte[] data)
|
||||
{
|
||||
m_log.DebugFormat("[CAPS]: Received baked texture {0}", assetID.ToString());
|
||||
// DEBUG ON
|
||||
m_log.WarnFormat("[CAPS]: Received baked texture {0}", assetID.ToString());
|
||||
// DEBUG OFF
|
||||
AssetBase asset;
|
||||
asset = new AssetBase(assetID, "Baked Texture", (sbyte)AssetType.Texture, m_agentID.ToString());
|
||||
asset.Data = data;
|
||||
|
||||
@@ -225,46 +225,6 @@ namespace OpenSim.Framework
|
||||
}
|
||||
}
|
||||
|
||||
public class AttachmentData
|
||||
{
|
||||
public int AttachPoint;
|
||||
public UUID ItemID;
|
||||
public UUID AssetID;
|
||||
|
||||
public AttachmentData(int point, UUID item, UUID asset)
|
||||
{
|
||||
AttachPoint = point;
|
||||
ItemID = item;
|
||||
AssetID = asset;
|
||||
}
|
||||
|
||||
public AttachmentData(OSDMap args)
|
||||
{
|
||||
UnpackUpdateMessage(args);
|
||||
}
|
||||
|
||||
public OSDMap PackUpdateMessage()
|
||||
{
|
||||
OSDMap attachdata = new OSDMap();
|
||||
attachdata["point"] = OSD.FromInteger(AttachPoint);
|
||||
attachdata["item"] = OSD.FromUUID(ItemID);
|
||||
attachdata["asset"] = OSD.FromUUID(AssetID);
|
||||
|
||||
return attachdata;
|
||||
}
|
||||
|
||||
|
||||
public void UnpackUpdateMessage(OSDMap args)
|
||||
{
|
||||
if (args["point"] != null)
|
||||
AttachPoint = args["point"].AsInteger();
|
||||
if (args["item"] != null)
|
||||
ItemID = args["item"].AsUUID();
|
||||
if (args["asset"] != null)
|
||||
AssetID = args["asset"].AsUUID();
|
||||
}
|
||||
}
|
||||
|
||||
public class ControllerData
|
||||
{
|
||||
public UUID ItemID;
|
||||
@@ -348,11 +308,14 @@ namespace OpenSim.Framework
|
||||
public UUID GranterID;
|
||||
|
||||
// Appearance
|
||||
public AvatarAppearance Appearance;
|
||||
|
||||
/*
|
||||
public byte[] AgentTextures;
|
||||
public byte[] VisualParams;
|
||||
public UUID[] Wearables;
|
||||
public AttachmentData[] Attachments;
|
||||
|
||||
public AvatarAttachment[] Attachments;
|
||||
*/
|
||||
// Scripted
|
||||
public ControllerData[] Controllers;
|
||||
|
||||
@@ -413,6 +376,9 @@ namespace OpenSim.Framework
|
||||
args["animations"] = anims;
|
||||
}
|
||||
|
||||
if (Appearance != null)
|
||||
args["packed_appearance"] = Appearance.Pack();
|
||||
|
||||
//if ((AgentTextures != null) && (AgentTextures.Length > 0))
|
||||
//{
|
||||
// OSDArray textures = new OSDArray(AgentTextures.Length);
|
||||
@@ -421,7 +387,7 @@ namespace OpenSim.Framework
|
||||
// args["agent_textures"] = textures;
|
||||
//}
|
||||
|
||||
|
||||
/*
|
||||
if ((AgentTextures != null) && (AgentTextures.Length > 0))
|
||||
args["texture_entry"] = OSD.FromBinary(AgentTextures);
|
||||
|
||||
@@ -441,11 +407,11 @@ namespace OpenSim.Framework
|
||||
if ((Attachments != null) && (Attachments.Length > 0))
|
||||
{
|
||||
OSDArray attachs = new OSDArray(Attachments.Length);
|
||||
foreach (AttachmentData att in Attachments)
|
||||
attachs.Add(att.PackUpdateMessage());
|
||||
foreach (AvatarAttachment att in Attachments)
|
||||
attachs.Add(att.Pack());
|
||||
args["attachments"] = attachs;
|
||||
}
|
||||
|
||||
*/
|
||||
if ((Controllers != null) && (Controllers.Length > 0))
|
||||
{
|
||||
OSDArray controls = new OSDArray(Controllers.Length);
|
||||
@@ -581,6 +547,12 @@ namespace OpenSim.Framework
|
||||
// AgentTextures[i++] = o.AsUUID();
|
||||
//}
|
||||
|
||||
if (args["packed_appearance"] != null)
|
||||
Appearance = new AvatarAppearance(AgentID,(OSDMap)args["packed_appearance"]);
|
||||
else
|
||||
Appearance = new AvatarAppearance(AgentID);
|
||||
|
||||
/*
|
||||
if (args["texture_entry"] != null)
|
||||
AgentTextures = args["texture_entry"].AsBinary();
|
||||
|
||||
@@ -599,17 +571,17 @@ namespace OpenSim.Framework
|
||||
if ((args["attachments"] != null) && (args["attachments"]).Type == OSDType.Array)
|
||||
{
|
||||
OSDArray attachs = (OSDArray)(args["attachments"]);
|
||||
Attachments = new AttachmentData[attachs.Count];
|
||||
Attachments = new AvatarAttachment[attachs.Count];
|
||||
int i = 0;
|
||||
foreach (OSD o in attachs)
|
||||
{
|
||||
if (o.Type == OSDType.Map)
|
||||
{
|
||||
Attachments[i++] = new AttachmentData((OSDMap)o);
|
||||
Attachments[i++] = new AvatarAttachment((OSDMap)o);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
*/
|
||||
if ((args["controllers"] != null) && (args["controllers"]).Type == OSDType.Array)
|
||||
{
|
||||
OSDArray controls = (OSDArray)(args["controllers"]);
|
||||
|
||||
@@ -43,7 +43,7 @@ namespace OpenSim.Framework
|
||||
|
||||
public delegate void TextureRequest(Object sender, TextureRequestArgs e);
|
||||
|
||||
public delegate void AvatarNowWearing(Object sender, AvatarWearingArgs e);
|
||||
public delegate void AvatarNowWearing(IClientAPI sender, AvatarWearingArgs e);
|
||||
|
||||
public delegate void ImprovedInstantMessage(IClientAPI remoteclient, GridInstantMessage im);
|
||||
|
||||
@@ -65,7 +65,7 @@ namespace OpenSim.Framework
|
||||
|
||||
public delegate void NetworkStats(int inPackets, int outPackets, int unAckedBytes);
|
||||
|
||||
public delegate void SetAppearance(Primitive.TextureEntry textureEntry, byte[] visualParams);
|
||||
public delegate void SetAppearance(IClientAPI remoteClient, Primitive.TextureEntry textureEntry, byte[] visualParams);
|
||||
|
||||
public delegate void StartAnim(IClientAPI remoteClient, UUID animID);
|
||||
|
||||
@@ -711,7 +711,7 @@ namespace OpenSim.Framework
|
||||
event TeleportLandmarkRequest OnTeleportLandmarkRequest;
|
||||
event DeRezObject OnDeRezObject;
|
||||
event Action<IClientAPI> OnRegionHandShakeReply;
|
||||
event GenericCall2 OnRequestWearables;
|
||||
event GenericCall1 OnRequestWearables;
|
||||
event GenericCall1 OnCompleteMovementToRegion;
|
||||
event UpdateAgent OnPreAgentUpdate;
|
||||
event UpdateAgent OnAgentUpdate;
|
||||
|
||||
@@ -65,9 +65,7 @@ namespace OpenSim.Framework.Tests
|
||||
SessionId = UUID.Random();
|
||||
|
||||
AvAppearance = new AvatarAppearance(AgentId);
|
||||
AvAppearance.SetDefaultWearables();
|
||||
VisualParams = new byte[218];
|
||||
AvAppearance.SetDefaultParams(VisualParams);
|
||||
|
||||
//body
|
||||
VisualParams[(int)AvatarAppearance.VPElement.SHAPE_HEIGHT] = 155;
|
||||
|
||||
Reference in New Issue
Block a user