Exemple #1
0
        public void setBodySpringStuff(CWRigidBody body, float spring, float damper, bool isFirst = true)
        {
            if (isFirst && body.getParentJoint() != null)
            {
                //Debug.Log(" ===== body === "+body.getParentJoint().jName);
                body.getParentJoint().setSpring(spring);
                body.getParentJoint().setDamper(damper);
                if (body.name.Contains("LowerArm") || body.name.Contains("LowerLeg"))
                {
                    body.getParentJoint().getParent().getParentJoint().setSpring(spring);
                    body.getParentJoint().getParent().getParentJoint().setDamper(damper);
                }
            }
            int count = body.getChildJointCount();

            for (int i = 0; i < count; i++)
            {
                CWJoint joint = body.getChildJoint(i);
                joint.setSpring(spring);
                joint.setDamper(damper);
                //Debug.Log(" ===== child body === "+joint.jName);
                if (joint.getChild().getChildJointCount() > 0)
                {
                    setBodySpringStuff(joint.getChild(), spring, damper, false);
                }
            }
        }
Exemple #2
0
        /**
         *      This method is used to get the relative angular velocities of the parent and child bodies of joint i,
         *      expressed in parent's local coordinates.
         *      We'll assume that i is in the range 0 - joints.size()-1!!!
         */
        public Vector3 getRelativeAngularVelocity(int i)
        {
            CWJoint    joint     = this.joints[i] as CWJoint;
            Quaternion parentOri = joint.getParent().getOrientation();

            return(Quaternion.Inverse(parentOri) * (joint.getChild().getAngularVelocity() - joint.getParent().getAngularVelocity()));
        }
Exemple #3
0
        /**
         *      This method is used to populate the relative orientation of the parent and child bodies of joint i.
         */
        public Quaternion getRelativeOrientation(int i)
        {
            CWJoint    joint     = this.joints[i] as CWJoint;
            Quaternion parentOri = joint.getParent().getOrientation();
            Quaternion childOri  = joint.getChild().getOrientation();

            return(Quaternion.Inverse(parentOri) * childOri);
        }