WaveFront OBJ文件格式简介

本文基本上是对(https://www.fileformat.info/format/wavefrontobj/egff.htm)的翻译。

Wavefront OBJ File Format Summary WaveFront OBJ文件格式摘要

Also Known As: Wavefront Object, OBJ
也称为:Wavefront对象,obj

Type 类型 3D Vector 3D矢量
Colors 颜色 Unlimited 无限
Compression 压缩 Uncompressed 未压缩
Maximum Image Size 最大图像大小 Unlimited 无限
Multiple Images Per File 每个文件多个图像 Yes 是的
Numerical Format 数值格式 NA
Originator 鼻祖 Wavefront
Platform 平台 UNIX
Supporting Applications 支持应用程序 Advanced Visualizer 高级可视化器
See Also 参见 Wavefront RLA

Wavefront OBJ (object) files are used by Wavefront's Advanced Visualizer application to store geometric objects composed of lines, polygons, and free-form curves and surfaces. Wavefront is best known for its high-end computer graphics tools, including modeling, animation, and image compositing tools. These programs run on powerful workstations such as those made by Silicon Graphics, Inc.
Wavefront OBJ(对象)文件由Wavefront的高级可视化器应用程序使用,以存储由线条,多边形和自由形式曲线和表面组成的几何对象。 Wavefront以其高端计算机图形工具而闻名,包括建模,动画和图像合成工具。这些程序在强大的工作站上运行,例如硅Graphics,Inc。

Wavefront OBJ files are often stored with the extension ".obj" following the UNIX convention of lowercase letters for filenames. The most recently documented version of OBJ is v3.0, superseding the previous v2.11 release.
WaveFront OBJ文件通常按照unix限制文件名的“ .OBJ”存储。 OBJ最近记录的版本是v3.0,取代了先前的v2.11版本。

Contents: 内容:

In Wavefront's 3D software, geometric object files may be stored in ASCII format (using the ".obj" file extension) or in binary format (using the .MOD extension). The binary format is proprietary and undocumented, so only the ASCII format is described here.
在WaveFront的3D软件中,几何对象文件可以以ASCII格式(使用“ .OBJ”文件扩展名)或二进制格式(使用.mod扩展名)存储。二进制格式是专有的且无证件的,因此此处仅描述ASCII格式。

The OBJ file format supports lines, polygons, and free-form curves and surfaces. Lines and polygons are described in terms of their points, while curves and surfaces are defined with control points and other information depending on the type of curve. The format supports rational and non-rational curves, including those based on Bezier, B-spline, Cardinal (Catmull-Rom splines), and Taylor equations.
OBJ文件格式支持行,多边形和自由形式曲线和表面。线条和多边形是用其点来描述的,而曲线和表面则根据控制点和其他信息定义,具体取决于曲线的类型。该格式支持有理曲线和非理性曲线,包括基于Bezier,B-Spline,Cardinal(Catmull-Rom Spline)和Taylor方程的曲线。

File Organization 文件组织

OBJ files do not require any sort of header, although it is common to begin the file with a comment line of some kind. Comment lines begin with a hash mark (#). Blank space and blank lines can be freely added to the file to aid in formatting and readability. Each non-blank line begins with a keyword and may be followed on the same line with the data for that keyword. Lines are read and processed until the end of the file. Lines can be logically joined with the line continuation character ( \ ) at the end of a line.
OBJ文件不需要任何类型的标题,尽管通常以某种评论行启动文件。评论行以哈希标记(#)开头。空白空间和空白行可以自由添加到文件中,以帮助格式化和可读性。每条非直率线以关键字开头,并且可以在同一条线上与该关键字的数据一起遵循。读取和处理线直到文件末尾。线可以在行末端与行延续字符(\)在逻辑上连接。

The following keywords may be included in an OBJ file. In this list, keywords are arranged by data type, and each is followed by a brief description.
以下关键字可以包含在OBJ文件中。在此列表中,关键字按数据类型排列,每个关键字随后是简短的描述。

Vertex data: 顶点数据:

v Geometric vertices 几何顶点
vt Texture vertices 纹理顶点
vn Vertex normals 顶点正常
vp Parameter space vertices 参数空间顶点

Free-form curve/surface attributes: 自由形式曲线/表面属性:

deg Degree 程度
bmat Basis matrix 基矩阵
step Step size 步长
cstype Curve or surface type 曲线或表面类型

Elements: 元素:

p Point 点
l Line 线
f Face 面
curv Curve 曲线
curv2 2D curve 2D曲线
surf Surface 表面

Free-form curve/surface body statements: 自由形式的曲线/表面主体语句:

parm Parameter values 参数值
trim Outer trimming loop 外部修剪循环
hole Inner trimming loop 内部修剪循环
scrv Special curve 特殊曲线
sp Special point 特殊点
end End statement 结束语句

Connectivity between free-form surfaces:自由形式表面之间的连通性:

con Connect 连接

Grouping: 分组:

g Group name 组名
s Smoothing group 平滑组
mg Merging group 合并小组
o Object name 对象名称

Display/render attributes: 显示/渲染属性:

bevel Bevel interpolation 斜角插值
c_interp Color interpolation 颜色插值
d_interp Dissolve interpolation 溶解插值
lod Level of detail 细节水平
usemtl Material name 材料名称
mtllib Material library 材料库
shadow_obj Shadow casting 影子铸造
trace_obj Ray tracing 射线追踪
ctech Curve approximation technique 曲线近似技术
stech Surface approximation technique 表面近似技术

File Details 文件详细信息

The most commonly encountered OBJ files contain only polygonal faces. To describe a polygon, the file first describes each point with the "v" keyword, then describes the face with the "f" keyword. The line of a face command contains the enumerations of the points in the face, as 1-based indices into the list of points, in the order they occurred in the file. For example, the following describes a simple triangle:
最常见的OBJ文件仅包含多边形face。为了描述多边形,文件首先用“v”关键字描述每个点,然后用“f”关键字描述face。face的线包含face点的枚举,作为一个基于1个点的索引,按照文件在文件中的顺序列表。例如,以下描述一个简单的三角形:

# Simple Wavefront file
v 0.0 0.0 0.0
v 0.0 1.0 0.0
v 1.0 0.0 0.0
f 1 2 3

It is also possible to reference points using negative indices. This makes it easy to describe the points in a face, then the face, without the need to store a large list of points and their indexes. In this way, "v" commands and "f" commands can be interspersed.
也可以使用负索引参考点。这使得可以轻松地描述脸部,然后是脸部的要点,而无需存储大量的积分及其索引。这样,可以将“v”命令和“f”命令穿插。

v -0.500000 0.000000 0.400000
v -0.500000 0.000000 -0.800000
v -0.500000 1.000000 -0.800000
v -0.500000 1.000000 0.400000
f -4 -3 -2 -1

OBJ files do not contain color definitions for faces, although they can reference materials that are stored in a separate material library file. The material library can be loaded using the "mtllib" keyword. The material library contains the definitions for the RGB values for the material's diffuse, ambient, and specular colors, along with other characteristics such as specularity, refraction, transparency, etc.
OBJ文件不包含面部的颜色定义,尽管它们可以引用存储在单独的材料库文件中的材料。可以使用“ mtllib”关键字加载材料库。材料库包含材料扩散,环境和镜面颜色的RGB值的定义,以及其他特征,例如镜面,折射,透明度等。

The OBJ file references materials by name with the "usemtl" keyword. All faces that follow are given the attributes of this material until the next "usemtl" command is encountered.
OBJ文件引用材料,名称为“ usemtl”关键字。在遇到下一个“ usemtl”命令之前,均给出了以下所有面孔的属性。

Faces and surfaces can be assigned into named groups with the "g" keyword. This is used to create convenient sub-objects to make it easier to edit and animate 3D models. Faces can belong to more than one group.
可以将面部和表面分配给带有“ G”关键字的命名组。这是用于创建方便的子对象,以使编辑和动画3D型号更容易。面孔可以属于多个组。

The following demonstrate more complicated examples of smooth surfaces of different types, material assignment, line continuation, and grouping.
以下显示了不同类型,材料分配,线路延续和分组的平滑表面的更复杂的例子。

Cube with Materials 与材料的立方体

# This cube has a different material
# applied to each of its faces.
	mtllib master.mtl
	v	0.000000	2.000000	2.000000
	v	0.000000	0.000000	2.000000
	v	2.000000	0.000000	2.000000
	v	2.000000	2.000000	2.000000
	v	0.000000	2.000000	0.000000
	v	0.000000	0.000000	0.000000
	v	2.000000	0.000000	0.000000
	v	2.000000	2.000000	0.000000
	# 8 vertices
	g front
	usemtl red
	f 1 2 3 4
	g back
	usemtl blue
	f 8 7 6 5
	g right
	usemtl green
	f 4 3 7 8
	g top
	usemtl gold
	f 5 1 4 8
	g left
	usemtl orange
	f 5 6 2 1
	g bottom
	usemtl purple
	f 2 6 7 3
	# 6 elements

Bezier Patch Bezier补丁

# 3.0 Bezier patch
v -5.000000 -5.000000 0.000000
v -5.000000 -1.666667 0.000000
v -5.000000 1.666667 0.000000
v -5.000000 5.000000 0.000000
v -1.666667 -5.000000 0.000000
v -1.666667 -1.666667 0.000000
v -1.666667 1.666667 0.000000
v -1.666667 5.000000 0.000000
v 1.666667 -5.000000 0.000000
v 1.666667 -1.666667 0.000000
v 1.666667 1.666667 0.000000
v 1.666667 5.000000 0.000000
v 5.000000 -5.000000 0.000000
v 5.000000 -1.666667 0.000000
v 5.000000 1.666667 0.000000
v 5.000000 5.000000 0.000000
# 16 vertices
cstype bezier
deg 3 3
# Example of line continuation
surf 0.000000 1.000000 0.000000 1.000000 13 14 \
				 15 16 9 10 11 12 5 6 7 8 1 2 3 4
parm u 0.000000 1.000000
parm v 0.000000 1.000000
end
# 1 element

Cardinal Curve 基本曲线

# 3.0 Cardinal curve
v 0.940000 1.340000 0.000000
v -0.670000 0.820000 0.000000
v -0.770000 -0.940000 0.000000
v 1.030000 -1.350000 0.000000
v 3.070000 -1.310000 0.000000
# 6 vertices
cstype cardinal
deg 3
curv 0.000000 3.000000 1 2 3 4 5 6
parm u 0.000000 1.000000 2.000000 3.000000 end
# 1 element

Texture-Mapped Square 纹理图广场

# A 2 x 2 square mapped with a 1 x 1 square
# texture stretched to fit the square exactly.
mtllib master.mtl
v  0.000000 2.000000 0.000000
v  0.000000 0.000000 0.000000
v  2.000000 0.000000 0.000000
v  2.000000 2.000000 0.000000
vt 0.000000 1.000000 0.000000
vt 0.000000 0.000000 0.000000
vt 1.000000 0.000000 0.000000
vt 1.000000 1.000000 0.000000
# 4 vertices
usemtl wood
# The first number is the point,
# then the slash,
# and the second is the texture point
f 1/1 2/2 3/3 4/4
# 1 element

For Further Information 有关更多信息

For further information about the Wavefront OBJ format, see the specification.
有关wavefrontOBJ格式的更多信息,请参见规范。

WWW: http://www.aw.sgi.com/

Wavefront also maintains a toll-free support number and a BBS for its customers. There are many Wavefront user groups, too.
Wavefront还为其客户维护免费的支持号码和BB。wavefront用户组也有很多。

This page is taken from the Encyclopedia of Graphics File Formats and is licensed by O'Reilly under the Creative Common/Attribution license.
此页面摘自图形文件格式的百科全书,并由O'Reilly在Creative Common/Atermitution许可下获得许可。

More Resources 更多资源

End

posted @ 2025-06-09 08:06  BIT祝威  阅读(30)  评论(0)    收藏  举报