OpenSim.Region.CoreModules.Avatar.AvatarFactory.AvatarFactoryModule.SetAppearance C# (CSharp) Method

SetAppearance() public method

Set appearance data (textureentry and slider settings) received from the client
public SetAppearance ( IClientAPI client, Primitive textureEntry, byte visualParams ) : void
client IClientAPI
textureEntry OpenMetaverse.Primitive
visualParams byte
return void
        public void SetAppearance(IClientAPI client, Primitive.TextureEntry textureEntry, byte[] visualParams)
        {
//            m_log.WarnFormat("[AVATAR FACTORY MODULE]: SetAppearance for {0}",client.AgentId);

            ScenePresence sp = m_scene.GetScenePresence(client.AgentId);
            if (sp == null)
            {
                m_log.WarnFormat("[AVATAR FACTORY MODULE]: SetAppearance unable to find presence for {0}",client.AgentId);
                return;
            }

            bool changed = false;

            // Process the texture entry
            if (textureEntry != null)
            {
                changed = sp.Appearance.SetTextureEntries(textureEntry);

                for (int i = 0; i < AvatarAppearance.BAKE_INDICES.Length; i++)
                {
                    int idx = AvatarAppearance.BAKE_INDICES[i];
                    Primitive.TextureEntryFace face = sp.Appearance.Texture.FaceTextures[idx];
                    if (face != null && face.TextureID != AppearanceManager.DEFAULT_AVATAR_TEXTURE)
                        Util.FireAndForget(delegate(object o) {
                                if (! CheckBakedTextureAsset(client,face.TextureID,idx))
                                    client.SendRebakeAvatarTextures(face.TextureID);
                            });
                }
            }

            // Process the visual params, this may change height as well
            if (visualParams != null)
            {
                if (sp.Appearance.SetVisualParams(visualParams))
                {
                    changed = true;
                    if (sp.Appearance.AvatarHeight > 0)
                        sp.SetHeight(sp.Appearance.AvatarHeight);
                }
            }

            // If something changed in the appearance then queue an appearance save
            if (changed)
                QueueAppearanceSave(client.AgentId);

            // And always queue up an appearance update to send out
            QueueAppearanceSend(client.AgentId);

            // Send the appearance back to the avatar
            // AvatarAppearance avp = sp.Appearance;
            // sp.ControllingClient.SendAvatarDataImmediate(sp);
            // sp.ControllingClient.SendAppearance(avp.Owner,avp.VisualParams,avp.Texture.GetBytes());
        }

Usage Example

Example #1
0
        public void TestCreate()
        {
            TestHelper.InMethod();
//            log4net.Config.XmlConfigurator.Configure();

            IConfigSource config = new IniConfigSource();
            config.AddConfig("NPC");
            config.Configs["NPC"].Set("Enabled", "true");

            AvatarFactoryModule afm = new AvatarFactoryModule();
            TestScene scene = SceneSetupHelpers.SetupScene();
            SceneSetupHelpers.SetupSceneModules(scene, config, afm, new NPCModule());
            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>();
            UUID npcId = npcModule.CreateNPC("John", "Smith", new Vector3(128, 128, 30), scene, originalClient.AgentId);

            ScenePresence npc = scene.GetScenePresence(npcId);

            Assert.That(npc, Is.Not.Null);
            Assert.That(npc.Appearance.Texture.FaceTextures[8].TextureID, Is.EqualTo(originalFace8TextureId));
        }
All Usage Examples Of OpenSim.Region.CoreModules.Avatar.AvatarFactory.AvatarFactoryModule::SetAppearance