private static UrdfJoint AddCorrectJointType(GameObject linkObject, JointTypes jointType) { UrdfJoint urdfJoint = null; switch (jointType) { case JointTypes.Fixed: urdfJoint = UrdfJointFixed.Create(linkObject); break; case JointTypes.Continuous: urdfJoint = UrdfJointContinuous.Create(linkObject); break; case JointTypes.Revolute: urdfJoint = UrdfJointRevolute.Create(linkObject); break; case JointTypes.Floating: urdfJoint = UrdfJointFloating.Create(linkObject); break; case JointTypes.Prismatic: urdfJoint = UrdfJointPrismatic.Create(linkObject); break; case JointTypes.Planar: urdfJoint = UrdfJointPlanar.Create(linkObject); break; } UnityEngine.Joint unityJoint = linkObject.GetComponent<UnityEngine.Joint>(); unityJoint.connectedBody = linkObject.transform.parent.gameObject.GetComponent<Rigidbody>(); unityJoint.autoConfigureConnectedAnchor = true; return urdfJoint; }
public static void ChangeJointType(GameObject linkObject, JointTypes newJointType) { linkObject.transform.DestroyImmediateIfExists<UrdfJoint>(); linkObject.transform.DestroyImmediateIfExists<HingeJointLimitsManager>(); linkObject.transform.DestroyImmediateIfExists<PrismaticJointLimitsManager>(); linkObject.transform.DestroyImmediateIfExists<UnityEngine.Joint>(); AddCorrectJointType(linkObject, newJointType); }
/// <summary> /// Changes the type of the joint /// </summary> /// <param name="linkObject">Joint whose type is to be changed</param> /// <param name="newJointType">Type of the new joint</param> public static void ChangeJointType(GameObject linkObject, JointTypes newJointType) { linkObject.transform.DestroyImmediateIfExists <UrdfJoint>(); linkObject.transform.DestroyImmediateIfExists <HingeJointLimitsManager>(); linkObject.transform.DestroyImmediateIfExists <PrismaticJointLimitsManager>(); #if UNITY_2020_1_OR_NEWER linkObject.transform.DestroyImmediateIfExists <UnityEngine.ArticulationBody>(); #else linkObject.transform.DestroyImmediateIfExists <UnityEngine.Joint>(); #endif AddCorrectJointType(linkObject, newJointType); }
public static void Create(GameObject linkObject, JointTypes jointType, Joint joint = null) { Rigidbody parentRigidbody = linkObject.transform.parent.gameObject.GetComponent<Rigidbody>(); if (parentRigidbody == null) return; UrdfJoint urdfJoint = AddCorrectJointType(linkObject, jointType); if (joint != null) { urdfJoint.JointName = joint.name; urdfJoint.ImportJointData(joint); } }
public static UrdfJoint Create(GameObject linkObject, JointTypes jointType, Joint joint = null) { #if UNITY_2020_1_OR_NEWER #else Rigidbody parentRigidbody = linkObject.transform.parent.gameObject.GetComponent <Rigidbody>(); if (parentRigidbody == null) { return; } #endif UrdfJoint urdfJoint = AddCorrectJointType(linkObject, jointType); if (joint != null) { urdfJoint.jointName = joint.name; urdfJoint.ImportJointData(joint); } return(urdfJoint); }
private static UrdfJoint AddCorrectJointType(GameObject linkObject, JointTypes jointType) { UrdfJoint urdfJoint = null; switch (jointType) { case JointTypes.Fixed: urdfJoint = UrdfJointFixed.Synchronize(linkObject); break; case JointTypes.Continuous: urdfJoint = UrdfJointContinuous.Synchronize(linkObject); break; case JointTypes.Revolute: urdfJoint = UrdfJointRevolute.Synchronize(linkObject); break; case JointTypes.Floating: urdfJoint = UrdfJointFloating.Synchronize(linkObject); break; case JointTypes.Prismatic: urdfJoint = UrdfJointPrismatic.Synchronize(linkObject); break; case JointTypes.Planar: urdfJoint = UrdfJointPlanar.Synchronize(linkObject); break; } //SynchTodo: This assignment probably does not break stuff, but is not necessary. UnityEngine.Joint unityJoint = linkObject.GetComponent <UnityEngine.Joint>(); unityJoint.connectedBody = linkObject.transform.parent.gameObject.GetComponent <Rigidbody>(); unityJoint.autoConfigureConnectedAnchor = true; return(urdfJoint); }
/// <summary> /// Ei käytössä Physics2d moottorissa. /// </summary> /// <param name="obj1"></param> /// <param name="obj2"></param> /// <param name="type"></param> /// <returns></returns> public IAxleJoint CreateJoint(IPhysicsObject obj1, IPhysicsObject obj2, JointTypes type) { throw new NotImplementedException(); }