aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework
diff options
context:
space:
mode:
authorUbitUmarov2012-12-07 21:26:58 +0000
committerUbitUmarov2012-12-07 21:26:58 +0000
commit93bede4e6aa0838e14f39f5e641b028267d2683c (patch)
tree2b19bb7e14edb0529ad0a038db819690b1397a25 /OpenSim/Framework
parent create a new ode character also with the new information (diff)
downloadopensim-SC-93bede4e6aa0838e14f39f5e641b028267d2683c.zip
opensim-SC-93bede4e6aa0838e14f39f5e641b028267d2683c.tar.gz
opensim-SC-93bede4e6aa0838e14f39f5e641b028267d2683c.tar.bz2
opensim-SC-93bede4e6aa0838e14f39f5e641b028267d2683c.tar.xz
revert the use of avatar skeleton and use avatar size provided by viewers,
since at least for now seems good enought
Diffstat (limited to '')
-rw-r--r--OpenSim/Framework/AvatarAppearance.cs47
-rw-r--r--OpenSim/Framework/AvatarSkeleton.cs282
-rw-r--r--OpenSim/Framework/IClientAPI.cs2
3 files changed, 31 insertions, 300 deletions
diff --git a/OpenSim/Framework/AvatarAppearance.cs b/OpenSim/Framework/AvatarAppearance.cs
index 9e912de..b01b8da 100644
--- a/OpenSim/Framework/AvatarAppearance.cs
+++ b/OpenSim/Framework/AvatarAppearance.cs
@@ -40,6 +40,11 @@ namespace OpenSim.Framework
40 /// </summary> 40 /// </summary>
41 public class AvatarAppearance 41 public class AvatarAppearance
42 { 42 {
43 const float AVBOXAJUST = 0.2f;
44 const float AVBOXMINX = 0.2f;
45 const float AVBOXMINY = 0.3f;
46 const float AVBOXMINZ = 0.5f;
47
43 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 48 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
44 49
45 // this is viewer capabilities and weared things dependent 50 // this is viewer capabilities and weared things dependent
@@ -60,9 +65,6 @@ namespace OpenSim.Framework
60 protected float m_avatarFeetOffset = 0; 65 protected float m_avatarFeetOffset = 0;
61 protected float m_avatarAnimOffset = 0; 66 protected float m_avatarAnimOffset = 0;
62 67
63
64 private AvatarSkeleton skeleton = new AvatarSkeleton();
65
66 public virtual int Serial 68 public virtual int Serial
67 { 69 {
68 get { return m_serial; } 70 get { return m_serial; }
@@ -120,7 +122,8 @@ namespace OpenSim.Framework
120 SetDefaultWearables(); 122 SetDefaultWearables();
121 SetDefaultTexture(); 123 SetDefaultTexture();
122 SetDefaultParams(); 124 SetDefaultParams();
123 SetHeight(); 125// SetHeight();
126 SetSize(new Vector3(0.45f,0.6f,1.9f));
124 m_attachments = new Dictionary<int, List<AvatarAttachment>>(); 127 m_attachments = new Dictionary<int, List<AvatarAttachment>>();
125 } 128 }
126 129
@@ -129,7 +132,7 @@ namespace OpenSim.Framework
129// m_log.WarnFormat("[AVATAR APPEARANCE]: create appearance from OSDMap"); 132// m_log.WarnFormat("[AVATAR APPEARANCE]: create appearance from OSDMap");
130 133
131 Unpack(map); 134 Unpack(map);
132 SetHeight(); 135// SetHeight(); done in Unpack
133 } 136 }
134 137
135 public AvatarAppearance(AvatarWearable[] wearables, Primitive.TextureEntry textureEntry, byte[] visualParams) 138 public AvatarAppearance(AvatarWearable[] wearables, Primitive.TextureEntry textureEntry, byte[] visualParams)
@@ -153,7 +156,7 @@ namespace OpenSim.Framework
153 else 156 else
154 SetDefaultParams(); 157 SetDefaultParams();
155 158
156 SetHeight(); 159// SetHeight();
157 160
158 m_attachments = new Dictionary<int, List<AvatarAttachment>>(); 161 m_attachments = new Dictionary<int, List<AvatarAttachment>>();
159 } 162 }
@@ -172,7 +175,8 @@ namespace OpenSim.Framework
172 SetDefaultWearables(); 175 SetDefaultWearables();
173 SetDefaultTexture(); 176 SetDefaultTexture();
174 SetDefaultParams(); 177 SetDefaultParams();
175 SetHeight(); 178// SetHeight();
179 SetSize(new Vector3(0.45f, 0.6f, 1.9f));
176 m_attachments = new Dictionary<int, List<AvatarAttachment>>(); 180 m_attachments = new Dictionary<int, List<AvatarAttachment>>();
177 181
178 return; 182 return;
@@ -201,7 +205,8 @@ namespace OpenSim.Framework
201 if (appearance.VisualParams != null) 205 if (appearance.VisualParams != null)
202 m_visualparams = (byte[])appearance.VisualParams.Clone(); 206 m_visualparams = (byte[])appearance.VisualParams.Clone();
203 207
204 m_avatarHeight = appearance.m_avatarHeight; 208// m_avatarHeight = appearance.m_avatarHeight;
209 SetSize(appearance.AvatarSize);
205 210
206 // Copy the attachment, force append mode since that ensures consistency 211 // Copy the attachment, force append mode since that ensures consistency
207 m_attachments = new Dictionary<int, List<AvatarAttachment>>(); 212 m_attachments = new Dictionary<int, List<AvatarAttachment>>();
@@ -368,8 +373,8 @@ namespace OpenSim.Framework
368 } 373 }
369 } 374 }
370 // Reset the height if the visual parameters actually changed 375 // Reset the height if the visual parameters actually changed
371 if (changed) 376// if (changed)
372 SetHeight(); 377// SetHeight();
373 378
374 return changed; 379 return changed;
375 } 380 }
@@ -399,11 +404,19 @@ namespace OpenSim.Framework
399 + 0.08f * (float)m_visualparams[(int)VPElement.SHOES_HEEL_HEIGHT] / 255.0f 404 + 0.08f * (float)m_visualparams[(int)VPElement.SHOES_HEEL_HEIGHT] / 255.0f
400 + 0.076f * (float)m_visualparams[(int)VPElement.SHAPE_NECK_LENGTH] / 255.0f; 405 + 0.076f * (float)m_visualparams[(int)VPElement.SHAPE_NECK_LENGTH] / 255.0f;
401*/ 406*/
402 407 }
403 skeleton.ApplyVisualParameters(m_visualparams); 408
404 m_avatarSize = skeleton.StandSize; 409 public void SetSize(Vector3 avSize)
405 m_avatarBoxSize = skeleton.StandBoxSize; 410 {
406 m_avatarFeetOffset = skeleton.FeetOffset; 411 m_avatarSize = avSize;
412 m_avatarBoxSize = avSize;
413 m_avatarBoxSize.Z += AVBOXAJUST;
414 if (m_avatarBoxSize.X < AVBOXMINX)
415 m_avatarBoxSize.X = AVBOXMINX;
416 if (m_avatarBoxSize.Y < AVBOXMINY)
417 m_avatarBoxSize.Y = AVBOXMINY;
418 if (m_avatarBoxSize.Z < AVBOXMINZ)
419 m_avatarBoxSize.Z = AVBOXMINZ;
407 m_avatarHeight = m_avatarSize.Z; 420 m_avatarHeight = m_avatarSize.Z;
408 } 421 }
409 422
@@ -678,8 +691,9 @@ namespace OpenSim.Framework
678 { 691 {
679 if ((data != null) && (data["serial"] != null)) 692 if ((data != null) && (data["serial"] != null))
680 m_serial = data["serial"].AsInteger(); 693 m_serial = data["serial"].AsInteger();
681// if ((data != null) && (data["height"] != null)) 694 if ((data != null) && (data["height"] != null))
682// m_avatarHeight = (float)data["height"].AsReal(); 695// m_avatarHeight = (float)data["height"].AsReal();
696 SetSize(new Vector3(0.45f,0.6f, (float)data["height"].AsReal()));
683 697
684 try 698 try
685 { 699 {
@@ -741,7 +755,6 @@ namespace OpenSim.Framework
741// att.ItemID, att.AssetID, att.AttachPoint); 755// att.ItemID, att.AssetID, att.AttachPoint);
742 } 756 }
743 } 757 }
744 SetHeight();
745 } 758 }
746 catch (Exception e) 759 catch (Exception e)
747 { 760 {
diff --git a/OpenSim/Framework/AvatarSkeleton.cs b/OpenSim/Framework/AvatarSkeleton.cs
deleted file mode 100644
index 7a49f22..0000000
--- a/OpenSim/Framework/AvatarSkeleton.cs
+++ /dev/null
@@ -1,282 +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 OpenSimulator 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// Ubit 2012
28using System;
29using System.Collections;
30using System.Collections.Generic;
31using OpenMetaverse;
32using OpenMetaverse.StructuredData;
33using log4net;
34using VPElement = OpenSim.Framework.AvatarAppearance.VPElement;
35
36
37
38namespace OpenSim.Framework
39{
40 /// <summary>
41 /// Contains the Avatar's Skeleton
42 /// </summary>
43 public class AvatarSkeleton
44 {
45 const int NBONES = 26;
46 const float BOXAJUST = 0.2f;
47
48 public enum Bones : int
49 {
50 EyeLeft,
51 Eyeright,
52 Skull,
53 Head,
54 Neck,
55 CollarRight,
56 CollarLeft,
57 Shoulderright,
58 ShoulderLeft,
59 ElbowRight,
60 ElbowLeft,
61 WristRight,
62 WristLeft,
63 Chest,
64 Torso,
65 Pelvis,
66 Hipright,
67 HipLeft,
68 KneeRight,
69 KneeLeft,
70 AnkleRight,
71 AnkleLeft,
72 FootRight,
73 FootLeft,
74 ToeRight,
75 ToeLeft
76 }
77
78 public struct bone
79 {
80 public Vector3 Offset;
81 public Vector3 Scale;
82 public bone(float x, float y, float z)
83 {
84 Offset = new Vector3(x, y, z);
85 Scale = new Vector3(1f, 1f, 1f);
86 }
87
88 public void addScale(float x, float y, float z, float factor)
89 {
90 Scale.X += x * factor;
91 Scale.Y += y * factor;
92 Scale.Y += z * factor;
93 }
94
95 public void addOffset(float x, float y, float z, float factor)
96 {
97 Offset.X += x * factor;
98 Offset.Y += y * factor;
99 Offset.Y += z * factor;
100 }
101 }
102
103 private bone[] DefaultBones = new bone[]
104 {
105 new bone(0.098f, 0.036f, 0.079f), // EyeLeft
106 new bone(0.098f, -0.036f, 0.079f), // Eyeright
107 new bone(0.0f, 0.0f, 0.079f), // Skull
108 new bone(0.0f, 0.0f, 0.076f), // Head
109 new bone(-0.1f, 0.0f, 0.251f), // Neck
110 new bone(-0.021f, -0.085f, 0.165f), // CollarRight
111 new bone(-0.021f, 0.085f, 0.165f), // CollarLeft
112 new bone(0.0f, -0.79f, 0.0f), // Shoulderright
113 new bone(0.0f, 0.79f, 0.0f), // ShoulderLeft
114 new bone(0.0f, -0.248f, 0.0f), // ElbowRight
115 new bone(0.0f, 0.248f, 0.0f), // ElbowLeft
116 new bone(0.0f, -0.205f, 0.0f), // WristRight
117 new bone(0.0f, 0.205f, 0.0f), // WristLeft
118 new bone(-0.015f, 0.000f, 0.205f), // Chest
119 new bone(0.0f, 0.0f, 0.084f), // Torso
120 new bone(0.0f, 0.0f, 1.067f), // Pelvis
121 new bone(0.034f, -0.129f, -0.041f), // Hipright
122 new bone(0.034f, 0.127f, -0.041f), // HipLeft
123 new bone(-0.001f, 0.049f, -0.491f), // KneeRight
124 new bone(-0.001f, -0.046f, -0.491f), // KneeLeft
125 new bone(-0.029f, 0.0f, -0.468f), // AnkleRight
126 new bone(-0.029f, 0.001f, -0.468f), // AnkleLeft
127 new bone(0.112f, 0.0f, -0.061f), // FootRight
128 new bone(0.112f, 0.0f, -0.061f), // FootLeft
129 new bone(0.109f, 0.0f, 0.0f), // ToeRight
130 new bone(0.109f, 0.0f, 0.0f) // ToeLeft
131 };
132
133 private bone[] m_bones = null;
134 private byte[] m_visualParams = null;
135
136 const float bytescale = 1.0f / 255.0f;
137
138 private float convertVP(AvatarAppearance.VPElement vp)
139 {
140 return (float)m_visualParams[(int)vp] * bytescale;
141 }
142
143 private Vector3 m_standSize;
144 private float m_feetOffset = 0f;
145
146 public Vector3 StandSize
147 {
148 get
149 {
150 if (m_bones == null || m_visualParams == null)
151 return new Vector3(0.45f, 0.6f, 1.9f);
152 else
153 return m_standSize;
154 }
155 }
156
157 public Vector3 StandBoxSize
158 {
159 get
160 {
161 if (m_bones == null || m_visualParams == null)
162 return new Vector3(0.45f, 0.6f, 1.9f + BOXAJUST);
163 else
164 {
165 Vector3 r = m_standSize;
166 r.Z += BOXAJUST;
167 return r;
168 }
169 }
170 }
171
172 public float FeetOffset
173 {
174 get
175 {
176 if (m_bones == null || m_visualParams == null)
177 return 0.0f;
178 else
179 {
180 return m_feetOffset;
181 }
182 }
183 }
184
185 /// <summary>
186 /// Set avatar height by a calculation based on their visual parameters.
187 /// </summary>
188
189 public void ApplyVisualParameters(byte[] vPs)
190 {
191 m_visualParams = vPs;
192
193 if (m_bones == null)
194 {
195 m_bones = new bone[NBONES];
196 for (int i = 0; i < NBONES; i++)
197 m_bones[i] = DefaultBones[i];
198 }
199
200 float bone_skull = m_bones[(int)Bones.Skull].Offset.Z;
201 float bone_head = m_bones[(int)Bones.Head].Offset.Z;
202 float bone_neck = m_bones[(int)Bones.Neck].Offset.Z;
203 float bone_chest = m_bones[(int)Bones.Chest].Offset.Z;
204 float bone_torso = m_bones[(int)Bones.Torso].Offset.Z;
205 float bone_hip = m_bones[(int)Bones.Hipright].Offset.Z;
206 float bone_knee = m_bones[(int)Bones.KneeRight].Offset.Z;
207 float bone_ank = m_bones[(int)Bones.AnkleRight].Offset.Z;
208 float bone_foot = m_bones[(int)Bones.FootRight].Offset.Z;
209
210 float sbone_skull = m_bones[(int)Bones.Skull].Scale.Z;
211 float sbone_head = m_bones[(int)Bones.Head].Scale.Z;
212 float sbone_neck = m_bones[(int)Bones.Neck].Scale.Z;
213 float sbone_chest = m_bones[(int)Bones.Chest].Scale.Z;
214 float sbone_torso = m_bones[(int)Bones.Torso].Scale.Z;
215 float sbone_pelvis = m_bones[(int)Bones.Pelvis].Scale.Z;
216 float sbone_hip = m_bones[(int)Bones.Hipright].Scale.Z;
217 float sbone_knee = m_bones[(int)Bones.KneeRight].Scale.Z;
218 float sbone_ank = m_bones[(int)Bones.AnkleRight].Scale.Z;
219 float sbone_foot = m_bones[(int)Bones.FootRight].Scale.Z;
220
221 float v_male = (m_visualParams[(int)VPElement.SHAPE_MALE] == 0) ? 0.0f : 1.0f;
222 sbone_neck += v_male * 0.2f;
223 sbone_chest += v_male * 0.05f;
224 sbone_torso += v_male * 0.05f;
225 sbone_knee += v_male * 0.1f;
226
227 float v_height = convertVP(VPElement.SHAPE_HEIGHT) * 4.3f - 2.3f;
228 sbone_neck += v_height * 0.02f;
229 sbone_chest += v_height * 0.05f;
230 sbone_torso += v_height * 0.05f;
231 sbone_hip += v_height * 0.1f;
232 sbone_knee += v_height * 0.1f;
233
234 float v_hip_len = convertVP(VPElement.SHAPE_HIP_LENGTH) * 2f - 1f;
235 sbone_pelvis += v_hip_len * 0.3f;
236
237 float v_torso_len = convertVP(VPElement.SHAPE_TORSO_LENGTH) * 2f - 1f;
238 sbone_torso += v_torso_len * 0.3f;
239 sbone_pelvis += v_torso_len * 0.1f;
240 sbone_hip += v_torso_len * -0.1f;
241 sbone_knee += v_torso_len * -0.05f;
242
243 float v_head_size = convertVP(VPElement.SHAPE_HEAD_SIZE) * 0.35f - 0.25f;
244 bone_skull += v_head_size * 0.1f;
245 sbone_skull += v_head_size;
246 sbone_head += v_head_size;
247
248 float v_shoes_heel = convertVP(VPElement.SHOES_HEEL_HEIGHT);
249 bone_foot += v_shoes_heel * -0.08f;
250
251 float v_shoes_plat = convertVP(VPElement.SHOES_PLATFORM_HEIGHT);
252 bone_foot += v_shoes_plat * -0.07f;
253
254 float v_leg_lenght = convertVP(VPElement.SHAPE_LEG_LENGTH) * 2f - 1f;
255 sbone_hip += v_leg_lenght * 0.2f;
256 sbone_knee += v_leg_lenght * 0.2f;
257
258 float v_neck_len = convertVP(VPElement.SHAPE_NECK_LENGTH) * 2f - 1f;
259 sbone_neck += v_neck_len * 0.5f;
260
261 float hipmess = bone_hip * sbone_pelvis;
262
263 float pelvisToFoot = hipmess -
264 bone_knee * sbone_hip -
265 bone_ank * sbone_knee -
266 bone_foot * sbone_ank;
267
268
269 float size = 1.4142f * bone_skull * sbone_head +
270 bone_head * sbone_neck +
271 bone_neck * sbone_chest +
272 bone_chest * sbone_torso +
273 bone_torso * sbone_pelvis;
274
275 size += pelvisToFoot;
276
277 m_standSize = new Vector3(0.45f, 0.6f, size);
278 // m_feetOffset = 0.5f * size - pelvisToFoot;
279 m_feetOffset = 0.0f;
280 }
281 }
282}
diff --git a/OpenSim/Framework/IClientAPI.cs b/OpenSim/Framework/IClientAPI.cs
index f686c60..c9b67de 100644
--- a/OpenSim/Framework/IClientAPI.cs
+++ b/OpenSim/Framework/IClientAPI.cs
@@ -64,7 +64,7 @@ namespace OpenSim.Framework
64 64
65 public delegate void NetworkStats(int inPackets, int outPackets, int unAckedBytes); 65 public delegate void NetworkStats(int inPackets, int outPackets, int unAckedBytes);
66 66
67 public delegate void SetAppearance(IClientAPI remoteClient, Primitive.TextureEntry textureEntry, byte[] visualParams); 67 public delegate void SetAppearance(IClientAPI remoteClient, Primitive.TextureEntry textureEntry, byte[] visualParams, Vector3 AvSize);
68 68
69 public delegate void StartAnim(IClientAPI remoteClient, UUID animID); 69 public delegate void StartAnim(IClientAPI remoteClient, UUID animID);
70 70