コード例 #1
0
        public static void Create(Transform parent, UrdfGeometry.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 == UrdfGeometry.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);
            }

            EditorGUIUtility.PingObject(collisionObject);
        }
コード例 #2
0
        public static void 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);
        }
コード例 #3
0
        public static void Create(Transform parent, List <Link.Collision> collisions = null)
        {
            GameObject collisionsObject = new GameObject("Collisions");

            collisionsObject.transform.SetParentAndAlign(parent);
            UrdfCollisions urdfCollisions = collisionsObject.AddComponent <UrdfCollisions>();

            collisionsObject.hideFlags = HideFlags.NotEditable;
            urdfCollisions.hideFlags   = HideFlags.None;

            if (collisions != null)
            {
                foreach (Link.Collision collision in collisions)
                {
                    UrdfCollision.Create(urdfCollisions.transform, collision);
                }
            }
        }
コード例 #4
0
        public void AddCorrespondingCollision()
        {
            UrdfCollisions collisions = GetComponentInParent <UrdfLink>().GetComponentInChildren <UrdfCollisions>();

            UrdfCollision.Create(collisions.transform, geometryType, transform);
        }