summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoe Crayne <joe@jerkface.net>2019-06-14 03:14:01 -0400
committerJoe Crayne <joe@jerkface.net>2019-06-14 03:14:01 -0400
commit5de38abbd755b060f818f683f4903bf317ee82df (patch)
treea7058a704576a1566ba3f046c8da1b69b6daba7d
parent15d46d75c67faa64425e1013957617239a9f4790 (diff)
More file format docs.
-rw-r--r--doc/cs-notes.txt28
-rw-r--r--doc/mtl-format.txt1404
-rw-r--r--doc/obj-spec.txt292
3 files changed, 1724 insertions, 0 deletions
diff --git a/doc/cs-notes.txt b/doc/cs-notes.txt
new file mode 100644
index 0000000..8ccd536
--- /dev/null
+++ b/doc/cs-notes.txt
@@ -0,0 +1,28 @@
1cstypes
2
3bezier
4
5Type bezier specifies a sequence of Bezier curves of similar degree, each
6beginning where the prior terminated. If there are multiple curves in the
7sequence, then the initial control point of a latter curve is not explicitly
8specified since it is equal to the last control point of the prior curve.
9
10Consider the following example.
11
12 curv2 -6 -5 -4 -3 -2 -1 -6
13
14When the degree is 3, the above specifies two Bézier curves: C₁=(-6,-5,-4,-3) and
15C₂=(-3,-2,-1,-6).
16
17The Bézier curve functions are taken to be branches of a peicewise function C
18obtianed by dividing the parameter space into regions and mapping each region
19to a different curve. For example,
20
21 parm u 0.00 1.00 2.00
22
23specifies two intervals, [0,1] and [1,2]. If the parameter is between 0 and 1,
24it will be mapped via the first curve C₁ and if it is between 1 and 2, it will
25be mapped via the second curve C₂. In order to maintain continuity, an affine
26transformation will be applied first to obtain a value between 0 and 1 so that
27C(1.5) = C₂(0.5).
28
diff --git a/doc/mtl-format.txt b/doc/mtl-format.txt
new file mode 100644
index 0000000..ebeab6e
--- /dev/null
+++ b/doc/mtl-format.txt
@@ -0,0 +1,1404 @@
1 MTL material format (Lightwave, OBJ)
2
3 Excerpt from FILE FORMATS, Version 4.2
4 October 1995
5 Documentation created by: Diane Ramey, Linda Rose, and Lisa Tyerman
6 Copyright 1995 Alias|Wavefront, Inc.
7 All rights reserved
8
9
10
115. Material Library File (.mtl)
12
13 Material library files contain one or more material definitions, each
14of which includes the color, texture, and reflection map of individual
15materials. These are applied to the surfaces and vertices of objects.
16Material files are stored in ASCII format and have the .mtl extension.
17
18 An .mtl file differs from other Alias|Wavefront property files, such as
19light and atmosphere files, in that it can contain more than one
20material definition (other files contain the definition of only one
21item).
22
23 An .mtl file is typically organized as shown below.
24
25
26 newmtl my_red
27 Material color
28 & illumination
29 statements
30
31 texture map
32 statements
33
34 reflection map
35 statement
36
37 newmtl my_blue
38 Material color
39 & illumination
40 statements
41
42 texture map
43 statements
44
45 reflection map
46 statement
47
48 newmtl my_green
49 Material color
50 & illumination
51 statements
52
53 texture map
54 statements
55
56 reflection map
57 statement
58
59 Figure 5-1. Typical organization of .mtl file
60
61
62 Each material description in an .mtl file consists of the newmtl
63statement, which assigns a name to the material and designates the start
64of a material description. This statement is followed by the material
65color, texture map, and reflection map statements that describe the
66material. An .mtl file map contain many different material
67descriptions.
68
69 After you specify a new material with the "newmtl" statement, you can
70enter the statements that describe the materials in any order. However,
71when the Property Editor writes an .mtl file, it puts the statements in
72a system-assigned order. In this chapter, the statements are described
73in the system-assigned order.
74
75
76 Format
77
78 The following is a sample format for a material definition in an .mtl
79file:
80
81 Material
82 name
83 statement:
84 newmtl my_mtl
85
86 Material
87 color and
88 illumination
89 statements:
90 Ka 0.0435 0.0435 0.0435
91 Kd 0.1086 0.1086 0.1086
92 Ks 0.0000 0.0000 0.0000
93 Tf 0.9885 0.9885 0.9885
94 illum 6
95 d -halo 0.6600
96 Ns 10.0000
97 sharpness 60
98 Ni 1.19713
99
100 Texture
101 map
102 statements:
103 map_Ka -s 1 1 1 -o 0 0 0 -mm 0 1 chrome.mpc
104 map_Kd -s 1 1 1 -o 0 0 0 -mm 0 1 chrome.mpc
105 map_Ks -s 1 1 1 -o 0 0 0 -mm 0 1 chrome.mpc
106 map_Ns -s 1 1 1 -o 0 0 0 -mm 0 1 wisp.mps
107 map_d -s 1 1 1 -o 0 0 0 -mm 0 1 wisp.mps
108 disp -s 1 1 .5 wisp.mps
109 decal -s 1 1 1 -o 0 0 0 -mm 0 1 sand.mps
110 bump -s 1 1 1 -o 0 0 0 -bm 1 sand.mpb
111
112 Reflection
113 map
114 statement:
115 refl -type sphere -mm 0 1 clouds.mpc
116
117
118 Material Name
119
120 The material name statement assigns a name to the material description.
121
122 Syntax
123 The folowing syntax describes the material name statement.
124
125 newmtl name
126
127 Specifies the start of a material description and assigns a name to the
128material. An .mtl file must have one newmtl statement at the start of
129each material description.
130
131 "name" is the name of the material. Names may be any length but
132cannot include blanks. Underscores may be used in material names.
133
134
135 Material color and illumination
136
137 The statements in this section specify color, transparency, and
138reflectivity values.
139
140 Syntax
141 The following syntax describes the material color and illumination
142statements that apply to all .mtl files.
143
144
145 Ka r g b
146 Ka spectral file.rfl factor
147 Ka xyz x y z
148
149 To specify the ambient reflectivity of the current material, you can
150use the "Ka" statement, the "Ka spectral" statement, or the "Ka xyz"
151statement.
152
153 Tip These statements are mutually exclusive. They cannot be used
154concurrently in the same material.
155
156 Ka r g b
157
158 The Ka statement specifies the ambient reflectivity using RGB values.
159
160 "r g b" are the values for the red, green, and blue components of the
161color. The g and b arguments are optional. If only r is specified,
162then g, and b are assumed to be equal to r. The r g b values are
163normally in the range of 0.0 to 1.0. Values outside this range increase
164or decrease the relectivity accordingly.
165
166 Ka spectral file.rfl factor
167
168 The "Ka spectral" statement specifies the ambient reflectivity using a
169spectral curve.
170
171 "file.rfl" is the name of the .rfl file.
172 "factor" is an optional argument.
173 "factor" is a multiplier for the values in the .rfl file and defaults
174to 1.0, if not specified.
175
176 Ka xyz x y z
177
178 The "Ka xyz" statement specifies the ambient reflectivity using CIEXYZ
179values.
180
181 "x y z" are the values of the CIEXYZ color space. The y and z
182arguments are optional. If only x is specified, then y and z are
183assumed to be equal to x. The x y z values are normally in the range of
1840 to 1. Values outside this range increase or decrease the reflectivity
185accordingly.
186
187
188 Kd r g b
189 Kd spectral file.rfl factor
190 Kd xyz x y z
191
192 To specify the diffuse reflectivity of the current material, you can
193use the "Kd" statement, the "Kd spectral" statement, or the "Kd xyz"
194statement.
195
196 Tip These statements are mutually exclusive. They cannot be used
197concurrently in the same material.
198
199 Kd r g b
200
201 The Kd statement specifies the diffuse reflectivity using RGB values.
202
203 "r g b" are the values for the red, green, and blue components of the
204atmosphere. The g and b arguments are optional. If only r is
205specified, then g, and b are assumed to be equal to r. The r g b values
206are normally in the range of 0.0 to 1.0. Values outside this range
207increase or decrease the relectivity accordingly.
208
209 Kd spectral file.rfl factor
210
211 The "Kd spectral" statement specifies the diffuse reflectivity using a
212spectral curve.
213
214 "file.rfl" is the name of the .rfl file.
215 "factor" is an optional argument.
216 "factor" is a multiplier for the values in the .rfl file and defaults
217to 1.0, if not specified.
218
219 Kd xyz x y z
220
221 The "Kd xyz" statement specifies the diffuse reflectivity using CIEXYZ
222values.
223
224 "x y z" are the values of the CIEXYZ color space. The y and z
225arguments are optional. If only x is specified, then y and z are
226assumed to be equal to x. The x y z values are normally in the range of
2270 to 1. Values outside this range increase or decrease the reflectivity
228accordingly.
229
230
231 Ks r g b
232 Ks spectral file.rfl factor
233 Ks xyz x y z
234
235 To specify the specular reflectivity of the current material, you can
236use the "Ks" statement, the "Ks spectral" statement, or the "Ks xyz"
237statement.
238
239 Tip These statements are mutually exclusive. They cannot be used
240concurrently in the same material.
241
242 Ks r g b
243
244 The Ks statement specifies the specular reflectivity using RGB values.
245
246 "r g b" are the values for the red, green, and blue components of the
247atmosphere. The g and b arguments are optional. If only r is
248specified, then g, and b are assumed to be equal to r. The r g b values
249are normally in the range of 0.0 to 1.0. Values outside this range
250increase or decrease the relectivity accordingly.
251
252 Ks spectral file.rfl factor
253
254 The "Ks spectral" statement specifies the specular reflectivity using a
255spectral curve.
256
257 "file.rfl" is the name of the .rfl file.
258 "factor" is an optional argument.
259 "factor" is a multiplier for the values in the .rfl file and defaults
260to 1.0, if not specified.
261
262 Ks xyz x y z
263
264 The "Ks xyz" statement specifies the specular reflectivity using CIEXYZ
265values.
266
267 "x y z" are the values of the CIEXYZ color space. The y and z
268arguments are optional. If only x is specified, then y and z are
269assumed to be equal to x. The x y z values are normally in the range of
2700 to 1. Values outside this range increase or decrease the reflectivity
271accordingly.
272
273
274 Tf r g b
275 Tf spectral file.rfl factor
276 Tf xyz x y z
277
278 To specify the transmission filter of the current material, you can use
279the "Tf" statement, the "Tf spectral" statement, or the "Tf xyz"
280statement.
281
282 Any light passing through the object is filtered by the transmission
283filter, which only allows the specifiec colors to pass through. For
284example, Tf 0 1 0 allows all the green to pass through and filters out
285all the red and blue.
286
287 Tip These statements are mutually exclusive. They cannot be used
288concurrently in the same material.
289
290 Tf r g b
291
292 The Tf statement specifies the transmission filter using RGB values.
293
294 "r g b" are the values for the red, green, and blue components of the
295atmosphere. The g and b arguments are optional. If only r is
296specified, then g, and b are assumed to be equal to r. The r g b values
297are normally in the range of 0.0 to 1.0. Values outside this range
298increase or decrease the relectivity accordingly.
299
300 Tf spectral file.rfl factor
301
302 The "Tf spectral" statement specifies the transmission filterusing a
303spectral curve.
304
305 "file.rfl" is the name of the .rfl file.
306 "factor" is an optional argument.
307 "factor" is a multiplier for the values in the .rfl file and defaults
308to 1.0, if not specified.
309
310 Tf xyz x y z
311
312 The "Ks xyz" statement specifies the specular reflectivity using CIEXYZ
313values.
314
315 "x y z" are the values of the CIEXYZ color space. The y and z
316arguments are optional. If only x is specified, then y and z are
317assumed to be equal to x. The x y z values are normally in the range of
3180 to 1. Values outside this range will increase or decrease the
319intensity of the light transmission accordingly.
320
321
322 illum illum_#
323
324 The "illum" statement specifies the illumination model to use in the
325material. Illumination models are mathematical equations that represent
326various material lighting and shading effects.
327
328 "illum_#"can be a number from 0 to 10. The illumination models are
329summarized below; for complete descriptions see "Illumination models" on
330page 5-30.
331
332 Illumination Properties that are turned on in the
333 model Property Editor
334
335 0 Color on and Ambient off
336 1 Color on and Ambient on
337 2 Highlight on
338 3 Reflection on and Ray trace on
339 4 Transparency: Glass on
340 Reflection: Ray trace on
341 5 Reflection: Fresnel on and Ray trace on
342 6 Transparency: Refraction on
343 Reflection: Fresnel off and Ray trace on
344 7 Transparency: Refraction on
345 Reflection: Fresnel on and Ray trace on
346 8 Reflection on and Ray trace off
347 9 Transparency: Glass on
348 Reflection: Ray trace off
349 10 Casts shadows onto invisible surfaces
350
351
352 d factor
353
354 Specifies the dissolve for the current material.
355
356 "factor" is the amount this material dissolves into the background. A
357factor of 1.0 is fully opaque. This is the default when a new material
358is created. A factor of 0.0 is fully dissolved (completely
359transparent).
360
361 Unlike a real transparent material, the dissolve does not depend upon
362material thickness nor does it have any spectral character. Dissolve
363works on all illumination models.
364
365 d -halo factor
366
367 Specifies that a dissolve is dependent on the surface orientation
368relative to the viewer. For example, a sphere with the following
369dissolve, d -halo 0.0, will be fully dissolved at its center and will
370appear gradually more opaque toward its edge.
371
372 "factor" is the minimum amount of dissolve applied to the material.
373The amount of dissolve will vary between 1.0 (fully opaque) and the
374specified "factor". The formula is:
375
376 dissolve = 1.0 - (N*v)(1.0-factor)
377
378 For a definition of terms, see "Illumination models" on page 5-30.
379
380
381 Ns exponent
382
383 Specifies the specular exponent for the current material. This defines
384the focus of the specular highlight.
385
386 "exponent" is the value for the specular exponent. A high exponent
387results in a tight, concentrated highlight. Ns values normally range
388from 0 to 1000.
389
390
391 sharpness value
392
393 Specifies the sharpness of the reflections from the local reflection
394map. If a material does not have a local reflection map defined in its
395material definition, sharpness will apply to the global reflection map
396defined in PreView.
397
398 "value" can be a number from 0 to 1000. The default is 60. A high
399value results in a clear reflection of objects in the reflection map.
400
401 Tip Sharpness values greater than 100 map introduce aliasing effects
402in flat surfaces that are viewed at a sharp angle
403
404
405 Ni optical_density
406
407 Specifies the optical density for the surface. This is also known as
408index of refraction.
409
410 "optical_density" is the value for the optical density. The values can
411range from 0.001 to 10. A value of 1.0 means that light does not bend
412as it passes through an object. Increasing the optical_density
413increases the amount of bending. Glass has an index of refraction of
414about 1.5. Values of less than 1.0 produce bizarre results and are not
415recommended.
416
417
418 Material texture map
419
420 Texture map statements modify the material parameters of a surface by
421associating an image or texture file with material parameters that can
422be mapped. By modifying existing parameters instead of replacing them,
423texture maps provide great flexibility in changing the appearance of an
424object's surface.
425
426 Image files and texture files can be used interchangeably. If you use
427an image file, that file is converted to a texture in memory and is
428discarded after rendering.
429
430 Tip Using images instead of textures saves disk space and setup time,
431however, it introduces a small computational cost at the beginning of a
432render.
433
434 The material parameters that can be modified by a texture map are:
435
436 - Ka (color)
437 - Kd (color)
438 - Ks (color)
439 - Ns (scalar)
440 - d (scalar)
441
442 In addition to the material parameters, the surface normal can be
443modified.
444
445
446 Image file types
447
448 You can link any image file type that is currently supported.
449Supported image file types are listed in the chapter "About Image" in
450the "Advanced Visualizer User's Guide". You can also use the "im_info -
451a" command to list Image file types, among other things.
452
453
454 Texture file types
455
456 The texture file types you can use are:
457
458 - mip-mapped texture files (.mpc, .mps, .mpb)
459 - compiled procedural texture files (.cxc, .cxs, .cxb)
460
461
462 Mip-mapped texture files
463
464 Mip-mapped texture files are created from images using the Create
465Textures panel in the Director or the "texture2D" program. There are
466three types of texture files:
467
468 - color texture files (.mpc)
469 - scalar texture files (.mps)
470 - bump texture files (.mpb)
471
472 Color textures. Color texture files are designated by an extension of
473".mpc" in the filename, such as "chrome.mpc". Color textures modify the
474material color as follows:
475
476 - Ka - material ambient is multiplied by the texture value
477 - Kd - material diffuse is multiplied by the texture value
478 - Ks - material specular is multiplied by the texture value
479
480 Scalar textures. Scalar texture files are designated by an extension
481of ".mps" in the filename, such as "wisp.mps". Scalar textures modify
482the material scalar values as follows:
483
484 - Ns - material specular exponent is multiplied by the texture value
485 - d - material dissolve is multiplied by the texture value
486 - decal - uses a scalar value to deform the surface of an object to
487create surface roughness
488
489 Bump textures. Bump texture files are designated by an extension of
490".mpb" in the filename, such as "sand.mpb". Bump textures modify
491surface normals. The image used for a bump texture represents the
492topology or height of the surface relative to the average surface. Dark
493areas are depressions and light areas are high points. The effect is
494like embossing the surface with the texture.
495
496
497 Procedural texture files
498
499 Procedural texture files use mathematical formulas to calculate sample
500values of the texture. The procedural texture file is compiled, stored,
501and accessed by the Image program when rendering. for more information
502see chapter 9, "Procedural Texture Files (.cxc, .cxb. and .cxs)".
503
504 Syntax
505
506 The following syntax describes the texture map statements that apply to
507.mtl files. These statements can be used alone or with any combination
508of options. The options and their arguments are inserted between the
509keyword and the "filename".
510
511 map_Ka -options args filename
512
513 Specifies that a color texture file or a color procedural texture file
514is applied to the ambient reflectivity of the material. During
515rendering, the "map_Ka" value is multiplied by the "Ka" value.
516
517 "filename" is the name of a color texture file (.mpc), a color
518procedural texture file (.cxc), or an image file.
519
520 Tip To make sure that the texture retains its original look, use the
521.rfl file "ident" as the underlying material. This applies to the
522"map_Ka", "map_Kd", and "map_Ks" statements. For more information on
523.rfl files, see chapter 8, "Spectral Curve File (.rfl)".
524
525 The options for the "map_Ka" statement are listed below. These options
526are described in detail in "Options for texture map statements" on page
5275-18.
528
529 -blendu on | off
530 -blendv on | off
531 -cc on | off
532 -clamp on | off
533 -mm base gain
534 -o u v w
535 -s u v w
536 -t u v w
537 -texres value
538
539
540 map_Kd -options args filename
541
542 Specifies that a color texture file or color procedural texture file is
543linked to the diffuse reflectivity of the material. During rendering,
544the map_Kd value is multiplied by the Kd value.
545
546 "filename" is the name of a color texture file (.mpc), a color
547procedural texture file (.cxc), or an image file.
548
549 The options for the map_Kd statement are listed below. These options
550are described in detail in "Options for texture map statements" on page
5515-18.
552
553 -blendu on | off
554 -blendv on | off
555 -cc on | off
556 -clamp on | off
557 -mm base gain
558 -o u v w
559 -s u v w
560 -t u v w
561 -texres value
562
563
564 map_Ks -options args filename
565
566 Specifies that a color texture file or color procedural texture file is
567linked to the specular reflectivity of the material. During rendering,
568the map_Ks value is multiplied by the Ks value.
569
570 "filename" is the name of a color texture file (.mpc), a color
571procedural texture file (.cxc), or an image file.
572
573 The options for the map_Ks statement are listed below. These options
574are described in detail in "Options for texture map statements" on page
5755-18.
576
577 -blendu on | off
578 -blendv on | off
579 -cc on | off
580 -clamp on | off
581 -mm base gain
582 -o u v w
583 -s u v w
584 -t u v w
585 -texres value
586
587
588 map_Ns -options args filename
589
590 Specifies that a scalar texture file or scalar procedural texture file
591is linked to the specular exponent of the material. During rendering,
592the map_Ns value is multiplied by the Ns value.
593
594 "filename" is the name of a scalar texture file (.mps), a scalar
595procedural texture file (.cxs), or an image file.
596
597 The options for the map_Ns statement are listed below. These options
598are described in detail in "Options for texture map statements" on page
5995-18.
600
601 -blendu on | off
602 -blendv on | off
603 -clamp on | off
604 -imfchan r | g | b | m | l | z
605 -mm base gain
606 -o u v w
607 -s u v w
608 -t u v w
609 -texres value
610
611
612 map_d -options args filename
613
614 Specifies that a scalar texture file or scalar procedural texture file
615is linked to the dissolve of the material. During rendering, the map_d
616value is multiplied by the d value.
617
618 "filename" is the name of a scalar texture file (.mps), a scalar
619procedural texture file (.cxs), or an image file.
620
621 The options for the map_d statement are listed below. These options
622are described in detail in "Options for texture map statements" on page
6235-18.
624
625 -blendu on | off
626 -blendv on | off
627 -clamp on | off
628 -imfchan r | g | b | m | l | z
629 -mm base gain
630 -o u v w
631 -s u v w
632 -t u v w
633 -texres value
634
635
636 map_aat on
637
638 Turns on anti-aliasing of textures in this material without anti-
639aliasing all textures in the scene.
640
641 If you wish to selectively anti-alias textures, first insert this
642statement in the material file. Then, when rendering with the Image
643panel, choose the anti-alias settings: "shadows", "reflections
644polygons", or "polygons only". If using Image from the command line,
645use the -aa or -os options. Do not use the -aat option.
646
647 Image will anti-alias all textures in materials with the map_aat on
648statement, using the oversampling level you choose when you run Image.
649Textures in other materials will not be oversampled.
650
651 You cannot set a different oversampling level individually for each
652material, nor can you anti-alias some textures in a material and not
653others. To anti-alias all textures in all materials, use the -aat
654option from the Image command line. If a material with "map_aat on"
655includes a reflection map, all textures in that reflection map will be
656anti-aliased as well.
657
658 You will not see the effects of map_aat in the Property Editor.
659
660 Tip Some .mpc textures map exhibit undesirable effects around the
661edges of smoothed objects. The "map_aat" statement will correct this.
662
663
664 decal -options args filename
665
666 Specifies that a scalar texture file or a scalar procedural texture
667file is used to selectively replace the material color with the texture
668color.
669
670 "filename" is the name of a scalar texture file (.mps), a scalar
671procedural texture file (.cxs), or an image file.
672
673 During rendering, the Ka, Kd, and Ks values and the map_Ka, map_Kd, and
674map_Ks values are blended according to the following formula:
675
676 result_color=tex_color(tv)*decal(tv)+mtl_color*(1.0-decal(tv))
677
678 where tv is the texture vertex.
679
680 "result_color" is the blended Ka, Kd, and Ks values.
681
682 The options for the decal statement are listed below. These options
683are described in detail in "Options for texture map statements" on page
6845-18.
685
686 -blendu on | off
687 -blendv on | off
688 -clamp on | off
689 -imfchan r | g | b | m | l | z
690 -mm base gain
691 -o u v w
692 -s u v w
693 -t u v w
694 -texres value
695
696
697 disp -options args filename
698
699 Specifies that a scalar texture is used to deform the surface of an
700object, creating surface roughness.
701
702 "filename" is the name of a scalar texture file (.mps), a bump
703procedural texture file (.cxb), or an image file.
704
705 The options for the disp statement are listed below. These options are
706described in detail in "Options for texture map statements" on page 5-
70718.
708
709 -blendu on | off
710 -blendv on | off
711 -clamp on | off
712 -imfchan r | g | b | m | l | z
713 -mm base gain
714 -o u v w
715 -s u v w
716 -t u v w
717 -texres value
718
719
720 bump -options args filename
721
722 Specifies that a bump texture file or a bump procedural texture file is
723linked to the material.
724
725 "filename" is the name of a bump texture file (.mpb), a bump procedural
726texture file (.cxb), or an image file.
727
728 The options for the bump statement are listed below. These options are
729described in detail in "Options for texture map statements" on page 5-
73018.
731
732 -bm mult
733 -clamp on | off
734 -blendu on | off
735 -blendv on | off
736 -imfchan r | g | b | m | l | z
737 -mm base gain
738 -o u v w
739 -s u v w
740 -t u v w
741 -texres value
742
743
744 Options for texture map statements
745
746 The following options and arguments can be used to modify the texture
747map statements.
748
749 -blenu on | off
750
751 The -blendu option turns texture blending in the horizontal direction
752(u direction) on or off. The default is on.
753
754 -blenv on | off
755
756 The -blendv option turns texture blending in the vertical direction (v
757direction) on or off. The default is on.
758
759 -bm mult
760
761 The -bm option specifies a bump multiplier. You can use it only with
762the "bump" statement. Values stored with the texture or procedural
763texture file are multiplied by this value before they are applied to the
764surface.
765
766 "mult" is the value for the bump multiplier. It can be positive or
767negative. Extreme bump multipliers may cause odd visual results because
768only the surface normal is perturbed and the surface position does not
769change. For best results, use values between 0 and 1.
770
771 -boost value
772
773 The -boost option increases the sharpness, or clarity, of mip-mapped
774texture files -- that is, color (.mpc), scalar (.mps), and bump (.mpb)
775files. If you render animations with boost, you may experience some
776texture crawling. The effects of boost are seen when you render in
777Image or test render in Model or PreView; they aren't as noticeable in
778Property Editor.
779
780 "value" is any non-negative floating point value representing the
781degree of increased clarity; the greater the value, the greater the
782clarity. You should start with a boost value of no more than 1 or 2 and
783increase the value as needed. Note that larger values have more
784potential to introduce texture crawling when animated.
785
786 -cc on | off
787
788 The -cc option turns on color correction for the texture. You can use
789it only with the color map statements: map_Ka, map_Kd, and map_Ks.
790
791 -clamp on | off
792
793 The -clamp option turns clamping on or off. When clamping is on,
794textures are restricted to 0-1 in the uvw range. The default is off.
795
796 When clamping is turned on, one copy of the texture is mapped onto the
797surface, rather than repeating copies of the original texture across the
798surface of a polygon, which is the default. Outside of the origin
799texture, the underlying material is unchanged.
800
801 A postage stamp on an envelope or a label on a can of soup is an
802example of a texture with clamping turned on. A tile floor or a
803sidewalk is an example of a texture with clamping turned off.
804
805 Two-dimensional textures are clamped in the u and v dimensions; 3D
806procedural textures are clamped in the u, v, and w dimensions.
807
808 -imfchan r | g | b | m | l | z
809
810 The -imfchan option specifies the channel used to create a scalar or
811bump texture. Scalar textures are applied to:
812
813 transparency
814 specular exponent
815 decal
816 displacement
817
818 The channel choices are:
819
820 r specifies the red channel.
821 g specifies the green channel.
822 b specifies the blue channel.
823 m specifies the matte channel.
824 l specifies the luminance channel.
825 z specifies the z-depth channel.
826
827 The default for bump and scalar textures is "l" (luminance), unless you
828are building a decal. In that case, the default is "m" (matte).
829
830 -mm base gain
831
832 The -mm option modifies the range over which scalar or color texture
833values may vary. This has an effect only during rendering and does not
834change the file.
835
836 "base" adds a base value to the texture values. A positive value makes
837everything brighter; a negative value makes everything dimmer. The
838default is 0; the range is unlimited.
839
840 "gain" expands the range of the texture values. Increasing the number
841increases the contrast. The default is 1; the range is unlimited.
842
843 -o u v w
844
845 The -o option offsets the position of the texture map on the surface by
846shifting the position of the map origin. The default is 0, 0, 0.
847
848 "u" is the value for the horizontal direction of the texture
849
850 "v" is an optional argument.
851 "v" is the value for the vertical direction of the texture.
852
853 "w" is an optional argument.
854 "w" is the value used for the depth of a 3D texture.
855
856 -s u v w
857
858 The -s option scales the size of the texture pattern on the textured
859surface by expanding or shrinking the pattern. The default is 1, 1, 1.
860
861 "u" is the value for the horizontal direction of the texture
862
863 "v" is an optional argument.
864 "v" is the value for the vertical direction of the texture.
865
866 "w" is an optional argument.
867 "w" is a value used for the depth of a 3D texture.
868 "w" is a value used for the amount of tessellation of the displacement
869map.
870
871 -t u v w
872
873 The -t option turns on turbulence for textures. Adding turbulence to a
874texture along a specified direction adds variance to the original image
875and allows a simple image to be repeated over a larger area without
876noticeable tiling effects.
877
878 turbulence also lets you use a 2D image as if it were a solid texture,
879similar to 3D procedural textures like marble and granite.
880
881 "u" is the value for the horizontal direction of the texture
882turbulence.
883
884 "v" is an optional argument.
885 "v" is the value for the vertical direction of the texture turbulence.
886
887 "w" is an optional argument.
888 "w" is a value used for the depth of the texture turbulence.
889
890 By default, the turbulence for every texture map used in a material is
891uvw = (0,0,0). This means that no turbulence will be applied and the 2D
892texture will behave normally.
893
894 Only when you raise the turbulence values above zero will you see the
895effects of turbulence.
896
897 -texres resolution
898
899 The -texres option specifies the resolution of texture created when an
900image is used. The default texture size is the largest power of two
901that does not exceed the original image size.
902
903 If the source image is an exact power of 2, the texture cannot be built
904any larger. If the source image size is not an exact power of 2, you
905can specify that the texture be built at the next power of 2 greater
906than the source image size.
907
908 The original image should be square, otherwise, it will be scaled to
909fit the closest square size that is not larger than the original.
910Scaling reduces sharpness.
911
912
913 Material reflection map
914
915 A reflection map is an environment that simulates reflections in
916specified objects. The environment is represented by a color texture
917file or procedural texture file that is mapped on the inside of an
918infinitely large, space. Reflection maps can be spherical or cubic. A
919spherical reflection map requires only one texture or image file, while
920a cubic reflection map requires six.
921
922 Each material description can contain one reflection map statement that
923specifies a color texture file or a color procedural texture file to
924represent the environment. The material itself must be assigned an
925illumination model of 3 or greater.
926
927 The reflection map statement in the .mtl file defines a local
928reflection map. That is, each material assigned to an object in a scene
929can have an individual reflection map. In PreView, you can assign a
930global reflection map to an object and specify the orientation of the
931reflection map. Rotating the reflection map creates the effect of
932animating reflections independently of object motion. When you replace
933a global reflection map with a local reflection map, the local
934reflection map inherits the transformation of the global reflection map.
935
936 Syntax
937
938 The following syntax statements describe the reflection map statement
939for .mtl files.
940
941 refl -type sphere -options -args filename
942
943 Specifies an infinitely large sphere that casts reflections onto the
944material. You specify one texture file.
945
946 "filename" is the color texture file, color procedural texture file, or
947image file that will be mapped onto the inside of the shape.
948
949 refl -type cube_side -options -args filenames
950
951 Specifies an infinitely large sphere that casts reflections onto the
952material. You can specify different texture files for the "top",
953"bottom", "front", "back", "left", and "right" with the following
954statements:
955
956 refl -type cube_top
957 refl -type cube_bottom
958 refl -type cube_front
959 refl -type cube_back
960 refl -type cube_left
961 refl -type cube_right
962
963 "filenames" are the color texture files, color procedural texture
964files, or image files that will be mapped onto the inside of the shape.
965
966 The "refl" statements for sphere and cube can be used alone or with
967 any combination of the following options. The options and their
968arguments are inserted between "refl" and "filename".
969
970 -blendu on | off
971 -blendv on | off
972 -cc on | off
973 -clamp on | off
974 -mm base gain
975 -o u v w
976 -s u v w
977 -t u v w
978 -texres value
979
980 The options for the reflection map statement are described in detail in
981"Options for texture map statements" on page 18.
982
983
984 Examples
985
986 1 Neon green
987
988 This is a bright green material. When applied to an object, it will
989remain bright green regardless of any lighting in the scene.
990
991 newmtl neon_green
992 Kd 0.0000 1.0000 0.0000
993 illum 0
994
995 2 Flat green
996
997 This is a flat green material.
998
999 newmtl flat_green
1000 Ka 0.0000 1.0000 0.0000
1001 Kd 0.0000 1.0000 0.0000
1002 illum 1
1003
1004 3 Dissolved green
1005
1006 This is a flat green, partially dissolved material.
1007
1008 newmtl diss_green
1009 Ka 0.0000 1.0000 0.0000
1010 Kd 0.0000 1.0000 0.0000
1011 d 0.8000
1012 illum 1
1013
1014 4 Shiny green
1015
1016 This is a shiny green material. When applied to an object, it shows a
1017white specular highlight.
1018
1019 newmtl shiny_green
1020 Ka 0.0000 1.0000 0.0000
1021 Kd 0.0000 1.0000 0.0000
1022 Ks 1.0000 1.0000 1.0000
1023 Ns 200.0000
1024 illum 1
1025
1026 5 Green mirror
1027
1028 This is a reflective green material. When applied to an object, it
1029reflects other objects in the same scene.
1030
1031 newmtl green_mirror
1032 Ka 0.0000 1.0000 0.0000
1033 Kd 0.0000 1.0000 0.0000
1034 Ks 0.0000 1.0000 0.0000
1035 Ns 200.0000
1036 illum 3
1037
1038 6 Fake windshield
1039
1040 This material approximates a glass surface. Is it almost completely
1041transparent, but it shows reflections of other objects in the scene. It
1042will not distort the image of objects seen through the material.
1043
1044 newmtl fake_windsh
1045 Ka 0.0000 0.0000 0.0000
1046 Kd 0.0000 0.0000 0.0000
1047 Ks 0.9000 0.9000 0.9000
1048 d 0.1000
1049 Ns 200
1050 illum 4
1051
1052 7 Fresnel blue
1053
1054 This material exhibits an effect known as Fresnel reflection. When
1055applied to an object, white fringes may appear where the object's
1056surface is viewed at a glancing angle.
1057
1058 newmtl fresnel_blu
1059 Ka 0.0000 0.0000 0.0000
1060 Kd 0.0000 0.0000 0.0000
1061 Ks 0.6180 0.8760 0.1430
1062 Ns 200
1063 illum 5
1064
1065 8 Real windshield
1066
1067 This material accurately represents a glass surface. It filters of
1068colorizes objects that are seen through it. Filtering is done according
1069to the transmission color of the material. The material also distorts
1070the image of objects according to its optical density. Note that the
1071material is not dissolved and that its ambient, diffuse, and specular
1072reflective colors have been set to black. Only the transmission color
1073is non-black.
1074
1075 newmtl real_windsh
1076 Ka 0.0000 0.0000 0.0000
1077 Kd 0.0000 0.0000 0.0000
1078 Ks 0.0000 0.0000 0.0000
1079 Tf 1.0000 1.0000 1.0000
1080 Ns 200
1081 Ni 1.2000
1082 illum 6
1083
1084 9 Fresnel windshield
1085
1086 This material combines the effects in examples 7 and 8.
1087
1088 newmtl fresnel_win
1089 Ka 0.0000 0.0000 1.0000
1090 Kd 0.0000 0.0000 1.0000
1091 Ks 0.6180 0.8760 0.1430
1092 Tf 1.0000 1.0000 1.0000
1093 Ns 200
1094 Ni 1.2000
1095 illum 7
1096
1097 10 Tin
1098
1099 This material is based on spectral reflectance samples taken from an
1100actual piece of tin. These samples are stored in a separate .rfl file
1101that is referred to by name in the material. Spectral sample files
1102(.rfl) can be used in any type of material as an alternative to RGB
1103values.
1104
1105 newmtl tin
1106 Ka spectral tin.rfl
1107 Kd spectral tin.rfl
1108 Ks spectral tin.rfl
1109 Ns 200
1110 illum 3
1111
1112 11 Pine Wood
1113
1114 This material includes a texture map of a pine pattern. The material
1115color is set to "ident" to preserve the texture's true color. When
1116applied to an object, this texture map will affect only the ambient and
1117diffuse regions of that object's surface.
1118
1119 The color information for the texture is stored in a separate .mpc file
1120that is referred to in the material by its name, "pine.mpc". If you use
1121different .mpc files for ambient and diffuse, you will get unrealistic
1122results.
1123
1124 newmtl pine_wood
1125 Ka spectral ident.rfl 1
1126 Kd spectral ident.rfl 1
1127 illum 1
1128 map_Ka pine.mpc
1129 map_Kd pine.mpc
1130
1131 12 Bumpy leather
1132
1133 This material includes a texture map of a leather pattern. The
1134material color is set to "ident" to preserve the texture's true color.
1135When applied to an object, it affects both the color of the object's
1136surface and its apparent bumpiness.
1137
1138 The color information for the texture is stored in a separate .mpc file
1139that is referred to in the material by its name, "brown.mpc". The bump
1140information is stored in a separate .mpb file that is referred to in the
1141material by its name, "leath.mpb". The -bm option is used to raise the
1142apparent height of the leather bumps.
1143
1144 newmtl bumpy_leath
1145 Ka spectral ident.rfl 1
1146 Kd spectral ident.rfl 1
1147 Ks spectral ident.rfl 1
1148 illum 2
1149 map_Ka brown.mpc
1150 map_Kd brown.mpc
1151 map_Ks brown.mpc
1152 bump -bm 2.000 leath.mpb
1153
1154 13 Frosted window
1155
1156 This material includes a texture map used to alter the opacity of an
1157object's surface. The material color is set to "ident" to preserve the
1158texture's true color. When applied to an object, the object becomes
1159transparent in certain areas and opaque in others.
1160
1161 The variation between opaque and transparent regions is controlled by
1162scalar information stored in a separate .mps file that is referred to in
1163the material by its name, "window.mps". The "-mm" option is used to
1164shift and compress the range of opacity.
1165
1166 newmtl frost_wind
1167 Ka 0.2 0.2 0.2
1168 Kd 0.6 0.6 0.6
1169 Ks 0.1 0.1 0.1
1170 d 1
1171 Ns 200
1172 illum 2
1173 map_d -mm 0.200 0.800 window.mps
1174
1175 14 Shifted logo
1176
1177 This material includes a texture map which illustrates how a texture's
1178origin may be shifted left/right (the "u" direction) or up/down (the "v"
1179direction). The material color is set to "ident" to preserve the
1180texture's true color.
1181
1182 In this example, the original image of the logo is off-center to the
1183left. To compensate, the texture's origin is shifted back to the right
1184(the positive "u" direction) using the "-o" option to modify the origin.
1185
1186 Ka spectral ident.rfl 1
1187 Kd spectral ident.rfl 1
1188 Ks spectral ident.rfl 1
1189 illum 2
1190 map_Ka -o 0.200 0.000 0.000 logo.mpc
1191 map_Kd -o 0.200 0.000 0.000 logo.mpc
1192 map_Ks -o 0.200 0.000 0.000 logo.mpc
1193
1194 15 Scaled logo
1195
1196 This material includes a texture map showing how a texture may be
1197scaled left or right (in the "u" direction) or up and down (in the "v"
1198direction). The material color is set to "ident" to preserve the
1199texture's true color.
1200
1201 In this example, the original image of the logo is too small. To
1202compensate, the texture is scaled slightly to the right (in the positive
1203"u" direction) and up (in the positive "v" direction) using the "-s"
1204option to modify the scale.
1205
1206 Ka spectral ident.rfl 1
1207 Kd spectral ident.rfl 1
1208 Ks spectral ident.rfl 1
1209 illum 2
1210 map_Ka -s 1.200 1.200 0.000 logo.mpc
1211 map_Kd -s 1.200 1.200 0.000 logo.mpc
1212 map_Ks -s 1.200 1.200 0.000 logo.mpc
1213
1214 16 Chrome with spherical reflection map
1215
1216 This illustrates a common use for local reflection maps (defined in a
1217material).
1218
1219 this material is highly reflective with no diffuse or ambient
1220contribution. Its reflection map is an image with silver streaks that
1221yields a chrome appearance when viewed as a reflection.
1222
1223 ka 0 0 0
1224 kd 0 0 0
1225 ks .7 .7 .7
1226 illum 1
1227 refl -type sphere chrome.rla
1228
1229
1230 Illumination models
1231
1232 The following list defines the terms and vectors that are used in the
1233illumination model equations:
1234
1235 Term Definition
1236
1237 Ft Fresnel reflectance
1238 Ft Fresnel transmittance
1239 Ia ambient light
1240 I light intensity
1241 Ir intensity from reflected direction
1242 (reflection map and/or ray tracing)
1243 It intensity from transmitted direction
1244 Ka ambient reflectance
1245 Kd diffuse reflectance
1246 Ks specular reflectance
1247 Tf transmission filter
1248
1249 Vector Definition
1250
1251 H unit vector bisector between L and V
1252 L unit light vector
1253 N unit surface normal
1254 V unit view vector
1255
1256 The illumination models are:
1257
1258 0 This is a constant color illumination model. The color is the
1259specified Kd for the material. The formula is:
1260
1261 color = Kd
1262
1263 1 This is a diffuse illumination model using Lambertian shading. The
1264color includes an ambient constant term and a diffuse shading term for
1265each light source. The formula is
1266
1267 color = KaIa + Kd { SUM j=1..ls, (N * Lj)Ij }
1268
1269 2 This is a diffuse and specular illumination model using Lambertian
1270shading and Blinn's interpretation of Phong's specular illumination
1271model (BLIN77). The color includes an ambient constant term, and a
1272diffuse and specular shading term for each light source. The formula
1273is:
1274
1275 color = KaIa
1276 + Kd { SUM j=1..ls, (N*Lj)Ij }
1277 + Ks { SUM j=1..ls, ((H*Hj)^Ns)Ij }
1278
1279 3 This is a diffuse and specular illumination model with reflection
1280using Lambertian shading, Blinn's interpretation of Phong's specular
1281illumination model (BLIN77), and a reflection term similar to that in
1282Whitted's illumination model (WHIT80). The color includes an ambient
1283constant term and a diffuse and specular shading term for each light
1284source. The formula is:
1285
1286 color = KaIa
1287 + Kd { SUM j=1..ls, (N*Lj)Ij }
1288 + Ks ({ SUM j=1..ls, ((H*Hj)^Ns)Ij } + Ir)
1289
1290 Ir = (intensity of reflection map) + (ray trace)
1291
1292 4 The diffuse and specular illumination model used to simulate glass
1293is the same as illumination model 3. When using a very low dissolve
1294(approximately 0.1), specular highlights from lights or reflections
1295become imperceptible.
1296
1297 Simulating glass requires an almost transparent object that still
1298reflects strong highlights. The maximum of the average intensity of
1299highlights and reflected lights is used to adjust the dissolve factor.
1300The formula is:
1301
1302 color = KaIa
1303 + Kd { SUM j=1..ls, (N*Lj)Ij }
1304 + Ks ({ SUM j=1..ls, ((H*Hj)^Ns)Ij } + Ir)
1305
1306 5 This is a diffuse and specular shading models similar to
1307illumination model 3, except that reflection due to Fresnel effects is
1308introduced into the equation. Fresnel reflection results from light
1309striking a diffuse surface at a grazing or glancing angle. When light
1310reflects at a grazing angle, the Ks value approaches 1.0 for all color
1311samples. The formula is:
1312
1313 color = KaIa
1314 + Kd { SUM j=1..ls, (N*Lj)Ij }
1315 + Ks ({ SUM j=1..ls, ((H*Hj)^Ns)Ij Fr(Lj*Hj,Ks,Ns)Ij} +
1316Fr(N*V,Ks,Ns)Ir})
1317
1318
1319 6 This is a diffuse and specular illumination model similar to that
1320used by Whitted (WHIT80) that allows rays to refract through a surface.
1321The amount of refraction is based on optical density (Ni). The
1322intensity of light that refracts is equal to 1.0 minus the value of Ks,
1323and the resulting light is filtered by Tf (transmission filter) as it
1324passes through the object. The formula is:
1325
1326 color = KaIa
1327 + Kd { SUM j=1..ls, (N*Lj)Ij }
1328 + Ks ({ SUM j=1..ls, ((H*Hj)^Ns)Ij } + Ir)
1329 + (1.0 - Ks) TfIt
1330
1331 7 This illumination model is similar to illumination model 6, except
1332that reflection and transmission due to Fresnel effects has been
1333introduced to the equation. At grazing angles, more light is reflected
1334and less light is refracted through the object. The formula is:
1335
1336 color = KaIa
1337 + Kd { SUM j=1..ls, (N*Lj)Ij }
1338 + Ks ({ SUM j=1..ls, ((H*Hj)^Ns)Ij Fr(Lj*Hj,Ks,Ns)Ij} +
1339Fr(N*V,Ks,Ns)Ir})
1340
1341 + (1.0 - Kx)Ft (N*V,(1.0-Ks),Ns)TfIt
1342
1343 8 This illumination model is similar to illumination model 3 without
1344ray tracing. The formula is:
1345
1346 color = KaIa
1347 + Kd { SUM j=1..ls, (N*Lj)Ij }
1348 + Ks ({ SUM j=1..ls, ((H*Hj)^Ns)Ij } + Ir)
1349
1350 Ir = (intensity of reflection map)
1351
1352 9 This illumination model is similar to illumination model 4without
1353ray tracing. The formula is:
1354
1355
1356 color = KaIa
1357 + Kd { SUM j=1..ls, (N*Lj)Ij }
1358 + Ks ({ SUM j=1..ls, ((H*Hj)^Ns)Ij } + Ir)
1359
1360 Ir = (intensity of reflection map)
1361
1362 10 This illumination model is used to cast shadows onto an invisible
1363surface. This is most useful when compositing computer-generated
1364imagery onto live action, since it allows shadows from rendered objects
1365to be composited directly on top of video-grabbed images. The equation
1366for computation of a shadowmatte is formulated as follows.
1367
1368 color = Pixel color. The pixel color of a shadowmatte material is
1369always black.
1370
1371 color = black
1372
1373 M = Matte channel value. This is the image channel which typically
1374represents the opacity of the point on the surface. To store the shadow
1375in the matte channel of the image, it is calculated as:
1376
1377 M = 1 - W / P
1378
1379 where:
1380
1381 P = Unweighted sum. This is the sum of all S values for each light:
1382
1383 P = S1 + S2 + S3 + .....
1384
1385 W = Weighted sum. This is the sum of all S values, each weighted by
1386the visibility factor (Q) for the light:
1387
1388 W = (S1 * Q1) + (S2 * Q2) + .....
1389
1390 Q = Visibility factor. This is the amount of light from a particular
1391light source that reaches the point to be shaded, after traveling
1392through all shadow objects between the light and the point on the
1393surface. Q = 0 means no light reached the point to be shaded; it was
1394blocked by shadow objects, thus casting a shadow. Q = 1 means that
1395nothing blocked the light, and no shadow was cast. 0 < Q < 1 means that
1396the light was partially blocked by objects that were partially
1397dissolved.
1398
1399 S = Summed brightness. This is the sum of the spectral sample
1400intensities for a particular light. The samples are variable, but the
1401default is 3:
1402
1403 S = samp1 + samp2 + samp3.
1404
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