如何创建 JT 3D 文件格式的查看器

发布于 2024-10-16 17:22:27 字数 1435 浏览 4 评论 0原文

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

心病无药医 2024-10-23 17:22:27

首先从以下位置获取规范:

http://www. plm.automation.siemens.com/en_us/Images/JT_v95_File_Format_Reference_Rev-A_tcm1023-111987.pdf

并编写一个库来读取该文件。该规范看起来很大,但实施起来很简单。我认为应该可以访问文件的元素,而无需将整个数据结构保留在内存中。

在对查看器部分进行编程时,不要直接使用OpenGL,而是使用场景图形库。 (我第一个想到的就是OpenSceneGraph)

Start by getting the spec at:

http://www.plm.automation.siemens.com/en_us/Images/JT_v95_File_Format_Reference_Rev-A_tcm1023-111987.pdf

and write a library to read the file. The spec looks big but straight forward to implement. I think it should be possible to access elements of the file without keeping the whole datastructure in memory.

When programming the viewer part, don't use OpenGL directly, but use a scene graph library. (OpenSceneGraph is the first one that pops into my mind)

温折酒 2024-10-23 17:22:27

您可以从这里使用 Java 库:http://www.johannes-raida.de/jnetcad
据我所知,它应该支持 JT 版本 8 文件。我使用了 DXF 导入库并且非常高兴。 API 是相同的,因此您可以访问所有三角形及其坐标、法线、颜色和图层。

You can use the Java library from here: http://www.johannes-raida.de/jnetcad.
As far as I can see, it should support JT version 8 files. I used the DXF import library and was quite happy. The API is the same, so you have access to all triangles with their coordinates, normals, color and layer.

雪花飘飘的天空 2024-10-23 17:22:27

还可以使用 Open Cascade 库。它是一个开源 C++ 库 (LGPL),主要为 CAD 设计。目前还支持读取JT文档的facets(三角形):
http://www.opencascade.org/support/applications/jt_assistant/
Jt助手还可以可视化JT文档。该应用程序的 C++ 代码是开源的 (GPL)。与 Jt2Go 相比,Jt 助手的优点之一是可以显示 JT 文档的不同层(组)。

It is also possible to use the Open Cascade library. It is an open source C++ library (LGPL), and is primarily designed for CAD. Currently it also supports to read the facets (triangles) of JT documents:
http://www.opencascade.org/support/applications/jt_assistant/
and the Jt assistant can also visualize the JT documents. The C++ code is of this application is open source (GPL). One advantage of the Jt assistant compare to Jt2Go is that it is possible to show different layers (groups) of the JT document.

乖乖公主 2024-10-23 17:22:27

您可以尝试向开放资源导入库添加对此文件格式的支持:

http://assimp.sourceforge.net/

还知道不幸的缩写 ASSIMP。他们已经有一个查看器,所以一旦您将格式添加到导入库中,您就完成了。此外,您还将向现有开源库添加对另一种格式的支持。

You might try adding support for this file format to the Open Asset Import Library:

http://assimp.sourceforge.net/

Also know by the unfortunate abbreviation ASSIMP. They already have a viewer, so once you add the format to the import library you'll be done. In addition you will have added support for another format to an existing open source library.

墨小沫ゞ 2024-10-23 17:22:27

要在加载文件后查看文件,基本上需要在程序中实现 OpenGL。每个对象都是一个浮点值数组,表示其几何形状(顶点)。因此,一旦提取出这些信息,您只需使用标准 OpenGL 调用来渲染它。例如,将顶点放入密堆积数组(一维浮点数数组)中:

vertexX, vertexY, vertexZ, normalX, normalY, normalZ

该浮点数数组代表模型的所有面。每个面三个顶点,上面的线是一个顶点。一旦有了浮点数组,渲染就很简单了。

glEnableClientState(GL_VERTEX_ARRAY);
glEnableClientState(GL_NORMAL_ARRAY);

glVertexPointer(3, GL_FLOAT, sizeof(vertices[0])*6, &vertices[0]);
glNormalPointer(GL_FLOAT, sizeof(vertices[0])*6, &vertices[3]);

glColor4f(R, G, B, 1); //range 0-1
glDrawArrays(GL_TRIANGLES, 0, numVertices); //number of floats in array divided by 6

glDisableClientState(GL_VERTEX_ARRAY);
glDisableClientState(GL_NORMAL_ARRAY);

然后将其放入 OpenGL-ES 1.1 渲染循环中。让我知道这是否适合您。另外,如果您可以使用,请分享如何读取 JT 文件格式。

To view the files once you load them, you basically need to implement OpenGL in your program. Each object is an array of float values that represent it's geometry (vertices). So once you pull this information out, you just render it using standard OpenGL calls. For example, put your vertices into a close packed array (single dimension array of floats):

vertexX, vertexY, vertexZ, normalX, normalY, normalZ

This array of floats represents all the faces of your model. Three vertices per face, with the above line being one vertex. Once you have a float array, it's simple to render.

glEnableClientState(GL_VERTEX_ARRAY);
glEnableClientState(GL_NORMAL_ARRAY);

glVertexPointer(3, GL_FLOAT, sizeof(vertices[0])*6, &vertices[0]);
glNormalPointer(GL_FLOAT, sizeof(vertices[0])*6, &vertices[3]);

glColor4f(R, G, B, 1); //range 0-1
glDrawArrays(GL_TRIANGLES, 0, numVertices); //number of floats in array divided by 6

glDisableClientState(GL_VERTEX_ARRAY);
glDisableClientState(GL_NORMAL_ARRAY);

Then just put this in your OpenGL-ES 1.1 render loop. Let me know if this does it for you. Also, please share how to read the JT file format if you have it working.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文