aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Environment/Scenes/AvatarAppearance.cs
diff options
context:
space:
mode:
authorMW2007-12-07 17:23:11 +0000
committerMW2007-12-07 17:23:11 +0000
commite23290eff67ec2b19cffa3a555deef0a63511358 (patch)
treeec1bed4d0571eca6099ec4de2453a2f8e293824f /OpenSim/Region/Environment/Scenes/AvatarAppearance.cs
parentThis small patch means that the inventoryserver for grid mode now (diff)
downloadopensim-SC_OLD-e23290eff67ec2b19cffa3a555deef0a63511358.zip
opensim-SC_OLD-e23290eff67ec2b19cffa3a555deef0a63511358.tar.gz
opensim-SC_OLD-e23290eff67ec2b19cffa3a555deef0a63511358.tar.bz2
opensim-SC_OLD-e23290eff67ec2b19cffa3a555deef0a63511358.tar.xz
Avatar Appearance refactoring /changes. Added a AvatarAppearance class, each ScenePresence "has" a AvatarAppearance object. All the ScenePresences in a opensim related to one user (so a user's various ScenePresence's in all the regions in that instance) share the same AvatarAppearance object. This means that a user's avatar should appear correctly (to both that user and other users) no matter what border crossing or teleporting they have done.
Note: this mainly improves Standalone mode, as in grid mode the appearance data isn't passed between region servers. Although people should notice a improvement when moving between regions in the same instance.
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/Environment/Scenes/AvatarAppearance.cs126
1 files changed, 126 insertions, 0 deletions
diff --git a/OpenSim/Region/Environment/Scenes/AvatarAppearance.cs b/OpenSim/Region/Environment/Scenes/AvatarAppearance.cs
new file mode 100644
index 0000000..d8e69e6
--- /dev/null
+++ b/OpenSim/Region/Environment/Scenes/AvatarAppearance.cs
@@ -0,0 +1,126 @@
1using System;
2using System.Collections.Generic;
3using System.Text;
4using libsecondlife;
5using libsecondlife.Packets;
6using OpenSim.Framework;
7using OpenSim.Framework.Console;
8using OpenSim.Framework.Communications;
9using OpenSim.Region.Environment.Types;
10
11namespace OpenSim.Region.Environment.Scenes
12{
13 public class AvatarAppearance
14 {
15 protected LLUUID m_scenePresenceID;
16 protected int m_wearablesSerial = 1;
17
18 protected byte[] m_visualParams;
19
20 public byte[] VisualParams
21 {
22 get { return m_visualParams; }
23 set { m_visualParams = value; }
24 }
25
26 protected AvatarWearable[] m_wearables;
27
28 public AvatarWearable[] Wearables
29 {
30 get { return m_wearables; }
31 set { m_wearables = value; }
32 }
33
34 protected LLObject.TextureEntry m_textureEntry;
35
36 public LLObject.TextureEntry TextureEntry
37 {
38 get { return m_textureEntry; }
39 set { m_textureEntry = value; }
40 }
41
42 protected float m_avatarHeight = 0;
43
44 public float AvatarHeight
45 {
46 get { return m_avatarHeight; }
47 set { m_avatarHeight = value; }
48 }
49
50 public AvatarAppearance()
51 {
52 }
53
54 public AvatarAppearance(LLUUID avatarID, AvatarWearable[] wearables, byte[] visualParams)
55 {
56 m_scenePresenceID = avatarID;
57 m_wearablesSerial = 1;
58 m_wearables = wearables;
59 m_visualParams = visualParams;
60 m_textureEntry = GetDefaultTextureEntry();
61 }
62
63
64 public void SetID(LLUUID avatarID)
65 {
66 m_scenePresenceID = avatarID;
67 }
68
69 /// <summary>
70 ///
71 /// </summary>
72 /// <param name="texture"></param>
73 /// <param name="visualParam"></param>
74 public void SetAppearance(byte[] texture, AgentSetAppearancePacket.VisualParamBlock[] visualParam)
75 {
76 LLObject.TextureEntry textureEnt = new LLObject.TextureEntry(texture, 0, texture.Length);
77 m_textureEntry = textureEnt;
78
79 for (int i = 0; i < visualParam.Length; i++)
80 {
81 m_visualParams[i] = visualParam[i].ParamValue;
82 }
83
84 // Teravus : Nifty AV Height Getting Maaaaagical formula. Oh how we love turning 0-255 into meters.
85 // (float)m_visualParams[25] = Height
86 // (float)m_visualParams[125] = LegLength
87 m_avatarHeight = (1.50856f + (((float)m_visualParams[25] / 255.0f) * (2.525506f - 1.50856f)))
88 + (((float)m_visualParams[125] / 255.0f) / 1.5f);
89
90 }
91
92 /// <summary>
93 ///
94 /// </summary>
95 /// <param name="avatar"></param>
96 public void SendAppearanceToOtherAgent(ScenePresence avatar)
97 {
98 avatar.ControllingClient.SendAppearance(m_scenePresenceID, m_visualParams,
99 m_textureEntry.ToBytes());
100 }
101
102 public void SetWearable(IClientAPI client, int wearableId, AvatarWearable wearable)
103 {
104 m_wearables[wearableId] = wearable;
105 SendOwnWearables(client);
106 }
107
108 public void SendOwnWearables(IClientAPI ourClient)
109 {
110 ourClient.SendWearables(m_wearables, m_wearablesSerial++);
111 }
112
113 public static LLObject.TextureEntry GetDefaultTextureEntry()
114 {
115 LLObject.TextureEntry textu = new LLObject.TextureEntry(new LLUUID("C228D1CF-4B5D-4BA8-84F4-899A0796AA97"));
116 textu.CreateFace(0).TextureID = new LLUUID("00000000-0000-1111-9999-000000000012");
117 textu.CreateFace(1).TextureID = new LLUUID("5748decc-f629-461c-9a36-a35a221fe21f");
118 textu.CreateFace(2).TextureID = new LLUUID("5748decc-f629-461c-9a36-a35a221fe21f");
119 textu.CreateFace(3).TextureID = new LLUUID("6522E74D-1660-4E7F-B601-6F48C1659A77");
120 textu.CreateFace(4).TextureID = new LLUUID("7CA39B4C-BD19-4699-AFF7-F93FD03D3E7B");
121 textu.CreateFace(5).TextureID = new LLUUID("00000000-0000-1111-9999-000000000010");
122 textu.CreateFace(6).TextureID = new LLUUID("00000000-0000-1111-9999-000000000011");
123 return textu;
124 }
125 }
126}