static public int constructor(IntPtr l)
 {
     try {
                     #if DEBUG
         var    method     = System.Reflection.MethodBase.GetCurrentMethod();
         string methodName = GetMethodName(method);
                     #if UNITY_5_5_OR_NEWER
         UnityEngine.Profiling.Profiler.BeginSample(methodName);
                     #else
         Profiler.BeginSample(methodName);
                     #endif
                     #endif
         UnityEngine.SoftJointLimitSpring o;
         o = new UnityEngine.SoftJointLimitSpring();
         pushValue(l, true);
         pushValue(l, o);
         return(2);
     }
     catch (Exception e) {
         return(error(l, e));
     }
             #if DEBUG
     finally {
                     #if UNITY_5_5_OR_NEWER
         UnityEngine.Profiling.Profiler.EndSample();
                     #else
         Profiler.EndSample();
                     #endif
     }
             #endif
 }
 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;
     }
 }
Beispiel #4
0
 static public 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);
     }
 }
Beispiel #5
0
 static public 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));
     }
 }
Beispiel #6
0
 static void CharacterJoint_swingLimitSpring(JSVCall vc)
 {
     if (vc.bGet)
     {
         UnityEngine.CharacterJoint _this = (UnityEngine.CharacterJoint)vc.csObj;
         var result = _this.swingLimitSpring;
         JSMgr.datax.setObject((int)JSApi.SetType.Rval, result);
     }
     else
     {
         UnityEngine.SoftJointLimitSpring arg0  = (UnityEngine.SoftJointLimitSpring)JSMgr.datax.getObject((int)JSApi.GetType.Arg);
         UnityEngine.CharacterJoint       _this = (UnityEngine.CharacterJoint)vc.csObj;
         _this.swingLimitSpring = arg0;
     }
 }
 static void ConfigurableJoint_angularYZLimitSpring(JSVCall vc)
 {
     if (vc.bGet)
     {
         UnityEngine.ConfigurableJoint _this = (UnityEngine.ConfigurableJoint)vc.csObj;
         var result = _this.angularYZLimitSpring;
         JSMgr.datax.setObject((int)JSApi.SetType.Rval, result);
     }
     else
     {
         UnityEngine.SoftJointLimitSpring arg0  = (UnityEngine.SoftJointLimitSpring)JSMgr.datax.getObject((int)JSApi.GetType.Arg);
         UnityEngine.ConfigurableJoint    _this = (UnityEngine.ConfigurableJoint)vc.csObj;
         _this.angularYZLimitSpring = arg0;
     }
 }
 static void SoftJointLimitSpring_damper(JSVCall vc)
 {
     if (vc.bGet)
     {
         UnityEngine.SoftJointLimitSpring _this = (UnityEngine.SoftJointLimitSpring)vc.csObj;
         var result = _this.damper;
         JSApi.setSingle((int)JSApi.SetType.Rval, (System.Single)(result));
     }
     else
     {
         System.Single arg0 = (System.Single)JSApi.getSingle((int)JSApi.GetType.Arg);
         UnityEngine.SoftJointLimitSpring _this = (UnityEngine.SoftJointLimitSpring)vc.csObj;
         _this.damper = arg0;
         JSMgr.changeJSObj(vc.jsObjID, _this);
     }
 }
Beispiel #9
0
        /// <summary>
        /// Read the data using the reader.
        /// </summary>
        /// <param name="reader">Reader.</param>
        public override object Read(ISaveGameReader reader)
        {
            UnityEngine.SoftJointLimitSpring softJointLimitSpring = new UnityEngine.SoftJointLimitSpring();
            foreach (string property in reader.Properties)
            {
                switch (property)
                {
                case "spring":
                    softJointLimitSpring.spring = reader.ReadProperty <System.Single> ();
                    break;

                case "damper":
                    softJointLimitSpring.damper = reader.ReadProperty <System.Single> ();
                    break;
                }
            }
            return(softJointLimitSpring);
        }
 private void INTERNAL_get_angularXLimitSpring(out SoftJointLimitSpring value);
		private extern void INTERNAL_set_angularYZLimitSpring(ref SoftJointLimitSpring value);
		private extern void INTERNAL_get_angularYZLimitSpring(out SoftJointLimitSpring value);
		private extern void INTERNAL_set_linearLimitSpring(ref SoftJointLimitSpring value);
		private extern void INTERNAL_get_linearLimitSpring(out SoftJointLimitSpring value);
 // 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;
 }
 // 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;
 }
        /// <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
        }
 private void INTERNAL_set_swingLimitSpring(ref SoftJointLimitSpring value);
 private void INTERNAL_set_angularXLimitSpring(ref SoftJointLimitSpring value);
Beispiel #20
0
 /// <summary>
 /// Write the specified value using the writer.
 /// </summary>
 /// <param name="value">Value.</param>
 /// <param name="writer">Writer.</param>
 public override void Write(object value, ISaveGameWriter writer)
 {
     UnityEngine.SoftJointLimitSpring softJointLimitSpring = (UnityEngine.SoftJointLimitSpring)value;
     writer.WriteProperty("spring", softJointLimitSpring.spring);
     writer.WriteProperty("damper", softJointLimitSpring.damper);
 }
    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;*/
    }
 private void INTERNAL_get_swingLimitSpring(out SoftJointLimitSpring value);
Beispiel #23
0
    //---------------------------------------------------------------------------	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;
    }