Get osNpcCreate appearance working with avatars that are currently in the scene.
Had to stop using AvatarService for now since it doesn't store baked texture IDs (which is why this was failing). Also failing because cloning appearance was also cloning the AvatarApperance.Owner field, which we weren't then changing. Extended TestCreate() to check this.bulletsim
parent
05e94ff27e
commit
59f548cda8
|
@ -77,7 +77,11 @@ namespace OpenSim.Framework
|
||||||
public virtual Primitive.TextureEntry Texture
|
public virtual Primitive.TextureEntry Texture
|
||||||
{
|
{
|
||||||
get { return m_texture; }
|
get { return m_texture; }
|
||||||
set { m_texture = value; }
|
set
|
||||||
|
{
|
||||||
|
// m_log.DebugFormat("[AVATAR APPEARANCE]: Set TextureEntry to {0}", value);
|
||||||
|
m_texture = value;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual AvatarWearable[] Wearables
|
public virtual AvatarWearable[] Wearables
|
||||||
|
|
|
@ -151,6 +151,10 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory
|
||||||
if (face == null)
|
if (face == null)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
// m_log.DebugFormat(
|
||||||
|
// "[AVFACTORY]: Looking for texture {0}, id {1} for {2} {3}",
|
||||||
|
// face.TextureID, idx, client.Name, client.AgentId);
|
||||||
|
|
||||||
// if the texture is one of the "defaults" then skip it
|
// if the texture is one of the "defaults" then skip it
|
||||||
// this should probably be more intelligent (skirt texture doesnt matter
|
// this should probably be more intelligent (skirt texture doesnt matter
|
||||||
// if the avatar isnt wearing a skirt) but if any of the main baked
|
// if the avatar isnt wearing a skirt) but if any of the main baked
|
||||||
|
|
|
@ -2647,7 +2647,8 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
/// <param name="avatar"></param>
|
/// <param name="avatar"></param>
|
||||||
public void SendAppearanceToAgent(ScenePresence avatar)
|
public void SendAppearanceToAgent(ScenePresence avatar)
|
||||||
{
|
{
|
||||||
// m_log.WarnFormat("[SP] Send appearance from {0} to {1}",m_uuid,avatar.ControllingClient.AgentId);
|
// m_log.DebugFormat(
|
||||||
|
// "[SCENE PRESENCE] Send appearance from {0} {1} to {2} {3}", Name, m_uuid, avatar.Name, avatar.UUID);
|
||||||
|
|
||||||
avatar.ControllingClient.SendAppearance(
|
avatar.ControllingClient.SendAppearance(
|
||||||
m_appearance.Owner, m_appearance.VisualParams, m_appearance.Texture.GetBytes());
|
m_appearance.Owner, m_appearance.VisualParams, m_appearance.Texture.GetBytes());
|
||||||
|
@ -2659,7 +2660,11 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
public AvatarAppearance Appearance
|
public AvatarAppearance Appearance
|
||||||
{
|
{
|
||||||
get { return m_appearance; }
|
get { return m_appearance; }
|
||||||
set { m_appearance = value; }
|
set
|
||||||
|
{
|
||||||
|
m_appearance = value;
|
||||||
|
// m_log.DebugFormat("[SCENE PRESENCE]: Set appearance for {0} to {1}", Name, value);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
|
@ -59,15 +59,22 @@ namespace OpenSim.Region.OptionalModules.World.NPC
|
||||||
if (m_appearanceCache.ContainsKey(target))
|
if (m_appearanceCache.ContainsKey(target))
|
||||||
return m_appearanceCache[target];
|
return m_appearanceCache[target];
|
||||||
|
|
||||||
AvatarAppearance appearance = scene.AvatarService.GetAppearance(target);
|
ScenePresence originalPresence = scene.GetScenePresence(target);
|
||||||
if (appearance != null)
|
|
||||||
|
if (originalPresence != null)
|
||||||
{
|
{
|
||||||
m_appearanceCache.Add(target, appearance);
|
AvatarAppearance originalAppearance = originalPresence.Appearance;
|
||||||
return appearance;
|
m_appearanceCache.Add(target, originalAppearance);
|
||||||
|
return originalAppearance;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
m_log.DebugFormat(
|
||||||
|
"[NPC MODULE]: Avatar {0} is not in the scene for us to grab baked textures from them. Using defaults.", target);
|
||||||
|
|
||||||
return new AvatarAppearance();
|
return new AvatarAppearance();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public UUID CreateNPC(string firstname, string lastname, Vector3 position, Scene scene, UUID cloneAppearanceFrom)
|
public UUID CreateNPC(string firstname, string lastname, Vector3 position, Scene scene, UUID cloneAppearanceFrom)
|
||||||
{
|
{
|
||||||
|
@ -86,8 +93,16 @@ namespace OpenSim.Region.OptionalModules.World.NPC
|
||||||
|
|
||||||
AvatarAppearance originalAppearance = GetAppearance(cloneAppearanceFrom, scene);
|
AvatarAppearance originalAppearance = GetAppearance(cloneAppearanceFrom, scene);
|
||||||
AvatarAppearance npcAppearance = new AvatarAppearance(originalAppearance, true);
|
AvatarAppearance npcAppearance = new AvatarAppearance(originalAppearance, true);
|
||||||
|
npcAppearance.Owner = acd.AgentID;
|
||||||
acd.Appearance = npcAppearance;
|
acd.Appearance = npcAppearance;
|
||||||
|
|
||||||
|
// for (int i = 0; i < acd.Appearance.Texture.FaceTextures.Length; i++)
|
||||||
|
// {
|
||||||
|
// m_log.DebugFormat(
|
||||||
|
// "[NPC MODULE]: NPC avatar {0} has texture id {1} : {2}",
|
||||||
|
// acd.AgentID, i, acd.Appearance.Texture.FaceTextures[i]);
|
||||||
|
// }
|
||||||
|
|
||||||
scene.AuthenticateHandler.AddNewCircuit(npcAvatar.CircuitCode, acd);
|
scene.AuthenticateHandler.AddNewCircuit(npcAvatar.CircuitCode, acd);
|
||||||
scene.AddNewClient(npcAvatar);
|
scene.AddNewClient(npcAvatar);
|
||||||
|
|
||||||
|
|
|
@ -27,11 +27,13 @@
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
|
using log4net;
|
||||||
using Nini.Config;
|
using Nini.Config;
|
||||||
using NUnit.Framework;
|
using NUnit.Framework;
|
||||||
using OpenMetaverse;
|
using OpenMetaverse;
|
||||||
using OpenSim.Framework;
|
using OpenSim.Framework;
|
||||||
using OpenSim.Framework.Communications;
|
using OpenSim.Framework.Communications;
|
||||||
|
using OpenSim.Region.CoreModules.Avatar.AvatarFactory;
|
||||||
using OpenSim.Region.CoreModules.ServiceConnectorsOut.Avatar;
|
using OpenSim.Region.CoreModules.ServiceConnectorsOut.Avatar;
|
||||||
using OpenSim.Region.Framework.Interfaces;
|
using OpenSim.Region.Framework.Interfaces;
|
||||||
using OpenSim.Region.Framework.Scenes;
|
using OpenSim.Region.Framework.Scenes;
|
||||||
|
@ -58,14 +60,31 @@ namespace OpenSim.Region.OptionalModules.World.NPC.Tests
|
||||||
config.Configs["AvatarService"].Set("LocalServiceModule", "OpenSim.Services.AvatarService.dll:AvatarService");
|
config.Configs["AvatarService"].Set("LocalServiceModule", "OpenSim.Services.AvatarService.dll:AvatarService");
|
||||||
config.Configs["AvatarService"].Set("StorageProvider", "OpenSim.Data.Null.dll");
|
config.Configs["AvatarService"].Set("StorageProvider", "OpenSim.Data.Null.dll");
|
||||||
|
|
||||||
|
AvatarFactoryModule afm = new AvatarFactoryModule();
|
||||||
TestScene scene = SceneSetupHelpers.SetupScene();
|
TestScene scene = SceneSetupHelpers.SetupScene();
|
||||||
SceneSetupHelpers.SetupSceneModules(scene, config, new NPCModule(), new LocalAvatarServicesConnector());
|
SceneSetupHelpers.SetupSceneModules(scene, config, afm, new NPCModule(), new LocalAvatarServicesConnector());
|
||||||
|
TestClient originalClient = SceneSetupHelpers.AddClient(scene, TestHelper.ParseTail(0x1));
|
||||||
|
// ScenePresence originalAvatar = scene.GetScenePresence(originalClient.AgentId);
|
||||||
|
|
||||||
|
// 8 is the index of the first baked texture in AvatarAppearance
|
||||||
|
UUID originalFace8TextureId = TestHelper.ParseTail(0x10);
|
||||||
|
Primitive.TextureEntry originalTe = new Primitive.TextureEntry(UUID.Zero);
|
||||||
|
Primitive.TextureEntryFace originalTef = originalTe.CreateFace(8);
|
||||||
|
originalTef.TextureID = originalFace8TextureId;
|
||||||
|
|
||||||
|
// We also need to add the texture to the asset service, otherwise the AvatarFactoryModule will tell
|
||||||
|
// ScenePresence.SendInitialData() to reset our entire appearance.
|
||||||
|
scene.AssetService.Store(AssetHelpers.CreateAsset(originalFace8TextureId));
|
||||||
|
|
||||||
|
afm.SetAppearance(originalClient, originalTe, null);
|
||||||
|
|
||||||
INPCModule npcModule = scene.RequestModuleInterface<INPCModule>();
|
INPCModule npcModule = scene.RequestModuleInterface<INPCModule>();
|
||||||
UUID npcId = npcModule.CreateNPC("John", "Smith", new Vector3(128, 128, 30), scene, UUID.Zero);
|
UUID npcId = npcModule.CreateNPC("John", "Smith", new Vector3(128, 128, 30), scene, originalClient.AgentId);
|
||||||
|
|
||||||
ScenePresence npc = scene.GetScenePresence(npcId);
|
ScenePresence npc = scene.GetScenePresence(npcId);
|
||||||
|
|
||||||
Assert.That(npc, Is.Not.Null);
|
Assert.That(npc, Is.Not.Null);
|
||||||
|
Assert.That(npc.Appearance.Texture.FaceTextures[8].TextureID, Is.EqualTo(originalFace8TextureId));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -42,7 +42,7 @@ namespace OpenSim.Tests.Common
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public static AssetBase CreateAsset()
|
public static AssetBase CreateAsset()
|
||||||
{
|
{
|
||||||
return CreateAsset(UUID.Random(), AssetType.Notecard, "hello", UUID.Random());
|
return CreateAsset(UUID.Random());
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -50,9 +50,9 @@ namespace OpenSim.Tests.Common
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="creatorId">/param>
|
/// <param name="creatorId">/param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public static AssetBase CreateAsset(UUID creatorId)
|
public static AssetBase CreateAsset(UUID id)
|
||||||
{
|
{
|
||||||
return CreateAsset(UUID.Random(), AssetType.Notecard, "hello", creatorId);
|
return CreateAsset(id, AssetType.Notecard, "hello", UUID.Random());
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
|
@ -0,0 +1,33 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8" ?>
|
||||||
|
<configuration>
|
||||||
|
<configSections>
|
||||||
|
<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler,log4net" />
|
||||||
|
</configSections>
|
||||||
|
<runtime>
|
||||||
|
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
|
||||||
|
<dependentAssembly>
|
||||||
|
<assemblyIdentity name="nunit.framework" publicKeyToken="96d09a1eb7f44a77" culture="Neutral" />
|
||||||
|
<bindingRedirect oldVersion="2.0.6.0" newVersion="2.4.6.0" />
|
||||||
|
<bindingRedirect oldVersion="2.1.4.0" newVersion="2.4.6.0" />
|
||||||
|
<bindingRedirect oldVersion="2.2.8.0" newVersion="2.4.6.0" />
|
||||||
|
</dependentAssembly>
|
||||||
|
</assemblyBinding>
|
||||||
|
</runtime>
|
||||||
|
<log4net>
|
||||||
|
<!-- A1 is set to be a ConsoleAppender -->
|
||||||
|
<appender name="A1" type="log4net.Appender.ConsoleAppender">
|
||||||
|
|
||||||
|
<!-- A1 uses PatternLayout -->
|
||||||
|
<layout type="log4net.Layout.PatternLayout">
|
||||||
|
<!-- Print the date in ISO 8601 format -->
|
||||||
|
<conversionPattern value="%date [%thread] %-5level %logger %ndc - %message%newline" />
|
||||||
|
</layout>
|
||||||
|
</appender>
|
||||||
|
|
||||||
|
<!-- Set root logger level to DEBUG and its only appender to A1 -->
|
||||||
|
<root>
|
||||||
|
<level value="DEBUG" />
|
||||||
|
<appender-ref ref="A1" />
|
||||||
|
</root>
|
||||||
|
</log4net>
|
||||||
|
</configuration>
|
Loading…
Reference in New Issue