Example #1
0
        public static UrdfCollision Create(Transform parent, Link.Collision collision)
        {
            GameObject collisionObject = new GameObject("unnamed");

            collisionObject.transform.SetParentAndAlign(parent);
            UrdfCollision urdfCollision = collisionObject.AddComponent <UrdfCollision>();

            urdfCollision.geometryType = UrdfGeometry.GetGeometryType(collision.geometry);
            UrdfGeometryCollision.Create(collisionObject.transform, urdfCollision.geometryType, collision.geometry);
            UrdfOrigin.ImportOriginData(collisionObject.transform, collision.origin);
            return(urdfCollision);
        }
Example #2
0
        public static UrdfCollision Create(Transform parent, GeometryTypes type, Transform visualToCopy = null)
        {
            GameObject collisionObject = new GameObject("unnamed");

            collisionObject.transform.SetParentAndAlign(parent);

            UrdfCollision urdfCollision = collisionObject.AddComponent <UrdfCollision>();

            urdfCollision.geometryType = type;

            if (visualToCopy != null)
            {
                if (urdfCollision.geometryType == GeometryTypes.Mesh)
                {
                    UrdfGeometryCollision.CreateMatchingMeshCollision(collisionObject.transform, visualToCopy);
                }
                else
                {
                    UrdfGeometryCollision.Create(collisionObject.transform, type);
                }

                //copy transform values from corresponding UrdfVisual
                collisionObject.transform.position   = visualToCopy.position;
                collisionObject.transform.localScale = visualToCopy.localScale;
                collisionObject.transform.rotation   = visualToCopy.rotation;
            }
            else
            {
                UrdfGeometryCollision.Create(collisionObject.transform, type);
            }

#if UNITY_EDITOR
            UnityEditor.EditorGUIUtility.PingObject(collisionObject);
#endif
            return(urdfCollision);
        }