Ejemplo n.º 1
0
        public static void 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);
            }

            UnityEditor.EditorGUIUtility.PingObject(collisionObject);
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 3
0
        public static void Create(Transform parent, Link.Collision collision)
        {
            if (String.IsNullOrEmpty(collision.name))
            {
                collision.name = collision.GenerateNonReferenceID();
            }

            if (parent.FindChildOrCreateWithComponent(collision.name, out GameObject collisionObject, out UrdfCollision urdfCollision))
            {
                urdfCollision.geometryType = UrdfGeometry.GetGeometryType(collision.geometry);

                UrdfGeometryCollision.Create(collisionObject.transform, urdfCollision.geometryType, collision.geometry);
                UrdfOrigin.ImportOriginData(collisionObject.transform, collision.origin);
            }
        }