Exemple #1
0
        private static GameObject CreateMeshColliderRuntime(Link.Geometry.Mesh mesh)
        {
            string     meshFilePath = UrdfAssetPathHandler.GetRelativeAssetPathFromUrdfPath(mesh.filename, false);
            GameObject meshObject   = null;

            if (meshFilePath.ToLower().EndsWith(".stl"))
            {
                meshObject = StlAssetPostProcessor.CreateStlGameObjectRuntime(meshFilePath);
            }
            else
            {
                Debug.LogError("Unable to create mesh collider for the mesh: " + mesh.filename);
            }

            if (meshObject != null)
            {
                ConvertMeshToColliders(meshObject);
            }
            return(meshObject);
        }
Exemple #2
0
        private static GameObject CreateMeshVisualRuntime(Link.Geometry.Mesh mesh)
        {
            GameObject meshObject = null;

            if (!string.IsNullOrEmpty(mesh.filename))
            {
                try
                {
                    string meshFilePath = UrdfAssetPathHandler.GetRelativeAssetPathFromUrdfPath(mesh.filename, false);
                    if (meshFilePath.ToLower().EndsWith(".stl"))
                    {
                        meshObject = StlAssetPostProcessor.CreateStlGameObjectRuntime(meshFilePath);
                    }
                    else if (meshFilePath.ToLower().EndsWith(".dae"))
                    {
                        float globalScale = ColladaAssetPostProcessor.ReadGlobalScale(meshFilePath);
                        meshObject = MeshImporter.Load(meshFilePath, globalScale, globalScale, globalScale);
                        if (meshObject != null)
                        {
                            ColladaAssetPostProcessor.ApplyColladaOrientation(meshObject, meshFilePath);
                        }
                    }
                    else if (meshFilePath.ToLower().EndsWith(".obj"))
                    {
                        meshObject = MeshImporter.Load(meshFilePath);
                    }
                }
                catch (Exception ex)
                {
                    Debug.LogAssertion(ex);
                }

                if (meshObject == null)
                {
                    Debug.LogError("Unable to load visual mesh: " + mesh.filename);
                }
            }
            return(meshObject);
        }