如何从几何形状创建3D模型文件? [英] How can I create a 3D model file from geometric shapes?

查看:344
本文介绍了如何从几何形状创建3D模型文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在编写一个程序,该程序将基于三维空间中具有已知坐标的简单几何形状(例如矩形棱柱和柱面)输出3D模型文件。作为一个例子,想象一下创建巨石阵的3D模型。 这个问题表明OBJ文件是最容易生成的,但我正在努力寻找一个好的教程或易于使用的库。

任何人都可以

(1)分步描述如何创建一个简单文件OR
(2)将我指向一个描述如何操作的教程



注意:
*使用基于GUI的程序绘制这些文件是不是我的选择
*我以前没有3D建模经验
* WRL或DAE等其他格式也适用于我

编辑:



我不需要使用纹理,只需将三维空间中的简单几何图形组合在一起即可。

ASCII交换格式,这里面有很多我通常使用的这些:


  1. *。x DirectX对象(它是C ++源代码)



    这一个最容易实现!但是没有很多工具可以处理它们。如果你不想花太多时间编码,那么这是正确的选择。只需从任何 *。x 文件中复制模板即可开始使用。



    这里有一些规范

  2. *。iges 在大多数CAD / CAM平台(包括Catia)上通用且可导入 p

    有点复杂,但出口目的并不是那么糟糕。它支持像 +, - ,&,^ 这样的音量操作,它们是 VERY HARD 来正确实施,但您不必使用它们:)
    $ b

    这个更复杂,然后 IGES 。我不推荐使用它。

  3. / p>

    我第一次看到这是一架飞行器。

    这里有些规格



    首先看起来很容易,对象实现非常棘手。除非你使用它,否则你应该没问题。


    这种方法很容易在笔记本中验证,或者通过加载一些 3D 模型查看器。选择一个最适合您的需求,并为您的Apps内部模型 class / struct 编写 save / load 函数。通过这种方式,您将与其他软件兼容,并消除创建几乎已知二进制格式(如 3ds ,...

    )的原始不兼容性问题。

    在您的情况下,我会使用 IGES (初始图形交换规范)



    对于导出,您不需要只实现几个基本形状,所以不会太困难。我编码更复杂的进口商。我的 IGES 加载器类是 C ++ 源代码外观的 30KB here 了解更多信息



    您没有提供任何关于您的 3D 网格模型结构和功能

    类似于您使用的原语,您的对象是简单的还是骨架层次结构,您是否在使用纹理以及更多...这是不可能的回答



    无论如何,出口往往是这样的:


    1. 创建目标文件格式的标题和结构
    2. 如果格式有任何目录结构填充并写入(IGES),则为
    3. 对于子对象,不要忘记添加变换矩阵...



      $ b

    4. 写出您需要的区块(点列表,脸部列表,法线......)
      您可以使用 ASCII 格式在String变量中做这个,这样你可以很容易地插入或修改。在内存中执行所有操作,并在最后写入整个文件,并且可以使用内存而不是文件。如果要将许多文件打包到单个包文件(如 *。pak )或通过 IPC LAN发送/接收文件, ...



      [Edit1]有关IGES的更多信息



      fileformat specs



      我从这篇PDF文件中了解到 IGES ...不知道从哪里得到它,但这是我今天在谷歌搜索到的第一个有效链接。我确信有一些非注册链接也在那里。它的大小约为13.7 MB,原名 IGES5-3_forDownload.pdf



      win32 viewer



      这是免费的 IGES 浏览器。我不喜欢界面和处理,但它的工作原理。这是必要的功能查看器来测试你的......



      examples



      这里有很多实体的教程文件,有3个子链接( igs, peek,gif )您可以通过更多方式查看示例文件以便更好地理解。



      导出到IGES



      您没有提供任何有关 3D 网格内部结构的信息,因此我无法帮助导出。有许多方法可以用相同的方式导出,因此请选择离您的 App 3D 网格表示最近的一个。例如,您可以使用:
      $ b


      • 点云

      • 旋转曲面

      • 矩形(QUAD)曲面

      • 边界线表示形式(非实体)

      • 修剪曲面以及更多...


      I am writing a program that will output 3D model files based on simple geometric shapes (e. g. rectangular prisms & cylinders) with known coordinates in 3-dimensional space. As an example, imagine creating a 3D model of stonehenge. this question suggests that OBJ files are the easiest to generate, but I'm struggling to find a good tutorial or easy-to-use library for doing so.

      Can anyone either

      (1) describe step-by-step how to create a simple file OR (2) point me to a tutorial that describes how to do so

      Notes: * Using a GUI-based program to draw such files is not an option for me * I have no prior experience with 3D modeling * Other formats such as WRL or DAE would work for me as well

      EDIT:

      I do not need to use textures, just combinations of simple geometric shapes positioned in 3D space.

      解决方案

      I strongly recommend to use some ASCII exchange format there are many out there I usually use these:

      1. *.x DirectX object (it is a C++ source code)

        this one is easiest to implement !!! But there are not many tools that can handle them. If you do not want to spend too much time coding then this is the right choice. Just copy the templates (at the start) from any *.x file to get started.

        here some specs

      2. *.iges common and importable on most CAD/CAM platform (Catia included)

        this one is a bit complicated but for export purposes it is not that bad. It supports Volume operation like +,-,&,^ which are VERY HARD to implement properly but you do not have to use them :)

      3. *.dxf AutoCAD exchange format

        this one is even more complicated then IGES. I do not recommend to use it

      4. *.ac AC3D

        I first saw this one in flight gear.

        here some specs

        at first look it is quite easy but the sub-object implementation is really tricky. Unless you use it you should be fine.

      This approach is easily verifiable in note pad or by loading to some 3D model viewer. Chose one that is most suitable for your needs and code save/load function to your Apps internal model class/struct. This way you will be compatible with other software and eliminate incompatibility problems which are native to creating 'almost known' binary formats like 3ds,...

      In your case I would use IGES (Initial Graphics Exchange Specification)

      For export you do not need to implement all just few basic shapes so it would not be too difficult. I code importers which are much much more complicated. Mine IGES loader class is about 30KB of C++ source code look here for more info

      You did not provide any info about your 3D mesh model structure and capabilities

      like what primitives you use, are your object simple or in skeleton hierarchy, are you using textures, and more ... so it is impossible to answer

      Anyway export often looks like this:

      1. create header and structure of target file format
      2. if the format has any directory structure fill it and write it (IGES)

        for sub-objects do not forget to add transformation matrices ...

      3. write the chunks you need (points list, faces list, normals, ...)

      With ASCII formats you can do this inside String variable so you can easily insert into or modify. Do all thing in memory and write the whole thing to file at the end which is fast and also add capability to work with memory instead of files. This is handy if you want to pack many files to single package file like *.pak or send/receive files through IPC or LAN ...

      [Edit1] more about IGES

      fileformat specs

      I learned IGES from this pdf ... Have no clue where from I got it but this was first valid link I found in google today. I am sure there is some non registration link out there too. It is about 13.7 MB and original name IGES5-3_forDownload.pdf.

      win32 viewer

      this is free IGES viewer. I do not like the interface and handling but it works. It is necessary to have functional viewer for testing yours ...

      examples

      here are many tutorial files for many entities there are 3 sub-links (igs,peek,gif) where you can see example file in more ways for better understanding.

      exporting to IGES

      you did not provide any info about your 3D mesh internal structure so I can not help with export. There are many ways to export the same way so pick one that is closest to your App 3D mesh representation. For example you can use:

      • point cloud
      • rotation surfaces
      • rectangle (QUAD) surfaces
      • border lines representation (non solid)
      • trim surface and many more ...

      这篇关于如何从几何形状创建3D模型文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆