Пример #1
0
 private void ConfigureJointShared(Joint joint, Transform root, ref AuthorChHit.Rep self)
 {
     AuthorChHit.Rep rep;
     if (this.connect)
     {
         if (!self.mirrored)
         {
             rep = this.connect.primary;
             if (!rep.valid)
             {
                 rep = this.connect.secondary;
             }
         }
         else
         {
             rep = this.connect.secondary;
             if (!rep.valid)
             {
                 rep = this.connect.primary;
             }
         }
         if (!rep.valid)
         {
             Debug.LogWarning("No means of making/getting rigidbody", this.connect);
         }
         else
         {
             Transform transforms = root.FindChild(rep.path);
             Rigidbody rigidbody  = transforms.rigidbody;
             if (!rigidbody)
             {
                 rigidbody = transforms.gameObject.AddComponent <Rigidbody>();
             }
             joint.connectedBody = rigidbody;
         }
     }
     joint.anchor      = self.Flip(this.anchor);
     joint.axis        = self.AxisFlip(this.axis);
     joint.breakForce  = this.breakForce;
     joint.breakTorque = this.breakTorque;
 }
Пример #2
0
    private bool DoTransformHandles(ref AuthorChHit.Rep self, ref AuthorChHit.Rep connect)
    {
        if (!self.valid)
        {
            return(false);
        }
        Vector3   vector3   = self.Flip(this.anchor);
        Vector3   vector31  = self.AxisFlip(this.axis);
        Vector3   vector32  = self.AxisFlip(this.swingAxis);
        Matrix4x4 matrix4x4 = AuthorShared.Scene.matrix;

        if (connect.valid)
        {
            AuthorShared.Scene.matrix = connect.bone.localToWorldMatrix;
            Color color = AuthorShared.Scene.color;
            AuthorShared.Scene.color = color * new Color(1f, 1f, 1f, 0.4f);
            Vector3 vector33 = connect.bone.InverseTransformPoint(self.bone.position);
            if (vector33 != Vector3.zero)
            {
                AuthorShared.Scene.DrawBone(Vector3.zero, Quaternion.LookRotation(vector33), vector33.magnitude, 0.02f, new Vector3(0.05f, 0.05f, 0.5f));
            }
            AuthorShared.Scene.color = color;
        }
        AuthorShared.Scene.matrix = self.bone.localToWorldMatrix;
        bool flag = false;

        if (AuthorShared.Scene.PivotDrag(ref vector3, ref vector31))
        {
            flag        = true;
            this.anchor = self.Flip(vector3);
            this.axis   = self.AxisFlip(vector31);
        }
        AuthorChJoint.Kind kind = this.kind;
        if (kind != AuthorChJoint.Kind.Hinge)
        {
            if (kind == AuthorChJoint.Kind.Character)
            {
                Color color1 = AuthorShared.Scene.color;
                AuthorShared.Scene.color = color1 * AuthorChJoint.twistColor;
                SoftJointLimit softJointLimit  = this.lowTwist;
                SoftJointLimit softJointLimit1 = this.highTwist;
                if (AuthorShared.Scene.LimitDrag(vector3, vector31, ref this.twistOffset, ref softJointLimit, ref softJointLimit1))
                {
                    flag           = true;
                    this.lowTwist  = softJointLimit;
                    this.highTwist = softJointLimit1;
                }
                AuthorShared.Scene.color = color1 * AuthorChJoint.swing1Color;
                softJointLimit           = this.swing1;
                if (AuthorShared.Scene.LimitDrag(vector3, vector32, ref this.swingOffset1, ref softJointLimit))
                {
                    flag        = true;
                    this.swing1 = softJointLimit;
                }
                AuthorShared.Scene.color = color1 * AuthorChJoint.swing2Color;
                softJointLimit           = this.swing2;
                if (AuthorShared.Scene.LimitDrag(vector3, Vector3.Cross(vector32, vector31), ref this.swingOffset2, ref softJointLimit))
                {
                    flag        = true;
                    this.swing2 = softJointLimit;
                }
                AuthorShared.Scene.color = color1;
            }
        }
        else if (this.useLimit)
        {
            JointLimits jointLimit = this.limit;
            if (AuthorShared.Scene.LimitDrag(vector3, vector31, ref this.limitOffset, ref jointLimit))
            {
                flag       = true;
                this.limit = jointLimit;
            }
        }
        AuthorShared.Scene.matrix = matrix4x4;
        return(flag);
    }
Пример #3
0
    private bool DoTransformHandles(ref AuthorChHit.Rep self, ref AuthorChHit.Rep connect)
    {
        if (!self.valid)
        {
            return(false);
        }
        Vector3   anchor  = self.Flip(this.anchor);
        Vector3   axis    = self.AxisFlip(this.axis);
        Vector3   vector3 = self.AxisFlip(this.swingAxis);
        Matrix4x4 matrix  = AuthorShared.Scene.matrix;

        if (connect.valid)
        {
            AuthorShared.Scene.matrix = connect.bone.localToWorldMatrix;
            Color color = AuthorShared.Scene.color;
            AuthorShared.Scene.color = color * new Color(1f, 1f, 1f, 0.4f);
            Vector3 forward = connect.bone.InverseTransformPoint(self.bone.position);
            if (forward != Vector3.zero)
            {
                Quaternion rot = Quaternion.LookRotation(forward);
                AuthorShared.Scene.DrawBone(Vector3.zero, rot, forward.magnitude, 0.02f, new Vector3(0.05f, 0.05f, 0.5f));
            }
            AuthorShared.Scene.color = color;
        }
        AuthorShared.Scene.matrix = self.bone.localToWorldMatrix;
        bool flag = false;

        if (AuthorShared.Scene.PivotDrag(ref anchor, ref axis))
        {
            flag        = true;
            this.anchor = self.Flip(anchor);
            this.axis   = self.AxisFlip(axis);
        }
        switch (this.kind)
        {
        case Kind.Hinge:
            if (this.useLimit)
            {
                JointLimits limits = this.limit;
                if (AuthorShared.Scene.LimitDrag(anchor, axis, ref this.limitOffset, ref limits))
                {
                    flag       = true;
                    this.limit = limits;
                }
            }
            break;

        case Kind.Character:
        {
            Color color2 = AuthorShared.Scene.color;
            AuthorShared.Scene.color = color2 * twistColor;
            SoftJointLimit lowTwist  = this.lowTwist;
            SoftJointLimit highTwist = this.highTwist;
            if (AuthorShared.Scene.LimitDrag(anchor, axis, ref this.twistOffset, ref lowTwist, ref highTwist))
            {
                flag           = true;
                this.lowTwist  = lowTwist;
                this.highTwist = highTwist;
            }
            AuthorShared.Scene.color = color2 * swing1Color;
            lowTwist = this.swing1;
            if (AuthorShared.Scene.LimitDrag(anchor, vector3, ref this.swingOffset1, ref lowTwist))
            {
                flag        = true;
                this.swing1 = lowTwist;
            }
            AuthorShared.Scene.color = color2 * swing2Color;
            lowTwist = this.swing2;
            if (AuthorShared.Scene.LimitDrag(anchor, Vector3.Cross(vector3, axis), ref this.swingOffset2, ref lowTwist))
            {
                flag        = true;
                this.swing2 = lowTwist;
            }
            AuthorShared.Scene.color = color2;
            break;
        }
        }
        AuthorShared.Scene.matrix = matrix;
        return(flag);
    }