在 Mathematica 中导入 Google Sketchup 模型
Google 的 Sketchup 是一个漂亮、简单的 3D 对象建模器。此外,Google 拥有巨大的3D 对象仓库,因此您实际上不必进行太多建模如果您在这方面不是特别有天赋,那么您自己也可以。 Google 地球中的许多 3D 建筑物都是使用 Sketchup 制作的。在 Mathematica 中导入 Sketchup 的 SKP 文件的功能会非常好,但可惜的是,它还没有做到这一点。
Sketchup 免费版本不会导出为除 KMZ (Google Earth) 和 DAE (Collada) 格式之外的任何其他格式。虽然 MMA 可以读取 KMZ/KML 文件,但它不能读取包含 3D 对象的文件。 DAE 文件是压缩的 Collada 文件,这些文件可以通过 MMA 的导入以 XML 形式读取。生成的 XML 树相当复杂,Collada 的定义 以及获取对象的几何形状也是如此远非微不足道(我设法从中强制转换模型的坐标集)。
我的问题是:如何在 Mathematica 中将 SKP 文件转换为基于干净多边形的结构?
我更喜欢一个为 MMA 提供此导入功能的 导入转换器,但其他路线也受欢迎。明天我将发布我目前正在使用的相当间接的方法作为答案。
Google's Sketchup is a nice, simple 3D-object modeler. Moreover Google has an enormous warehouse of 3D objects so that you actually don't have to do much modeling yourself if you aren't particularly gifted in this area. Many of the 3D buildings in Google Earth are made with Sketchup. The capability to import Sketchup's SKP files in Mathematica would be very nice, but alas, it doesn't do that yet.
The free version of Sketchup doesn't export to any other formats than the KMZ (Google Earth) and DAE (Collada) formats. Though MMA can read KMZ/KML files it doesn't read those containing 3D objects. DAE files are zipped Collada files and these can be read as XML by MMA's Import. The resulting XML tree is rather complex as is the definition of Collada and getting at the geometry of the object is far from trivial (I managed to coerce the coordinate set of a model from it).
My question is: How to convert SKP files in a clean polygon based structure in Mathematica?
I would prefer an import converter that provides MMA with this import capability, but other routes are welcome too. I'll post the rather indirect method I'm currently using as an answer tomorrow.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
它可能不完全是你要找的,但我维护一个名为 pycollada 的 python 库。您可以使用它导出为 Mathematica 的格式。我还一直在开发一个名为 meshtool 的导入/导出/转换实用程序,您可以为其编写一个模块这将导出为 Mathematica 的格式。
It's probably not exactly what you're looking for, but I maintain a python library called pycollada. You could use it to export to Mathematica's format. I've also been working on an import/export/convert utility called meshtool which you could write a module for that would export to Mathematica's format.
下面的代码成功地将免费版 SketchUp 8.0 生成的非常简单的 .dae 文件导入到 Mathematica 8 中。该代码不会检测或作用于变换,它只查看坐标和三角形,因此不要期望太多。
Here is code that successfully imported a very simple .dae file produced by the free version of SketchUp 8.0 into Mathematica 8. This code is not detecting or acting on transformations, it only looks at coordinates and triangles, so don't expect too much.
我当前遵循的路线涉及多个步骤:
结果相当不错,尽管你似乎失去了纹理。下图显示了结果。左:原始Sketchup模型,中:通过DXF转换/导入,右:通过OBJ转换/导入。
显然,您不想经常这样做,对于特定的应用程序,我我想要一个不太懂计算机的用户也可以处理的解决方案。
更新:
从版本 10.4 开始,Mathematica 能够导入和导出 DAE 文件:https ://reference.wolfram.com/language/ref/format/DAE.html
The route I currently follow involves a number of steps:
The results are pretty good, though you seem to lose the textures. Figures below show the results. Left: the original Sketchup model, middle: conversion/import via DXF, right: conversion/import via OBJ.
Obviously, you don't want to do this all too often, and for the specific application I'm working on I'd like a solution that users that aren't very computer savvy can handle too.
Update:
As of version 10.4 Mathematica has the capability to import and export DAE files: https://reference.wolfram.com/language/ref/format/DAE.html
答案取决于您到底想做什么。如果您只想查看图像,可以导出为 .obj 文件(曲面细分文件,而不是目标代码!)。
尝试一下这个例子:
如果你真的想将它作为一个实体模型来使用,你将会遇到更困难的时期。实体模型具有相当复杂的数据结构来表示拓扑和几何。例如,您可能能够从模型中获取曲面,但您必须有一些拓扑来说明面使用了曲面的哪一部分。
The answer depends on what you want to do exactly. If you just want to see the image you could export as an .obj file (tessellation file, not object code!).
Try this for example:
If you actually want to work with it as a solid model you're going to have a more difficult time. Solid models have fairly complex data structures to represent the topology as well as the geometry. You might be able to get the surfaces out of the model for example, but you'll have to have some topology to say what portion of the surface is used by a face.