public override void OnInspectorGUI()
        {
            RigidbodyUrdfDataManager rigidbodyUrdfDataManager = (RigidbodyUrdfDataManager)target;

            bool newValue = EditorGUILayout.Toggle("Use URDF Data", rigidbodyUrdfDataManager.UseUrdfData);

            EditorGUILayout.Vector3Field("URDF Center of Mass", rigidbodyUrdfDataManager.CenterOfMass);
            EditorGUILayout.Vector3Field("URDF Inertia Tensor", rigidbodyUrdfDataManager.InertiaTensor);
            EditorGUILayout.Vector3Field("URDF Inertia Tensor Rotation", rigidbodyUrdfDataManager.InertiaTensorRotation.eulerAngles);
            if (newValue != rigidbodyUrdfDataManager.UseUrdfData)
            {
                rigidbodyUrdfDataManager.UseUrdfData = newValue;
                rigidbodyUrdfDataManager.UpdateRigidBodyData();
            }
        }
Exemple #2
0
        public static Rigidbody Create(this Link.Inertial inertial, GameObject gameObject)
        {
            Rigidbody rigidbody = gameObject.AddComponent <Rigidbody>();

            rigidbody.mass = (float)inertial.mass;

            if (inertial.origin != null)
            {
                rigidbody.centerOfMass = inertial.origin.GetPosition();
            }

            inertial.inertia.SetInertia(rigidbody);

            RigidbodyUrdfDataManager rigidbodyUrdfDataManager
                = gameObject.AddComponent <RigidbodyUrdfDataManager>();

            rigidbodyUrdfDataManager.GetValuesFromUrdf(
                rigidbody.centerOfMass,
                rigidbody.inertiaTensor,
                rigidbody.inertiaTensorRotation);
            rigidbodyUrdfDataManager.UseUrdfData = true;

            return(rigidbody);
        }