aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Environment/Scenes
diff options
context:
space:
mode:
authorSean Dague2008-05-15 14:39:54 +0000
committerSean Dague2008-05-15 14:39:54 +0000
commit8e7f2d6d0efe37108b2931cfdda36e695830abb0 (patch)
treee8b558217b05901f50fc65148cb1196510ce8eca /OpenSim/Region/Environment/Scenes
parentadd some additional bits to AvatarAppearance to make this (diff)
downloadopensim-SC-8e7f2d6d0efe37108b2931cfdda36e695830abb0.zip
opensim-SC-8e7f2d6d0efe37108b2931cfdda36e695830abb0.tar.gz
opensim-SC-8e7f2d6d0efe37108b2931cfdda36e695830abb0.tar.bz2
opensim-SC-8e7f2d6d0efe37108b2931cfdda36e695830abb0.tar.xz
refactoring to move AvatarAppearance into Framework and
move the appearance sending bits to ScenePresence
Diffstat (limited to 'OpenSim/Region/Environment/Scenes')
-rw-r--r--OpenSim/Region/Environment/Scenes/AvatarAppearance.cs233
-rw-r--r--OpenSim/Region/Environment/Scenes/ScenePresence.cs24
2 files changed, 16 insertions, 241 deletions
diff --git a/OpenSim/Region/Environment/Scenes/AvatarAppearance.cs b/OpenSim/Region/Environment/Scenes/AvatarAppearance.cs
deleted file mode 100644
index a88306f..0000000
--- a/OpenSim/Region/Environment/Scenes/AvatarAppearance.cs
+++ /dev/null
@@ -1,233 +0,0 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSim Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using System.Collections.Generic;
30using System.Runtime.Serialization;
31using System.Security.Permissions;
32using libsecondlife;
33using libsecondlife.Packets;
34using OpenSim.Framework;
35
36namespace OpenSim.Region.Environment.Scenes
37{
38 [Serializable]
39 public class AvatarAppearance : ISerializable
40 {
41 // these are guessed at by the list here -
42 // http://wiki.secondlife.com/wiki/Avatar_Appearance. We'll
43 // correct them over time for when were are wrong.
44 public readonly static int BODY = 0;
45 public readonly static int SKIN = 1;
46 public readonly static int HAIR = 2;
47 public readonly static int EYES = 3;
48 public readonly static int SHIRT = 4;
49 public readonly static int PANTS = 5;
50 public readonly static int SHOES = 6;
51 public readonly static int SOCKS = 7;
52 public readonly static int JACKET = 8;
53 public readonly static int GLOVES = 9;
54 public readonly static int UNDERSHIRT = 10;
55 public readonly static int UNDERPANTS = 11;
56 public readonly static int SKIRT = 12;
57
58 private readonly static int MAX_WEARABLES = 13;
59
60 private static LLUUID BODY_ASSET = new LLUUID("66c41e39-38f9-f75a-024e-585989bfab73");
61 private static LLUUID BODY_ITEM = new LLUUID("66c41e39-38f9-f75a-024e-585989bfaba9");
62 private static LLUUID SKIN_ASSET = new LLUUID("77c41e39-38f9-f75a-024e-585989bbabbb");
63 private static LLUUID SKIN_ITEM = new LLUUID("77c41e39-38f9-f75a-024e-585989bfabc9");
64 private static LLUUID SHIRT_ASSET = new LLUUID("00000000-38f9-1111-024e-222222111110");
65 private static LLUUID SHIRT_ITEM = new LLUUID("77c41e39-38f9-f75a-0000-585989bf0000");
66 private static LLUUID PANTS_ASSET = new LLUUID("00000000-38f9-1111-024e-222222111120");
67 private static LLUUID PANTS_ITEM = new LLUUID("77c41e39-38f9-f75a-0000-5859892f1111");
68
69 public readonly static int VISUALPARAM_COUNT = 218;
70
71 protected LLUUID m_scenePresenceID;
72
73 public LLUUID ScenePresenceID
74 {
75 get { return m_scenePresenceID; }
76 set { m_scenePresenceID = value; }
77 }
78 protected int m_wearablesSerial = 1;
79
80 public int WearablesSerial
81 {
82 get { return m_wearablesSerial; }
83 set { m_wearablesSerial = value; }
84 }
85
86 protected byte[] m_visualParams;
87
88 public byte[] VisualParams
89 {
90 get { return m_visualParams; }
91 set { m_visualParams = value; }
92 }
93
94 protected AvatarWearable[] m_wearables;
95
96 public AvatarWearable[] Wearables
97 {
98 get { return m_wearables; }
99 set { m_wearables = value; }
100 }
101
102 protected LLObject.TextureEntry m_textureEntry;
103
104 public LLObject.TextureEntry TextureEntry
105 {
106 get { return m_textureEntry; }
107 set { m_textureEntry = value; }
108 }
109
110 protected float m_avatarHeight = 0;
111
112 public float AvatarHeight
113 {
114 get { return m_avatarHeight; }
115 set { m_avatarHeight = value; }
116 }
117
118 public AvatarAppearance()
119 {
120 m_wearables = new AvatarWearable[MAX_WEARABLES];
121 for (int i = 0; i < MAX_WEARABLES; i++)
122 {
123 // this makes them all null
124 m_wearables[i] = new AvatarWearable();
125 }
126 m_wearablesSerial = 0;
127 m_scenePresenceID = LLUUID.Zero;
128 m_visualParams = new byte[VISUALPARAM_COUNT];
129 }
130
131 public AvatarAppearance(LLUUID avatarID, AvatarWearable[] wearables, byte[] visualParams)
132 {
133 m_scenePresenceID = avatarID;
134 m_wearablesSerial = 1;
135 m_wearables = wearables;
136 m_visualParams = visualParams;
137 m_textureEntry = GetDefaultTextureEntry();
138 }
139
140 /// <summary>
141 ///
142 /// </summary>
143 /// <param name="texture"></param>
144 /// <param name="visualParam"></param>
145 public void SetAppearance(byte[] texture, List<byte> visualParam)
146 {
147 LLObject.TextureEntry textureEnt = new LLObject.TextureEntry(texture, 0, texture.Length);
148 m_textureEntry = textureEnt;
149
150 m_visualParams = visualParam.ToArray();
151
152 // Teravus : Nifty AV Height Getting Maaaaagical formula. Oh how we love turning 0-255 into meters.
153 // (float)m_visualParams[25] = Height
154 // (float)m_visualParams[125] = LegLength
155 m_avatarHeight = (1.50856f + (((float) m_visualParams[25]/255.0f)*(2.525506f - 1.50856f)))
156 + (((float) m_visualParams[125]/255.0f)/1.5f);
157 }
158
159 /// <summary>
160 ///
161 /// </summary>
162 /// <param name="avatar"></param>
163 public void SendAppearanceToOtherAgent(ScenePresence avatar)
164 {
165 avatar.ControllingClient.SendAppearance(m_scenePresenceID, m_visualParams,
166 m_textureEntry.ToBytes());
167 }
168
169 public void SetWearable(IClientAPI client, int wearableId, AvatarWearable wearable)
170 {
171 m_wearables[wearableId] = wearable;
172 SendOwnWearables(client);
173 }
174
175 public void SendOwnWearables(IClientAPI ourClient)
176 {
177 ourClient.SendWearables(m_wearables, m_wearablesSerial++);
178 }
179
180 public static LLObject.TextureEntry GetDefaultTextureEntry()
181 {
182 LLObject.TextureEntry textu = new LLObject.TextureEntry(new LLUUID("C228D1CF-4B5D-4BA8-84F4-899A0796AA97"));
183 textu.CreateFace(0).TextureID = new LLUUID("00000000-0000-1111-9999-000000000012");
184 textu.CreateFace(1).TextureID = new LLUUID("5748decc-f629-461c-9a36-a35a221fe21f");
185 textu.CreateFace(2).TextureID = new LLUUID("5748decc-f629-461c-9a36-a35a221fe21f");
186 textu.CreateFace(3).TextureID = new LLUUID("6522E74D-1660-4E7F-B601-6F48C1659A77");
187 textu.CreateFace(4).TextureID = new LLUUID("7CA39B4C-BD19-4699-AFF7-F93FD03D3E7B");
188 textu.CreateFace(5).TextureID = new LLUUID("00000000-0000-1111-9999-000000000010");
189 textu.CreateFace(6).TextureID = new LLUUID("00000000-0000-1111-9999-000000000011");
190 return textu;
191 }
192
193 protected AvatarAppearance(SerializationInfo info, StreamingContext context)
194 {
195 //System.Console.WriteLine("AvatarAppearance Deserialize BGN");
196
197 if (info == null)
198 {
199 throw new ArgumentNullException("info");
200 }
201
202 m_scenePresenceID = new LLUUID((Guid)info.GetValue("m_scenePresenceID", typeof(Guid)));
203 m_wearablesSerial = (int)info.GetValue("m_wearablesSerial", typeof(int));
204 m_visualParams = (byte[])info.GetValue("m_visualParams", typeof(byte[]));
205 m_wearables = (AvatarWearable[])info.GetValue("m_wearables", typeof(AvatarWearable[]));
206
207 byte[] m_textureEntry_work = (byte[])info.GetValue("m_textureEntry", typeof(byte[]));
208 m_textureEntry = new LLObject.TextureEntry(m_textureEntry_work, 0, m_textureEntry_work.Length);
209
210 m_avatarHeight = (float)info.GetValue("m_avatarHeight", typeof(float));
211
212 //System.Console.WriteLine("AvatarAppearance Deserialize END");
213 }
214
215 [SecurityPermission(SecurityAction.LinkDemand,
216 Flags = SecurityPermissionFlag.SerializationFormatter)]
217 public virtual void GetObjectData(
218 SerializationInfo info, StreamingContext context)
219 {
220 if (info == null)
221 {
222 throw new ArgumentNullException("info");
223 }
224
225 info.AddValue("m_scenePresenceID", m_scenePresenceID.UUID);
226 info.AddValue("m_wearablesSerial", m_wearablesSerial);
227 info.AddValue("m_visualParams", m_visualParams);
228 info.AddValue("m_wearables", m_wearables);
229 info.AddValue("m_textureEntry", m_textureEntry.ToBytes());
230 info.AddValue("m_avatarHeight", m_avatarHeight);
231 }
232 }
233}
diff --git a/OpenSim/Region/Environment/Scenes/ScenePresence.cs b/OpenSim/Region/Environment/Scenes/ScenePresence.cs
index 8ac1a77..6f591e8 100644
--- a/OpenSim/Region/Environment/Scenes/ScenePresence.cs
+++ b/OpenSim/Region/Environment/Scenes/ScenePresence.cs
@@ -1461,16 +1461,20 @@ namespace OpenSim.Region.Environment.Scenes
1461 SendAppearanceToAllOtherAgents(); 1461 SendAppearanceToAllOtherAgents();
1462 } 1462 }
1463 1463
1464
1465 public void SetWearable(IClientAPI client, int wearableId, AvatarWearable wearable)
1466 {
1467 m_appearance.SetWearable(wearableId, wearable);
1468 client.SendWearables(m_appearance.Wearables, m_appearance.WearablesSerial++);
1469 }
1470
1464 /// <summary> 1471 /// <summary>
1465 /// 1472 ///
1466 /// </summary> 1473 /// </summary>
1467 /// <param name="client"></param> 1474 /// <param name="client"></param>
1468 public void SendOwnAppearance() 1475 public void SendOwnAppearance()
1469 { 1476 {
1470 m_appearance.SendOwnWearables(ControllingClient); 1477 ControllingClient.SendWearables(m_appearance.Wearables, m_appearance.WearablesSerial++);
1471
1472 // TODO: remove this once the SunModule is slightly more tested
1473 // m_controllingClient.SendViewerTime(m_scene.TimePhase);
1474 } 1478 }
1475 1479
1476 /// <summary> 1480 /// <summary>
@@ -1484,15 +1488,19 @@ namespace OpenSim.Region.Environment.Scenes
1484 { 1488 {
1485 if (scenePresence.UUID != UUID) 1489 if (scenePresence.UUID != UUID)
1486 { 1490 {
1487 m_appearance.SendAppearanceToOtherAgent(scenePresence); 1491 SendAppearanceToOtherAgent(scenePresence);
1488 } 1492 }
1489 }); 1493 });
1490 m_scene.AddAgentTime(System.Environment.TickCount - m_perfMonMS); 1494 m_scene.AddAgentTime(System.Environment.TickCount - m_perfMonMS);
1491 } 1495 }
1492 1496
1493 public void SendAppearanceToOtherAgent(ScenePresence avatar) 1497 public void SendAppearanceToOtherAgent(ScenePresence avatar)
1494 { 1498 {
1495 m_appearance.SendAppearanceToOtherAgent(avatar); 1499 avatar.ControllingClient.SendAppearance(
1500 m_appearance.ScenePresenceID,
1501 m_appearance.VisualParams,
1502 m_appearance.TextureEntry.ToBytes()
1503 );
1496 } 1504 }
1497 1505
1498 public void SetAppearance(byte[] texture, List<byte> visualParam) 1506 public void SetAppearance(byte[] texture, List<byte> visualParam)
@@ -1505,7 +1513,7 @@ namespace OpenSim.Region.Environment.Scenes
1505 1513
1506 public void SetWearable(int wearableId, AvatarWearable wearable) 1514 public void SetWearable(int wearableId, AvatarWearable wearable)
1507 { 1515 {
1508 m_appearance.SetWearable(ControllingClient, wearableId, wearable); 1516 m_appearance.SetWearable(wearableId, wearable);
1509 } 1517 }
1510 1518
1511 /// <summary> 1519 /// <summary>