From c4efb97d49dec736151dfa3fa102efe6a5f6fbab Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Thu, 15 Sep 2011 22:59:29 +0100 Subject: Write code to create minimum necessary body parts/clothing and avatar entries to make a newly created user appear as a non-cloud on viewer 2 Viewer 2 no longer contains the default avatar assets (i.e. "Ruth") that would appear if the user had insufficient body part/clothing entries. Instead, avatars always appear as a cloud, which is a very bad experience for out-of-the-box OpenSim. Default is currently off. My intention is to switch it on for standalone shortly. This is not particularly flexible as "Ruth" is hardcoded, but this can change in the future, in co-ordination with the existing RemoteAdmin capabilities. Need to fix creation of suitable entries for users created as estate owners on standalone. Avatars still appear with spooky empty eyes, need to see if we can address this. This commit adds a "Default Iris" to the library (thanks to Eirynne Sieyes from http://opensimulator.org/mantis/view.php?id=1461) which can be used. --- .../Avatar/AvatarFactory/AvatarFactoryModule.cs | 2 +- OpenSim/Region/Framework/Scenes/Scene.cs | 1 + .../UserAccountService/UserAccountService.cs | 152 ++++++++++++++- bin/assets/BodyPartsAssetSet/BodyPartsAssetSet.xml | 10 +- bin/assets/BodyPartsAssetSet/base_eyes.dat | 26 +++ bin/assets/BodyPartsAssetSet/base_hair.dat | 26 +++ bin/assets/BodyPartsAssetSet/base_shape.dat | 212 +++++++++++++-------- bin/assets/BodyPartsAssetSet/newhair.dat | 63 ------ bin/assets/TexturesAssetSet/TexturesAssetSet.xml | 7 + bin/assets/TexturesAssetSet/default_iris.jp2 | Bin 0 -> 15719 bytes bin/config-include/Standalone.ini | 1 + .../TexturesLibrary/TexturesLibraryItems.xml | 10 + 12 files changed, 362 insertions(+), 148 deletions(-) create mode 100644 bin/assets/BodyPartsAssetSet/base_eyes.dat create mode 100644 bin/assets/BodyPartsAssetSet/base_hair.dat delete mode 100644 bin/assets/BodyPartsAssetSet/newhair.dat create mode 100644 bin/assets/TexturesAssetSet/default_iris.jp2 diff --git a/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs b/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs index b6a1564..c5a1828 100644 --- a/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs @@ -467,7 +467,7 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory return; } - // m_log.WarnFormat("[AVFACTORY]: Received request for wearables of {0}", client.AgentId); +// m_log.DebugFormat("[AVFACTORY]: Received request for wearables of {0}", client.Name); client.SendWearables(sp.Appearance.Wearables, sp.Appearance.Serial++); } diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index c5c9260..f394a95 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -1237,6 +1237,7 @@ namespace OpenSim.Region.Framework.Scenes first, last); + m_log.InfoFormat("[USER ACCOUNT SERVICE]: Account {0} {1} created successfully", first, last); m_regInfo.EstateSettings.EstateOwner = account.PrincipalID; diff --git a/OpenSim/Services/UserAccountService/UserAccountService.cs b/OpenSim/Services/UserAccountService/UserAccountService.cs index 8b8a8f9..21ce86c 100644 --- a/OpenSim/Services/UserAccountService/UserAccountService.cs +++ b/OpenSim/Services/UserAccountService/UserAccountService.cs @@ -28,15 +28,15 @@ using System; using System.Collections.Generic; using System.Reflection; +using log4net; using Nini.Config; +using OpenMetaverse; using OpenSim.Data; +using OpenSim.Framework; using OpenSim.Services.Interfaces; using OpenSim.Framework.Console; using GridRegion = OpenSim.Services.Interfaces.GridRegion; -using OpenMetaverse; -using log4net; - namespace OpenSim.Services.UserAccountService { public class UserAccountService : UserAccountServiceBase, IUserAccountService @@ -44,10 +44,16 @@ namespace OpenSim.Services.UserAccountService private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); private static UserAccountService m_RootInstance; + /// + /// Should we create default entries (minimum body parts/clothing, avatar wearable entries) for a new avatar? + /// + private bool m_CreateDefaultAvatarEntries; + protected IGridService m_GridService; protected IAuthenticationService m_AuthenticationService; protected IGridUserService m_GridUserService; protected IInventoryService m_InventoryService; + protected IAvatarService m_AvatarService; public UserAccountService(IConfigSource config) : base(config) @@ -77,6 +83,12 @@ namespace OpenSim.Services.UserAccountService if (invServiceDll != string.Empty) m_InventoryService = LoadPlugin(invServiceDll, new Object[] { config }); + string avatarServiceDll = userConfig.GetString("AvatarService", string.Empty); + if (avatarServiceDll != string.Empty) + m_AvatarService = LoadPlugin(avatarServiceDll, new Object[] { config }); + + m_CreateDefaultAvatarEntries = userConfig.GetBoolean("CreateDefaultAvatarEntries", false); + if (MainConsole.Instance != null) { MainConsole.Instance.Commands.AddCommand("UserService", false, @@ -102,9 +114,7 @@ namespace OpenSim.Services.UserAccountService "show account ", "Show account details for the given user", HandleShowAccount); } - } - } #region IUserAccountService @@ -493,12 +503,20 @@ namespace OpenSim.Services.UserAccountService { success = m_InventoryService.CreateUserInventory(account.PrincipalID); if (!success) + { m_log.WarnFormat("[USER ACCOUNT SERVICE]: Unable to create inventory for account {0} {1}.", firstName, lastName); + } + else if (m_CreateDefaultAvatarEntries) + { + CreateDefaultAppearanceEntries(account.PrincipalID); + } } m_log.InfoFormat("[USER ACCOUNT SERVICE]: Account {0} {1} created successfully", firstName, lastName); - } else { + } + else + { m_log.ErrorFormat("[USER ACCOUNT SERVICE]: Account creation failed for account {0} {1}", firstName, lastName); } } @@ -507,5 +525,125 @@ namespace OpenSim.Services.UserAccountService m_log.ErrorFormat("[USER ACCOUNT SERVICE]: A user with the name {0} {1} already exists!", firstName, lastName); } } + + private void CreateDefaultAppearanceEntries(UUID principalID) + { + m_log.DebugFormat("[USER ACCOUNT SERVICE]: Creating default appearance items for {0}", principalID); + + InventoryFolderBase bodyPartsFolder = m_InventoryService.GetFolderForType(principalID, AssetType.Bodypart); + + InventoryItemBase eyes = new InventoryItemBase(UUID.Random(), principalID); + eyes.AssetID = new UUID("4bb6fa4d-1cd2-498a-a84c-95c1a0e745a7"); + eyes.Name = "Default Eyes"; + eyes.CreatorId = principalID.ToString(); + eyes.AssetType = (int)AssetType.Bodypart; + eyes.InvType = (int)InventoryType.Wearable; + eyes.Folder = bodyPartsFolder.ID; + eyes.BasePermissions = (uint)PermissionMask.All; + eyes.CurrentPermissions = (uint)PermissionMask.All; + eyes.EveryOnePermissions = (uint)PermissionMask.All; + eyes.GroupPermissions = (uint)PermissionMask.All; + eyes.NextPermissions = (uint)PermissionMask.All; + eyes.Flags = (uint)WearableType.Eyes; + m_InventoryService.AddItem(eyes); + + InventoryItemBase shape = new InventoryItemBase(UUID.Random(), principalID); + shape.AssetID = AvatarWearable.DEFAULT_BODY_ASSET; + shape.Name = "Default Shape"; + shape.CreatorId = principalID.ToString(); + shape.AssetType = (int)AssetType.Bodypart; + shape.InvType = (int)InventoryType.Wearable; + shape.Folder = bodyPartsFolder.ID; + shape.BasePermissions = (uint)PermissionMask.All; + shape.CurrentPermissions = (uint)PermissionMask.All; + shape.EveryOnePermissions = (uint)PermissionMask.All; + shape.GroupPermissions = (uint)PermissionMask.All; + shape.NextPermissions = (uint)PermissionMask.All; + shape.Flags = (uint)WearableType.Shape; + m_InventoryService.AddItem(shape); + + InventoryItemBase skin = new InventoryItemBase(UUID.Random(), principalID); + skin.AssetID = AvatarWearable.DEFAULT_SKIN_ASSET; + skin.Name = "Default Skin"; + skin.CreatorId = principalID.ToString(); + skin.AssetType = (int)AssetType.Bodypart; + skin.InvType = (int)InventoryType.Wearable; + skin.Folder = bodyPartsFolder.ID; + skin.BasePermissions = (uint)PermissionMask.All; + skin.CurrentPermissions = (uint)PermissionMask.All; + skin.EveryOnePermissions = (uint)PermissionMask.All; + skin.GroupPermissions = (uint)PermissionMask.All; + skin.NextPermissions = (uint)PermissionMask.All; + skin.Flags = (uint)WearableType.Skin; + m_InventoryService.AddItem(skin); + + InventoryItemBase hair = new InventoryItemBase(UUID.Random(), principalID); + hair.AssetID = AvatarWearable.DEFAULT_HAIR_ASSET; + hair.Name = "Default Hair"; + hair.CreatorId = principalID.ToString(); + hair.AssetType = (int)AssetType.Bodypart; + hair.InvType = (int)InventoryType.Wearable; + hair.Folder = bodyPartsFolder.ID; + hair.BasePermissions = (uint)PermissionMask.All; + hair.CurrentPermissions = (uint)PermissionMask.All; + hair.EveryOnePermissions = (uint)PermissionMask.All; + hair.GroupPermissions = (uint)PermissionMask.All; + hair.NextPermissions = (uint)PermissionMask.All; + hair.Flags = (uint)WearableType.Hair; + m_InventoryService.AddItem(hair); + + InventoryFolderBase clothingFolder = m_InventoryService.GetFolderForType(principalID, AssetType.Clothing); + + InventoryItemBase shirt = new InventoryItemBase(UUID.Random(), principalID); + shirt.AssetID = AvatarWearable.DEFAULT_SHIRT_ASSET; + shirt.Name = "Default Shirt"; + shirt.CreatorId = principalID.ToString(); + shirt.AssetType = (int)AssetType.Clothing; + shirt.InvType = (int)InventoryType.Wearable; + shirt.Folder = clothingFolder.ID; + shirt.BasePermissions = (uint)PermissionMask.All; + shirt.CurrentPermissions = (uint)PermissionMask.All; + shirt.EveryOnePermissions = (uint)PermissionMask.All; + shirt.GroupPermissions = (uint)PermissionMask.All; + shirt.NextPermissions = (uint)PermissionMask.All; + shirt.Flags = (uint)WearableType.Shirt; + m_InventoryService.AddItem(shirt); + + InventoryItemBase pants = new InventoryItemBase(UUID.Random(), principalID); + pants.AssetID = AvatarWearable.DEFAULT_PANTS_ASSET; + pants.Name = "Default Pants"; + pants.CreatorId = principalID.ToString(); + pants.AssetType = (int)AssetType.Clothing; + pants.InvType = (int)InventoryType.Wearable; + pants.Folder = clothingFolder.ID; + pants.BasePermissions = (uint)PermissionMask.All; + pants.CurrentPermissions = (uint)PermissionMask.All; + pants.EveryOnePermissions = (uint)PermissionMask.All; + pants.GroupPermissions = (uint)PermissionMask.All; + pants.NextPermissions = (uint)PermissionMask.All; + pants.Flags = (uint)WearableType.Pants; + m_InventoryService.AddItem(pants); + + if (m_AvatarService != null) + { + m_log.DebugFormat("[USER ACCOUNT SERVICE]: Creating default avatar entries for {0}", principalID); + + AvatarWearable[] wearables = new AvatarWearable[6]; + wearables[AvatarWearable.EYES] = new AvatarWearable(eyes.ID, eyes.AssetID); + wearables[AvatarWearable.BODY] = new AvatarWearable(shape.ID, shape.AssetID); + wearables[AvatarWearable.SKIN] = new AvatarWearable(skin.ID, skin.AssetID); + wearables[AvatarWearable.HAIR] = new AvatarWearable(hair.ID, hair.AssetID); + wearables[AvatarWearable.SHIRT] = new AvatarWearable(shirt.ID, shirt.AssetID); + wearables[AvatarWearable.PANTS] = new AvatarWearable(pants.ID, pants.AssetID); + + AvatarAppearance ap = new AvatarAppearance(); + for (int i = 0; i < 6; i++) + { + ap.SetWearable(i, wearables[i]); + } + + m_AvatarService.SetAppearance(principalID, ap); + } + } } -} +} \ No newline at end of file diff --git a/bin/assets/BodyPartsAssetSet/BodyPartsAssetSet.xml b/bin/assets/BodyPartsAssetSet/BodyPartsAssetSet.xml index 8ef0fe7..a3d7ba3 100644 --- a/bin/assets/BodyPartsAssetSet/BodyPartsAssetSet.xml +++ b/bin/assets/BodyPartsAssetSet/BodyPartsAssetSet.xml @@ -4,7 +4,7 @@ - +
@@ -34,6 +34,14 @@
+ +
+ + + + +
+