summaryrefslogtreecommitdiff
path: root/doc/obj-spec.txt
diff options
context:
space:
mode:
Diffstat (limited to 'doc/obj-spec.txt')
-rw-r--r--doc/obj-spec.txt292
1 files changed, 292 insertions, 0 deletions
diff --git a/doc/obj-spec.txt b/doc/obj-spec.txt
new file mode 100644
index 0000000..2430367
--- /dev/null
+++ b/doc/obj-spec.txt
@@ -0,0 +1,292 @@
1Wavefront OBJ
2
3Also Known As: Wavefront Object, OBJ
4
5━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
6
7Type 3D Vector
8Colors Unlimited
9Compression Uncompressed
10Maximum Image Size Unlimited
11Multiple Images Per File Yes
12Numerical Format NA
13Originator Wavefront
14Platform UNIX
15Supporting Applications Advanced Visualizer
16See Also Wavefront RLA
17
18Usage
19Used to store and exchange 3D data.
20
21Comments
22The Wavefront OBJ format is a useful standard for representing polygonal data
23in ASCII form.
24
25Vendor specifications are available for this format.
26
27━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
28
29Wavefront OBJ (object) files are used by Wavefront's Advanced Visualizer
30application to store geometric objects composed of lines, polygons, and
31free-form curves and surfaces. Wavefront is best known for its high-end
32computer graphics tools, including modeling, animation, and image compositing
33tools. These programs run on powerful workstations such as those made by
34Silicon Graphics, Inc.
35
36Wavefront OBJ files are often stored with the extension ".obj" following the
37UNIX convention of lowercase letters for filenames. The most recently
38documented version of OBJ is v3.0, superseding the previous v2.11 release.
39
40Contents:
41File Organization
42File Details
43For Further Information
44
45In Wavefront's 3D software, geometric object files may be stored in ASCII
46format (using the ".obj" file extension) or in binary format (using the .MOD
47extension). The binary format is proprietary and undocumented, so only the
48ASCII format is described here.
49
50The OBJ file format supports lines, polygons, and free-form curves and
51surfaces. Lines and polygons are described in terms of their points, while
52curves and surfaces are defined with control points and other information
53depending on the type of curve. The format supports rational and non-rational
54curves, including those based on Bezier, B-spline, Cardinal (Catmull-Rom
55splines), and Taylor equations.
56
57File Organization
58
59OBJ files do not require any sort of header, although it is common to begin the
60file with a comment line of some kind. Comment lines begin with a hash mark
61(#). Blank space and blank lines can be freely added to the file to aid in
62formatting and readability. Each non-blank line begins with a keyword and may
63be followed on the same line with the data for that keyword. Lines are read and
64processed until the end of the file. Lines can be logically joined with the
65line continuation character ( \ ) at the end of a line.
66
67The following keywords may be included in an OBJ file. In this list, keywords
68are arranged by data type, and each is followed by a brief description.
69
70Vertex data:
71
72 v Geometric vertices
73 vt Texture vertices
74 vn Vertex normals
75 vp Parameter space vertices
76
77Free-form curve/surface attributes:
78
79 deg Degree
80 bmat Basis matrix
81 step Step size
82 cstype Curve or surface type
83
84Elements:
85
86 p Point
87 l Line
88 f Face
89 curv Curve
90 curv2 2D curve
91 surf Surface
92
93Free-form curve/surface body statements:
94
95 parm Parameter values
96 trim Outer trimming loop
97 hole Inner trimming loop
98 scrv Special curve
99 sp Special point
100 end End statement
101
102Connectivity between free-form surfaces:
103
104 con Connect
105
106Grouping:
107
108 g Group name
109 s Smoothing group
110 mg Merging group
111 o Object name
112
113Display/render attributes:
114
115 bevel Bevel interpolation
116 c_interp Color interpolation
117 d_interp Dissolve interpolation
118 lod Level of detail
119 usemtl Material name
120 mtllib Material library
121 shadow_obj Shadow casting
122 trace_obj Ray tracing
123 ctech Curve approximation technique
124 stech Surface approximation technique
125
126File Details
127
128The most commonly encountered OBJ files contain only polygonal faces. To
129describe a polygon, the file first describes each point with the "v" keyword,
130then describes the face with the "f" keyword. The line of a face command
131contains the enumerations of the points in the face, as 1-based indices into
132the list of points, in the order they occurred in the file. For example, the
133following describes a simple triangle:
134
135# Simple Wavefront file
136v 0.0 0.0 0.0
137v 0.0 1.0 0.0
138v 1.0 0.0 0.0
139f 1 2 3
140
141It is also possible to reference points using negative indices. This makes it
142easy to describe the points in a face, then the face, without the need to store
143a large list of points and their indexes. In this way, "v" commands and "f"
144commands can be interspersed.
145
146v -0.500000 0.000000 0.400000
147v -0.500000 0.000000 -0.800000
148v -0.500000 1.000000 -0.800000
149v -0.500000 1.000000 0.400000
150f -4 -3 -2 -1
151
152OBJ files do not contain color definitions for faces, although they can
153reference materials that are stored in a separate material library file. The
154material library can be loaded using the "mtllib" keyword. The material library
155contains the definitions for the RGB values for the material's diffuse,
156ambient, and specular colors, along with other characteristics such as
157specularity, refraction, transparency, etc.
158
159The OBJ file references materials by name with the "usemtl" keyword. All faces
160that follow are given the attributes of this material until the next "usemtl"
161command is encountered.
162
163Faces and surfaces can be assigned into named groups with the "g" keyword. This
164is used to create convenient sub-objects to make it easier to edit and animate
1653D models. Faces can belong to more than one group.
166
167The following demonstrate more complicated examples of smooth surfaces of
168different types, material assignment, line continuation, and grouping.
169
170Cube with Materials
171
172# This cube has a different material
173# applied to each of its faces.
174 mtllib master.mtl
175 v 0.000000 2.000000 2.000000
176 v 0.000000 0.000000 2.000000
177 v 2.000000 0.000000 2.000000
178 v 2.000000 2.000000 2.000000
179 v 0.000000 2.000000 0.000000
180 v 0.000000 0.000000 0.000000
181 v 2.000000 0.000000 0.000000
182 v 2.000000 2.000000 0.000000
183 # 8 vertices
184 g front
185 usemtl red
186 f 1 2 3 4
187 g back
188 usemtl blue
189 f 8 7 6 5
190 g right
191 usemtl green
192 f 4 3 7 8
193 g top
194 usemtl gold
195 f 5 1 4 8
196 g left
197 usemtl orange
198 f 5 6 2 1
199 g bottom
200 usemtl purple
201 f 2 6 7 3
202 # 6 elements
203
204Bezier Patch
205
206# 3.0 Bezier patch
207v -5.000000 -5.000000 0.000000
208v -5.000000 -1.666667 0.000000
209v -5.000000 1.666667 0.000000
210v -5.000000 5.000000 0.000000
211v -1.666667 -5.000000 0.000000
212v -1.666667 -1.666667 0.000000
213v -1.666667 1.666667 0.000000
214v -1.666667 5.000000 0.000000
215v 1.666667 -5.000000 0.000000
216v 1.666667 -1.666667 0.000000
217v 1.666667 1.666667 0.000000
218v 1.666667 5.000000 0.000000
219v 5.000000 -5.000000 0.000000
220v 5.000000 -1.666667 0.000000
221v 5.000000 1.666667 0.000000
222v 5.000000 5.000000 0.000000
223# 16 vertices
224cstype bezier
225deg 3 3
226# Example of line continuation
227surf 0.000000 1.000000 0.000000 1.000000 13 14 \
228 15 16 9 10 11 12 5 6 7 8 1 2 3 4
229parm u 0.000000 1.000000
230parm v 0.000000 1.000000
231end
232# 1 element
233
234Cardinal Curve
235
236# 3.0 Cardinal curve
237v 0.940000 1.340000 0.000000
238v -0.670000 0.820000 0.000000
239v -0.770000 -0.940000 0.000000
240v 1.030000 -1.350000 0.000000
241v 3.070000 -1.310000 0.000000
242# 6 vertices
243cstype cardinal
244deg 3
245curv 0.000000 3.000000 1 2 3 4 5 6
246parm u 0.000000 1.000000 2.000000 3.000000 end
247# 1 element
248
249Texture-Mapped Square
250
251# A 2 x 2 square mapped with a 1 x 1 square
252# texture stretched to fit the square exactly.
253mtllib master.mtl
254v 0.000000 2.000000 0.000000
255v 0.000000 0.000000 0.000000
256v 2.000000 0.000000 0.000000
257v 2.000000 2.000000 0.000000
258vt 0.000000 1.000000 0.000000
259vt 0.000000 0.000000 0.000000
260vt 1.000000 0.000000 0.000000
261vt 1.000000 1.000000 0.000000
262# 4 vertices
263usemtl wood
264# The first number is the point,
265# then the slash,
266# and the second is the texture point
267f 1/1 2/2 3/3 4/4
268# 1 element
269
270For Further Information
271
272For further information about the Wavefront OBJ format, see the specification.
273
274You can also contact:
275
276Wavefront Technologies
277530 East Montecito Street
278Santa Barbara, CA 93103
279Voice: 805-962-8117
280FAX: 805-963-0410
281WWW: http://www.aw.sgi.com/
282
283Wavefront also maintains a toll-free support number and a BBS for its
284customers. There are many Wavefront user groups, too.
285
286━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
287
288[txtpreva] [txtnexta] [txtupa] [txttoidx]
289[btntoc] [btnglos] [btnmain] [btnfmt] [btnsoft] [btninet] [btnbook]
290
291Copyright © 1996, 1994 O'Reilly & Associates, Inc. All Rights Reserved.
292