aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
authorMW2007-12-07 17:23:11 +0000
committerMW2007-12-07 17:23:11 +0000
commite23290eff67ec2b19cffa3a555deef0a63511358 (patch)
treeec1bed4d0571eca6099ec4de2453a2f8e293824f /OpenSim
parentThis small patch means that the inventoryserver for grid mode now (diff)
downloadopensim-SC-e23290eff67ec2b19cffa3a555deef0a63511358.zip
opensim-SC-e23290eff67ec2b19cffa3a555deef0a63511358.tar.gz
opensim-SC-e23290eff67ec2b19cffa3a555deef0a63511358.tar.bz2
opensim-SC-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 'OpenSim')
-rw-r--r--OpenSim/Region/Environment/Interfaces/IAvatarFactory.cs3
-rw-r--r--OpenSim/Region/Environment/Modules/AvatarFactoryModule.cs63
-rw-r--r--OpenSim/Region/Environment/Scenes/AvatarAppearance.cs126
-rw-r--r--OpenSim/Region/Environment/Scenes/InnerScene.cs4
-rw-r--r--OpenSim/Region/Environment/Scenes/Scene.cs15
-rw-r--r--OpenSim/Region/Environment/Scenes/ScenePresence.cs268
6 files changed, 291 insertions, 188 deletions
diff --git a/OpenSim/Region/Environment/Interfaces/IAvatarFactory.cs b/OpenSim/Region/Environment/Interfaces/IAvatarFactory.cs
index dd3f75d..a0053fe 100644
--- a/OpenSim/Region/Environment/Interfaces/IAvatarFactory.cs
+++ b/OpenSim/Region/Environment/Interfaces/IAvatarFactory.cs
@@ -1,10 +1,11 @@
1using libsecondlife; 1using libsecondlife;
2using OpenSim.Framework; 2using OpenSim.Framework;
3using OpenSim.Region.Environment.Scenes;
3 4
4namespace OpenSim.Region.Environment.Interfaces 5namespace OpenSim.Region.Environment.Interfaces
5{ 6{
6 public interface IAvatarFactory : IRegionModule 7 public interface IAvatarFactory : IRegionModule
7 { 8 {
8 bool TryGetInitialAvatarAppearance(LLUUID avatarId, out AvatarWearable[] wearables, out byte[] visualParams); 9 bool TryGetAvatarAppearance(LLUUID avatarId, out AvatarAppearance appearance);
9 } 10 }
10} \ No newline at end of file 11} \ No newline at end of file
diff --git a/OpenSim/Region/Environment/Modules/AvatarFactoryModule.cs b/OpenSim/Region/Environment/Modules/AvatarFactoryModule.cs
index edaad82..4f9aa2a 100644
--- a/OpenSim/Region/Environment/Modules/AvatarFactoryModule.cs
+++ b/OpenSim/Region/Environment/Modules/AvatarFactoryModule.cs
@@ -12,26 +12,27 @@ namespace OpenSim.Region.Environment.Modules
12 public class AvatarFactoryModule : IAvatarFactory 12 public class AvatarFactoryModule : IAvatarFactory
13 { 13 {
14 private Scene m_scene = null; 14 private Scene m_scene = null;
15 private Dictionary<LLUUID, AvatarAppearance> m_avatarsClothes = new Dictionary<LLUUID, AvatarAppearance>(); 15 private Dictionary<LLUUID, AvatarAppearance> m_avatarsAppearance = new Dictionary<LLUUID, AvatarAppearance>();
16 16
17 public bool TryGetInitialAvatarAppearance(LLUUID avatarId, out AvatarWearable[] wearables, 17 public bool TryGetAvatarAppearance(LLUUID avatarId, out AvatarAppearance appearance)
18 out byte[] visualParams)
19 { 18 {
20 if (m_avatarsClothes.ContainsKey(avatarId)) 19 if (m_avatarsAppearance.ContainsKey(avatarId))
21 { 20 {
22 visualParams = GetDefaultVisualParams(); 21 appearance = m_avatarsAppearance[avatarId];
23 wearables = m_avatarsClothes[avatarId].IsWearing;
24 return true; 22 return true;
25 } 23 }
26 else 24 else
27 { 25 {
26 AvatarWearable[] wearables;
27 byte[] visualParams;
28 GetDefaultAvatarAppearance(out wearables, out visualParams); 28 GetDefaultAvatarAppearance(out wearables, out visualParams);
29 AvatarAppearance wearing = new AvatarAppearance(wearables); 29 appearance = new AvatarAppearance(avatarId, wearables, visualParams);
30 m_avatarsClothes[avatarId] = wearing; 30 m_avatarsAppearance[avatarId] = appearance;
31 return true; 31 return true;
32 } 32 }
33 } 33 }
34 34
35
35 public void Initialise(Scene scene, IConfigSource source) 36 public void Initialise(Scene scene, IConfigSource source)
36 { 37 {
37 scene.RegisterModuleInterface<IAvatarFactory>(this); 38 scene.RegisterModuleInterface<IAvatarFactory>(this);
@@ -92,11 +93,12 @@ namespace OpenSim.Region.Environment.Modules
92 { 93 {
93 assetId = baseItem.assetID; 94 assetId = baseItem.assetID;
94 //temporary dictionary storage. This should be storing to a database 95 //temporary dictionary storage. This should be storing to a database
95 if (m_avatarsClothes.ContainsKey(clientView.AgentId)) 96
97 if (m_avatarsAppearance.ContainsKey(clientView.AgentId))
96 { 98 {
97 AvatarAppearance avWearing = m_avatarsClothes[clientView.AgentId]; 99 AvatarAppearance avatAppearance = m_avatarsAppearance[clientView.AgentId];
98 avWearing.IsWearing[wear.Type].AssetID = assetId; 100 avatAppearance.Wearables[wear.Type].AssetID = assetId;
99 avWearing.IsWearing[wear.Type].ItemID = wear.ItemID; 101 avatAppearance.Wearables[wear.Type].ItemID = wear.ItemID;
100 } 102 }
101 } 103 }
102 104
@@ -123,41 +125,6 @@ namespace OpenSim.Region.Environment.Modules
123 return visualParams; 125 return visualParams;
124 } 126 }
125 127
126 public class AvatarAppearance 128
127 {
128 public AvatarWearable[] IsWearing;
129 public byte[] VisualParams;
130
131 public AvatarAppearance()
132 {
133 IsWearing = new AvatarWearable[13];
134 for (int i = 0; i < 13; i++)
135 {
136 IsWearing[i] = new AvatarWearable();
137 }
138 }
139
140 public AvatarAppearance(AvatarWearable[] wearing)
141 {
142 if (wearing.Length == 13)
143 {
144 IsWearing = new AvatarWearable[13];
145 for (int i = 0; i < 13; i++)
146 {
147 IsWearing[i] = new AvatarWearable();
148 IsWearing[i].AssetID = wearing[i].AssetID;
149 IsWearing[i].ItemID = wearing[i].ItemID;
150 }
151 }
152 else
153 {
154 IsWearing = new AvatarWearable[13];
155 for (int i = 0; i < 13; i++)
156 {
157 IsWearing[i] = new AvatarWearable();
158 }
159 }
160 }
161 }
162 } 129 }
163} 130}
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}
diff --git a/OpenSim/Region/Environment/Scenes/InnerScene.cs b/OpenSim/Region/Environment/Scenes/InnerScene.cs
index 501f519..5335b6f 100644
--- a/OpenSim/Region/Environment/Scenes/InnerScene.cs
+++ b/OpenSim/Region/Environment/Scenes/InnerScene.cs
@@ -161,11 +161,11 @@ namespace OpenSim.Region.Environment.Scenes
161 } 161 }
162 } 162 }
163 163
164 public ScenePresence CreateAndAddScenePresence(IClientAPI client, bool child, AvatarWearable[] wearables, byte[] visualParams) 164 public ScenePresence CreateAndAddScenePresence(IClientAPI client, bool child, AvatarAppearance appearance)
165 { 165 {
166 ScenePresence newAvatar = null; 166 ScenePresence newAvatar = null;
167 167
168 newAvatar = new ScenePresence(client, m_parentScene, m_regInfo, visualParams, wearables); 168 newAvatar = new ScenePresence(client, m_parentScene, m_regInfo, appearance);
169 newAvatar.IsChildAgent = child; 169 newAvatar.IsChildAgent = child;
170 170
171 if (child) 171 if (child)
diff --git a/OpenSim/Region/Environment/Scenes/Scene.cs b/OpenSim/Region/Environment/Scenes/Scene.cs
index 40de870..b2cc750 100644
--- a/OpenSim/Region/Environment/Scenes/Scene.cs
+++ b/OpenSim/Region/Environment/Scenes/Scene.cs
@@ -991,11 +991,10 @@ namespace OpenSim.Region.Environment.Scenes
991 { 991 {
992 ScenePresence avatar = null; 992 ScenePresence avatar = null;
993 993
994 byte[] visualParams; 994 AvatarAppearance appearance;
995 AvatarWearable[] wearables; 995 LoadAvatarAppearance(client, out appearance);
996 LoadAvatarAppearance(client, out visualParams, out wearables);
997 996
998 avatar = m_innerScene.CreateAndAddScenePresence(client, child, wearables, visualParams); 997 avatar = m_innerScene.CreateAndAddScenePresence(client, child, appearance);
999 998
1000 if (avatar.IsChildAgent) 999 if (avatar.IsChildAgent)
1001 { 1000 {
@@ -1005,12 +1004,16 @@ namespace OpenSim.Region.Environment.Scenes
1005 return avatar; 1004 return avatar;
1006 } 1005 }
1007 1006
1008 protected void LoadAvatarAppearance(IClientAPI client, out byte[] visualParams, out AvatarWearable[] wearables) 1007 protected void LoadAvatarAppearance(IClientAPI client, out AvatarAppearance appearance)
1009 { 1008 {
1010 if (m_AvatarFactory == null || 1009 if (m_AvatarFactory == null ||
1011 !m_AvatarFactory.TryGetInitialAvatarAppearance(client.AgentId, out wearables, out visualParams)) 1010 !m_AvatarFactory.TryGetAvatarAppearance(client.AgentId, out appearance))
1012 { 1011 {
1012 //not found Appearance
1013 byte[] visualParams;
1014 AvatarWearable[] wearables;
1013 AvatarFactoryModule.GetDefaultAvatarAppearance(out wearables, out visualParams); 1015 AvatarFactoryModule.GetDefaultAvatarAppearance(out wearables, out visualParams);
1016 appearance = new AvatarAppearance(client.AgentId, wearables, visualParams);
1014 } 1017 }
1015 } 1018 }
1016 1019
diff --git a/OpenSim/Region/Environment/Scenes/ScenePresence.cs b/OpenSim/Region/Environment/Scenes/ScenePresence.cs
index 66872fa..f8571a9 100644
--- a/OpenSim/Region/Environment/Scenes/ScenePresence.cs
+++ b/OpenSim/Region/Environment/Scenes/ScenePresence.cs
@@ -58,10 +58,7 @@ namespace OpenSim.Region.Environment.Scenes
58 private bool m_setAlwaysRun = false; 58 private bool m_setAlwaysRun = false;
59 59
60 private Quaternion m_bodyRot; 60 private Quaternion m_bodyRot;
61 private byte[] m_visualParams; 61
62 private AvatarWearable[] m_wearables;
63 private LLObject.TextureEntry m_textureEntry;
64
65 public bool IsRestrictedToRegion = false; 62 public bool IsRestrictedToRegion = false;
66 63
67 private bool m_newForce = false; 64 private bool m_newForce = false;
@@ -75,7 +72,7 @@ namespace OpenSim.Region.Environment.Scenes
75 72
76 private readonly Vector3[] Dir_Vectors = new Vector3[6]; 73 private readonly Vector3[] Dir_Vectors = new Vector3[6];
77 private LLVector3 lastPhysPos = new LLVector3(); 74 private LLVector3 lastPhysPos = new LLVector3();
78 private int m_wearablesSerial = 1; 75
79 76
80 // Position of agent's camera in world 77 // Position of agent's camera in world
81 protected Vector3 m_CameraCenter = new Vector3(0, 0, 0); 78 protected Vector3 m_CameraCenter = new Vector3(0, 0, 0);
@@ -89,6 +86,8 @@ namespace OpenSim.Region.Environment.Scenes
89 // Agent's Draw distance. 86 // Agent's Draw distance.
90 protected float m_DrawDistance = 0f; 87 protected float m_DrawDistance = 0f;
91 88
89 protected AvatarAppearance m_appearance;
90
92 private readonly List<ulong> m_knownChildRegions = new List<ulong>(); //neighbouring regions we have enabled a child agent in 91 private readonly List<ulong> m_knownChildRegions = new List<ulong>(); //neighbouring regions we have enabled a child agent in
93 92
94 private enum Dir_ControlFlags 93 private enum Dir_ControlFlags
@@ -110,13 +109,6 @@ namespace OpenSim.Region.Environment.Scenes
110 109
111 public event SignificantClientMovement OnSignificantClientMovement; 110 public event SignificantClientMovement OnSignificantClientMovement;
112 111
113 //public List<SceneObjectGroup> InterestList = new List<SceneObjectGroup>();
114
115 // private string m_currentQuadNode = " ";
116
117 // private Queue<SceneObjectPart> m_fullPartUpdates = new Queue<SceneObjectPart>();
118 //private Queue<SceneObjectPart> m_tersePartUpdates = new Queue<SceneObjectPart>();
119
120 private UpdateQueue m_partsUpdateQueue = new UpdateQueue(); 112 private UpdateQueue m_partsUpdateQueue = new UpdateQueue();
121 private Dictionary<LLUUID, ScenePartUpdate> m_updateTimes = new Dictionary<LLUUID, ScenePartUpdate>(); 113 private Dictionary<LLUUID, ScenePartUpdate> m_updateTimes = new Dictionary<LLUUID, ScenePartUpdate>();
122 114
@@ -280,23 +272,74 @@ namespace OpenSim.Region.Environment.Scenes
280 public ScenePresence(IClientAPI client, Scene world, RegionInfo reginfo, byte[] visualParams, 272 public ScenePresence(IClientAPI client, Scene world, RegionInfo reginfo, byte[] visualParams,
281 AvatarWearable[] wearables) 273 AvatarWearable[] wearables)
282 { 274 {
283 m_scene = world; 275 //couldn't move the following into SetInitialValues as they are readonly
284 m_uuid = client.AgentId; 276 m_regionHandle = reginfo.RegionHandle;
277 m_controllingClient = client;
278 m_firstname = m_controllingClient.FirstName;
279 m_lastname = m_controllingClient.LastName;
285 280
286 m_regionInfo = reginfo; 281 SetInitialValues(client, world, reginfo);
282
283 m_appearance = new AvatarAppearance(m_uuid, wearables, visualParams);
284
285 Animations = new AvatarAnimations();
286 Animations.LoadAnims();
287
288 RegisterToEvents();
289
290 SetDirectionVectors();
291
292 //m_textureEntry = new LLObject.TextureEntry(DefaultTexture, 0, DefaultTexture.Length);
293
294 // m_textureEntry = GetDefaultTextureEntry();
295 //temporary until we move some code into the body classes
296
297 if (m_newAvatar)
298 {
299 //do we need to use newAvatar? not sure so have added this to kill the compile warning
300 }
301
302 m_scene.LandManager.sendLandUpdate(this);
303 }
304
305
306 public ScenePresence(IClientAPI client, Scene world, RegionInfo reginfo, AvatarAppearance appearance)
307 {
308 //couldn't move the following into SetInitialValues as they are readonly
287 m_regionHandle = reginfo.RegionHandle; 309 m_regionHandle = reginfo.RegionHandle;
288 m_controllingClient = client; 310 m_controllingClient = client;
289 m_firstname = m_controllingClient.FirstName; 311 m_firstname = m_controllingClient.FirstName;
290 m_lastname = m_controllingClient.LastName; 312 m_lastname = m_controllingClient.LastName;
291 m_localId = m_scene.NextLocalId;
292 AbsolutePosition = m_controllingClient.StartPos;
293 313
294 m_visualParams = visualParams; 314 SetInitialValues(client, world, reginfo);
295 m_wearables = wearables; 315
316 m_appearance = appearance;
296 317
297 Animations = new AvatarAnimations(); 318 Animations = new AvatarAnimations();
298 Animations.LoadAnims(); 319 Animations.LoadAnims();
299 320
321 RegisterToEvents();
322 SetDirectionVectors();
323
324 if (m_newAvatar)
325 {
326 //do we need to use newAvatar? not sure so have added this to kill the compile warning
327 }
328
329 m_scene.LandManager.sendLandUpdate(this);
330 }
331
332 private void SetInitialValues(IClientAPI client, Scene world, RegionInfo reginfo)
333 {
334 m_scene = world;
335 m_uuid = client.AgentId;
336 m_regionInfo = reginfo;
337 m_localId = m_scene.NextLocalId;
338 AbsolutePosition = m_controllingClient.StartPos;
339 }
340
341 private void RegisterToEvents()
342 {
300 //register for events 343 //register for events
301 m_controllingClient.OnRequestWearables += SendOwnAppearance; 344 m_controllingClient.OnRequestWearables += SendOwnAppearance;
302 m_controllingClient.OnSetAppearance += SetAppearance; 345 m_controllingClient.OnSetAppearance += SetAppearance;
@@ -306,30 +349,21 @@ namespace OpenSim.Region.Environment.Scenes
306 m_controllingClient.OnAgentRequestSit += HandleAgentRequestSit; 349 m_controllingClient.OnAgentRequestSit += HandleAgentRequestSit;
307 m_controllingClient.OnAgentSit += HandleAgentSit; 350 m_controllingClient.OnAgentSit += HandleAgentSit;
308 m_controllingClient.OnSetAlwaysRun += HandleSetAlwaysRun; 351 m_controllingClient.OnSetAlwaysRun += HandleSetAlwaysRun;
309 352
310 // ControllingClient.OnStartAnim += new StartAnim(this.SendAnimPack); 353 // ControllingClient.OnStartAnim += new StartAnim(this.SendAnimPack);
311 // ControllingClient.OnChildAgentStatus += new StatusChange(this.ChildStatusChange); 354 // ControllingClient.OnChildAgentStatus += new StatusChange(this.ChildStatusChange);
312 //ControllingClient.OnStopMovement += new GenericCall2(this.StopMovement); 355 //ControllingClient.OnStopMovement += new GenericCall2(this.StopMovement);
356 }
313 357
358 private void SetDirectionVectors()
359 {
314 Dir_Vectors[0] = new Vector3(1, 0, 0); //FOWARD 360 Dir_Vectors[0] = new Vector3(1, 0, 0); //FOWARD
315 Dir_Vectors[1] = new Vector3(-1, 0, 0); //BACK 361 Dir_Vectors[1] = new Vector3(-1, 0, 0); //BACK
316 Dir_Vectors[2] = new Vector3(0, 1, 0); //LEFT 362 Dir_Vectors[2] = new Vector3(0, 1, 0); //LEFT
317 Dir_Vectors[3] = new Vector3(0, -1, 0); //RIGHT 363 Dir_Vectors[3] = new Vector3(0, -1, 0); //RIGHT
318 Dir_Vectors[4] = new Vector3(0, 0, 1); //UP 364 Dir_Vectors[4] = new Vector3(0, 0, 1); //UP
319 Dir_Vectors[5] = new Vector3(0, 0, -1); //DOWN 365 Dir_Vectors[5] = new Vector3(0, 0, -1); //DOWN
320
321 m_textureEntry = new LLObject.TextureEntry(DefaultTexture, 0, DefaultTexture.Length);
322
323 //temporary until we move some code into the body classes
324
325 if (m_newAvatar)
326 {
327 //do we need to use newAvatar? not sure so have added this to kill the compile warning
328 }
329
330 m_scene.LandManager.sendLandUpdate(this);
331 } 366 }
332
333 #endregion 367 #endregion
334 368
335 public void QueuePartForUpdate(SceneObjectPart part) 369 public void QueuePartForUpdate(SceneObjectPart part)
@@ -371,33 +405,33 @@ namespace OpenSim.Region.Environment.Scenes
371 if (m_updateTimes.ContainsKey(part.UUID)) 405 if (m_updateTimes.ContainsKey(part.UUID))
372 { 406 {
373 ScenePartUpdate update = m_updateTimes[part.UUID]; 407 ScenePartUpdate update = m_updateTimes[part.UUID];
374 408
375 // Two updates can occur with the same timestamp (especially 409 // Two updates can occur with the same timestamp (especially
376 // since our timestamp resolution is to the nearest second). The first 410 // since our timestamp resolution is to the nearest second). The first
377 // could have been sent in the last update - we still need to send the 411 // could have been sent in the last update - we still need to send the
378 // second here. 412 // second here.
379 413
380 414
381 415
382 if (update.LastFullUpdateTime < part.TimeStampFull) 416 if (update.LastFullUpdateTime < part.TimeStampFull)
383 { 417 {
384 //need to do a full update 418 //need to do a full update
385 part.SendFullUpdate(ControllingClient, GenerateClientFlags(part.UUID)); 419 part.SendFullUpdate(ControllingClient, GenerateClientFlags(part.UUID));
386 420
387 // We'll update to the part's timestamp rather than the current to 421 // We'll update to the part's timestamp rather than the current to
388 // avoid the race condition whereby the next tick occurs while we are 422 // avoid the race condition whereby the next tick occurs while we are
389 // doing this update. If this happened, then subsequent updates which occurred 423 // doing this update. If this happened, then subsequent updates which occurred
390 // on the same tick or the next tick of the last update would be ignored. 424 // on the same tick or the next tick of the last update would be ignored.
391 update.LastFullUpdateTime = part.TimeStampFull; 425 update.LastFullUpdateTime = part.TimeStampFull;
392 426
393 updateCount++; 427 updateCount++;
394 } 428 }
395 else if (update.LastTerseUpdateTime <= part.TimeStampTerse) 429 else if (update.LastTerseUpdateTime <= part.TimeStampTerse)
396 { 430 {
397 431
398 432
399 part.SendTerseUpdate(ControllingClient); 433 part.SendTerseUpdate(ControllingClient);
400 434
401 update.LastTerseUpdateTime = part.TimeStampTerse; 435 update.LastTerseUpdateTime = part.TimeStampTerse;
402 updateCount++; 436 updateCount++;
403 } 437 }
@@ -437,8 +471,8 @@ namespace OpenSim.Region.Environment.Scenes
437 m_scene.CommsManager.UserProfileCacheService.UpdateUserInventory(m_uuid); 471 m_scene.CommsManager.UserProfileCacheService.UpdateUserInventory(m_uuid);
438 //if (!m_gotAllObjectsInScene) 472 //if (!m_gotAllObjectsInScene)
439 //{ 473 //{
440 //m_scene.SendAllSceneObjectsToClient(this); 474 //m_scene.SendAllSceneObjectsToClient(this);
441 //m_gotAllObjectsInScene = true; 475 //m_gotAllObjectsInScene = true;
442 //} 476 //}
443 477
444 } 478 }
@@ -449,7 +483,7 @@ namespace OpenSim.Region.Environment.Scenes
449 m_isChildAgent = true; 483 m_isChildAgent = true;
450 484
451 RemoveFromPhysicalScene(); 485 RemoveFromPhysicalScene();
452 486
453 //this.Pos = new LLVector3(128, 128, 70); 487 //this.Pos = new LLVector3(128, 128, 70);
454 } 488 }
455 489
@@ -500,34 +534,14 @@ namespace OpenSim.Region.Environment.Scenes
500 534
501 #region Event Handlers 535 #region Event Handlers
502 536
503 /// <summary> 537 internal void SetHeight(float height)
504 ///
505 /// </summary>
506 /// <param name="texture"></param>
507 /// <param name="visualParam"></param>
508 public void SetAppearance(byte[] texture, AgentSetAppearancePacket.VisualParamBlock[] visualParam)
509 { 538 {
510 LLObject.TextureEntry textureEnt = new LLObject.TextureEntry(texture, 0, texture.Length); 539 m_avHeight = height;
511 m_textureEntry = textureEnt;
512
513 for (int i = 0; i < visualParam.Length; i++)
514 {
515 m_visualParams[i] = visualParam[i].ParamValue;
516 //MainLog.Instance.Verbose("CLIENT", "VisualData[" + i.ToString() + "]: " + visualParam[i].ParamValue.ToString() + "m");
517 }
518
519 // Teravus : Nifty AV Height Getting Maaaaagical formula. Oh how we love turning 0-255 into meters.
520 // (float)m_visualParams[25] = Height
521 // (float)m_visualParams[125] = LegLength
522 m_avHeight = (1.50856f + (((float)m_visualParams[25] / 255.0f) * (2.525506f - 1.50856f)))
523 + (((float)m_visualParams[125] / 255.0f) / 1.5f);
524 if (PhysicsActor != null) 540 if (PhysicsActor != null)
525 { 541 {
526 PhysicsVector SetSize = new PhysicsVector(0.45f, 0.6f, m_avHeight); 542 PhysicsVector SetSize = new PhysicsVector(0.45f, 0.6f, m_avHeight);
527 PhysicsActor.Size = SetSize; 543 PhysicsActor.Size = SetSize;
528 } 544 }
529 //MainLog.Instance.Verbose("CLIENT", "Set Avatar Height to: " + (1.50856f + (((float)m_visualParams[25] / 255.0f) * (2.525506f - 1.50856f))).ToString() + "m" + " Leglength: " + ((float)m_visualParams[125]).ToString() + ":" + (((float)m_visualParams[125] / 255.0f)).ToString() + "m");
530 SendAppearanceToAllOtherAgents();
531 } 545 }
532 546
533 /// <summary> 547 /// <summary>
@@ -571,7 +585,7 @@ namespace OpenSim.Region.Environment.Scenes
571 m_CameraCenter.x = agentData.AgentData.CameraCenter.X; 585 m_CameraCenter.x = agentData.AgentData.CameraCenter.X;
572 m_CameraCenter.y = agentData.AgentData.CameraCenter.Y; 586 m_CameraCenter.y = agentData.AgentData.CameraCenter.Y;
573 m_CameraCenter.z = agentData.AgentData.CameraCenter.Z; 587 m_CameraCenter.z = agentData.AgentData.CameraCenter.Z;
574 588
575 // Use these three vectors to figure out what the agent is looking at 589 // Use these three vectors to figure out what the agent is looking at
576 // Convert it to a Matrix and/or Quaternion 590 // Convert it to a Matrix and/or Quaternion
577 m_CameraAtAxis.x = agentData.AgentData.CameraAtAxis.X; 591 m_CameraAtAxis.x = agentData.AgentData.CameraAtAxis.X;
@@ -592,24 +606,24 @@ namespace OpenSim.Region.Environment.Scenes
592 // We don't know the agent's draw distance until the first agentUpdate packet 606 // We don't know the agent's draw distance until the first agentUpdate packet
593 //if (m_DrawDistance > 0) 607 //if (m_DrawDistance > 0)
594 //{ 608 //{
595 //if (!m_gotAllObjectsInScene && m_DrawDistance > 0) 609 //if (!m_gotAllObjectsInScene && m_DrawDistance > 0)
596 //{ 610 //{
597 // This will need to end up being a space based invalidator 611 // This will need to end up being a space based invalidator
598 // where we send object updates on spaces in 3d space (possibily a cube) 612 // where we send object updates on spaces in 3d space (possibily a cube)
599 // that the avatar hasn't been surrounding it's draw distance. 613 // that the avatar hasn't been surrounding it's draw distance.
600 // It would be better if the distance increased incrementally 614 // It would be better if the distance increased incrementally
601 // until there was no space to update because either the avatar's draw 615 // until there was no space to update because either the avatar's draw
602 // distance is smaller then the space they've been or the avatar has explored 616 // distance is smaller then the space they've been or the avatar has explored
603 // all the space in the sim. 617 // all the space in the sim.
604 618
605 //m_scene.SendAllSceneObjectsToClient(this); 619 //m_scene.SendAllSceneObjectsToClient(this);
606 //m_gotAllObjectsInScene = true; 620 //m_gotAllObjectsInScene = true;
607 //} 621 //}
608 //} 622 //}
609 //MainLog.Instance.Verbose("CAMERA", "AtAxis:" + m_CameraAtAxis.ToString() + " Center:" + m_CameraCenter.ToString() + " LeftAxis:" + m_CameraLeftAxis.ToString() + " UpAxis:" + m_CameraUpAxis.ToString() + " Far:" + m_CameraFar); 623 //MainLog.Instance.Verbose("CAMERA", "AtAxis:" + m_CameraAtAxis.ToString() + " Center:" + m_CameraCenter.ToString() + " LeftAxis:" + m_CameraLeftAxis.ToString() + " UpAxis:" + m_CameraUpAxis.ToString() + " Far:" + m_CameraFar);
610
611 624
612 if ((flags & (uint) AgentManager.ControlFlags.AGENT_CONTROL_STAND_UP) != 0) 625
626 if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_STAND_UP) != 0)
613 { 627 {
614 StandUp(); 628 StandUp();
615 } 629 }
@@ -684,7 +698,7 @@ namespace OpenSim.Region.Environment.Scenes
684 { 698 {
685 if (m_parentID != 0) 699 if (m_parentID != 0)
686 { 700 {
687 m_pos += m_parentPosition + new LLVector3(0.0f, 0.0f, 2.0f*m_sitAvatarHeight); 701 m_pos += m_parentPosition + new LLVector3(0.0f, 0.0f, 2.0f * m_sitAvatarHeight);
688 m_parentPosition = new LLVector3(); 702 m_parentPosition = new LLVector3();
689 703
690 AddToPhysicalScene(); 704 AddToPhysicalScene();
@@ -692,7 +706,7 @@ namespace OpenSim.Region.Environment.Scenes
692 m_parentID = 0; 706 m_parentID = 0;
693 SendFullUpdateToAllClients(); 707 SendFullUpdateToAllClients();
694 } 708 }
695 709
696 UpdateMovementAnimations(true); 710 UpdateMovementAnimations(true);
697 } 711 }
698 712
@@ -718,13 +732,13 @@ namespace OpenSim.Region.Environment.Scenes
718 m_sitAvatarHeight = m_physicsActor.Size.Z; 732 m_sitAvatarHeight = m_physicsActor.Size.Z;
719 } 733 }
720 734
721// this doesn't seem to quite work yet.... 735 // this doesn't seem to quite work yet....
722// // if we're close, set the avatar position to the target position and forgo autopilot 736 // // if we're close, set the avatar position to the target position and forgo autopilot
723// if (AbsolutePosition.GetDistanceTo(pos) < 2.5) 737 // if (AbsolutePosition.GetDistanceTo(pos) < 2.5)
724// { 738 // {
725// autopilot = false; 739 // autopilot = false;
726// AbsolutePosition = pos + new LLVector3(0.0f, 0.0f, m_sitAvatarHeight); 740 // AbsolutePosition = pos + new LLVector3(0.0f, 0.0f, m_sitAvatarHeight);
727// } 741 // }
728 } 742 }
729 743
730 avatarSitResponse.SitTransform.AutoPilot = autopilot; 744 avatarSitResponse.SitTransform.AutoPilot = autopilot;
@@ -796,7 +810,7 @@ namespace OpenSim.Region.Environment.Scenes
796 } 810 }
797 else 811 else
798 { 812 {
799 if (((m_movementflag & (uint) AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG) != 0) && 813 if (((m_movementflag & (uint)AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG) != 0) &&
800 PhysicsActor.IsColliding) 814 PhysicsActor.IsColliding)
801 { 815 {
802 SendAnimPack(Animations.AnimsLLUUID["CROUCHWALK"], 1); 816 SendAnimPack(Animations.AnimsLLUUID["CROUCHWALK"], 1);
@@ -807,7 +821,7 @@ namespace OpenSim.Region.Environment.Scenes
807 { 821 {
808 SendAnimPack(Animations.AnimsLLUUID["FALLDOWN"], 1); 822 SendAnimPack(Animations.AnimsLLUUID["FALLDOWN"], 1);
809 } 823 }
810 else if (!PhysicsActor.IsColliding && Velocity.Z > 0 && (m_movementflag & (uint) AgentManager.ControlFlags.AGENT_CONTROL_UP_POS) != 0) 824 else if (!PhysicsActor.IsColliding && Velocity.Z > 0 && (m_movementflag & (uint)AgentManager.ControlFlags.AGENT_CONTROL_UP_POS) != 0)
811 { 825 {
812 SendAnimPack(Animations.AnimsLLUUID["JUMP"], 1); 826 SendAnimPack(Animations.AnimsLLUUID["JUMP"], 1);
813 } 827 }
@@ -839,7 +853,7 @@ namespace OpenSim.Region.Environment.Scenes
839 } 853 }
840 else 854 else
841 { 855 {
842 if (((m_movementflag & (uint) AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG) != 0) && 856 if (((m_movementflag & (uint)AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG) != 0) &&
843 PhysicsActor.IsColliding) 857 PhysicsActor.IsColliding)
844 { 858 {
845 SendAnimPack(Animations.AnimsLLUUID["CROUCH"], 1); 859 SendAnimPack(Animations.AnimsLLUUID["CROUCH"], 1);
@@ -854,7 +868,7 @@ namespace OpenSim.Region.Environment.Scenes
854 { 868 {
855 SendAnimPack(Animations.AnimsLLUUID["FALLDOWN"], 1); 869 SendAnimPack(Animations.AnimsLLUUID["FALLDOWN"], 1);
856 } 870 }
857 else if (!PhysicsActor.IsColliding && Velocity.Z > 0 && !m_physicsActor.Flying && (m_movementflag & (uint) AgentManager.ControlFlags.AGENT_CONTROL_UP_POS) != 0) 871 else if (!PhysicsActor.IsColliding && Velocity.Z > 0 && !m_physicsActor.Flying && (m_movementflag & (uint)AgentManager.ControlFlags.AGENT_CONTROL_UP_POS) != 0)
858 { 872 {
859 SendAnimPack(Animations.AnimsLLUUID["JUMP"], 1); 873 SendAnimPack(Animations.AnimsLLUUID["JUMP"], 1);
860 } 874 }
@@ -865,7 +879,7 @@ namespace OpenSim.Region.Environment.Scenes
865 SendAnimPack(Animations.AnimsLLUUID["STAND"], 1); 879 SendAnimPack(Animations.AnimsLLUUID["STAND"], 1);
866 } 880 }
867 } 881 }
868 882
869 } 883 }
870 } 884 }
871 } 885 }
@@ -1022,7 +1036,7 @@ namespace OpenSim.Region.Environment.Scenes
1022 public void SendFullUpdateToOtherClient(ScenePresence remoteAvatar) 1036 public void SendFullUpdateToOtherClient(ScenePresence remoteAvatar)
1023 { 1037 {
1024 remoteAvatar.m_controllingClient.SendAvatarData(m_regionInfo.RegionHandle, m_firstname, m_lastname, m_uuid, 1038 remoteAvatar.m_controllingClient.SendAvatarData(m_regionInfo.RegionHandle, m_firstname, m_lastname, m_uuid,
1025 LocalId, m_pos, m_textureEntry.ToBytes(), m_parentID); 1039 LocalId, m_pos, m_appearance.TextureEntry.ToBytes(), m_parentID);
1026 } 1040 }
1027 1041
1028 public void SendFullUpdateToAllClients() 1042 public void SendFullUpdateToAllClients()
@@ -1048,7 +1062,7 @@ namespace OpenSim.Region.Environment.Scenes
1048 public void SendInitialData() 1062 public void SendInitialData()
1049 { 1063 {
1050 m_controllingClient.SendAvatarData(m_regionInfo.RegionHandle, m_firstname, m_lastname, m_uuid, LocalId, 1064 m_controllingClient.SendAvatarData(m_regionInfo.RegionHandle, m_firstname, m_lastname, m_uuid, LocalId,
1051 m_pos, m_textureEntry.ToBytes(), m_parentID); 1065 m_pos, m_appearance.TextureEntry.ToBytes(), m_parentID);
1052 if (!m_isChildAgent) 1066 if (!m_isChildAgent)
1053 { 1067 {
1054 m_scene.InformClientOfNeighbours(this); 1068 m_scene.InformClientOfNeighbours(this);
@@ -1065,7 +1079,7 @@ namespace OpenSim.Region.Environment.Scenes
1065 /// <param name="client"></param> 1079 /// <param name="client"></param>
1066 public void SendOwnAppearance() 1080 public void SendOwnAppearance()
1067 { 1081 {
1068 SendOwnWearables(); 1082 m_appearance.SendOwnWearables(ControllingClient);
1069 1083
1070 // TODO: remove this once the SunModule is slightly more tested 1084 // TODO: remove this once the SunModule is slightly more tested
1071 // m_controllingClient.SendViewerTime(m_scene.TimePhase); 1085 // m_controllingClient.SendViewerTime(m_scene.TimePhase);
@@ -1078,23 +1092,32 @@ namespace OpenSim.Region.Environment.Scenes
1078 { 1092 {
1079 m_scene.ForEachScenePresence(delegate(ScenePresence scenePresence) 1093 m_scene.ForEachScenePresence(delegate(ScenePresence scenePresence)
1080 { 1094 {
1081 // if (scenePresence != this) 1095 if (scenePresence.UUID != UUID)
1082 // { 1096 {
1083 SendAppearanceToOtherAgent(scenePresence); 1097 m_appearance.SendAppearanceToOtherAgent(scenePresence);
1084 // } 1098 }
1085 }); 1099 });
1086 } 1100 }
1087 1101
1088 /// <summary> 1102 public void SendAppearanceToOtherAgent(ScenePresence avatar)
1089 ///
1090 /// </summary>
1091 /// <param name="avatarInfo"></param>
1092 public void SendAppearanceToOtherAgent(ScenePresence avatarInfo)
1093 { 1103 {
1094 avatarInfo.m_controllingClient.SendAppearance(m_controllingClient.AgentId, m_visualParams, 1104 m_appearance.SendAppearanceToOtherAgent(avatar);
1095 m_textureEntry.ToBytes());
1096 } 1105 }
1097 1106
1107 public void SetAppearance(byte[] texture, AgentSetAppearancePacket.VisualParamBlock[] visualParam)
1108 {
1109 m_appearance.SetAppearance(texture, visualParam);
1110 SetHeight(m_appearance.AvatarHeight);
1111
1112 SendAppearanceToAllOtherAgents();
1113 }
1114
1115 public void SetWearable(int wearableId, AvatarWearable wearable)
1116 {
1117 m_appearance.SetWearable(ControllingClient, wearableId, wearable);
1118 }
1119
1120
1098 /// <summary> 1121 /// <summary>
1099 /// 1122 ///
1100 /// </summary> 1123 /// </summary>
@@ -1147,9 +1170,9 @@ namespace OpenSim.Region.Environment.Scenes
1147 LLVector3 vel = Velocity; 1170 LLVector3 vel = Velocity;
1148 1171
1149 float timeStep = 0.1f; 1172 float timeStep = 0.1f;
1150 pos2.X = pos2.X + (vel.X*timeStep); 1173 pos2.X = pos2.X + (vel.X * timeStep);
1151 pos2.Y = pos2.Y + (vel.Y*timeStep); 1174 pos2.Y = pos2.Y + (vel.Y * timeStep);
1152 pos2.Z = pos2.Z + (vel.Z*timeStep); 1175 pos2.Z = pos2.Z + (vel.Z * timeStep);
1153 1176
1154 if ((pos2.X < 0) || (pos2.X > 256)) 1177 if ((pos2.X < 0) || (pos2.X > 256))
1155 { 1178 {
@@ -1194,7 +1217,7 @@ namespace OpenSim.Region.Environment.Scenes
1194 } 1217 }
1195 1218
1196 LLVector3 vel = m_velocity; 1219 LLVector3 vel = m_velocity;
1197 ulong neighbourHandle = Helpers.UIntsToLong((uint) (neighbourx*256), (uint) (neighboury*256)); 1220 ulong neighbourHandle = Helpers.UIntsToLong((uint)(neighbourx * 256), (uint)(neighboury * 256));
1198 SimpleRegionInfo neighbourRegion = m_scene.RequestNeighbouringRegionInfo(neighbourHandle); 1221 SimpleRegionInfo neighbourRegion = m_scene.RequestNeighbouringRegionInfo(neighbourHandle);
1199 if (neighbourRegion != null) 1222 if (neighbourRegion != null)
1200 { 1223 {
@@ -1269,14 +1292,7 @@ namespace OpenSim.Region.Environment.Scenes
1269 1292
1270 static ScenePresence() 1293 static ScenePresence()
1271 { 1294 {
1272 LLObject.TextureEntry textu = new LLObject.TextureEntry(new LLUUID("C228D1CF-4B5D-4BA8-84F4-899A0796AA97")); 1295 LLObject.TextureEntry textu = AvatarAppearance.GetDefaultTextureEntry();
1273 textu.CreateFace(0).TextureID = new LLUUID("00000000-0000-1111-9999-000000000012");
1274 textu.CreateFace(1).TextureID = new LLUUID("5748decc-f629-461c-9a36-a35a221fe21f");
1275 textu.CreateFace(2).TextureID = new LLUUID("5748decc-f629-461c-9a36-a35a221fe21f");
1276 textu.CreateFace(3).TextureID = new LLUUID("6522E74D-1660-4E7F-B601-6F48C1659A77");
1277 textu.CreateFace(4).TextureID = new LLUUID("7CA39B4C-BD19-4699-AFF7-F93FD03D3E7B");
1278 textu.CreateFace(5).TextureID = new LLUUID("00000000-0000-1111-9999-000000000010");
1279 textu.CreateFace(6).TextureID = new LLUUID("00000000-0000-1111-9999-000000000011");
1280 DefaultTexture = textu.ToBytes(); 1296 DefaultTexture = textu.ToBytes();
1281 } 1297 }
1282 1298
@@ -1334,15 +1350,5 @@ namespace OpenSim.Region.Environment.Scenes
1334 RemoveFromPhysicalScene(); 1350 RemoveFromPhysicalScene();
1335 } 1351 }
1336 1352
1337 public void SetWearable(int wearableId, AvatarWearable wearable)
1338 {
1339 m_wearables[wearableId] = wearable;
1340 SendOwnWearables();
1341 }
1342
1343 private void SendOwnWearables()
1344 {
1345 m_controllingClient.SendWearables(m_wearables, m_wearablesSerial++);
1346 }
1347 } 1353 }
1348} 1354}