// Constructor
 public CompressedMatrix(TransformCrusher crusher, ref CompressedElement cPos, ref CompressedElement cRot, ref CompressedElement cScl, int pBits, int rBits, int sBits)
 {
     this.crusher = crusher;
     this.cPos    = cPos;
     this.cRot    = cRot;
     this.cScl    = cScl;
 }
Beispiel #2
0
        // Constructor
        public Matrix(TransformCrusher crusher, Transform transform)
        {
            this.crusher = crusher;

            bool lclpos = (crusher == null || crusher.PosCrusher == null || crusher.PosCrusher.local);

            this.position = (lclpos) ? transform.localPosition : transform.position;

            // Not sure the idea option for scale... lossy or local.
            bool lclscl = (crusher == null || crusher.SclCrusher == null || crusher.SclCrusher.local);

            this.scale = (lclscl) ? transform.localScale : transform.lossyScale;

            bool lclrot     = (crusher == null || crusher.RotCrusher == null || crusher.RotCrusher.local);
            var  rotcrusher = crusher.RotCrusher;

            if (crusher != null && rotcrusher != null && rotcrusher.TRSType == TRSType.Quaternion)
            {
                this.rotation = (lclrot) ? transform.localRotation : transform.rotation;
            }
            else
            {
                this.rotation = (lclrot) ? transform.localEulerAngles : transform.eulerAngles;
            }
        }
 public void Clear()
 {
     crusher = null;
     cPos.Clear();
     cRot.Clear();
     cScl.Clear();
 }
Beispiel #4
0
 // Constructor
 public MatrixRB(TransformCrusher crusher, Vector3 position, Element rotation, Vector3 scale)
 {
     this.crusher  = crusher;
     this.position = position;
     this.scale    = scale;
     this.rotation = rotation;
 }
 // Constructor
 public CompressedMatrix(TransformCrusher crusher, CompressedElement cPos, CompressedElement cRot, CompressedElement cScl)
 {
     this.crusher = crusher;
     this.cPos    = cPos;
     this.cRot    = cRot;
     this.cScl    = cScl;
 }
Beispiel #6
0
        // Constructor
        public CompressedMatrix(TransformCrusher crusher, CompressedElement cPos, CompressedElement cRot, CompressedElement cScl, int pBits, int rBits, int sBits) : this()
        {
            this.crusher = crusher;
            this.cPos    = cPos;
            this.cRot    = cRot;
            this.cScl    = cScl;

            this.bitstream = new Bitstream(cPos.bitstream, pBits, cRot.bitstream, rBits, cScl.bitstream, sBits);
        }
 public void Read(TransformCrusher crusher, ref Bitstream bitstream, BitCullingLevel bcl = BitCullingLevel.NoCulling)
 {
     if (crusher != null)
     {
         crusher.Read(this, ref bitstream, bcl);
     }
     else
     {
         Debug.LogError("CompressedMatrix does not have a crusher associated with it.");
     }
 }
Beispiel #8
0
 public Matrix(TransformCrusher crusher, Vector3 position, Element rotation, Vector3 scale) : this()
 {
     this.crusher  = crusher;
     this.position = position;
     this.scale    = scale;
     if (rotation.vectorType == Element.VectorType.Vector3)
     {
         this.rotationType = (rotation.vectorType == Element.VectorType.Vector3) ?
                             RotationType.Euler :
                             RotationType.Quaternion;
     }
     this.rotation = rotation;
 }
Beispiel #9
0
        /// <summary>
        /// Set Matrix values to the current values of the supplied Rigidbody. Also set the crusher ref.
        /// </summary>
        public void Capture(TransformCrusher crusher, Transform transform)
        {
            this.crusher  = crusher;
            this.position = transform.position;

            // Not sure the idea option for scale... lossy or local.
            this.scale = transform.localScale;

            if (crusher != null && crusher.RotCrusher != null && crusher.RotCrusher.TRSType == TRSType.Quaternion)
            {
                this.rotation = transform.rotation;
            }
            else
            {
                this.rotation = transform.eulerAngles;
            }
        }
Beispiel #10
0
        /// <summary>
        /// Set Matrix values to the current values of the supplied Rigidbody. Also set the crusher ref.
        /// </summary>
        public void Capture(TransformCrusher crusher, Rigidbody rb)
        {
            this.crusher  = crusher;
            this.position = rb.position;

            // Not sure the ideal option for scale... lossy or local.
            this.scale = rb.transform.localScale;

            var rotcrusher = crusher.RotCrusher;

            if (crusher != null && rotcrusher != null && rotcrusher.TRSType == TRSType.Quaternion)
            {
                this.rotation = rb.rotation;
            }
            else
            {
                this.rotation = rb.rotation.eulerAngles;
            }
        }
        public override void OnGUI(Rect r, SerializedProperty property, GUIContent label)
        {
            gc.text    = label.text;
            gc.tooltip = label.tooltip;

            EditorGUI.BeginProperty(r, label, property);
            base.OnGUI(r, property, label);

            //property.serializedObject.ApplyModifiedProperties();
            //property.serializedObject.Update();

            //haschanged = true;
            // Hacky way to get the real object
            TransformCrusher target = (TransformCrusher)DrawerUtils.GetParent(property.FindPropertyRelative("posCrusher"));

            float currentline = r.yMin;

            SerializedProperty pos        = property.FindPropertyRelative("posCrusher");
            SerializedProperty rot        = property.FindPropertyRelative("rotCrusher");
            SerializedProperty scl        = property.FindPropertyRelative("sclCrusher");
            SerializedProperty isExpanded = property.FindPropertyRelative("isExpanded");

            float ph = EditorGUI.GetPropertyHeight(pos);
            float rh = EditorGUI.GetPropertyHeight(rot);
            float sh = EditorGUI.GetPropertyHeight(scl);


            /// Header

            bool _isExpanded = EditorGUI.Foldout(new Rect(r.xMin, currentline, r.width, TITL_HGHT), isExpanded.boolValue, "");

            if (isExpanded.boolValue != _isExpanded)
            {
                isExpanded.boolValue = _isExpanded;
                property.serializedObject.ApplyModifiedProperties();
            }

            EditorGUI.LabelField(new Rect(r.xMin, currentline, r.width, TITL_HGHT), gc);            // property.displayName /*new GUIContent("Transform Crusher " + label)*//*, (GUIStyle)"BoldLabel"*/);

            int totalbits = target.TallyBits();
            int frag0bits = Mathf.Clamp(totalbits, 0, 64);
            int frag1bits = Mathf.Clamp(totalbits - 64, 0, 64);
            int frag2bits = Mathf.Clamp(totalbits - 128, 0, 64);
            int frag3bits = Mathf.Clamp(totalbits - 192, 0, 64);

            string bitstr = frag0bits.ToString();

            if (frag1bits > 0)
            {
                bitstr += "|" + frag1bits;
            }
            if (frag2bits > 0)
            {
                bitstr += "|" + frag2bits;
            }
            if (frag3bits > 0)
            {
                bitstr += "|" + frag3bits;
            }

            bitstr = bitstr + " bits";
            EditorGUI.LabelField(new Rect(paddedleft, currentline, paddedwidth, 16), bitstr, miniLabelRight);

            if (isExpanded.boolValue)
            {
                Rect ir = r;                 // EditorGUI.IndentedRect(r);;
                ir.yMin      = ir.yMin + HEADR_HGHT + 2;
                ir.xMin     -= BOUNDING_PADDING;
                ir.xMax     += BOUNDING_PADDING;
                ir.yMax     -= 6;
                currentline += BOUNDING_PADDING;
                //EditorGUI.LabelField(ir, GUIContent.none, /*(GUIStyle)"RectangleToolVBar");// */(GUIStyle)"HelpBox");
                ir = EditorGUI.IndentedRect(ir);
                //ir.xMin += 1; ir.xMax -= 1;
                //ir.yMin += 1; ir.yMax -= 1;
                SolidTextures.DrawTexture(ir, SolidTextures.darken202D);

                /// TRS Element Boxes
                currentline += TITL_HGHT;
                //float leftConnectorY = currentline;


                DrawSet(r, currentline, ph, pos);
                currentline += ph + SET_PAD;

                DrawSet(r, currentline, rh, rot);
                currentline += rh + SET_PAD;

                DrawSet(r, currentline, sh, scl);
                currentline += sh /*+ SET_PAD*/;

                /// Connecting line between TRS Elements
                //SolidTextures.DrawTexture(new Rect(4, leftConnectorY + 4, 4, currentline - leftConnectorY), SolidTextures.lowcontrast2D);
                //EditorGUI.LabelField(new Rect(0, leftConnectorY + 4, 4, currentline - leftConnectorY - 12), GUIContent.none, (GUIStyle)"MiniSliderVertical");
            }


            EditorGUI.EndProperty();
        }
Beispiel #12
0
 // Constructor
 public MatrixRB(TransformCrusher crusher)
 {
     this.crusher = crusher;
 }
Beispiel #13
0
        public override void OnGUI(Rect r, SerializedProperty property, GUIContent label)
        {
            base.OnGUI(r, property, label);

            // Hacky way to get the real object
            TransformCrusher target = (TransformCrusher)DrawerUtils.GetParent(property.FindPropertyRelative("posCrusher"));

            float currentline = r.yMin;

            SerializedProperty pos = property.FindPropertyRelative("posCrusher");
            SerializedProperty rot = property.FindPropertyRelative("rotCrusher");
            SerializedProperty scl = property.FindPropertyRelative("sclCrusher");

            float ph = EditorGUI.GetPropertyHeight(pos);
            float rh = EditorGUI.GetPropertyHeight(rot);
            float sh = EditorGUI.GetPropertyHeight(scl);

            /// Header
            EditorGUI.LabelField(new Rect(r.xMin, currentline, r.width, TITL_HGHT), new GUIContent("Transform Crusher"), (GUIStyle)"BoldLabel");

            int totalbits = target.TallyBits();
            int frag0bits = Mathf.Clamp(totalbits, 0, 64);
            int frag1bits = Mathf.Clamp(totalbits - 64, 0, 64);
            int frag2bits = Mathf.Clamp(totalbits - 128, 0, 64);
            int frag3bits = Mathf.Clamp(totalbits - 192, 0, 64);

            string bitstr = frag0bits.ToString();

            if (frag1bits > 0)
            {
                bitstr += " | " + frag1bits;
            }
            if (frag2bits > 0)
            {
                bitstr += " | " + frag2bits;
            }
            if (frag3bits > 0)
            {
                bitstr += " | " + frag3bits;
            }

            bitstr = bitstr + " Bits";
            EditorGUI.LabelField(new Rect(paddedleft, currentline, paddedwidth, 16), bitstr, miniLabelRight);

            ///GameObject target
            currentline            += LINEHEIGHT;
            target.defaultTransform = (Transform)EditorGUI.ObjectField(new Rect(r.xMin, currentline, r.width, 16), new GUIContent("Target"), target.defaultTransform, typeof(Transform), true);

            if (target.defaultTransform == null)
            {
                target.defaultTransform = (property.serializedObject.targetObject as Component).transform;
            }

            /// TRS Element Boxes
            currentline += TITL_HGHT;

            DrawSet(r, currentline, ph, pos);
            currentline += ph + SET_PAD;

            DrawSet(r, currentline, rh, rot);
            currentline += rh + SET_PAD;

            DrawSet(r, currentline, sh, scl);
        }
Beispiel #14
0
 public void Clear()
 {
     this.crusher = null;
 }
Beispiel #15
0
 public void Set(TransformCrusher crusher, Transform transform)
 {
     Capture(crusher, transform);
 }
Beispiel #16
0
 public void Set(TransformCrusher crusher, Rigidbody rb)
 {
     Capture(crusher, rb);
 }
 public CompressedMatrix(TransformCrusher crusher)
 {
     this.crusher = crusher;
 }