public static void Create(Transform parent, Link.Visual visual)
        {
            GameObject visualObject = new GameObject(visual.name ?? "unnamed");

            visualObject.transform.SetParentAndAlign(parent);
            UrdfVisual urdfVisual = visualObject.AddComponent <UrdfVisual>();

            urdfVisual.geometryType = UrdfGeometry.GetGeometryType(visual.geometry);
            UrdfGeometryVisual.Create(visualObject.transform, urdfVisual.geometryType, visual.geometry);

            UrdfMaterial.SetUrdfMaterial(visualObject, visual.material);
            UrdfOrigin.ImportOriginData(visualObject.transform, visual.origin);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Compares visual information of two links
        /// </summary>
        /// <param name="source">First link's visual information to be compared</param>
        /// <param name="exported">Second link's visual information to be compared</param>
        /// <param name="indent">Indent level in the log file</param>
        /// <returns></returns>
        private bool CompareVisual(Link.Visual source, Link.Visual exported, int indent)
        {
            bool visualNameEqual = (source.name == exported.name);

            linkLog.AppendLine(String.Format("{0}Visual Component Name : {1,6}", Indent(indent + 1), visualNameEqual));
            if (!visualNameEqual)
            {
                return(false);
            }

            if (!CompareOrigin(source.origin, exported.origin, indent))
            {
                return(false);
            }

            linkLog.AppendLine(String.Format("{0}Geometry Checks", Indent(indent)));
            if (!CompareGeometry(source.geometry, exported.geometry, indent + 1))
            {
                return(false);
            }

            linkLog.AppendLine(String.Format("{0}Material Checks", Indent(indent)));
            if (source.material == null && exported.material == null)
            {
                linkLog.AppendLine(String.Format("{0}Material Nullity Check: {1,6}", Indent(indent), "True"));
                return(true);
            }
            else if (source.material != null && exported.material != null)
            {
                linkLog.AppendLine(String.Format("{0}Material Nullity Check: {1,6}", Indent(indent), "True"));
                if (!CompareMaterial(source.material, exported.material, indent + 1))
                {
                    return(false);
                }
            }
            else if ((source.material == null && exported.material.name == "Default-Material") || (exported.material == null && source.material?.name == "Default-Material"))
            {
                linkLog.AppendLine(String.Format("{0}Material Nullity Check: {1,6}", Indent(indent), "True"));
                return(true);
            }
            else
            {
                linkLog.AppendLine(String.Format("{0}Material Nullity Check: {1,6}", Indent(indent), "False"));
                return(false);
            }

            return(true);
        }