Esempio n. 1
0
        public static void Create(Transform parent, Link link = null, Joint joint = null)
        {
            GameObject linkObject = new GameObject("link");

            linkObject.transform.SetParentAndAlign(parent);

            UrdfVisualsExtensions.Create(linkObject.transform, link?.visuals);
            UrdfCollisionsExtensions.Create(linkObject.transform, link?.collisions);

            if (link != null)
            {
                linkObject.ImportSimulationLinkData(link, joint);
            }
            else
            {
            }
        }
Esempio n. 2
0
        public static UrdfLink Synchronize(Transform parent, Link link = null, Joint joint = null)
        {
            parent.FindChildOrCreateWithComponent <UrdfLink>(link != null ? link.name : Utils.GenerateNonReferenceID(link), out GameObject linkObject, out UrdfLink urdfLink);


            UrdfVisualsExtensions.Synchronize(linkObject.transform, link?.visuals);
            UrdfCollisionsExtensions.Synchronize(linkObject.transform, link?.collisions);

            if (link != null)
            {
                urdfLink.ImportLinkData(link, joint);
            }
            else
            {
                UrdfInertial.Synchronize(linkObject);
            }

            if (link != null)
            {
                foreach (var attachedComponent in link.attachableComponents)
                {
                    if (AttachedDataSynchronizer.Instance.ShouldCreateComponent(attachedComponent))
                    {
                        AttachedDataSynchronizer.Instance.HandleAttachedComponent(linkObject, attachedComponent, link);
                    }
                }
            }

            //Remove Attached Values that are too much
            var attachedValueChildren = linkObject.GetComponentsInDirectChildrenFromGameobject <AttachedValue>();

            attachedValueChildren.RemoveAll(x => link.attachableComponents.Any(y => y.component.name == x.name));

            foreach (var attachedComponent in attachedValueChildren)
            {
                AttachedDataSynchronizer.Instance.RemoveAttachedComponent(attachedComponent.AttachedComponent);
            }

            Utils.DestroyAll(attachedValueChildren.Select(x => x.gameObject));
            return(urdfLink);
        }
        public static UrdfLink Create(Transform parent, Link link = null, Joint joint = null)
        {
            GameObject linkObject = new GameObject("link");

            linkObject.transform.SetParentAndAlign(parent);
            UrdfLink urdfLink = linkObject.AddComponent <UrdfLink>();

            UrdfVisualsExtensions.Create(linkObject.transform, link?.visuals);
            UrdfCollisionsExtensions.Create(linkObject.transform, link?.collisions);

            if (link != null)
            {
                urdfLink.ImportLinkData(link, joint);
            }
            else
            {
                UrdfInertial.Create(linkObject);
                UnityEditor.EditorGUIUtility.PingObject(linkObject);
            }

            return(urdfLink);
        }