首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >WaveFront .obj文件- "f“命令做什么?

WaveFront .obj文件- "f“命令做什么?
EN

Stack Overflow用户
提问于 2012-06-09 15:30:07
回答 2查看 3.3K关注 0票数 2

我一直在阅读大卫·布雷斯基恩的“Java开发游戏”。到目前为止,我已经理解了这本书中的每一件事。在Wavefront对象文件中,我理解v命令的作用,但不理解f命令。例如:

代码语言:javascript
复制
# OBJ - Wavefront object file
# The javagamebook loader only understands these commands:
#   mtllib <filename>    - Load materials from an external .mtl
#                          file.
#   v <x> <y> <z>        - Define a vertex with floating-point
#                          coords (x,y,z).
#   f <v1> <v2> <v3> ... - Define a new face. a face is a flat,
#                          convex polygon with vertices in
#                          counter-clockwise order. Positive
#                          numbers indicate the index of the
#                          vertex that is defined in the file.
#                          Negative numbers indicate the vertex
#                          defined relative to last vertex read.
#                          For example, 1 indicates the first
#                          vertex in the file, -1 means the last
#                          vertex read, and -2 is the vertex
#                          before that.
#   g <name>             - Define a new group by name. The faces
#                          following are added to this group.
#   usemtl <name>        - Use the named material (loaded from a
#                          .mtl file) for the faces in this group.

# load materials
mtllib textures.mtl

# define vertices
v 16 32 16
v 16 32 -16
v 16 0 16
v 16 0 -16
v -16 32 16
v -16 32 -16
v -16 0 16
v -16 0 -16

g myCube
usemtl wall1
f 1 3 4 2
f 6 8 7 5
f 2 6 5 1
f 3 7 8 4
f 1 5 7 3
f 4 8 6 2

f命令在这里做什么?

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2012-06-09 16:19:08

f表示模型的一个面(例如,三角形或四角体)。数字是指向顶点列表的索引,它指示您应该以何种方式加入它来形成脸。

在已发布的obj文件中,您找到的第一个f表示脸是由一个四角(因为有4个顶点)与顶点#1、#3、#4和#2形成的。

重要事项:您应该以指定的顺序加入顶点,以避免以后法线计算和/或非多边形(自相交)形状的问题。

票数 4
EN

Stack Overflow用户

发布于 2012-06-09 16:11:05

一个立方体有八个角(用顶点或点表示),这些角由v (v表示顶点)定义。面(f)是由角的坐标(v)定义的曲面,插图见网格

代码语言:javascript
复制
    v1+-----------+  v2
     /            /
    /     f1     /
   /            /
v4+------------+v3
  |            |
  |            |
  |     f2     |
  |            |
  |            |
v6+------------+v5

这意味着face f1 ist由v1、v2、v3和v4定义;f2由v4、v3、v5、v6定义。

票数 5
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/10962232

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档