Annotation of /trunk/ModularRex/RexFramework/RexObjectProperties.cs
Parent Directory
|
Revision Log
Revision 291 - (view) (download)
| 1 : | mikkopa | 28 | using System; |
| 2 : | mikkopa | 39 | using System.Collections; |
| 3 : | mikkopa | 28 | using System.Collections.Generic; |
| 4 : | using System.Reflection; | ||
| 5 : | using System.Text; | ||
| 6 : | using System.Xml; | ||
| 7 : | using System.Xml.Schema; | ||
| 8 : | using System.Xml.Serialization; | ||
| 9 : | using log4net; | ||
| 10 : | using OpenMetaverse; | ||
| 11 : | |||
| 12 : | namespace ModularRex.RexFramework | ||
| 13 : | { | ||
| 14 : | public class RexObjectProperties | ||
| 15 : | { | ||
| 16 : | tuco | 57 | private IRexObjectPropertiesEventManager RexEventManager = null; |
| 17 : | tuco | 64 | private bool mProcessingPacketData = false; |
| 18 : | tuco | 57 | |
| 19 : | mikkopa | 28 | private static readonly ILog m_log = |
| 20 : | LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
| 21 : | |||
| 22 : | mikkopa | 39 | #region Properties |
| 23 : | mikkopa | 28 | |
| 24 : | mikkopa | 39 | private UUID parentObjectID = UUID.Zero; |
| 25 : | public UUID ParentObjectID | ||
| 26 : | { | ||
| 27 : | get { return parentObjectID; } | ||
| 28 : | set { parentObjectID = value; } | ||
| 29 : | mikkopa | 28 | } |
| 30 : | |||
| 31 : | tuco | 57 | private byte m_RexDrawType = 0; |
| 32 : | mikkopa | 28 | public byte RexDrawType |
| 33 : | { | ||
| 34 : | get { return m_RexDrawType; } | ||
| 35 : | set | ||
| 36 : | { | ||
| 37 : | m_RexDrawType = value; | ||
| 38 : | tuco | 57 | TriggerChangedRexObjectProperties(); |
| 39 : | mikkopa | 28 | } |
| 40 : | } | ||
| 41 : | |||
| 42 : | private bool m_RexIsVisible = true; | ||
| 43 : | public bool RexIsVisible | ||
| 44 : | { | ||
| 45 : | get { return m_RexIsVisible; } | ||
| 46 : | set | ||
| 47 : | { | ||
| 48 : | m_RexIsVisible = value; | ||
| 49 : | tuco | 57 | TriggerChangedRexObjectProperties(); |
| 50 : | mikkopa | 28 | } |
| 51 : | } | ||
| 52 : | |||
| 53 : | mikkopa | 39 | private bool m_RexCastShadows = false; |
| 54 : | mikkopa | 28 | public bool RexCastShadows |
| 55 : | { | ||
| 56 : | get { return m_RexCastShadows; } | ||
| 57 : | set | ||
| 58 : | { | ||
| 59 : | m_RexCastShadows = value; | ||
| 60 : | tuco | 57 | TriggerChangedRexObjectProperties(); |
| 61 : | mikkopa | 28 | } |
| 62 : | } | ||
| 63 : | |||
| 64 : | mikkopa | 39 | private bool m_RexLightCreatesShadows = false; |
| 65 : | mikkopa | 28 | public bool RexLightCreatesShadows |
| 66 : | { | ||
| 67 : | get { return m_RexLightCreatesShadows; } | ||
| 68 : | set | ||
| 69 : | { | ||
| 70 : | m_RexLightCreatesShadows = value; | ||
| 71 : | tuco | 57 | TriggerChangedRexObjectProperties(); |
| 72 : | mikkopa | 28 | } |
| 73 : | } | ||
| 74 : | |||
| 75 : | mikkopa | 39 | private bool m_RexDescriptionTexture = false; |
| 76 : | mikkopa | 28 | public bool RexDescriptionTexture |
| 77 : | { | ||
| 78 : | get { return m_RexDescriptionTexture; } | ||
| 79 : | set | ||
| 80 : | { | ||
| 81 : | m_RexDescriptionTexture = value; | ||
| 82 : | tuco | 57 | TriggerChangedRexObjectProperties(); |
| 83 : | mikkopa | 28 | } |
| 84 : | } | ||
| 85 : | |||
| 86 : | mikkopa | 39 | private bool m_RexScaleToPrim = false; |
| 87 : | mikkopa | 28 | public bool RexScaleToPrim |
| 88 : | { | ||
| 89 : | get { return m_RexScaleToPrim; } | ||
| 90 : | set | ||
| 91 : | { | ||
| 92 : | tuco | 57 | bool oldscale = m_RexScaleToPrim; |
| 93 : | mikkopa | 28 | m_RexScaleToPrim = value; |
| 94 : | tuco | 57 | |
| 95 : | if (oldscale != m_RexScaleToPrim && RexEventManager != null) | ||
| 96 : | RexEventManager.TriggerOnChangeScaleToPrim(parentObjectID); | ||
| 97 : | |||
| 98 : | TriggerChangedRexObjectProperties(); | ||
| 99 : | mikkopa | 28 | } |
| 100 : | } | ||
| 101 : | |||
| 102 : | mikkopa | 39 | private float m_RexDrawDistance = 0; |
| 103 : | mikkopa | 28 | public float RexDrawDistance |
| 104 : | { | ||
| 105 : | get { return m_RexDrawDistance; } | ||
| 106 : | set | ||
| 107 : | { | ||
| 108 : | m_RexDrawDistance = value; | ||
| 109 : | tuco | 57 | TriggerChangedRexObjectProperties(); |
| 110 : | mikkopa | 28 | } |
| 111 : | } | ||
| 112 : | |||
| 113 : | private float m_RexLOD = 1.0F; | ||
| 114 : | public float RexLOD | ||
| 115 : | { | ||
| 116 : | get { return m_RexLOD; } | ||
| 117 : | set | ||
| 118 : | { | ||
| 119 : | m_RexLOD = value; | ||
| 120 : | tuco | 57 | TriggerChangedRexObjectProperties(); |
| 121 : | mikkopa | 28 | } |
| 122 : | } | ||
| 123 : | |||
| 124 : | private UUID m_RexMeshUUID = UUID.Zero; | ||
| 125 : | public UUID RexMeshUUID | ||
| 126 : | { | ||
| 127 : | get { return m_RexMeshUUID; } | ||
| 128 : | set | ||
| 129 : | { | ||
| 130 : | m_RexMeshUUID = value; | ||
| 131 : | tuco | 57 | TriggerChangedRexObjectProperties(); |
| 132 : | mikkopa | 28 | } |
| 133 : | } | ||
| 134 : | |||
| 135 : | private UUID m_RexCollisionMeshUUID = UUID.Zero; | ||
| 136 : | public UUID RexCollisionMeshUUID | ||
| 137 : | { | ||
| 138 : | get { return m_RexCollisionMeshUUID; } | ||
| 139 : | set | ||
| 140 : | { | ||
| 141 : | tuco | 57 | UUID oldcollision = m_RexCollisionMeshUUID; |
| 142 : | mikkopa | 28 | m_RexCollisionMeshUUID = value; |
| 143 : | tuco | 57 | |
| 144 : | if (oldcollision != m_RexCollisionMeshUUID && RexEventManager != null) | ||
| 145 : | RexEventManager.TriggerOnChangeCollisionMesh(parentObjectID); | ||
| 146 : | |||
| 147 : | TriggerChangedRexObjectProperties(); | ||
| 148 : | mikkopa | 28 | } |
| 149 : | } | ||
| 150 : | |||
| 151 : | private UUID m_RexParticleScriptUUID = UUID.Zero; | ||
| 152 : | public UUID RexParticleScriptUUID | ||
| 153 : | { | ||
| 154 : | get { return m_RexParticleScriptUUID; } | ||
| 155 : | set | ||
| 156 : | { | ||
| 157 : | m_RexParticleScriptUUID = value; | ||
| 158 : | tuco | 57 | TriggerChangedRexObjectProperties(); |
| 159 : | mikkopa | 28 | } |
| 160 : | } | ||
| 161 : | |||
| 162 : | private UUID m_RexAnimationPackageUUID = UUID.Zero; | ||
| 163 : | public UUID RexAnimationPackageUUID | ||
| 164 : | { | ||
| 165 : | get { return m_RexAnimationPackageUUID; } | ||
| 166 : | set | ||
| 167 : | { | ||
| 168 : | m_RexAnimationPackageUUID = value; | ||
| 169 : | tuco | 57 | TriggerChangedRexObjectProperties(); |
| 170 : | mikkopa | 28 | } |
| 171 : | } | ||
| 172 : | |||
| 173 : | private string m_RexAnimationName = String.Empty; | ||
| 174 : | public string RexAnimationName | ||
| 175 : | { | ||
| 176 : | get { return m_RexAnimationName; } | ||
| 177 : | set | ||
| 178 : | { | ||
| 179 : | m_RexAnimationName = value; | ||
| 180 : | tuco | 57 | TriggerChangedRexObjectProperties(); |
| 181 : | mikkopa | 28 | } |
| 182 : | } | ||
| 183 : | |||
| 184 : | private float m_RexAnimationRate = 1.0F; | ||
| 185 : | public float RexAnimationRate | ||
| 186 : | { | ||
| 187 : | get { return m_RexAnimationRate; } | ||
| 188 : | set | ||
| 189 : | { | ||
| 190 : | m_RexAnimationRate = value; | ||
| 191 : | tuco | 57 | TriggerChangedRexObjectProperties(); |
| 192 : | mikkopa | 28 | } |
| 193 : | } | ||
| 194 : | |||
| 195 : | mikkopa | 39 | |
| 196 : | #region Material Stuff | ||
| 197 : | |||
| 198 : | mikkopa | 28 | public RexMaterialsDictionary RexMaterials = new RexMaterialsDictionary(); |
| 199 : | public RexMaterialsDictionary GetRexMaterials() | ||
| 200 : | { | ||
| 201 : | return (RexMaterialsDictionary)RexMaterials.Clone(); | ||
| 202 : | } | ||
| 203 : | |||
| 204 : | mikkopa | 39 | /// <summary> |
| 205 : | /// This is only to be used from NHibernate. Use RexMaterials instead in other cases. | ||
| 206 : | /// </summary> | ||
| 207 : | public IList<RexMaterialsDictionaryItem> RexMaterialDictionaryItems | ||
| 208 : | { | ||
| 209 : | get | ||
| 210 : | { | ||
| 211 : | IList<RexMaterialsDictionaryItem> tempRexMaterialDictionaryItems = new List<RexMaterialsDictionaryItem>(); | ||
| 212 : | mikkopa | 171 | foreach (KeyValuePair<uint, RexMaterialsDictionaryItem> entry in RexMaterials) |
| 213 : | mikkopa | 39 | { |
| 214 : | tempRexMaterialDictionaryItems.Add(new RexMaterialsDictionaryItem(entry)); | ||
| 215 : | } | ||
| 216 : | return tempRexMaterialDictionaryItems; | ||
| 217 : | } | ||
| 218 : | set | ||
| 219 : | { | ||
| 220 : | //rexMaterialDictionary = new Dictionary<uint, UUID>(); | ||
| 221 : | if (value != null) | ||
| 222 : | { | ||
| 223 : | foreach (RexMaterialsDictionaryItem e in value) | ||
| 224 : | { | ||
| 225 : | //rexMaterialDictionary.Add(e.Num, e.AssetID); | ||
| 226 : | mikkopa | 171 | RexMaterials.Add(e.Num, e); |
| 227 : | mikkopa | 39 | } |
| 228 : | } | ||
| 229 : | } | ||
| 230 : | } | ||
| 231 : | |||
| 232 : | #endregion | ||
| 233 : | |||
| 234 : | mikkopa | 28 | private string m_RexClassName = String.Empty; |
| 235 : | public string RexClassName | ||
| 236 : | { | ||
| 237 : | get { return m_RexClassName; } | ||
| 238 : | set | ||
| 239 : | { | ||
| 240 : | tuco | 57 | string oldclass = m_RexClassName; |
| 241 : | mikkopa | 28 | m_RexClassName = value; |
| 242 : | tuco | 57 | |
| 243 : | if (m_RexClassName != oldclass && RexEventManager != null) | ||
| 244 : | RexEventManager.TriggerOnChangePythonClass(parentObjectID); | ||
| 245 : | |||
| 246 : | TriggerChangedRexObjectProperties(); | ||
| 247 : | mikkopa | 28 | } |
| 248 : | } | ||
| 249 : | |||
| 250 : | private UUID m_RexSoundUUID = UUID.Zero; | ||
| 251 : | public UUID RexSoundUUID | ||
| 252 : | { | ||
| 253 : | get { return m_RexSoundUUID; } | ||
| 254 : | set | ||
| 255 : | { | ||
| 256 : | m_RexSoundUUID = value; | ||
| 257 : | tuco | 57 | TriggerChangedRexObjectProperties(); |
| 258 : | mikkopa | 28 | } |
| 259 : | } | ||
| 260 : | |||
| 261 : | mikkopa | 39 | private float m_RexSoundVolume = 0; |
| 262 : | mikkopa | 28 | public float RexSoundVolume |
| 263 : | { | ||
| 264 : | get { return m_RexSoundVolume; } | ||
| 265 : | set | ||
| 266 : | { | ||
| 267 : | m_RexSoundVolume = value; | ||
| 268 : | tuco | 57 | TriggerChangedRexObjectProperties(); |
| 269 : | mikkopa | 28 | } |
| 270 : | } | ||
| 271 : | |||
| 272 : | mikkopa | 39 | private float m_RexSoundRadius = 0; |
| 273 : | mikkopa | 28 | public float RexSoundRadius |
| 274 : | { | ||
| 275 : | get { return m_RexSoundRadius; } | ||
| 276 : | set | ||
| 277 : | { | ||
| 278 : | m_RexSoundRadius = value; | ||
| 279 : | tuco | 57 | TriggerChangedRexObjectProperties(); |
| 280 : | mikkopa | 28 | } |
| 281 : | } | ||
| 282 : | |||
| 283 : | private string m_rexData = String.Empty; | ||
| 284 : | public string RexData | ||
| 285 : | { | ||
| 286 : | get { return m_rexData; } | ||
| 287 : | set | ||
| 288 : | { | ||
| 289 : | if (value.Length > 3000) | ||
| 290 : | m_rexData = value.Substring(0, 3000); | ||
| 291 : | else | ||
| 292 : | m_rexData = value; | ||
| 293 : | tuco | 57 | |
| 294 : | if (RexEventManager != null) | ||
| 295 : | RexEventManager.TriggerOnChangeRexObjectMetaData(parentObjectID); | ||
| 296 : | mikkopa | 28 | |
| 297 : | tuco | 57 | TriggerChangedRexObjectProperties(); |
| 298 : | mikkopa | 28 | } |
| 299 : | } | ||
| 300 : | |||
| 301 : | mikkopa | 39 | private int m_RexSelectPriority = 0; |
| 302 : | mikkopa | 28 | public int RexSelectPriority |
| 303 : | { | ||
| 304 : | get { return m_RexSelectPriority; } | ||
| 305 : | set | ||
| 306 : | { | ||
| 307 : | m_RexSelectPriority = value; | ||
| 308 : | tuco | 57 | TriggerChangedRexObjectProperties(); |
| 309 : | mikkopa | 28 | } |
| 310 : | } | ||
| 311 : | mikkopa | 170 | |
| 312 : | mikkopa | 172 | #region Asset URIS |
| 313 : | mikkopa | 170 | |
| 314 : | //These URLs are offered to NG-clients in SendRexObjectUpdate | ||
| 315 : | |||
| 316 : | private string m_rexMeshURL = String.Empty; | ||
| 317 : | private string m_rexCollisionMeshURL = String.Empty; | ||
| 318 : | private string m_rexParticleScriptURL = String.Empty; | ||
| 319 : | private string m_rexAnimationPackageURL = String.Empty; | ||
| 320 : | private string m_rexSoundURL = String.Empty; | ||
| 321 : | |||
| 322 : | mikkopa | 172 | public string RexMeshURI |
| 323 : | mikkopa | 170 | { |
| 324 : | get { return m_rexMeshURL; } | ||
| 325 : | set | ||
| 326 : | { | ||
| 327 : | m_rexMeshURL = value; | ||
| 328 : | TriggerChangedRexObjectProperties(); | ||
| 329 : | } | ||
| 330 : | } | ||
| 331 : | |||
| 332 : | mikkopa | 172 | public string RexCollisionMeshURI |
| 333 : | mikkopa | 170 | { |
| 334 : | get { return m_rexCollisionMeshURL; } | ||
| 335 : | set | ||
| 336 : | { | ||
| 337 : | m_rexCollisionMeshURL = value; | ||
| 338 : | TriggerChangedRexObjectProperties(); | ||
| 339 : | } | ||
| 340 : | } | ||
| 341 : | |||
| 342 : | mikkopa | 172 | public string RexParticleScriptURI |
| 343 : | mikkopa | 170 | { |
| 344 : | get { return m_rexParticleScriptURL; } | ||
| 345 : | set | ||
| 346 : | { | ||
| 347 : | m_rexParticleScriptURL = value; | ||
| 348 : | TriggerChangedRexObjectProperties(); | ||
| 349 : | } | ||
| 350 : | } | ||
| 351 : | |||
| 352 : | mikkopa | 172 | public string RexAnimationPackageURI |
| 353 : | mikkopa | 170 | { |
| 354 : | get { return m_rexAnimationPackageURL; } | ||
| 355 : | set | ||
| 356 : | { | ||
| 357 : | m_rexAnimationPackageURL = value; | ||
| 358 : | TriggerChangedRexObjectProperties(); | ||
| 359 : | } | ||
| 360 : | } | ||
| 361 : | |||
| 362 : | mikkopa | 172 | public string RexSoundURI |
| 363 : | mikkopa | 170 | { |
| 364 : | get { return m_rexSoundURL; } | ||
| 365 : | set | ||
| 366 : | { | ||
| 367 : | m_rexSoundURL = value; | ||
| 368 : | TriggerChangedRexObjectProperties(); | ||
| 369 : | } | ||
| 370 : | } | ||
| 371 : | |||
| 372 : | mikkopa | 28 | #endregion |
| 373 : | |||
| 374 : | mikkopa | 170 | #endregion |
| 375 : | |||
| 376 : | mikkopa | 291 | System.Timers.Timer m_saveProperties = null; |
| 377 : | |||
| 378 : | tuco | 57 | #region Constructors |
| 379 : | mikkopa | 28 | /// <summary> |
| 380 : | /// Initialises a new RexObjectProperties class from | ||
| 381 : | /// the specified binary array. Unpacks the array | ||
| 382 : | /// according to the viewer-specified format into | ||
| 383 : | /// the properties. | ||
| 384 : | /// </summary> | ||
| 385 : | /// <param name="data"></param> | ||
| 386 : | mikkopa | 173 | public RexObjectProperties(byte[] data, bool containsURIs) |
| 387 : | mikkopa | 28 | { |
| 388 : | mikkopa | 173 | SetRexPrimDataFromBytes(data, containsURIs); |
| 389 : | tuco | 80 | RexMaterials.SetSceneObjectPart(this); |
| 390 : | mikkopa | 28 | } |
| 391 : | |||
| 392 : | tuco | 80 | public RexObjectProperties() |
| 393 : | { | ||
| 394 : | RexMaterials.SetSceneObjectPart(this); | ||
| 395 : | } | ||
| 396 : | mikkopa | 39 | |
| 397 : | tuco | 57 | public RexObjectProperties(UUID parentid,IRexObjectPropertiesEventManager newrexeventmanager) |
| 398 : | { | ||
| 399 : | ParentObjectID = parentid; | ||
| 400 : | RexEventManager = newrexeventmanager; | ||
| 401 : | tuco | 80 | RexMaterials.SetSceneObjectPart(this); |
| 402 : | mikkopa | 291 | m_saveProperties = new System.Timers.Timer(); |
| 403 : | m_saveProperties.Interval = 1000; | ||
| 404 : | m_saveProperties.Elapsed += m_saveProperties_Elapsed; | ||
| 405 : | tuco | 57 | } |
| 406 : | |||
| 407 : | #endregion | ||
| 408 : | |||
| 409 : | mikkopa | 291 | void m_saveProperties_Elapsed(object sender, System.Timers.ElapsedEventArgs e) |
| 410 : | { | ||
| 411 : | m_saveProperties.Stop(); | ||
| 412 : | RexEventManager.TriggerOnSaveObject(this.parentObjectID); | ||
| 413 : | } | ||
| 414 : | tuco | 57 | |
| 415 : | public void SetRexEventManager(IRexObjectPropertiesEventManager newrexeventmanager) | ||
| 416 : | { | ||
| 417 : | RexEventManager = newrexeventmanager; | ||
| 418 : | } | ||
| 419 : | |||
| 420 : | public void SetRexPrimDataFromObject(RexObjectProperties source) | ||
| 421 : | { | ||
| 422 : | try | ||
| 423 : | { | ||
| 424 : | mProcessingPacketData = true; | ||
| 425 : | RexDrawType = source.RexDrawType; | ||
| 426 : | RexIsVisible = source.RexIsVisible; | ||
| 427 : | RexCastShadows = source.RexCastShadows; | ||
| 428 : | RexLightCreatesShadows = source.RexLightCreatesShadows; | ||
| 429 : | RexDescriptionTexture = source.RexDescriptionTexture; | ||
| 430 : | RexScaleToPrim = source.RexScaleToPrim; | ||
| 431 : | RexDrawDistance = source.RexDrawDistance; | ||
| 432 : | RexLOD = source.RexLOD; | ||
| 433 : | RexMeshUUID = source.RexMeshUUID; | ||
| 434 : | RexCollisionMeshUUID = source.RexCollisionMeshUUID; | ||
| 435 : | RexParticleScriptUUID = source.RexParticleScriptUUID; | ||
| 436 : | RexAnimationPackageUUID = source.RexAnimationPackageUUID; | ||
| 437 : | RexAnimationName = source.RexAnimationName; | ||
| 438 : | RexAnimationRate = source.RexAnimationRate; | ||
| 439 : | RexMaterials.ClearMaterials(); | ||
| 440 : | RexMaterials = (RexMaterialsDictionary)source.RexMaterials.Clone(); | ||
| 441 : | RexClassName = source.RexClassName; | ||
| 442 : | RexSoundUUID = source.RexSoundUUID; | ||
| 443 : | RexSoundVolume = source.RexSoundVolume; | ||
| 444 : | RexSoundRadius = source.RexSoundRadius; | ||
| 445 : | RexSelectPriority = source.RexSelectPriority; | ||
| 446 : | mProcessingPacketData = false; | ||
| 447 : | |||
| 448 : | TriggerChangedRexObjectProperties(); | ||
| 449 : | } | ||
| 450 : | catch (Exception e) | ||
| 451 : | { | ||
| 452 : | mProcessingPacketData = false; | ||
| 453 : | m_log.Error(e.ToString()); | ||
| 454 : | } | ||
| 455 : | } | ||
| 456 : | tuco | 80 | |
| 457 : | public void SetRexPrimDataFromLegacyData(RexLegacyPrimData source) | ||
| 458 : | { | ||
| 459 : | try | ||
| 460 : | { | ||
| 461 : | mProcessingPacketData = true; | ||
| 462 : | ParentObjectID = source.UUID; | ||
| 463 : | RexDrawType = Convert.ToByte(source.DrawType); | ||
| 464 : | RexIsVisible = ConvertStringToBoolean(source.IsVisible); | ||
| 465 : | RexCastShadows = ConvertStringToBoolean(source.CastShadows); | ||
| 466 : | RexLightCreatesShadows = ConvertStringToBoolean(source.LightCreatesShadows); | ||
| 467 : | RexDescriptionTexture = ConvertStringToBoolean(source.DescriptionTexture); | ||
| 468 : | RexScaleToPrim = ConvertStringToBoolean(source.ScaleToPrim); | ||
| 469 : | RexDrawDistance = source.DrawDistance; | ||
| 470 : | RexLOD = source.LODBias; | ||
| 471 : | RexMeshUUID = source.Mesh; | ||
| 472 : | RexCollisionMeshUUID = source.CollisionMesh; | ||
| 473 : | RexParticleScriptUUID = source.ParticleScript; | ||
| 474 : | RexAnimationPackageUUID = source.AnimationPackage; | ||
| 475 : | RexAnimationName = source.AnimationName; | ||
| 476 : | RexAnimationRate = source.AnimationRate; | ||
| 477 : | RexMaterials.ClearMaterials(); | ||
| 478 : | RexClassName = source.ClassName; | ||
| 479 : | RexSoundUUID = source.Sound; | ||
| 480 : | RexSoundVolume = source.SoundVolume; | ||
| 481 : | RexSoundRadius = source.SoundRadius; | ||
| 482 : | |||
| 483 : | if(source.RexExtraPrimData != null && source.RexExtraPrimData.Length > 0) | ||
| 484 : | RexData = Encoding.UTF8.GetString(source.RexExtraPrimData); | ||
| 485 : | |||
| 486 : | RexSelectPriority = source.SelectPriority; | ||
| 487 : | mProcessingPacketData = false; | ||
| 488 : | |||
| 489 : | TriggerChangedRexObjectProperties(); | ||
| 490 : | } | ||
| 491 : | catch (Exception e) | ||
| 492 : | { | ||
| 493 : | mProcessingPacketData = false; | ||
| 494 : | m_log.Error(e.ToString()); | ||
| 495 : | } | ||
| 496 : | } | ||
| 497 : | tuco | 57 | |
| 498 : | tuco | 80 | private bool ConvertStringToBoolean(string vValue) |
| 499 : | { | ||
| 500 : | if(vValue.Length == 0 || vValue == "0") | ||
| 501 : | return false; | ||
| 502 : | else | ||
| 503 : | return true; | ||
| 504 : | } | ||
| 505 : | |||
| 506 : | |||
| 507 : | |||
| 508 : | mikkopa | 28 | #region Old RexServer ToByte/FromByte methods |
| 509 : | mikkopa | 170 | public byte[] GetRexPrimDataToBytes(bool sendURLs) |
| 510 : | mikkopa | 28 | { |
| 511 : | try | ||
| 512 : | { | ||
| 513 : | // Display | ||
| 514 : | int size = sizeof(byte) + // drawtype | ||
| 515 : | sizeof(bool) + sizeof(bool) + sizeof(bool) + sizeof(bool) + sizeof(bool) + // visible,castshadows,lightcreatesshadows,desctex,scaletoprim | ||
| 516 : | sizeof(float) + sizeof(float) + // drawdist,lod | ||
| 517 : | 16 + 16 + 16 + 16 + // meshuuid,colmeshuuid,particleuuid,animpackuuid | ||
| 518 : | sizeof(int); // selectpriority | ||
| 519 : | |||
| 520 : | // Animname,animrate | ||
| 521 : | size += (m_RexAnimationName.Length + 1 + sizeof(float)); | ||
| 522 : | |||
| 523 : | // Materialdata | ||
| 524 : | size += sizeof(byte); // Number of materials | ||
| 525 : | RexMaterialsDictionary materials = GetRexMaterials(); | ||
| 526 : | size += (materials.Values.Count * (sizeof(byte) + 16 + sizeof(byte))); // materialassettype,matuuid,matindex | ||
| 527 : | |||
| 528 : | // Misc | ||
| 529 : | size = size + m_RexClassName.Length + 1 + // classname & endbyte | ||
| 530 : | tuco | 64 | 16 + sizeof(float) + sizeof(float); // sounduuid,sndvolume,sndradius |
| 531 : | mikkopa | 28 | |
| 532 : | mikkopa | 170 | //add url sizes and their endbyte to size |
| 533 : | if (sendURLs) | ||
| 534 : | { | ||
| 535 : | size += | ||
| 536 : | m_rexMeshURL.Length + 1 + | ||
| 537 : | m_rexCollisionMeshURL.Length + 1 + | ||
| 538 : | m_rexParticleScriptURL.Length + 1 + | ||
| 539 : | m_rexAnimationPackageURL.Length + 1 + | ||
| 540 : | m_rexSoundURL.Length + 1; | ||
| 541 : | |||
| 542 : | mikkopa | 171 | //Add material url lengths |
| 543 : | foreach(RexMaterialsDictionaryItem item in materials.Values) | ||
| 544 : | { | ||
| 545 : | mikkopa | 172 | size += item.AssetURI.Length + 1; |
| 546 : | mikkopa | 171 | } |
| 547 : | mikkopa | 170 | } |
| 548 : | |||
| 549 : | mikkopa | 28 | // Build byte array |
| 550 : | byte[] buffer = new byte[size]; | ||
| 551 : | int idx = 0; | ||
| 552 : | |||
| 553 : | buffer[idx++] = m_RexDrawType; | ||
| 554 : | BitConverter.GetBytes(m_RexIsVisible).CopyTo(buffer, idx); | ||
| 555 : | idx += sizeof(bool); | ||
| 556 : | BitConverter.GetBytes(m_RexCastShadows).CopyTo(buffer, idx); | ||
| 557 : | idx += sizeof(bool); | ||
| 558 : | BitConverter.GetBytes(m_RexLightCreatesShadows).CopyTo(buffer, idx); | ||
| 559 : | idx += sizeof(bool); | ||
| 560 : | BitConverter.GetBytes(m_RexDescriptionTexture).CopyTo(buffer, idx); | ||
| 561 : | idx += sizeof(bool); | ||
| 562 : | BitConverter.GetBytes(m_RexScaleToPrim).CopyTo(buffer, idx); | ||
| 563 : | idx += sizeof(bool); | ||
| 564 : | |||
| 565 : | BitConverter.GetBytes(m_RexDrawDistance).CopyTo(buffer, idx); | ||
| 566 : | idx += sizeof(float); | ||
| 567 : | BitConverter.GetBytes(m_RexLOD).CopyTo(buffer, idx); | ||
| 568 : | idx += sizeof(float); | ||
| 569 : | |||
| 570 : | m_RexMeshUUID.GetBytes().CopyTo(buffer, idx); | ||
| 571 : | idx += 16; | ||
| 572 : | m_RexCollisionMeshUUID.GetBytes().CopyTo(buffer, idx); | ||
| 573 : | idx += 16; | ||
| 574 : | m_RexParticleScriptUUID.GetBytes().CopyTo(buffer, idx); | ||
| 575 : | idx += 16; | ||
| 576 : | |||
| 577 : | m_RexAnimationPackageUUID.GetBytes().CopyTo(buffer, idx); | ||
| 578 : | idx += 16; | ||
| 579 : | Encoding.ASCII.GetBytes(m_RexAnimationName).CopyTo(buffer, idx); | ||
| 580 : | idx += (m_RexAnimationName.Length); | ||
| 581 : | buffer[idx++] = 0; | ||
| 582 : | BitConverter.GetBytes(m_RexAnimationRate).CopyTo(buffer, idx); | ||
| 583 : | idx += sizeof(float); | ||
| 584 : | |||
| 585 : | buffer[idx++] = (byte)materials.Values.Count; | ||
| 586 : | mikkopa | 171 | foreach (KeyValuePair<uint, RexMaterialsDictionaryItem> kvp in materials) |
| 587 : | mikkopa | 28 | { |
| 588 : | tuco | 64 | // Client needs assettype so that it knows if this is texture or material script |
| 589 : | byte assettype = 0; | ||
| 590 : | if(RexEventManager != null) | ||
| 591 : | mikkopa | 171 | assettype = RexEventManager.GetAssetType(kvp.Value.AssetID); |
| 592 : | tuco | 64 | |
| 593 : | buffer[idx++] = assettype; | ||
| 594 : | mikkopa | 171 | kvp.Value.AssetID.GetBytes().CopyTo(buffer, idx); // matuuid |
| 595 : | mikkopa | 28 | idx += 16; |
| 596 : | |||
| 597 : | byte tempindex = (byte)kvp.Key; // matindex | ||
| 598 : | buffer[idx++] = tempindex; | ||
| 599 : | } | ||
| 600 : | |||
| 601 : | Encoding.ASCII.GetBytes(m_RexClassName).CopyTo(buffer, idx); | ||
| 602 : | idx += (m_RexClassName.Length); | ||
| 603 : | buffer[idx++] = 0; | ||
| 604 : | |||
| 605 : | m_RexSoundUUID.GetBytes().CopyTo(buffer, idx); | ||
| 606 : | idx += 16; | ||
| 607 : | BitConverter.GetBytes(m_RexSoundVolume).CopyTo(buffer, idx); | ||
| 608 : | idx += sizeof(float); | ||
| 609 : | BitConverter.GetBytes(m_RexSoundRadius).CopyTo(buffer, idx); | ||
| 610 : | idx += sizeof(float); | ||
| 611 : | |||
| 612 : | BitConverter.GetBytes(m_RexSelectPriority).CopyTo(buffer, idx); | ||
| 613 : | idx += sizeof(int); | ||
| 614 : | |||
| 615 : | mikkopa | 171 | //Add URL to packet |
| 616 : | if (sendURLs) | ||
| 617 : | { | ||
| 618 : | Encoding.ASCII.GetBytes(m_rexMeshURL).CopyTo(buffer, idx); | ||
| 619 : | idx += (m_rexMeshURL.Length); | ||
| 620 : | buffer[idx++] = 0; | ||
| 621 : | |||
| 622 : | Encoding.ASCII.GetBytes(m_rexCollisionMeshURL).CopyTo(buffer, idx); | ||
| 623 : | idx += (m_rexCollisionMeshURL.Length); | ||
| 624 : | buffer[idx++] = 0; | ||
| 625 : | |||
| 626 : | Encoding.ASCII.GetBytes(m_rexParticleScriptURL).CopyTo(buffer, idx); | ||
| 627 : | idx += (m_rexParticleScriptURL.Length); | ||
| 628 : | buffer[idx++] = 0; | ||
| 629 : | |||
| 630 : | Encoding.ASCII.GetBytes(m_rexAnimationPackageURL).CopyTo(buffer, idx); | ||
| 631 : | idx += (m_rexAnimationPackageURL.Length); | ||
| 632 : | buffer[idx++] = 0; | ||
| 633 : | |||
| 634 : | Encoding.ASCII.GetBytes(m_rexSoundURL).CopyTo(buffer, idx); | ||
| 635 : | idx += (m_rexSoundURL.Length); | ||
| 636 : | buffer[idx++] = 0; | ||
| 637 : | |||
| 638 : | //And finally, the material urls | ||
| 639 : | foreach (RexMaterialsDictionaryItem item in materials.Values) | ||
| 640 : | { | ||
| 641 : | mikkopa | 172 | Encoding.ASCII.GetBytes(item.AssetURI).CopyTo(buffer, idx); |
| 642 : | idx += (item.AssetURI.Length); | ||
| 643 : | mikkopa | 171 | buffer[idx++] = 0; |
| 644 : | } | ||
| 645 : | } | ||
| 646 : | |||
| 647 : | mikkopa | 28 | return buffer; |
| 648 : | } | ||
| 649 : | catch (Exception e) | ||
| 650 : | { | ||
| 651 : | m_log.Error(e.ToString()); | ||
| 652 : | return null; | ||
| 653 : | } | ||
| 654 : | } | ||
| 655 : | |||
| 656 : | mikkopa | 173 | public void SetRexPrimDataFromBytes(byte[] bytes, bool containsURIs) |
| 657 : | mikkopa | 28 | { |
| 658 : | tuco | 57 | mProcessingPacketData = true; |
| 659 : | |||
| 660 : | mikkopa | 28 | try |
| 661 : | { | ||
| 662 : | int idx = 0; | ||
| 663 : | mikkopa | 173 | m_RexDrawType = bytes[idx++]; |
| 664 : | mikkopa | 28 | |
| 665 : | mikkopa | 173 | m_RexIsVisible = BitConverter.ToBoolean(bytes, idx); |
| 666 : | mikkopa | 28 | idx += sizeof(bool); |
| 667 : | mikkopa | 173 | m_RexCastShadows = BitConverter.ToBoolean(bytes, idx); |
| 668 : | mikkopa | 28 | idx += sizeof(bool); |
| 669 : | mikkopa | 173 | m_RexLightCreatesShadows = BitConverter.ToBoolean(bytes, idx); |
| 670 : | mikkopa | 28 | idx += sizeof(bool); |
| 671 : | mikkopa | 173 | m_RexDescriptionTexture = BitConverter.ToBoolean(bytes, idx); |
| 672 : | mikkopa | 28 | idx += sizeof(bool); |
| 673 : | mikkopa | 173 | m_RexScaleToPrim = BitConverter.ToBoolean(bytes, idx); |
| 674 : | mikkopa | 28 | idx += sizeof(bool); |
| 675 : | |||
| 676 : | mikkopa | 173 | m_RexDrawDistance = BitConverter.ToSingle(bytes, idx); |
| 677 : | mikkopa | 28 | idx += sizeof(float); |
| 678 : | mikkopa | 173 | m_RexLOD = BitConverter.ToSingle(bytes, idx); |
| 679 : | mikkopa | 28 | idx += sizeof(float); |
| 680 : | |||
| 681 : | mikkopa | 173 | m_RexMeshUUID = new UUID(bytes, idx); |
| 682 : | mikkopa | 28 | idx += 16; |
| 683 : | mikkopa | 173 | m_RexCollisionMeshUUID = new UUID(bytes, idx); |
| 684 : | mikkopa | 28 | idx += 16; |
| 685 : | mikkopa | 173 | m_RexParticleScriptUUID = new UUID(bytes, idx); |
| 686 : | mikkopa | 28 | idx += 16; |
| 687 : | |||
| 688 : | // animation | ||
| 689 : | mikkopa | 173 | m_RexAnimationPackageUUID = new UUID(bytes, idx); |
| 690 : | mikkopa | 28 | idx += 16; |
| 691 : | StringBuilder bufferanimname = new StringBuilder(); | ||
| 692 : | while ((idx < bytes.Length) && (bytes[idx] != 0)) | ||
| 693 : | { | ||
| 694 : | char c = (char)bytes[idx++]; | ||
| 695 : | bufferanimname.Append(c); | ||
| 696 : | } | ||
| 697 : | mikkopa | 173 | m_RexAnimationName = bufferanimname.ToString(); |
| 698 : | mikkopa | 28 | idx++; |
| 699 : | mikkopa | 173 | m_RexAnimationRate = BitConverter.ToSingle(bytes, idx); |
| 700 : | mikkopa | 28 | idx += sizeof(float); |
| 701 : | |||
| 702 : | // materials, before setting materials clear them | ||
| 703 : | RexMaterials.ClearMaterials(); | ||
| 704 : | mikkopa | 173 | Dictionary<uint, UUID> materialData = new Dictionary<uint, UUID>(); |
| 705 : | mikkopa | 28 | byte matcount = bytes[idx++]; |
| 706 : | for (int i = 0; i < matcount; i++) | ||
| 707 : | { | ||
| 708 : | idx++; // skip type | ||
| 709 : | UUID matuuid = new UUID(bytes, idx); | ||
| 710 : | idx += 16; | ||
| 711 : | byte matindex = bytes[idx++]; | ||
| 712 : | mikkopa | 173 | if (!containsURIs) |
| 713 : | { | ||
| 714 : | RexMaterials.AddMaterial(Convert.ToUInt32(matindex), matuuid); //old clients do it like this | ||
| 715 : | } | ||
| 716 : | else | ||
| 717 : | { | ||
| 718 : | materialData.Add(Convert.ToUInt32(matindex), matuuid); | ||
| 719 : | //add to temporary dictinary so the information can be found when adding materials with uris | ||
| 720 : | } | ||
| 721 : | mikkopa | 28 | } |
| 722 : | |||
| 723 : | // misc | ||
| 724 : | StringBuilder buffer = new StringBuilder(); | ||
| 725 : | while ((idx < bytes.Length) && (bytes[idx] != 0)) | ||
| 726 : | { | ||
| 727 : | char c = (char)bytes[idx++]; | ||
| 728 : | buffer.Append(c); | ||
| 729 : | } | ||
| 730 : | mikkopa | 173 | m_RexClassName = buffer.ToString(); |
| 731 : | mikkopa | 28 | idx++; |
| 732 : | |||
| 733 : | mikkopa | 173 | m_RexSoundUUID = new UUID(bytes, idx); |
| 734 : | mikkopa | 28 | idx += 16; |
| 735 : | mikkopa | 173 | m_RexSoundVolume = BitConverter.ToSingle(bytes, idx); |
| 736 : | mikkopa | 28 | idx += sizeof(float); |
| 737 : | mikkopa | 173 | m_RexSoundRadius = BitConverter.ToSingle(bytes, idx); |
| 738 : | mikkopa | 28 | idx += sizeof(float); |
| 739 : | |||
| 740 : | if (bytes.Length >= (idx + sizeof(int))) | ||
| 741 : | { | ||
| 742 : | mikkopa | 173 | m_RexSelectPriority = BitConverter.ToInt32(bytes, idx); |
| 743 : | mikkopa | 28 | idx += sizeof(int); |
| 744 : | } | ||
| 745 : | |||
| 746 : | mikkopa | 173 | if (containsURIs) |
| 747 : | { | ||
| 748 : | m_rexMeshURL = BuildStringFromBytes(bytes, ref idx); | ||
| 749 : | m_rexCollisionMeshURL = BuildStringFromBytes(bytes, ref idx); | ||
| 750 : | m_rexParticleScriptURL = BuildStringFromBytes(bytes, ref idx); | ||
| 751 : | m_rexAnimationPackageURL = BuildStringFromBytes(bytes, ref idx); | ||
| 752 : | m_rexSoundURL = BuildStringFromBytes(bytes, ref idx); | ||
| 753 : | |||
| 754 : | foreach (KeyValuePair<uint, UUID> kvp in materialData) | ||
| 755 : | { | ||
| 756 : | string uri = BuildStringFromBytes(bytes, ref idx); | ||
| 757 : | RexMaterials.AddMaterial(kvp.Key, kvp.Value, uri); | ||
| 758 : | } | ||
| 759 : | } | ||
| 760 : | |||
| 761 : | tuco | 57 | mProcessingPacketData = false; |
| 762 : | TriggerChangedRexObjectProperties(); | ||
| 763 : | mikkopa | 28 | } |
| 764 : | catch (Exception e) | ||
| 765 : | { | ||
| 766 : | tuco | 57 | mProcessingPacketData = false; |
| 767 : | mikkopa | 28 | m_log.Error(e.ToString()); |
| 768 : | } | ||
| 769 : | } | ||
| 770 : | mikkopa | 173 | |
| 771 : | private string BuildStringFromBytes(byte[] bytes, ref int idx) | ||
| 772 : | { | ||
| 773 : | StringBuilder uribuilder = new StringBuilder(); | ||
| 774 : | while ((idx < bytes.Length) && (bytes[idx] != 0)) | ||
| 775 : | { | ||
| 776 : | char c = (char)bytes[idx++]; | ||
| 777 : | uribuilder.Append(c); | ||
| 778 : | } | ||
| 779 : | idx++; | ||
| 780 : | return uribuilder.ToString(); | ||
| 781 : | } | ||
| 782 : | |||
| 783 : | mikkopa | 28 | #endregion |
| 784 : | |||
| 785 : | #region Debug | ||
| 786 : | public void PrintRexPrimdata() | ||
| 787 : | { | ||
| 788 : | try | ||
| 789 : | { | ||
| 790 : | m_log.Warn("RexDrawType:" + RexDrawType); | ||
| 791 : | m_log.Warn("RexIsVisible:" + RexIsVisible); | ||
| 792 : | m_log.Warn("RexCastShadows:" + RexCastShadows); | ||
| 793 : | m_log.Warn("RexLightCreatesShadows:" + RexLightCreatesShadows); | ||
| 794 : | m_log.Warn("RexDescriptionTexture:" + RexDescriptionTexture); | ||
| 795 : | m_log.Warn("RexScaleToPrim:" + RexScaleToPrim); | ||
| 796 : | m_log.Warn("RexDrawDistance:" + RexDrawDistance); | ||
| 797 : | m_log.Warn("RexLOD" + RexLOD); | ||
| 798 : | m_log.Warn("RexMeshUUID:" + RexMeshUUID); | ||
| 799 : | m_log.Warn("RexCollisionMeshUUID:" + RexCollisionMeshUUID); | ||
| 800 : | m_log.Warn("RexParticleScriptUUID:" + RexParticleScriptUUID); | ||
| 801 : | m_log.Warn("RexAnimationPackageUUID:" + RexAnimationPackageUUID); | ||
| 802 : | m_log.Warn("RexAnimationName:" + RexAnimationName); | ||
| 803 : | m_log.Warn("RexAnimationRate:" + RexAnimationRate); | ||
| 804 : | m_log.Warn("RexMaterials:" + RexMaterials); | ||
| 805 : | m_log.Warn("RexClassName:" + RexClassName); | ||
| 806 : | m_log.Warn("RexSoundUUID:" + RexSoundUUID); | ||
| 807 : | m_log.Warn("RexSoundVolume:" + RexSoundVolume); | ||
| 808 : | m_log.Warn("RexSoundRadius:" + RexSoundRadius); | ||
| 809 : | m_log.Warn("RexSelectPriority:" + RexSelectPriority); | ||
| 810 : | } | ||
| 811 : | catch (Exception e) | ||
| 812 : | { | ||
| 813 : | m_log.Error(e.ToString()); | ||
| 814 : | } | ||
| 815 : | } | ||
| 816 : | #endregion | ||
| 817 : | |||
| 818 : | tuco | 57 | public void TriggerChangedRexObjectProperties() |
| 819 : | mikkopa | 28 | { |
| 820 : | tuco | 57 | if (mProcessingPacketData) |
| 821 : | return; | ||
| 822 : | if (RexEventManager != null) | ||
| 823 : | RexEventManager.TriggerOnChangeRexObjectProperties(parentObjectID); | ||
| 824 : | mikkopa | 28 | } |
| 825 : | mikkopa | 291 | |
| 826 : | public void ScheduleSave() | ||
| 827 : | { | ||
| 828 : | if (!m_saveProperties.Enabled) | ||
| 829 : | { | ||
| 830 : | m_saveProperties.Start(); | ||
| 831 : | } | ||
| 832 : | } | ||
| 833 : | mikkopa | 28 | } |
| 834 : | } |
| ViewVC Help | |
| Powered by ViewVC 1.0.0 |

