aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Framework')
-rw-r--r--OpenSim/Framework/PrimitiveBaseShape.cs358
1 files changed, 357 insertions, 1 deletions
diff --git a/OpenSim/Framework/PrimitiveBaseShape.cs b/OpenSim/Framework/PrimitiveBaseShape.cs
index 6607c4b..aabd69d 100644
--- a/OpenSim/Framework/PrimitiveBaseShape.cs
+++ b/OpenSim/Framework/PrimitiveBaseShape.cs
@@ -71,7 +71,7 @@ namespace OpenSim.Framework
71 public class PrimitiveBaseShape 71 public class PrimitiveBaseShape
72 { 72 {
73 private static readonly LLObject.TextureEntry m_defaultTexture; 73 private static readonly LLObject.TextureEntry m_defaultTexture;
74 public byte[] ExtraParams; 74
75 private byte[] m_textureEntry; 75 private byte[] m_textureEntry;
76 76
77 public ushort PathBegin; 77 public ushort PathBegin;
@@ -97,6 +97,33 @@ namespace OpenSim.Framework
97 public ushort ProfileHollow; 97 public ushort ProfileHollow;
98 public LLVector3 Scale; 98 public LLVector3 Scale;
99 public byte State; 99 public byte State;
100 // Sculpted
101 [XmlIgnore] public LLUUID SculptTexture = LLUUID.Zero;
102 [XmlIgnore] public byte SculptType = (byte)0;
103
104 // Flexi
105 [XmlIgnore] public int FlexiSoftness = 0;
106 [XmlIgnore] public float FlexiTension = 0f;
107 [XmlIgnore] public float FlexiDrag = 0f;
108 [XmlIgnore] public float FlexiGravity = 0f;
109 [XmlIgnore] public float FlexiWind= 0f;
110 [XmlIgnore] public float FlexiForceX = 0f;
111 [XmlIgnore] public float FlexiForceY = 0f;
112 [XmlIgnore] public float FlexiForceZ = 0f;
113
114 //Bright n sparkly
115 [XmlIgnore] public float LightColorR = 0f;
116 [XmlIgnore] public float LightColorG = 0f;
117 [XmlIgnore] public float LightColorB = 0f;
118 [XmlIgnore] public float LightColorA = 1f;
119 [XmlIgnore] public float LightRadius = 0f;
120 [XmlIgnore] public float LightCutoff = 0f;
121 [XmlIgnore] public float LightFalloff = 0f;
122 [XmlIgnore] public float LightIntensity = 1f;
123 [XmlIgnore] public bool FlexiEntry = false;
124 [XmlIgnore] public bool LightEntry = false;
125 [XmlIgnore] public bool SculptEntry = false;
126
100 127
101 static PrimitiveBaseShape() 128 static PrimitiveBaseShape()
102 { 129 {
@@ -231,10 +258,339 @@ namespace OpenSim.Framework
231 PathEnd = LLObject.PackEndCut(pathRange.Y); 258 PathEnd = LLObject.PackEndCut(pathRange.Y);
232 } 259 }
233 260
261 public void SetSculptData(byte sculptType, LLUUID SculptTextureUUID)
262 {
263 SculptType = sculptType;
264 SculptTexture = SculptTextureUUID;
265 }
266
234 public void SetProfileRange(LLVector3 profileRange) 267 public void SetProfileRange(LLVector3 profileRange)
235 { 268 {
236 ProfileBegin = LLObject.PackBeginCut(profileRange.X); 269 ProfileBegin = LLObject.PackBeginCut(profileRange.X);
237 ProfileEnd = LLObject.PackEndCut(profileRange.Y); 270 ProfileEnd = LLObject.PackEndCut(profileRange.Y);
238 } 271 }
272 public byte[] ExtraParams
273 {
274 get
275 {
276 return ExtraParamsToBytes();
277 }
278 set
279 {
280 ReadInExtraParamsBytes(value);
281 }
282 }
283
284 public byte[] ExtraParamsToBytes()
285 {
286 ushort FlexiEP = 0x10;
287 ushort LightEP = 0x20;
288 ushort SculptEP = 0x30;
289
290 int i = 0;
291 uint TotalBytesLength = 5;
292
293 uint ExtraParamsNum = 0;
294 if (FlexiEntry)
295 {
296 ExtraParamsNum++;
297 TotalBytesLength += 16;// data
298 TotalBytesLength += 4; // type
299 }
300 if (LightEntry)
301 {
302 ExtraParamsNum++;
303 TotalBytesLength += 16;// data
304 TotalBytesLength += 4; // type
305 }
306 if (SculptEntry)
307 {
308 ExtraParamsNum++;
309 TotalBytesLength += 17;// data
310 TotalBytesLength += 4; // type
311 }
312
313 byte[] returnbytes = new byte[TotalBytesLength];
314
315
316 uint paramlength = ExtraParamsNum;
317
318 // Stick in the number of parameters
319 returnbytes[i++] = (byte)ExtraParamsNum;
320
321 if (FlexiEntry)
322 {
323 byte[] FlexiData = GetFlexiBytes();
324
325 returnbytes[i++] = (byte)(FlexiEP % 256);
326 returnbytes[i++] = (byte)((FlexiEP >> 8) % 256);
327
328 returnbytes[i++] = (byte)(FlexiData.Length % 256);
329 returnbytes[i++] = (byte)((FlexiData.Length >> 8) % 256);
330 returnbytes[i++] = (byte)((FlexiData.Length >> 16) % 256);
331 returnbytes[i++] = (byte)((FlexiData.Length >> 24) % 256);
332 Array.Copy(FlexiData, 0, returnbytes, i, FlexiData.Length);
333 i += FlexiData.Length;
334 }
335 if (LightEntry)
336 {
337 byte[] LightData = GetLightBytes();
338
339 returnbytes[i++] = (byte)(LightEP % 256);
340 returnbytes[i++] = (byte)((LightEP >> 8) % 256);
341
342 returnbytes[i++] = (byte)(LightData.Length % 256);
343 returnbytes[i++] = (byte)((LightData.Length >> 8) % 256);
344 returnbytes[i++] = (byte)((LightData.Length >> 16) % 256);
345 returnbytes[i++] = (byte)((LightData.Length >> 24) % 256);
346 Array.Copy(LightData, 0, returnbytes, i, LightData.Length);
347 i += LightData.Length;
348 }
349 if (SculptEntry)
350 {
351 byte[] SculptData = GetSculptBytes();
352
353 returnbytes[i++] = (byte)(SculptEP % 256);
354 returnbytes[i++] = (byte)((SculptEP >> 8) % 256);
355
356 returnbytes[i++] = (byte)(SculptData.Length % 256);
357 returnbytes[i++] = (byte)((SculptData.Length >> 8) % 256);
358 returnbytes[i++] = (byte)((SculptData.Length >> 16) % 256);
359 returnbytes[i++] = (byte)((SculptData.Length >> 24) % 256);
360 Array.Copy(SculptData, 0, returnbytes, i, SculptData.Length);
361 i += SculptData.Length;
362 }
363
364 if (!FlexiEntry && !LightEntry && !SculptEntry)
365 {
366 byte[] returnbyte = new byte[1];
367 returnbyte[0] = 0;
368 return returnbyte;
369 }
370
371
372 return returnbytes;
373 //m_log.Info("[EXTRAPARAMS]: Length = " + m_shape.ExtraParams.Length.ToString());
374
375 }
376
377 public void ReadInUpdateExtraParam(ushort type, bool inUse, byte[] data)
378 {
379 const ushort FlexiEP = 0x10;
380 const ushort LightEP = 0x20;
381 const ushort SculptEP = 0x30;
382
383 switch (type)
384 {
385 case FlexiEP:
386 if (!inUse)
387 {
388 FlexiEntry = false;
389 return;
390 }
391 ReadFlexiData(data, 0);
392 break;
393
394 case LightEP:
395 if (!inUse)
396 {
397 LightEntry = false;
398 return;
399 }
400 ReadLightData(data, 0);
401 break;
402
403 case SculptEP:
404 if (!inUse)
405 {
406 SculptEntry = false;
407 return;
408 }
409 ReadSculptData(data, 0);
410 break;
411 }
412 }
413
414 public void ReadInExtraParamsBytes(byte[] data)
415 {
416 const ushort FlexiEP = 0x10;
417 const ushort LightEP = 0x20;
418 const ushort SculptEP = 0x30;
419
420 bool lGotFlexi = false;
421 bool lGotLight = false;
422 bool lGotSculpt = false;
423
424 int i = 0;
425 int totalLength = 1;
426 byte extraParamCount = data[i++];
427
428 if (extraParamCount > 0)
429 {
430 int foo = 0;
431 }
432 for (int k = 0; k < extraParamCount; k++)
433 {
434 ushort epType = Helpers.BytesToUInt16(data, i);
435
436 i += 2;
437 uint paramLength = Helpers.BytesToUIntBig(data, i);
438
439 i += 4;
440 switch (epType)
441 {
442 case FlexiEP:
443 ReadFlexiData(data, i);
444 lGotFlexi = true;
445 break;
446
447 case LightEP:
448 ReadLightData(data, i);
449 lGotLight = true;
450 break;
451
452 case SculptEP:
453 ReadSculptData(data, i);
454 lGotSculpt = true;
455 break;
456 }
457 }
458
459 if (!lGotFlexi)
460 FlexiEntry = false;
461 if (!lGotLight)
462 LightEntry = false;
463 if (!lGotSculpt)
464 SculptEntry = false;
465
466 }
467
468 public void ReadSculptData(byte[] data, int pos)
469 {
470 byte[] SculptTextureUUID = new byte[16];
471 LLUUID SculptUUID = LLUUID.Zero;
472 byte SculptTypel = data[16+pos];
473
474 if (data.Length+pos >= 17)
475 {
476 SculptEntry = true;
477 SculptTextureUUID = new byte[16];
478 SculptTypel = data[16];
479 Array.Copy(data, pos, SculptTextureUUID,0, 16);
480 SculptUUID = new LLUUID(SculptTextureUUID, 0);
481 }
482 else
483 {
484 SculptEntry = false;
485 SculptUUID = LLUUID.Zero;
486 SculptTypel = 0x00;
487 }
488
489
490 SculptTexture = SculptUUID;
491 SculptType = SculptTypel;
492 //m_log.Info("[SCULPT]:" + SculptUUID.ToString());
493 }
494
495 public byte[] GetSculptBytes()
496 {
497 byte[] data = new byte[17];
498
499 SculptTexture.GetBytes().CopyTo(data, 0);
500 data[16] = (byte)SculptType;
501
502 return data;
503 }
504 public void ReadFlexiData(byte[] data, int pos)
505 {
506 if (data.Length-pos >= 5)
507 {
508 FlexiEntry = true;
509 FlexiSoftness = ((data[pos] & 0x80) >> 6) | ((data[pos + 1] & 0x80) >> 7);
510
511 FlexiTension = (float)(data[pos++] & 0x7F) / 10.0f;
512 FlexiDrag = (float)(data[pos++] & 0x7F) / 10.0f;
513 FlexiGravity = (float)(data[pos++] / 10.0f) - 10.0f;
514 FlexiWind = (float)data[pos++] / 10.0f;
515 LLVector3 lForce = new LLVector3(data, pos);
516 FlexiForceX = lForce.X;
517 FlexiForceY = lForce.Y;
518 FlexiForceZ = lForce.Z;
519 }
520 else
521 {
522 FlexiEntry = false;
523 FlexiSoftness = 0;
524
525 FlexiTension = 0.0f;
526 FlexiDrag = 0.0f;
527 FlexiGravity = 0.0f;
528 FlexiWind = 0.0f;
529 FlexiForceX = 0f;
530 FlexiForceY = 0f;
531 FlexiForceZ = 0f;
532 }
533 }
534 public byte[] GetFlexiBytes()
535 {
536 byte[] data = new byte[16];
537 int i = 0;
538
539 // Softness is packed in the upper bits of tension and drag
540 data[i] = (byte)((FlexiSoftness & 2) << 6);
541 data[i + 1] = (byte)((FlexiSoftness & 1) << 7);
542
543 data[i++] |= (byte)((byte)(FlexiTension * 10.01f) & 0x7F);
544 data[i++] |= (byte)((byte)(FlexiDrag * 10.01f) & 0x7F);
545 data[i++] = (byte)((FlexiGravity + 10.0f) * 10.01f);
546 data[i++] = (byte)(FlexiWind * 10.01f);
547 LLVector3 lForce = new LLVector3(FlexiForceX, FlexiForceY, FlexiForceZ);
548 lForce.GetBytes().CopyTo(data, i);
549
550 return data;
551 }
552 public void ReadLightData(byte[] data, int pos)
553 {
554 if (data.Length - pos >= 16)
555 {
556 LightEntry = true;
557 LLColor lColor = new LLColor(data, pos, false);
558 LightIntensity = lColor.A;
559 LightColorA = 1f;
560 LightColorR = lColor.R;
561 LightColorG = lColor.G;
562 LightColorB = lColor.B;
563
564 LightRadius = Helpers.BytesToFloat(data, pos + 4);
565 LightCutoff = Helpers.BytesToFloat(data, pos + 8);
566 LightFalloff = Helpers.BytesToFloat(data, pos + 12);
567 }
568 else
569 {
570 LightEntry = false;
571 LightColorA = 1f;
572 LightColorR = 0f;
573 LightColorG = 0f;
574 LightColorB = 0f;
575 LightRadius = 0f;
576 LightCutoff = 0f;
577 LightFalloff = 0f;
578 LightIntensity = 0f;
579 }
580 }
581 public byte[] GetLightBytes()
582 {
583 byte[] data = new byte[16];
584
585 // Alpha channel in color is intensity
586 LLColor tmpColor = new LLColor(LightColorR,LightColorG,LightColorB,LightIntensity);
587
588 tmpColor.GetBytes().CopyTo(data, 0);
589 Helpers.FloatToBytes(LightRadius).CopyTo(data, 4);
590 Helpers.FloatToBytes(LightCutoff).CopyTo(data, 8);
591 Helpers.FloatToBytes(LightFalloff).CopyTo(data, 12);
592
593 return data;
594 }
239 } 595 }
240} \ No newline at end of file 596} \ No newline at end of file