aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Client/Sirikata/Protocol/PBJ.cs
diff options
context:
space:
mode:
authorJonathan Freedman2010-10-05 20:06:27 -0400
committerJonathan Freedman2010-10-05 20:06:27 -0400
commit84cf0ffbf1a7a82caf39d0e19607b0030fb668de (patch)
tree4c4a66541dfe10c6d6b1bcfbaa9a52ca5b54898e /OpenSim/Client/Sirikata/Protocol/PBJ.cs
parentMerge branch 'master' of git://opensimulator.org/git/opensim (diff)
parentRemove sirikata project (diff)
downloadopensim-SC_OLD-84cf0ffbf1a7a82caf39d0e19607b0030fb668de.zip
opensim-SC_OLD-84cf0ffbf1a7a82caf39d0e19607b0030fb668de.tar.gz
opensim-SC_OLD-84cf0ffbf1a7a82caf39d0e19607b0030fb668de.tar.bz2
opensim-SC_OLD-84cf0ffbf1a7a82caf39d0e19607b0030fb668de.tar.xz
Merge branch 'master' of git://opensimulator.org/git/opensim
Diffstat (limited to 'OpenSim/Client/Sirikata/Protocol/PBJ.cs')
-rw-r--r--OpenSim/Client/Sirikata/Protocol/PBJ.cs2104
1 files changed, 0 insertions, 2104 deletions
diff --git a/OpenSim/Client/Sirikata/Protocol/PBJ.cs b/OpenSim/Client/Sirikata/Protocol/PBJ.cs
deleted file mode 100644
index 9b1951a..0000000
--- a/OpenSim/Client/Sirikata/Protocol/PBJ.cs
+++ /dev/null
@@ -1,2104 +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
28using System;
29namespace PBJ
30{
31
32 public class IMessage
33 {
34 public virtual Google.ProtocolBuffers.IMessage _PBJISuper { get { return null; } }
35 protected virtual bool _HasAllPBJFields { get { return true; } }
36 public void WriteTo(Google.ProtocolBuffers.CodedOutputStream output)
37 {
38 _PBJISuper.WriteTo(output);
39 }
40 public override bool Equals(object other)
41 {
42 return _PBJISuper.Equals(other);
43 }
44 public int SerializedSize { get { return _PBJISuper.SerializedSize; } }
45
46 public override int GetHashCode() { return _PBJISuper.GetHashCode(); }
47
48 public override string ToString()
49 {
50 return _PBJISuper.ToString();
51 }
52 public virtual IBuilder WeakCreateBuilderForType() { return null; }
53 public Google.ProtocolBuffers.ByteString ToByteString()
54 {
55 return _PBJISuper.ToByteString();
56 }
57 public byte[] ToByteArray()
58 {
59 return _PBJISuper.ToByteArray();
60 }
61 public void WriteTo(global::System.IO.Stream output)
62 {
63 _PBJISuper.WriteTo(output);
64 }
65 // Google.ProtocolBuffers.MessageDescriptor DescriptorForType { get {return _PBJISuper.DescriptorForType;} }
66 public Google.ProtocolBuffers.UnknownFieldSet UnknownFields { get { return _PBJISuper.UnknownFields; } }
67 public class IBuilder
68 {
69 public virtual Google.ProtocolBuffers.IBuilder _PBJISuper { get { return null; } }
70 protected virtual bool _HasAllPBJFields { get { return true; } }
71 }
72 }
73
74 public struct Vector2f
75 {
76
77 public float x;
78 public float y;
79
80
81 public Vector2f(float _x, float _y)
82 {
83 x = _x; y = _y;
84 }
85
86 public Vector2f(Vector2f cpy)
87 {
88 x = cpy.x; y = cpy.y;
89 }
90
91
92 public Vector2f Negate()
93 {
94 return new Vector2f(-x, -y);
95 }
96
97 public Vector2f Add(Vector2f rhs)
98 {
99 return new Vector2f(x + rhs.x, y + rhs.y);
100 }
101
102 public Vector2f Subtract(Vector2f rhs)
103 {
104 return new Vector2f(x - rhs.x, y - rhs.y);
105 }
106
107 public Vector2f Multiply(Vector2f rhs)
108 {
109 return new Vector2f(x * rhs.x, y * rhs.y);
110 }
111
112 public Vector2f Multiply(float s)
113 {
114 return new Vector2f(x * s, y * s);
115 }
116
117 public Vector2f Divide(Vector2f rhs)
118 {
119 return new Vector2f(x / rhs.x, y / rhs.y);
120 }
121
122 public Vector2f Divide(float s)
123 {
124 return new Vector2f(x / s, y / s);
125 }
126
127 public float Dot(Vector2f rhs)
128 {
129 return (x * rhs.x + y * rhs.y);
130 }
131
132 public void Normalize()
133 {
134 float len = Length;
135 if (len != 0.0)
136 {
137 x /= len; y /= len;
138 }
139 }
140
141 public Vector2f Normalized
142 {
143 get
144 {
145 Vector2f normed = new Vector2f(this);
146 normed.Normalize();
147 return normed;
148 }
149 }
150
151 public float SquaredLength
152 {
153 get
154 {
155 return (x * x + y * y);
156 }
157 }
158 public float Length
159 {
160 get
161 {
162 return (float)Math.Sqrt(SquaredLength);
163 }
164 }
165
166
167 public override string ToString()
168 {
169 return String.Format("<{0}, {1}>", x, y);
170 }
171
172
173 public static Vector2f operator -(Vector2f uo)
174 {
175 return uo.Negate();
176 }
177
178 public static Vector2f operator +(Vector2f lhs, Vector2f rhs)
179 {
180 return lhs.Add(rhs);
181 }
182
183 public static Vector2f operator -(Vector2f lhs, Vector2f rhs)
184 {
185 return lhs.Subtract(rhs);
186 }
187
188 public static Vector2f operator *(Vector2f lhs, Vector2f rhs)
189 {
190 return lhs.Multiply(rhs);
191 }
192
193 public static Vector2f operator *(Vector2f lhs, float rhs)
194 {
195 return lhs.Multiply(rhs);
196 }
197 public static Vector2f operator *(float lhs, Vector2f rhs)
198 {
199 return rhs.Multiply(lhs);
200 }
201
202 public static Vector2f operator /(Vector2f lhs, Vector2f rhs)
203 {
204 return lhs.Divide(rhs);
205 }
206
207 public static Vector2f operator /(Vector2f lhs, float rhs)
208 {
209 return lhs.Divide(rhs);
210 }
211
212 } // struct Vector2f
213
214 public struct Vector2d
215 {
216
217 public double x;
218 public double y;
219
220
221 public Vector2d(double _x, double _y)
222 {
223 x = _x; y = _y;
224 }
225
226 public Vector2d(Vector2d cpy)
227 {
228 x = cpy.x; y = cpy.y;
229 }
230
231
232 public Vector2d Negate()
233 {
234 return new Vector2d(-x, -y);
235 }
236
237 public Vector2d Add(Vector2d rhs)
238 {
239 return new Vector2d(x + rhs.x, y + rhs.y);
240 }
241
242 public Vector2d Subtract(Vector2d rhs)
243 {
244 return new Vector2d(x - rhs.x, y - rhs.y);
245 }
246
247 public Vector2d Multiply(Vector2d rhs)
248 {
249 return new Vector2d(x * rhs.x, y * rhs.y);
250 }
251
252 public Vector2d Multiply(double s)
253 {
254 return new Vector2d(x * s, y * s);
255 }
256
257 public Vector2d Divide(Vector2d rhs)
258 {
259 return new Vector2d(x / rhs.x, y / rhs.y);
260 }
261
262 public Vector2d Divide(double s)
263 {
264 return new Vector2d(x / s, y / s);
265 }
266
267 public double Dot(Vector2d rhs)
268 {
269 return (x * rhs.x + y * rhs.y);
270 }
271
272 public void Normalize()
273 {
274 double len = Length;
275 if (len != 0.0)
276 {
277 x /= len; y /= len;
278 }
279 }
280
281 public Vector2d Normalized
282 {
283 get
284 {
285 Vector2d normed = new Vector2d(this);
286 normed.Normalize();
287 return normed;
288 }
289 }
290
291 public double SquaredLength
292 {
293 get
294 {
295 return (x * x + y * y);
296 }
297 }
298 public double Length
299 {
300 get
301 {
302 return Math.Sqrt(SquaredLength);
303 }
304 }
305
306
307 public override string ToString()
308 {
309 return String.Format("<{0}, {1}>", x, y);
310 }
311
312
313 public static Vector2d operator -(Vector2d uo)
314 {
315 return uo.Negate();
316 }
317
318 public static Vector2d operator +(Vector2d lhs, Vector2d rhs)
319 {
320 return lhs.Add(rhs);
321 }
322
323 public static Vector2d operator -(Vector2d lhs, Vector2d rhs)
324 {
325 return lhs.Subtract(rhs);
326 }
327
328 public static Vector2d operator *(Vector2d lhs, Vector2d rhs)
329 {
330 return lhs.Multiply(rhs);
331 }
332
333 public static Vector2d operator *(Vector2d lhs, double rhs)
334 {
335 return lhs.Multiply(rhs);
336 }
337 public static Vector2d operator *(double lhs, Vector2d rhs)
338 {
339 return rhs.Multiply(lhs);
340 }
341
342 public static Vector2d operator /(Vector2d lhs, Vector2d rhs)
343 {
344 return lhs.Divide(rhs);
345 }
346
347 public static Vector2d operator /(Vector2d lhs, double rhs)
348 {
349 return lhs.Divide(rhs);
350 }
351
352 } // struct Vector2d
353
354 public struct Vector3f
355 {
356
357 public float x;
358 public float y;
359 public float z;
360
361
362 public Vector3f(float _x, float _y, float _z)
363 {
364 x = _x; y = _y; z = _z;
365 }
366
367 public Vector3f(Vector3f cpy)
368 {
369 x = cpy.x; y = cpy.y; z = cpy.z;
370 }
371
372
373 public Vector3f Negate()
374 {
375 return new Vector3f(-x, -y, -z);
376 }
377
378 public Vector3f Add(Vector3f rhs)
379 {
380 return new Vector3f(x + rhs.x, y + rhs.y, z + rhs.z);
381 }
382
383 public Vector3f Subtract(Vector3f rhs)
384 {
385 return new Vector3f(x - rhs.x, y - rhs.y, z - rhs.z);
386 }
387
388 public Vector3f Multiply(Vector3f rhs)
389 {
390 return new Vector3f(x * rhs.x, y * rhs.y, z * rhs.z);
391 }
392
393 public Vector3f Multiply(float s)
394 {
395 return new Vector3f(x * s, y * s, z * s);
396 }
397
398 public Vector3f Divide(Vector3f rhs)
399 {
400 return new Vector3f(x / rhs.x, y / rhs.y, z / rhs.z);
401 }
402
403 public Vector3f Divide(float s)
404 {
405 return new Vector3f(x / s, y / s, z / s);
406 }
407
408 public float Dot(Vector3f rhs)
409 {
410 return (x * rhs.x + y * rhs.y + z * rhs.z);
411 }
412
413 public Vector3f Cross(Vector3f rhs)
414 {
415 return new Vector3f(y * rhs.z - z * rhs.y, z * rhs.x - x * rhs.z, x * rhs.y - y * rhs.x);
416 }
417
418 public void Normalize()
419 {
420 float len = Length;
421 if (len != 0.0)
422 {
423 x /= len; y /= len; z /= len;
424 }
425 }
426
427 public Vector3f Normalized
428 {
429 get
430 {
431 Vector3f normed = new Vector3f(this);
432 normed.Normalize();
433 return normed;
434 }
435 }
436
437 public float SquaredLength
438 {
439 get
440 {
441 return (x * x + y * y + z * z);
442 }
443 }
444 public float Length
445 {
446 get
447 {
448 return (float)Math.Sqrt(SquaredLength);
449 }
450 }
451
452
453 public override string ToString()
454 {
455 return String.Format("<{0}, {1}, {2}>", x, y, z);
456 }
457
458
459 public static Vector3f operator -(Vector3f uo)
460 {
461 return uo.Negate();
462 }
463
464 public static Vector3f operator +(Vector3f lhs, Vector3f rhs)
465 {
466 return lhs.Add(rhs);
467 }
468
469 public static Vector3f operator -(Vector3f lhs, Vector3f rhs)
470 {
471 return lhs.Subtract(rhs);
472 }
473
474 public static Vector3f operator *(Vector3f lhs, Vector3f rhs)
475 {
476 return lhs.Multiply(rhs);
477 }
478
479 public static Vector3f operator *(Vector3f lhs, float rhs)
480 {
481 return lhs.Multiply(rhs);
482 }
483 public static Vector3f operator *(float lhs, Vector3f rhs)
484 {
485 return rhs.Multiply(lhs);
486 }
487
488 public static Vector3f operator /(Vector3f lhs, Vector3f rhs)
489 {
490 return lhs.Divide(rhs);
491 }
492
493 public static Vector3f operator /(Vector3f lhs, float rhs)
494 {
495 return lhs.Divide(rhs);
496 }
497
498 } // struct Vector3f
499
500 public struct Vector3d
501 {
502
503 public double x;
504 public double y;
505 public double z;
506
507
508 public Vector3d(double _x, double _y, double _z)
509 {
510 x = _x; y = _y; z = _z;
511 }
512
513 public Vector3d(Vector3d cpy)
514 {
515 x = cpy.x; y = cpy.y; z = cpy.z;
516 }
517
518
519 public Vector3d Negate()
520 {
521 return new Vector3d(-x, -y, -z);
522 }
523
524 public Vector3d Add(Vector3d rhs)
525 {
526 return new Vector3d(x + rhs.x, y + rhs.y, z + rhs.z);
527 }
528
529 public Vector3d Subtract(Vector3d rhs)
530 {
531 return new Vector3d(x - rhs.x, y - rhs.y, z - rhs.z);
532 }
533
534 public Vector3d Multiply(Vector3d rhs)
535 {
536 return new Vector3d(x * rhs.x, y * rhs.y, z * rhs.z);
537 }
538
539 public Vector3d Multiply(double s)
540 {
541 return new Vector3d(x * s, y * s, z * s);
542 }
543
544 public Vector3d Divide(Vector3d rhs)
545 {
546 return new Vector3d(x / rhs.x, y / rhs.y, z / rhs.z);
547 }
548
549 public Vector3d Divide(double s)
550 {
551 return new Vector3d(x / s, y / s, z / s);
552 }
553
554 public double Dot(Vector3d rhs)
555 {
556 return (x * rhs.x + y * rhs.y + z * rhs.z);
557 }
558
559 public Vector3d Cross(Vector3d rhs)
560 {
561 return new Vector3d(y * rhs.z - z * rhs.y, z * rhs.x - x * rhs.z, x * rhs.y - y * rhs.x);
562 }
563
564 public void Normalize()
565 {
566 double len = Length;
567 if (len != 0.0)
568 {
569 x /= len; y /= len; z /= len;
570 }
571 }
572
573 public Vector3d Normalized
574 {
575 get
576 {
577 Vector3d normed = new Vector3d(this);
578 normed.Normalize();
579 return normed;
580 }
581 }
582
583 public double SquaredLength
584 {
585 get
586 {
587 return (x * x + y * y + z * z);
588 }
589 }
590 public double Length
591 {
592 get
593 {
594 return Math.Sqrt(SquaredLength);
595 }
596 }
597
598
599 public override string ToString()
600 {
601 return String.Format("<{0}, {1}, {2}>", x, y, z);
602 }
603
604
605 public static Vector3d operator -(Vector3d uo)
606 {
607 return uo.Negate();
608 }
609
610 public static Vector3d operator +(Vector3d lhs, Vector3d rhs)
611 {
612 return lhs.Add(rhs);
613 }
614
615 public static Vector3d operator -(Vector3d lhs, Vector3d rhs)
616 {
617 return lhs.Subtract(rhs);
618 }
619
620 public static Vector3d operator *(Vector3d lhs, Vector3d rhs)
621 {
622 return lhs.Multiply(rhs);
623 }
624
625 public static Vector3d operator *(Vector3d lhs, double rhs)
626 {
627 return lhs.Multiply(rhs);
628 }
629 public static Vector3d operator *(double lhs, Vector3d rhs)
630 {
631 return rhs.Multiply(lhs);
632 }
633
634 public static Vector3d operator /(Vector3d lhs, Vector3d rhs)
635 {
636 return lhs.Divide(rhs);
637 }
638
639 public static Vector3d operator /(Vector3d lhs, double rhs)
640 {
641 return lhs.Divide(rhs);
642 }
643
644 } // struct Vector3d
645
646 public struct Quaternion
647 {
648
649 public float w;
650 public float x;
651 public float y;
652 public float z;
653
654
655 public Quaternion(float _w, float _x, float _y, float _z)
656 {
657 w = _w; x = _x; y = _y; z = _z;
658 }
659
660 public Quaternion(Quaternion cpy)
661 {
662 w = cpy.w; x = cpy.x; y = cpy.y; z = cpy.z;
663 }
664
665 public static readonly Quaternion Identity = new Quaternion((float)1.0, (float)0.0, (float)0.0, (float)0.0);
666
667 public static Quaternion FromAxisAngle(Vector3f axis, float rads)
668 {
669 float halfAngle = rads * 0.5f;
670 float sinHalf = (float)Math.Sin(halfAngle);
671 float w = (float)Math.Cos(halfAngle);
672 float x = sinHalf * axis.x;
673 float y = sinHalf * axis.y;
674 float z = sinHalf * axis.z;
675 return new Quaternion(w, x, y, z);
676 }
677
678 public static Quaternion FromAxisAngle(Vector3d axis, float rads)
679 {
680 float halfAngle = rads * 0.5f;
681 float sinHalf = (float)Math.Sin(halfAngle);
682 float w = (float)Math.Cos(halfAngle);
683 float x = (float)(sinHalf * axis.x);
684 float y = (float)(sinHalf * axis.y);
685 float z = (float)(sinHalf * axis.z);
686 return new Quaternion(w, x, y, z);
687 }
688
689
690 public Quaternion Add(Quaternion rhs)
691 {
692 return new Quaternion(w + rhs.w, x + rhs.x, y + rhs.y, z + rhs.z);
693 }
694
695 public Quaternion Subtract(Quaternion rhs)
696 {
697 return new Quaternion(w - rhs.w, x - rhs.x, y - rhs.y, z - rhs.z);
698 }
699
700 public Quaternion Multiply(Quaternion rhs)
701 {
702 return new Quaternion(
703 w * rhs.w - x * rhs.x - y * rhs.y - z * rhs.z,
704 w * rhs.x + x * rhs.w + y * rhs.z - z * rhs.y,
705 w * rhs.y + y * rhs.w + z * rhs.x - x * rhs.z,
706 w * rhs.z + z * rhs.w + x * rhs.y - y * rhs.x
707 );
708 }
709
710 public Vector3f Multiply(Vector3f rhs)
711 {
712 Vector3f qvec = new Vector3f(x, y, z);
713 Vector3f uv = qvec.Cross(rhs);
714 Vector3f uuv = qvec.Cross(uv);
715 uv *= 2.0f * w;
716 uuv *= 2.0f;
717
718 return rhs + uv + uuv;
719 }
720
721 public Vector3d Multiply(Vector3d rhs)
722 {
723 Vector3d qvec = new Vector3d(x, y, z);
724 Vector3d uv = qvec.Cross(rhs);
725 Vector3d uuv = qvec.Cross(uv);
726 uv *= 2.0f * w;
727 uuv *= 2.0f;
728
729 return rhs + uv + uuv;
730 }
731
732 public Quaternion Multiply(float rhs)
733 {
734 return new Quaternion(w * rhs, x * rhs, y * rhs, z * rhs);
735 }
736
737 public Quaternion Negate()
738 {
739 return new Quaternion(-w, -x, -y, -z);
740 }
741
742 public float Dot(Quaternion rhs)
743 {
744 return (w * rhs.w + x * rhs.x + y * rhs.y + z * rhs.z);
745 }
746
747 public float Norm
748 {
749 get
750 {
751 return (float)Math.Sqrt(w * w + x * x + y * y + z * z);
752 }
753 }
754
755 public float SquareNorm
756 {
757 get
758 {
759 return (w * w + x * x + y * y + z * z);
760 }
761 }
762
763 public void Normalize()
764 {
765 float len = SquareNorm;
766 if (len == 0.0) return;
767 float factor = 1.0f / (float)Math.Sqrt(len);
768 this *= factor;
769 }
770
771 public Quaternion Normalized
772 {
773 get
774 {
775 Quaternion q = new Quaternion(this);
776 q.Normalize();
777 return q;
778 }
779 }
780
781 public Quaternion Inverse
782 {
783 get
784 {
785 float norm = SquareNorm;
786 if (norm > 0.0)
787 {
788 double invnorm = 1.0 / norm;
789 return new Quaternion((float)(w * invnorm), (float)(-x * invnorm), (float)(-y * invnorm), (float)(-z * invnorm));
790 }
791 else
792 return new Quaternion((float)0.0, 0.0f, 0.0f, 0.0f);
793 }
794 }
795
796
797 public override string ToString()
798 {
799 return String.Format("<{0}, {1}, {2}, {3}>", w, x, y, z);
800 }
801
802
803
804 public static Quaternion operator -(Quaternion uo)
805 {
806 return uo.Negate();
807 }
808
809 public static Quaternion operator +(Quaternion lhs, Quaternion rhs)
810 {
811 return lhs.Add(rhs);
812 }
813
814 public static Quaternion operator -(Quaternion lhs, Quaternion rhs)
815 {
816 return lhs.Subtract(rhs);
817 }
818
819 public static Vector3f operator *(Quaternion lhs, Vector3f rhs)
820 {
821 return lhs.Multiply(rhs);
822 }
823
824 public static Vector3d operator *(Quaternion lhs, Vector3d rhs)
825 {
826 return lhs.Multiply(rhs);
827 }
828
829 public static Quaternion operator *(Quaternion lhs, Quaternion rhs)
830 {
831 return lhs.Multiply(rhs);
832 }
833
834 public static Quaternion operator *(Quaternion lhs, float rhs)
835 {
836 return lhs.Multiply(rhs);
837 }
838
839 public static Quaternion operator *(float lhs, Quaternion rhs)
840 {
841 return rhs.Multiply(lhs);
842 }
843
844 } // struct Quaternion
845
846
847 public struct Vector4f
848 {
849
850 public float x;
851 public float y;
852 public float z;
853 public float w;
854
855
856 public Vector4f(float _x, float _y, float _z, float _w)
857 {
858 x = _x; y = _y; z = _z; w = _w;
859 }
860
861 public Vector4f(Vector4f cpy)
862 {
863 x = cpy.x; y = cpy.y; z = cpy.z; w = cpy.w;
864 }
865
866
867 public Vector4f Negate()
868 {
869 return new Vector4f(-x, -y, -z, -w);
870 }
871
872 public Vector4f Add(Vector4f rhs)
873 {
874 return new Vector4f(x + rhs.x, y + rhs.y, z + rhs.z, w + rhs.w);
875 }
876
877 public Vector4f Subtract(Vector4f rhs)
878 {
879 return new Vector4f(x - rhs.x, y - rhs.y, z - rhs.z, w - rhs.w);
880 }
881
882 public Vector4f Multiply(Vector4f rhs)
883 {
884 return new Vector4f(x * rhs.x, y * rhs.y, z * rhs.z, w * rhs.w);
885 }
886
887 public Vector4f Multiply(float s)
888 {
889 return new Vector4f(x * s, y * s, z * s, w * s);
890 }
891
892 public Vector4f Divide(Vector4f rhs)
893 {
894 return new Vector4f(x / rhs.x, y / rhs.y, z / rhs.z, w / rhs.w);
895 }
896
897 public Vector4f Divide(float s)
898 {
899 return new Vector4f(x / s, y / s, z / s, w / s);
900 }
901
902 public float Dot(Vector4f rhs)
903 {
904 return (x * rhs.x + y * rhs.y + z * rhs.z + w * rhs.w);
905 }
906
907 public void Normalize()
908 {
909 float len = Length;
910 if (len != 0.0)
911 {
912 x /= len; y /= len; z /= len; w /= len;
913 }
914 }
915
916 public Vector4f Normalized
917 {
918 get
919 {
920 Vector4f normed = new Vector4f(this);
921 normed.Normalize();
922 return normed;
923 }
924 }
925
926 public float SquaredLength
927 {
928 get
929 {
930 return (x * x + y * y + z * z + w * w);
931 }
932 }
933 public float Length
934 {
935 get
936 {
937 return (float)Math.Sqrt(SquaredLength);
938 }
939 }
940
941
942 public override string ToString()
943 {
944 return String.Format("<{0}, {1}, {2}, {3}>", x, y, z, w);
945 }
946
947
948 public static Vector4f operator -(Vector4f uo)
949 {
950 return uo.Negate();
951 }
952
953 public static Vector4f operator +(Vector4f lhs, Vector4f rhs)
954 {
955 return lhs.Add(rhs);
956 }
957
958 public static Vector4f operator -(Vector4f lhs, Vector4f rhs)
959 {
960 return lhs.Subtract(rhs);
961 }
962
963 public static Vector4f operator *(Vector4f lhs, Vector4f rhs)
964 {
965 return lhs.Multiply(rhs);
966 }
967
968 public static Vector4f operator *(Vector4f lhs, float rhs)
969 {
970 return lhs.Multiply(rhs);
971 }
972 public static Vector4f operator *(float lhs, Vector4f rhs)
973 {
974 return rhs.Multiply(lhs);
975 }
976
977 public static Vector4f operator /(Vector4f lhs, Vector4f rhs)
978 {
979 return lhs.Divide(rhs);
980 }
981
982 public static Vector4f operator /(Vector4f lhs, float rhs)
983 {
984 return lhs.Divide(rhs);
985 }
986
987 } // struct Vector4f
988
989
990
991 public struct Vector4d
992 {
993
994 public double x;
995 public double y;
996 public double z;
997 public double w;
998
999
1000 public Vector4d(double _x, double _y, double _z, double _w)
1001 {
1002 x = _x; y = _y; z = _z; w = _w;
1003 }
1004
1005 public Vector4d(Vector4d cpy)
1006 {
1007 x = cpy.x; y = cpy.y; z = cpy.z; w = cpy.w;
1008 }
1009
1010
1011 public Vector4d Negate()
1012 {
1013 return new Vector4d(-x, -y, -z, -w);
1014 }
1015
1016 public Vector4d Add(Vector4d rhs)
1017 {
1018 return new Vector4d(x + rhs.x, y + rhs.y, z + rhs.z, w + rhs.w);
1019 }
1020
1021 public Vector4d Subtract(Vector4d rhs)
1022 {
1023 return new Vector4d(x - rhs.x, y - rhs.y, z - rhs.z, w - rhs.w);
1024 }
1025
1026 public Vector4d Multiply(Vector4d rhs)
1027 {
1028 return new Vector4d(x * rhs.x, y * rhs.y, z * rhs.z, w * rhs.w);
1029 }
1030
1031 public Vector4d Multiply(double s)
1032 {
1033 return new Vector4d(x * s, y * s, z * s, w * s);
1034 }
1035
1036 public Vector4d Divide(Vector4d rhs)
1037 {
1038 return new Vector4d(x / rhs.x, y / rhs.y, z / rhs.z, w / rhs.w);
1039 }
1040
1041 public Vector4d Divide(double s)
1042 {
1043 return new Vector4d(x / s, y / s, z / s, w / s);
1044 }
1045
1046 public double Dot(Vector4d rhs)
1047 {
1048 return (x * rhs.x + y * rhs.y + z * rhs.z + w * rhs.w);
1049 }
1050
1051 public void Normalize()
1052 {
1053 double len = Length;
1054 if (len != 0.0)
1055 {
1056 x /= len; y /= len; z /= len; w /= len;
1057 }
1058 }
1059
1060 public Vector4d Normalized
1061 {
1062 get
1063 {
1064 Vector4d normed = new Vector4d(this);
1065 normed.Normalize();
1066 return normed;
1067 }
1068 }
1069
1070 public double SquaredLength
1071 {
1072 get
1073 {
1074 return (x * x + y * y + z * z + w * w);
1075 }
1076 }
1077 public double Length
1078 {
1079 get
1080 {
1081 return Math.Sqrt(SquaredLength);
1082 }
1083 }
1084
1085
1086 public override string ToString()
1087 {
1088 return String.Format("<{0}, {1}, {2}, {3}>", x, y, z, w);
1089 }
1090
1091
1092 public static Vector4d operator -(Vector4d uo)
1093 {
1094 return uo.Negate();
1095 }
1096
1097 public static Vector4d operator +(Vector4d lhs, Vector4d rhs)
1098 {
1099 return lhs.Add(rhs);
1100 }
1101
1102 public static Vector4d operator -(Vector4d lhs, Vector4d rhs)
1103 {
1104 return lhs.Subtract(rhs);
1105 }
1106
1107 public static Vector4d operator *(Vector4d lhs, Vector4d rhs)
1108 {
1109 return lhs.Multiply(rhs);
1110 }
1111
1112 public static Vector4d operator *(Vector4d lhs, double rhs)
1113 {
1114 return lhs.Multiply(rhs);
1115 }
1116 public static Vector4d operator *(double lhs, Vector4d rhs)
1117 {
1118 return rhs.Multiply(lhs);
1119 }
1120
1121 public static Vector4d operator /(Vector4d lhs, Vector4d rhs)
1122 {
1123 return lhs.Divide(rhs);
1124 }
1125
1126 public static Vector4d operator /(Vector4d lhs, double rhs)
1127 {
1128 return lhs.Divide(rhs);
1129 }
1130
1131 } // struct Vector4d
1132
1133
1134
1135 public struct BoundingBox3f3f
1136 {
1137 Vector3f mMin;
1138 Vector3f mDiag;
1139 public BoundingBox3f3f(float minx, float miny, float minz, float diagx, float diagy, float diagz)
1140 {
1141 mMin.x = minx;
1142 mMin.y = miny;
1143 mMin.z = minz;
1144
1145 mDiag.x = diagx;
1146 mDiag.y = diagy;
1147 mDiag.z = diagz;
1148 }
1149 public BoundingBox3f3f(Vector3f min, Vector3f max)
1150 {
1151 mMin = min;
1152 mDiag = (max - min);
1153 }
1154 public BoundingBox3f3f(BoundingBox3f3f cpy, Vector3f scale)
1155 {
1156 mMin.x = (float)(cpy.mMin.x * scale.x);
1157 mMin.y = (float)(cpy.mMin.y * scale.y);
1158 mMin.z = (float)(cpy.mMin.z * scale.z);
1159
1160 mDiag.x = (float)(cpy.mDiag.x * scale.x);
1161 mDiag.y = (float)(cpy.mDiag.y * scale.y);
1162 mDiag.z = (float)(cpy.mDiag.z * scale.z);
1163 }
1164 public Vector3f Min
1165 {
1166 get
1167 {
1168 return new Vector3f(mMin.x, mMin.y, mMin.z);
1169 }
1170 }
1171 public Vector3f Max
1172 {
1173 get
1174 {
1175 return new Vector3f(mMin.x + mDiag.x, mMin.y + mDiag.y, mMin.z + mDiag.z);
1176 }
1177 }
1178
1179 public Vector3f Diag
1180 {
1181 get
1182 {
1183 return new Vector3f(mDiag.x, mDiag.y, mDiag.z);
1184 }
1185 }
1186
1187
1188 public override string ToString()
1189 {
1190 return "[" + this.Min.ToString() + " - " + this.Max.ToString() + "]";
1191 }
1192 public BoundingBox3f3f Merge(BoundingBox3f3f other)
1193 {
1194 Vector3f thisMax = Max;
1195 Vector3f otherMax = other.Max;
1196 bool xless = other.mMin.x > mMin.x;
1197 bool yless = other.mMin.y > mMin.y;
1198 bool zless = other.mMin.z > mMin.z;
1199
1200 bool xmore = otherMax.x < thisMax.x;
1201 bool ymore = otherMax.y < thisMax.y;
1202 bool zmore = otherMax.z < thisMax.z;
1203 return new BoundingBox3f3f(xless ? mMin.x : other.mMin.x,
1204 yless ? mMin.y : other.mMin.y,
1205 zless ? mMin.z : other.mMin.z,
1206 xmore ? (xless ? mDiag.x : otherMax.x - mMin.x) : (xless ? thisMax.x - other.mMin.x : other.mDiag.x),
1207 ymore ? (yless ? mDiag.y : otherMax.y - mMin.y) : (yless ? thisMax.y - other.mMin.y : other.mDiag.y),
1208 zmore ? (zless ? mDiag.z : otherMax.z - mMin.z) : (zless ? thisMax.z - other.mMin.z : other.mDiag.z));
1209 }
1210
1211 } // struct BoundingBox
1212
1213 public struct BoundingBox3d3f
1214 {
1215 Vector3d mMin;
1216 Vector3f mDiag;
1217 public BoundingBox3d3f(double minx, double miny, double minz, float diagx, float diagy, float diagz)
1218 {
1219 mMin.x = minx;
1220 mMin.y = miny;
1221 mMin.z = minz;
1222
1223 mDiag.x = diagx;
1224 mDiag.y = diagy;
1225 mDiag.z = diagz;
1226 }
1227 public BoundingBox3d3f(Vector3d min, Vector3f max)
1228 {
1229 mMin = min;
1230
1231 mDiag = new Vector3f((float)(max.x - min.x),
1232 (float)(max.y - min.y),
1233 (float)(max.z - min.z));
1234 }
1235 public BoundingBox3d3f(BoundingBox3d3f cpy, Vector3d scale)
1236 {
1237 mMin.x = (double)(cpy.mMin.x * scale.x);
1238 mMin.y = (double)(cpy.mMin.y * scale.y);
1239 mMin.z = (double)(cpy.mMin.z * scale.z);
1240
1241 mDiag.x = (float)(cpy.mDiag.x * scale.x);
1242 mDiag.y = (float)(cpy.mDiag.y * scale.y);
1243 mDiag.z = (float)(cpy.mDiag.z * scale.z);
1244 }
1245 public Vector3d Min
1246 {
1247 get
1248 {
1249 return new Vector3d(mMin.x, mMin.y, mMin.z);
1250 }
1251 }
1252 public Vector3d Max
1253 {
1254 get
1255 {
1256 return new Vector3d(mMin.x + mDiag.x, mMin.y + mDiag.y, mMin.z + mDiag.z);
1257 }
1258 }
1259
1260 public Vector3d Diag
1261 {
1262 get
1263 {
1264 return new Vector3d(mDiag.x, mDiag.y, mDiag.z);
1265 }
1266 }
1267
1268
1269 public override string ToString()
1270 {
1271 return "[" + this.Min.ToString() + " - " + this.Max.ToString() + "]";
1272 }
1273 public BoundingBox3d3f Merge(BoundingBox3d3f other)
1274 {
1275 Vector3d thisMax = Max;
1276 Vector3d otherMax = other.Max;
1277 bool xless = other.mMin.x > mMin.x;
1278 bool yless = other.mMin.y > mMin.y;
1279 bool zless = other.mMin.z > mMin.z;
1280
1281 bool xmore = otherMax.x < thisMax.x;
1282 bool ymore = otherMax.y < thisMax.y;
1283 bool zmore = otherMax.z < thisMax.z;
1284 return new BoundingBox3d3f(xless ? mMin.x : other.mMin.x,
1285 yless ? mMin.y : other.mMin.y,
1286 zless ? mMin.z : other.mMin.z,
1287 (float)(xmore ? (xless ? mDiag.x : otherMax.x - mMin.x) : (xless ? thisMax.x - other.mMin.x : other.mDiag.x)),
1288 (float)(ymore ? (yless ? mDiag.y : otherMax.y - mMin.y) : (yless ? thisMax.y - other.mMin.y : other.mDiag.y)),
1289 (float)(zmore ? (zless ? mDiag.z : otherMax.z - mMin.z) : (zless ? thisMax.z - other.mMin.z : other.mDiag.z)));
1290 }
1291
1292 } // struct BoundingBox
1293
1294
1295
1296
1297 public struct BoundingSphere3f
1298 {
1299 Vector3f mCenter;
1300 float mRadius;
1301 public BoundingSphere3f(float x, float y, float z, float r)
1302 {
1303 mCenter = new Vector3f(x, y, z);
1304 mRadius = r;
1305 }
1306 public BoundingSphere3f(Vector3f center, float radius)
1307 {
1308 mCenter = center;
1309 mRadius = radius;
1310 }
1311 public BoundingSphere3f(BoundingSphere3f cpy, float scale)
1312 {
1313 mCenter = cpy.mCenter;
1314 mRadius = cpy.mRadius * scale;
1315 }
1316 public Vector3f Center
1317 {
1318 get
1319 {
1320 return new Vector3f(mCenter.x, mCenter.y, mCenter.z);
1321 }
1322 }
1323 public float Radius
1324 {
1325 get
1326 {
1327 return mRadius;
1328 }
1329 }
1330
1331 public override string ToString()
1332 {
1333 return "[" + this.Center.ToString() + " : " + this.Radius.ToString() + "]";
1334 }
1335 } // struct BoundingSphere3f
1336
1337
1338
1339 public struct BoundingSphere3d
1340 {
1341 Vector3d mCenter;
1342 float mRadius;
1343 public BoundingSphere3d(double x, double y, double z, float r)
1344 {
1345 mCenter.x = x;
1346 mCenter.y = y;
1347 mCenter.z = z;
1348 mRadius = r;
1349 }
1350 public BoundingSphere3d(Vector3d center, float radius)
1351 {
1352 mCenter = center;
1353 mRadius = radius;
1354 }
1355 public BoundingSphere3d(BoundingSphere3d cpy, float scale)
1356 {
1357 mCenter = cpy.mCenter;
1358 mRadius = cpy.mRadius * scale;
1359 }
1360 public Vector3d Center
1361 {
1362 get
1363 {
1364 return new Vector3d(mCenter.x, mCenter.y, mCenter.z);
1365 }
1366 }
1367 public float Radius
1368 {
1369 get
1370 {
1371 return mRadius;
1372 }
1373 }
1374
1375 public override string ToString()
1376 {
1377 return "[" + this.Center.ToString() + " : " + this.Radius.ToString() + "]";
1378 }
1379 } // struct BoundingSphere3f
1380
1381 public struct UUID
1382 {
1383 ulong mLowOrderBytes;
1384 ulong mHighOrderBytes;
1385
1386
1387 static ulong SetUUIDlow(Google.ProtocolBuffers.ByteString data, int offset)
1388 {
1389 ulong LowOrderBytes = 0;
1390 int shiftVal = 0;
1391 for (int i = 0; i < 8; ++i)
1392 {
1393 ulong temp = data[i];
1394 LowOrderBytes |= (temp << shiftVal);
1395 shiftVal += 8;
1396 }
1397 return LowOrderBytes;
1398 }
1399 static ulong SetUUIDhigh(Google.ProtocolBuffers.ByteString data)
1400 {
1401 return SetUUIDlow(data, 8);
1402 }
1403 static ulong SetUUIDlow(byte[] data, int offset)
1404 {
1405 ulong LowOrderBytes = 0;
1406 int shiftVal = 0;
1407 for (int i = 0; i < 8; ++i)
1408 {
1409 ulong temp = data[i];
1410 LowOrderBytes |= (temp << shiftVal);
1411 shiftVal += 8;
1412 }
1413 return LowOrderBytes;
1414 }
1415 static ulong SetUUIDhigh(byte[] data)
1416 {
1417 return SetUUIDlow(data, 8);
1418 }
1419 public bool SetUUID(byte[] data)
1420 {
1421 if (data.Length == 16)
1422 {
1423 mLowOrderBytes = 0;
1424 mHighOrderBytes = 0;
1425 mLowOrderBytes = SetUUIDlow(data, 0);
1426 mHighOrderBytes = SetUUIDlow(data, 8);
1427 return true;
1428 }
1429 else
1430 {
1431 return false;
1432 }
1433 }
1434 public byte[] GetUUID()
1435 {
1436 byte[] data = new byte[16];
1437 int shiftVal = 0;
1438 for (int i = 0; i < 8; ++i)
1439 {
1440 ulong temp = 0xff;
1441 temp = (mLowOrderBytes & (temp << shiftVal));
1442 temp = (temp >> shiftVal);
1443 data[i] = (byte)temp;
1444 shiftVal += 8;
1445 }
1446 shiftVal = 0;
1447 for (int i = 8; i < 16; ++i)
1448 {
1449 ulong temp = 0xff;
1450 temp = (mHighOrderBytes & (temp << shiftVal));
1451 temp = (temp >> shiftVal);
1452 data[i] = (byte)temp;
1453 shiftVal += 8;
1454 }
1455 return data;
1456 }
1457
1458 public static UUID Empty = new UUID(new byte[16]);
1459 public UUID(byte[] data)
1460 {
1461 if (data.Length != 16)
1462 {
1463 throw new System.ArgumentException("UUIDs must be provided 16 bytes");
1464 }
1465 mLowOrderBytes = SetUUIDlow(data, 0);
1466 mHighOrderBytes = SetUUIDhigh(data);
1467 }
1468 public UUID(Google.ProtocolBuffers.ByteString data)
1469 {
1470 if (data.Length != 16)
1471 {
1472 throw new System.ArgumentException("UUIDs must be provided 16 bytes");
1473 }
1474 mLowOrderBytes = SetUUIDlow(data, 0);
1475 mHighOrderBytes = SetUUIDhigh(data);
1476 }
1477
1478 }
1479
1480
1481 public struct SHA256
1482 {
1483 ulong mLowOrderBytes;
1484 ulong mLowMediumOrderBytes;
1485 ulong mMediumHighOrderBytes;
1486 ulong mHighOrderBytes;
1487
1488
1489 static ulong SetLMH(Google.ProtocolBuffers.ByteString data, int offset)
1490 {
1491 ulong LowOrderBytes = 0;
1492 int shiftVal = 0;
1493 for (int i = 0; i < 8; ++i)
1494 {
1495 ulong temp = data[i];
1496 LowOrderBytes |= (temp << shiftVal);
1497 shiftVal += 8;
1498 }
1499 return LowOrderBytes;
1500 }
1501 static ulong SetLow(Google.ProtocolBuffers.ByteString data)
1502 {
1503 return SetLMH(data, 0);
1504 }
1505 static ulong SetLowMedium(Google.ProtocolBuffers.ByteString data)
1506 {
1507 return SetLMH(data, 8);
1508 }
1509 static ulong SetMediumHigh(Google.ProtocolBuffers.ByteString data)
1510 {
1511 return SetLMH(data, 16);
1512 }
1513 static ulong SetHigh(Google.ProtocolBuffers.ByteString data)
1514 {
1515 return SetLMH(data, 24);
1516 }
1517 static ulong SetLMH(byte[] data, int offset)
1518 {
1519 ulong LowOrderBytes = 0;
1520 int shiftVal = 0;
1521 for (int i = 0; i < 8; ++i)
1522 {
1523 ulong temp = data[i];
1524 LowOrderBytes |= (temp << shiftVal);
1525 shiftVal += 8;
1526 }
1527 return LowOrderBytes;
1528 }
1529 static ulong SetLow(byte[] data)
1530 {
1531 return SetLMH(data, 0);
1532 }
1533 static ulong SetLowMedium(byte[] data)
1534 {
1535 return SetLMH(data, 8);
1536 }
1537 static ulong SetMediumHigh(byte[] data)
1538 {
1539 return SetLMH(data, 16);
1540 }
1541 static ulong SetHigh(byte[] data)
1542 {
1543 return SetLMH(data, 24);
1544 }
1545 public bool SetSHA256(byte[] data)
1546 {
1547 if (data.Length == 32)
1548 {
1549 mLowOrderBytes = SetLow(data);
1550 mLowMediumOrderBytes = SetLowMedium(data);
1551 mMediumHighOrderBytes = SetMediumHigh(data);
1552 mHighOrderBytes = SetHigh(data);
1553 return true;
1554 }
1555 else
1556 {
1557 return false;
1558 }
1559 }
1560 public byte[] GetBinaryData()
1561 {
1562 byte[] data = new byte[32];
1563 int shiftVal = 0;
1564 for (int i = 0; i < 8; ++i)
1565 {
1566 ulong temp = 0xff;
1567 temp = (mLowOrderBytes & (temp << shiftVal));
1568 temp = (temp >> shiftVal);
1569 data[i] = (byte)temp;
1570 shiftVal += 8;
1571 }
1572 shiftVal = 0;
1573 for (int i = 8; i < 16; ++i)
1574 {
1575 ulong temp = 0xff;
1576 temp = (mLowMediumOrderBytes & (temp << shiftVal));
1577 temp = (temp >> shiftVal);
1578 data[i] = (byte)temp;
1579 shiftVal += 8;
1580 }
1581 shiftVal = 0;
1582 for (int i = 16; i < 24; ++i)
1583 {
1584 ulong temp = 0xff;
1585 temp = (mMediumHighOrderBytes & (temp << shiftVal));
1586 temp = (temp >> shiftVal);
1587 data[i] = (byte)temp;
1588 shiftVal += 8;
1589 }
1590 shiftVal = 0;
1591 for (int i = 24; i < 32; ++i)
1592 {
1593 ulong temp = 0xff;
1594 temp = (mHighOrderBytes & (temp << shiftVal));
1595 temp = (temp >> shiftVal);
1596 data[i] = (byte)temp;
1597 shiftVal += 8;
1598 }
1599 return data;
1600 }
1601
1602 public static SHA256 Empty = new SHA256(new byte[32]);
1603 public SHA256(byte[] data)
1604 {
1605 if (data.Length != 32)
1606 {
1607 throw new System.ArgumentException("SHA256s must be provided 32 bytes");
1608 }
1609 mLowOrderBytes = SetLow(data);
1610 mLowMediumOrderBytes = SetLowMedium(data);
1611 mMediumHighOrderBytes = SetMediumHigh(data);
1612 mHighOrderBytes = SetHigh(data);
1613 }
1614 public SHA256(Google.ProtocolBuffers.ByteString data)
1615 {
1616 if (data.Length != 32)
1617 {
1618 throw new System.ArgumentException("SHA256s must be provided 32 bytes");
1619 }
1620 mLowOrderBytes = SetLow(data);
1621 mLowMediumOrderBytes = SetLowMedium(data);
1622 mMediumHighOrderBytes = SetMediumHigh(data);
1623 mHighOrderBytes = SetHigh(data);
1624 }
1625
1626 }
1627
1628
1629
1630
1631 public struct Time
1632 {
1633 ulong usec;
1634 public Time(ulong usec_since_epoch)
1635 {
1636 usec = usec_since_epoch;
1637 }
1638 public ulong toMicro()
1639 {
1640 return usec;
1641 }
1642 }
1643 public class Duration
1644 {
1645 long usec;
1646 public Duration(long time_since)
1647 {
1648 usec = time_since;
1649 }
1650 public long toMicro()
1651 {
1652 return usec;
1653 }
1654 }
1655
1656 class _PBJ
1657 {
1658
1659 public static bool ValidateBool(bool d)
1660 {
1661 return true;
1662 }
1663 public static bool ValidateDouble(double d)
1664 {
1665 return true;
1666 }
1667 public static bool ValidateFloat(float d)
1668 {
1669 return true;
1670 }
1671 public static bool ValidateUint64(ulong d)
1672 {
1673 return true;
1674 }
1675 public static bool ValidateUint32(uint d)
1676 {
1677 return true;
1678 }
1679 public static bool ValidateUint16(ushort d)
1680 {
1681 return true;
1682 }
1683 public static bool ValidateUint8(byte d)
1684 {
1685 return true;
1686 }
1687 public static bool ValidateInt64(long d)
1688 {
1689 return true;
1690 }
1691 public static bool ValidateInt32(int d)
1692 {
1693 return true;
1694 }
1695 public static bool ValidateInt16(short d)
1696 {
1697 return true;
1698 }
1699 public static bool ValidateInt8(sbyte d)
1700 {
1701 return true;
1702 }
1703 public static bool ValidateString<S>(S input)
1704 {
1705 return true;
1706 }
1707 public static bool ValidateBytes<B>(B input)
1708 {
1709 return true;
1710 }
1711 public static bool ValidateUuid(Google.ProtocolBuffers.ByteString input)
1712 {
1713 return input.Length == 16;
1714 }
1715 public static bool ValidateSha256(Google.ProtocolBuffers.ByteString input)
1716 {
1717 return input.Length == 32;
1718 }
1719 public static bool ValidateAngle(float input)
1720 {
1721 return input >= 0 && input <= 3.1415926536 * 2.0;
1722 }
1723 public static bool ValidateTime(ulong input)
1724 {
1725 return true;
1726 }
1727 public static bool ValidateDuration(long input)
1728 {
1729 return true;
1730 }
1731 public static bool ValidateFlags(ulong input, ulong verification)
1732 {
1733 return (input & verification) == input;
1734 }
1735
1736
1737
1738
1739 public static bool CastBool(bool d)
1740 {
1741 return d;
1742 }
1743 public static double CastDouble(double d)
1744 {
1745 return d;
1746 }
1747 public static float CastFloat(float d)
1748 {
1749 return d;
1750 }
1751 public static ulong CastUint64(ulong d)
1752 {
1753 return d;
1754 }
1755 public static uint CastUint32(uint d)
1756 {
1757 return d;
1758 }
1759 public static ushort CastUint16(ushort d)
1760 {
1761 return d;
1762 }
1763 public static byte CastUint8(byte d)
1764 {
1765 return d;
1766 }
1767 public static long CastInt64(long d)
1768 {
1769 return d;
1770 }
1771 public static int CastInt32(int d)
1772 {
1773 return d;
1774 }
1775 public static short CastInt16(short d)
1776 {
1777 return d;
1778 }
1779 public static sbyte CastInt8(sbyte d)
1780 {
1781 return d;
1782 }
1783 public static S CastString<S>(S input)
1784 {
1785 return input;
1786 }
1787 public static B CastBytes<B>(B input)
1788 {
1789 return input;
1790 }
1791
1792
1793
1794 public static bool CastBool()
1795 {
1796 return false;
1797 }
1798 public static double CastDouble()
1799 {
1800 return 0;
1801 }
1802 public static float CastFloat()
1803 {
1804 return 0;
1805 }
1806 public static ulong CastUint64()
1807 {
1808 return 0;
1809 }
1810 public static uint CastUint32()
1811 {
1812 return 0;
1813 }
1814 public static ushort CastUint16()
1815 {
1816 return 0;
1817 }
1818 public static byte CastUint8()
1819 {
1820 return 0;
1821 }
1822 public static long CastInt64()
1823 {
1824 return 0;
1825 }
1826 public static int CastInt32()
1827 {
1828 return 0;
1829 }
1830 public static short CastInt16()
1831 {
1832 return 0;
1833 }
1834 public static sbyte CastInt8()
1835 {
1836 return 0;
1837 }
1838 public static string CastString()
1839 {
1840 return "";
1841 }
1842 public static Google.ProtocolBuffers.ByteString CastBytes()
1843 {
1844 return Google.ProtocolBuffers.ByteString.Empty;
1845 }
1846
1847
1848 public static ulong CastFlags(ulong data, ulong allFlagsOn)
1849 {
1850 return allFlagsOn & data;
1851 }
1852 public static ulong CastFlags(ulong allFlagsOn)
1853 {
1854 return 0;
1855 }
1856
1857 public static Vector3f CastNormal(float x, float y)
1858 {
1859 float neg = (x > 1.5f || y > 1.5f) ? -1.0f : 1.0f;
1860 if (x > 1.5)
1861 x -= 3;
1862 if (y > 1.5)
1863 y -= 3;
1864 return new Vector3f(x, y, neg - neg * (float)Math.Sqrt(x * x + y * y));
1865 }
1866 public static Vector3f CastNormal()
1867 {
1868 return new Vector3f(0, 1, 0);
1869 }
1870
1871
1872 public static Vector2f CastVector2f(float x, float y)
1873 {
1874 return new Vector2f(x, y);
1875 }
1876 public static Vector2f CastVector2f()
1877 {
1878 return new Vector2f(0, 0);
1879 }
1880
1881 public static Vector3f CastVector3f(float x, float y, float z)
1882 {
1883 return new Vector3f(x, y, z);
1884 }
1885 public static Vector3f CastVector3f()
1886 {
1887 return new Vector3f(0, 0, 0);
1888 }
1889
1890 public static Vector4f CastVector4f(float x, float y, float z, float w)
1891 {
1892 return new Vector4f(x, y, z, w);
1893 }
1894 public static Vector4f CastVector4f()
1895 {
1896 return new Vector4f(0, 0, 0, 0);
1897 }
1898 public static Vector2d CastVector2d(double x, double y)
1899 {
1900 return new Vector2d(x, y);
1901 }
1902 public static Vector2d CastVector2d()
1903 {
1904 return new Vector2d(0, 0);
1905 }
1906
1907 public static Vector3d CastVector3d(double x, double y, double z)
1908 {
1909 return new Vector3d(x, y, z);
1910 }
1911 public static Vector3d CastVector3d()
1912 {
1913 return new Vector3d(0, 0, 0);
1914 }
1915
1916 public static Vector4d CastVector4d(double x, double y, double z, double w)
1917 {
1918 return new Vector4d(x, y, z, w);
1919 }
1920 public static Vector4d CastVector4d()
1921 {
1922 return new Vector4d(0, 0, 0, 0);
1923 }
1924
1925 public static BoundingSphere3f CastBoundingsphere3f(float x, float y, float z, float r)
1926 {
1927 return new BoundingSphere3f(new Vector3f(x, y, z), r);
1928 }
1929 public static BoundingSphere3d CastBoundingsphere3d(double x, double y, double z, double r)
1930 {
1931 return new BoundingSphere3d(new Vector3d(x, y, z), (float)r);
1932 }
1933
1934 public static BoundingSphere3f CastBoundingsphere3f()
1935 {
1936 return new BoundingSphere3f(new Vector3f(0, 0, 0), 0);
1937 }
1938 public static BoundingSphere3d CastBoundingsphere3d()
1939 {
1940 return new BoundingSphere3d(new Vector3d(0, 0, 0), (float)0);
1941 }
1942
1943
1944 public static BoundingBox3f3f CastBoundingbox3f3f(float x, float y, float z, float dx, float dy, float dz)
1945 {
1946 return new BoundingBox3f3f(x, y, z, dx, dy, dz);
1947 }
1948 public static BoundingBox3d3f CastBoundingbox3d3f(double x, double y, double z, double dx, double dy, double dz)
1949 {
1950 return new BoundingBox3d3f(x, y, z, (float)dx, (float)dy, (float)dz);
1951 }
1952
1953 public static BoundingBox3f3f CastBoundingbox3f3f()
1954 {
1955 return new BoundingBox3f3f(new Vector3f(0, 0, 0), new Vector3f(0, 0, 0));
1956 }
1957 public static BoundingBox3d3f CastBoundingbox3d3f()
1958 {
1959 return new BoundingBox3d3f(0, 0, 0, 0, 0, 0);
1960 }
1961
1962
1963
1964 public static Quaternion CastQuaternion(float x, float y, float z)
1965 {
1966 float neg = (x > 1.5 || y > 1.5 || z > 1.5) ? -1.0f : 1.0f;
1967 if (x > 1.5)
1968 x -= 3.0f;
1969 if (y > 1.5)
1970 y -= 3.0f;
1971 if (z > 1.5)
1972 z -= 3.0f;
1973 return new Quaternion(neg - neg * (float)Math.Sqrt(x * x + y * y + z * z), x, y, z);
1974 }
1975 public static Quaternion CastQuaternion()
1976 {
1977 return new Quaternion(1, 0, 0, 0);
1978 }
1979
1980 public static UUID CastUuid(Google.ProtocolBuffers.ByteString input)
1981 {
1982 return new UUID(input);
1983 }
1984 public static SHA256 CastSha256(Google.ProtocolBuffers.ByteString input)
1985 {
1986 return new SHA256(input);
1987 }
1988 public static SHA256 CastSha256()
1989 {
1990 return SHA256.Empty;
1991 }
1992 public static UUID CastUuid()
1993 {
1994 return UUID.Empty;
1995 }
1996
1997 public static float CastAngle(float d)
1998 {
1999 return d;
2000 }
2001 public static float CastAngle()
2002 {
2003 return 0;
2004 }
2005
2006 public static Time CastTime(ulong t)
2007 {
2008 return new Time(t);
2009 }
2010 public static Time CastTime()
2011 {
2012 return new Time(0);
2013 }
2014 public static Duration CastDuration(long t)
2015 {
2016 return new Duration(t);
2017 }
2018 public static Duration CastDuration()
2019 {
2020 return new Duration(0);
2021 }
2022
2023 public static T Construct<T>(T retval)
2024 {
2025 return retval;
2026 }
2027 public static long Construct(Duration d)
2028 {
2029 return d.toMicro();
2030 }
2031 public static ulong Construct(Time t)
2032 {
2033 return t.toMicro();
2034 }
2035 public static Google.ProtocolBuffers.ByteString Construct(UUID u)
2036 {
2037 byte[] data = u.GetUUID();
2038 Google.ProtocolBuffers.ByteString retval = Google.ProtocolBuffers.ByteString.CopyFrom(data, 0, 16);
2039 return retval;
2040 }
2041 public static Google.ProtocolBuffers.ByteString Construct(SHA256 u)
2042 {
2043 byte[] data = u.GetBinaryData();
2044 Google.ProtocolBuffers.ByteString retval = Google.ProtocolBuffers.ByteString.CopyFrom(data, 0, 16);
2045 return retval;
2046 }
2047 public static float[] ConstructNormal(Vector3f d)
2048 {
2049 return new float[] { d.x + (d.z < 0 ? 3.0f : 0.0f), d.y };
2050 }
2051 public static float[] ConstructQuaternion(Quaternion d)
2052 {
2053 return new float[] { d.x + (d.w < 0 ? 3.0f : 0.0f), d.y, d.z };
2054 }
2055
2056 public static float[] ConstructVector2f(Vector2f d)
2057 {
2058 return new float[] { d.x, d.y };
2059 }
2060 public static double[] ConstructVector2d(Vector2d d)
2061 {
2062 return new double[] { d.x, d.y };
2063 }
2064
2065 public static float[] ConstructVector3f(Vector3f d)
2066 {
2067 return new float[] { d.x, d.y, d.z };
2068 }
2069 public static double[] ConstructVector3d(Vector3d d)
2070 {
2071 return new double[] { d.x, d.y, d.z };
2072 }
2073 public static float[] ConstructVector4f(Vector4f d)
2074 {
2075 return new float[] { d.x, d.y, d.z, d.w };
2076 }
2077 public static double[] ConstructVector4d(Vector4d d)
2078 {
2079 return new double[] { d.x, d.y, d.z, d.w };
2080 }
2081
2082
2083 public static float[] ConstructBoundingsphere3f(BoundingSphere3f d)
2084 {
2085 return new float[] { d.Center.x, d.Center.y, d.Center.z, d.Radius };
2086 }
2087 public static double[] ConstructBoundingsphere3d(BoundingSphere3d d)
2088 {
2089 return new double[] { d.Center.x, d.Center.y, d.Center.z, d.Radius };
2090 }
2091
2092 public static float[] ConstructBoundingbox3f3f(BoundingBox3f3f d)
2093 {
2094 return new float[] { d.Min.x, d.Min.y, d.Min.z, d.Diag.x, d.Diag.y, d.Diag.z };
2095 }
2096 public static double[] ConstructBoundingbox3d3f(BoundingBox3d3f d)
2097 {
2098 return new double[] { d.Min.x, d.Min.y, d.Min.z, d.Diag.x, d.Diag.y, d.Diag.z };
2099 }
2100
2101
2102 }
2103
2104}