public static int constructor(IntPtr l)
 {
     try {
         UnityEngine.SoftJointLimitSpring o;
         o=new UnityEngine.SoftJointLimitSpring();
         pushValue(l,true);
         pushValue(l,o);
         return 2;
     }
     catch(Exception e) {
         return error(l,e);
     }
 }
 public static int constructor(IntPtr l)
 {
     try {
         UnityEngine.SoftJointLimitSpring o;
         o=new UnityEngine.SoftJointLimitSpring();
         pushValue(l,o);
         return 1;
     }
     catch(Exception e) {
         LuaDLL.luaL_error(l, e.ToString());
         return 0;
     }
 }
コード例 #3
0
		private extern void INTERNAL_set_angularYZLimitSpring(ref SoftJointLimitSpring value);
コード例 #4
0
		private extern void INTERNAL_get_angularYZLimitSpring(out SoftJointLimitSpring value);
コード例 #5
0
		private extern void INTERNAL_set_linearLimitSpring(ref SoftJointLimitSpring value);
コード例 #6
0
		private extern void INTERNAL_get_linearLimitSpring(out SoftJointLimitSpring value);
コード例 #7
0
 // Returns a copy of the specified SoftJointLimitSpring
 private static SoftJointLimitSpring CopyLimitSpring(SoftJointLimitSpring src)
 {
     SoftJointLimitSpring limitSpring = new SoftJointLimitSpring();
     limitSpring.damper = src.damper;
     limitSpring.spring = src.spring;
     return limitSpring;
 }
コード例 #8
0
 // Conversion from JointLimit and JointSpring to SoftJointLimitSpring
 private static SoftJointLimitSpring ConvertToSoftJointLimitSpring(JointLimits src, JointSpring spring, bool useSpring)
 {
     SoftJointLimitSpring limitSpring = new SoftJointLimitSpring();
     limitSpring.damper = useSpring? spring.damper: 0f;
     limitSpring.spring = useSpring? spring.spring: 0f;
     return limitSpring;
 }
コード例 #9
0
        /// <summary>
        /// Replaces a SpringJoint with a ConfigurableJoint.
        /// </summary>
        public static void SpringToConfigurable(SpringJoint src)
        {
            #if UNITY_EDITOR
            ConfigurableJoint conf = UnityEditor.Undo.AddComponent(src.gameObject, typeof(ConfigurableJoint)) as ConfigurableJoint;
            #else
            ConfigurableJoint conf = src.gameObject.AddComponent<ConfigurableJoint>();
            #endif

            ConvertJoint(ref conf, src as Joint);

            conf.xMotion = ConfigurableJointMotion.Limited;
            conf.yMotion = ConfigurableJointMotion.Limited;
            conf.zMotion = ConfigurableJointMotion.Limited;

            conf.angularXMotion = ConfigurableJointMotion.Free;
            conf.angularYMotion = ConfigurableJointMotion.Free;
            conf.angularZMotion = ConfigurableJointMotion.Free;

            SoftJointLimit linearLimit = new SoftJointLimit();
            linearLimit.bounciness = 0f;
            linearLimit.limit = src.maxDistance;
            conf.linearLimit = linearLimit;

            SoftJointLimitSpring linearLimitSpring = new SoftJointLimitSpring();
            linearLimitSpring.damper = src.damper;
            linearLimitSpring.spring = src.spring;
            conf.linearLimitSpring = linearLimitSpring;

            #if UNITY_EDITOR
            UnityEditor.Undo.DestroyObjectImmediate(src);
            #else
            GameObject.DestroyImmediate(src);
            #endif
        }
コード例 #10
0
 private void INTERNAL_set_swingLimitSpring(ref SoftJointLimitSpring value);
コード例 #11
0
 private void INTERNAL_get_swingLimitSpring(out SoftJointLimitSpring value);
コード例 #12
0
    void SetupJoint(ConfigurableJoint joint)
    {
        SoftJointLimitSpring jointLimit = new SoftJointLimitSpring();
		jointLimit.spring     = 0.0f;
		jointLimit.damper     = 0.0f;
		//jointLimit.bounciness = 0.0f;
		
		JointDrive jointDrive     = new JointDrive();
		jointDrive.mode           = JointDriveMode.Position;
		jointDrive.positionSpring = LinkJointSpringValue;
		jointDrive.positionDamper = LinkJointDamperValue;
		jointDrive.maximumForce   = LinkJointMaxForceValue;

        joint.axis              = Vector3.right;
        joint.secondaryAxis     = Vector3.up;
		joint.breakForce        = LinkJointBreakForce;
		joint.breakTorque       = LinkJointBreakTorque;

		joint.xMotion           = ConfigurableJointMotion.Locked;
		joint.yMotion           = ConfigurableJointMotion.Locked;
		joint.zMotion           = ConfigurableJointMotion.Locked;
		joint.angularXMotion    = Mathf.Approximately(LinkJointAngularXLimit, 0.0f) == false ? ConfigurableJointMotion.Limited : ConfigurableJointMotion.Locked;
		joint.angularYMotion    = Mathf.Approximately(LinkJointAngularYLimit, 0.0f) == false ? ConfigurableJointMotion.Limited : ConfigurableJointMotion.Locked;
		joint.angularZMotion    = Mathf.Approximately(LinkJointAngularZLimit, 0.0f) == false ? ConfigurableJointMotion.Limited : ConfigurableJointMotion.Locked;

		//jointLimit.limit        = -LinkJointAngularXLimit;
		//joint.lowAngularXLimit  = jointLimit;

		//jointLimit.limit        = LinkJointAngularXLimit;
		//joint.highAngularXLimit = jointLimit;

        //jointLimit.limit        = LinkJointAngularYLimit;
		//joint.angularYLimit     = jointLimit;

        //jointLimit.limit        = LinkJointAngularZLimit;
		//joint.angularZLimit     = jointLimit;

        joint.angularXDrive     = jointDrive;
		joint.angularYZDrive    = jointDrive;
/*
        joint.projectionMode     = JointProjectionMode.PositionAndRotation;
        joint.projectionDistance = 0.1f;
        joint.projectionAngle    = 0.1f;*/
    }
コード例 #13
0
 private void INTERNAL_set_angularXLimitSpring(ref SoftJointLimitSpring value);
コード例 #14
0
 private void INTERNAL_get_angularXLimitSpring(out SoftJointLimitSpring value);
コード例 #15
0
ファイル: CActor.cs プロジェクト: dvochin/Scripts
    //---------------------------------------------------------------------------	COBJECT EVENTS
    public void OnPropSet_Pinned(float nValueOld, float nValueNew)
    {
        // Reflection call to service all the 'Pinned' properties of our derived classes.
        if (_oJointExtremity == null)			//###CHECK
            return;

        if (_oConfJoint_Extremity == null)
            CUtility.ThrowException("*Err: CActor.PinOrUnpin() called with no extremity joint set!");

        bool bPinned = nValueNew == 1;
        if (CGame.INSTANCE.BoneDebugMode && GetType() != typeof(CActorChest))           // Disable pinning in bone debug mode on extremities so we can test bone orientation
            bPinned = false;
        if (bPinned) {		// How pinning init works: 1) Remember current location/rotation, 2) set to where extremity is now, 3) activate joint, 4) move back to old pos/rot = extremity's spring will gradually move & rotate toward current position of pin!  (just what we want!)
            //###IMPROVE: When user pins make pin location where limb extremity is (ie. no movement)
            Vector3 vecPosOld = transform.position;
            Quaternion quatRotOld = transform.rotation;
            Transform oAnchorT = _oJointExtremity.transform;			// Joint extremity is used as anchor unless a subnode called 'Anchor' exists (e.g. place outside hand or toes that is used to pull forces)
            Transform oAnchorChildT = oAnchorT.FindChild("Anchor");
            if (oAnchorChildT != null)
                oAnchorT = oAnchorChildT;
            transform.position = oAnchorT.position;			//? Doesn't matter as it gets calculated every frame anyway but just to be cleaner in 3D scene...
            transform.rotation = oAnchorT.rotation;
            _oConfJoint_Extremity.connectedBody = _oJointExtremity._oRigidBody;
            SoftJointLimit oJointLimit = new SoftJointLimit();                  //###WEAK: Do everytime?? ###TUNE?
            oJointLimit.limit = 0.001f;				//###LEARN: If this is zero there is NO spring functionality!!
            SoftJointLimitSpring oJointLimitSpring = new SoftJointLimitSpring();    //###WEAK: Do everytime??		//####MOD: To Unity5
            oJointLimitSpring.spring = _nDrivePos;
            _oConfJoint_Extremity.linearLimit = oJointLimit;
            _oConfJoint_Extremity.linearLimitSpring = oJointLimitSpring;
            transform.position = vecPosOld;
            transform.rotation = quatRotOld;
        } else {
            _oConfJoint_Extremity.connectedBody = null;			// Destroy the joint and the actor's limb will float in space as drive by various limb joints.
        }
        if (_oHotSpot != null)									// We can move/rotate/scale by gizmo only if we're pinned
            _oHotSpot._bEnableEditing = bPinned;
    }