aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework/AvatarAppearance.cs
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/Framework/AvatarAppearance.cs
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/Framework/AvatarAppearance.cs')
-rw-r--r--OpenSim/Framework/AvatarAppearance.cs217
1 files changed, 217 insertions, 0 deletions
diff --git a/OpenSim/Framework/AvatarAppearance.cs b/OpenSim/Framework/AvatarAppearance.cs
new file mode 100644
index 0000000..50afa75
--- /dev/null
+++ b/OpenSim/Framework/AvatarAppearance.cs
@@ -0,0 +1,217 @@
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.Framework
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 public void SetWearable(int wearableId, AvatarWearable wearable)
160 {
161 m_wearables[wearableId] = wearable;
162 }
163
164 public static LLObject.TextureEntry GetDefaultTextureEntry()
165 {
166 LLObject.TextureEntry textu = new LLObject.TextureEntry(new LLUUID("C228D1CF-4B5D-4BA8-84F4-899A0796AA97"));
167 textu.CreateFace(0).TextureID = new LLUUID("00000000-0000-1111-9999-000000000012");
168 textu.CreateFace(1).TextureID = new LLUUID("5748decc-f629-461c-9a36-a35a221fe21f");
169 textu.CreateFace(2).TextureID = new LLUUID("5748decc-f629-461c-9a36-a35a221fe21f");
170 textu.CreateFace(3).TextureID = new LLUUID("6522E74D-1660-4E7F-B601-6F48C1659A77");
171 textu.CreateFace(4).TextureID = new LLUUID("7CA39B4C-BD19-4699-AFF7-F93FD03D3E7B");
172 textu.CreateFace(5).TextureID = new LLUUID("00000000-0000-1111-9999-000000000010");
173 textu.CreateFace(6).TextureID = new LLUUID("00000000-0000-1111-9999-000000000011");
174 return textu;
175 }
176
177 protected AvatarAppearance(SerializationInfo info, StreamingContext context)
178 {
179 //System.Console.WriteLine("AvatarAppearance Deserialize BGN");
180
181 if (info == null)
182 {
183 throw new ArgumentNullException("info");
184 }
185
186 m_scenePresenceID = new LLUUID((Guid)info.GetValue("m_scenePresenceID", typeof(Guid)));
187 m_wearablesSerial = (int)info.GetValue("m_wearablesSerial", typeof(int));
188 m_visualParams = (byte[])info.GetValue("m_visualParams", typeof(byte[]));
189 m_wearables = (AvatarWearable[])info.GetValue("m_wearables", typeof(AvatarWearable[]));
190
191 byte[] m_textureEntry_work = (byte[])info.GetValue("m_textureEntry", typeof(byte[]));
192 m_textureEntry = new LLObject.TextureEntry(m_textureEntry_work, 0, m_textureEntry_work.Length);
193
194 m_avatarHeight = (float)info.GetValue("m_avatarHeight", typeof(float));
195
196 //System.Console.WriteLine("AvatarAppearance Deserialize END");
197 }
198
199 [SecurityPermission(SecurityAction.LinkDemand,
200 Flags = SecurityPermissionFlag.SerializationFormatter)]
201 public virtual void GetObjectData(
202 SerializationInfo info, StreamingContext context)
203 {
204 if (info == null)
205 {
206 throw new ArgumentNullException("info");
207 }
208
209 info.AddValue("m_scenePresenceID", m_scenePresenceID.UUID);
210 info.AddValue("m_wearablesSerial", m_wearablesSerial);
211 info.AddValue("m_visualParams", m_visualParams);
212 info.AddValue("m_wearables", m_wearables);
213 info.AddValue("m_textureEntry", m_textureEntry.ToBytes());
214 info.AddValue("m_avatarHeight", m_avatarHeight);
215 }
216 }
217}