summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoe Crayne <joe@jerkface.net>2019-06-10 23:31:31 -0400
committerJoe Crayne <joe@jerkface.net>2019-06-10 23:31:31 -0400
commitb2f326bc7d7e1a7896b4b47e6c5fb5899c53aebf (patch)
tree02978fedc49e172ee63de350e20c1ae4f147aa39
parente4102da4f6e0eeaba3c8f7d658c5b4872d9d0ddb (diff)
Added Wavefront OBJ format specification.
-rw-r--r--doc/OBJ.spec3013
1 files changed, 3013 insertions, 0 deletions
diff --git a/doc/OBJ.spec b/doc/OBJ.spec
new file mode 100644
index 0000000..09b6e72
--- /dev/null
+++ b/doc/OBJ.spec
@@ -0,0 +1,3013 @@
1B1. Object Files (.obj)
2
3Object files define the geometry and other properties for objects in
4Wavefront's Advanced Visualizer. Object files can also be used to
5transfer geometric data back and forth between the Advanced Visualizer
6and other applications.
7
8Object files can be in ASCII format (.obj) or binary format (.mod).
9This appendix describes the ASCII format for object files. These files
10must have the extension .obj.
11
12In this release, the .obj file format supports both polygonal objects
13and free-form objects. Polygonal geometry uses points, lines, and faces
14to define objects while free-form geometry uses curves and surfaces.
15
16About this section
17
18The .obj appendix is for those who want to use the .obj format to
19translate geometric data from other software applications to Wavefront
20products. It also provides information for Advanced Visualizer users
21who want detailed information on the Wavefront .obj file format.
22
23If you are a 2.11 user and want to understand the significance of the
243.0 release and how it affects your existing files, you may be
25especially interested in the section called "Superseded statements" at
26the end of the appendix. The section, "Patches and free-form surfaces,"
27gives examples of how 2.11 patches look in 3.0.
28
29How this section is organized
30
31Most of this appendix describes the different parts of an .obj file and
32how those parts are arranged in the file. The three sections at the end
33of the appendix provide background information on the 3.0 release of
34the .obj format.
35
36The .obj appendix includes the following sections:
37
38o File structure
39
40o General statement
41
42o Vertex data
43
44o Specifying free-form curves/surfaces
45
46o Free-form curve/surface attributes
47
48o Elements
49
50o Free-form curve/surface body statements
51
52o Connectivity between free-form surfaces
53
54o Grouping
55
56o Display/render attributes
57
58o Comments
59
60o Mathematics for free-form curves/surfaces
61
62o Superseded statements
63
64o Patches and free-form surfaces
65
66---------------
67
68 The curve and surface extensions to the .obj file format were
69 developed in conjunction with mental images GmbH&Co.KG, Berlin,
70 Germany, as part of a joint development project to incorporate
71 free-form surfaces into Wavefront's Advanced Visualizer.
72
73File structure
74
75The following types of data may be included in an .obj file. In this
76list, the keyword (in parentheses) follows the data type.
77
78Vertex data
79
80o geometric vertices (v)
81
82o texture vertices (vt)
83
84o vertex normals (vn)
85
86o parameter space vertices (vp)
87 Free-form curve/surface attributes
88
89o rational or non-rational forms of curve or surface type:
90 basis matrix, Bezier, B-spline, Cardinal, Taylor (cstype)
91
92o degree (deg)
93
94o basis matrix (bmat)
95
96o step size (step)
97
98Elements
99
100o point (p)
101
102o line (l)
103
104o face (f)
105
106o curve (curv)
107
108o 2D curve (curv2)
109
110o surface (surf)
111
112Free-form curve/surface body statements
113
114o parameter values (parm)
115
116o outer trimming loop (trim)
117
118o inner trimming loop (hole)
119
120o special curve (scrv)
121
122o special point (sp)
123
124o end statement (end)
125
126Connectivity between free-form surfaces
127
128
129o connect (con)
130
131Grouping
132
133o group name (g)
134
135o smoothing group (s)
136
137o merging group (mg)
138
139o object name (o)
140
141Display/render attributes
142
143o bevel interpolation (bevel)
144
145o color interpolation (c_interp)
146
147o dissolve interpolation (d_interp)
148
149o level of detail (lod)
150
151o material name (usemtl)
152
153o material library (mtllib)
154
155o shadow casting (shadow_obj)
156
157o ray tracing (trace_obj)
158
159o curve approximation technique (ctech)
160
161o surface approximation technique (stech)
162
163
164The following diagram shows how these parts fit together in a typical
165.obj file.
166
167Figure B1-1. Typical .obj file structure
168
169General statement
170
171call filename.ext arg1 arg2 . . .
172
173 Reads the contents of the specified .obj or .mod file at this
174 location. The call statement can be inserted into .obj files using
175 a text editor.
176
177 filename.ext is the name of the .obj or .mod file to be read. You
178 must include the extension with the filename.
179
180 arg1 arg2 . . . specifies a series of optional integer arguments
181 that are passed to the called file. There is no limit to the number
182 of nested calls that can be made.
183
184 Arguments passed to the called file are substituted in the same way
185 as in UNIX scripts; for example, $1 in the called file is replaced
186 by arg1, $2 in the called file is replaced by arg2, and so on.
187
188 If the frame number is needed in the called file for variable
189 substitution, "$1" must be used as the first argument in the call
190 statement. For example:
191
192 call filename.obj $1
193
194 Then the statement in the called file,
195
196 scmp filename.pv $1
197
198 will work as expected. For more information on the scmp statement,
199 see appendix C, Variable Substitution for more information.
200
201 Another method to do the same thing is:
202
203 scmp filename.pv $1
204
205 call filename.obj
206
207 Using this method, the scmp statement provides the .pv file for all
208 subsequently called .obj or .mod files.
209
210csh command
211
212csh -command
213
214 Executes the requested UNIX command. If the UNIX command returns an
215 error, the parser flags an error during parsing.
216
217 If a dash (-) precedes the UNIX command, the error is ignored.
218
219 command is the UNIX command.
220
221Vertex data
222
223Vertex data provides coordinates for:
224
225o geometric vertices
226
227o texture vertices
228
229o vertex normals
230
231For free-form objects, the vertex data also provides:
232
233o parameter space vertices
234
235The vertex data is represented by four vertex lists; one for each type
236of vertex coordinate. A right-hand coordinate system is used to specify
237the coordinate locations.
238
239The following sample is a portion of an .obj file that contains the
240four types of vertex information.
241
242 v -5.000000 5.000000 0.000000
243 v -5.000000 -5.000000 0.000000
244 v 5.000000 -5.000000 0.000000
245 v 5.000000 5.000000 0.000000
246 vt -5.000000 5.000000 0.000000
247 vt -5.000000 -5.000000 0.000000
248 vt 5.000000 -5.000000 0.000000
249 vt 5.000000 5.000000 0.000000
250 vn 0.000000 0.000000 1.000000
251 vn 0.000000 0.000000 1.000000
252 vn 0.000000 0.000000 1.000000
253 vn 0.000000 0.000000 1.000000
254 vp 0.210000 3.590000
255 vp 0.000000 0.000000
256 vp 1.000000 0.000000
257 vp 0.500000 0.500000
258
259
260
261When vertices are loaded into the Advanced Visualizer, they are
262sequentially numbered, starting with 1. These reference numbers are
263used in element statements.
264
265Syntax
266
267The following syntax statements are listed in order of complexity.
268
269v x y z w
270
271 Polygonal and free-form geometry statement.
272
273 Specifies a geometric vertex and its x y z coordinates. Rational
274 curves and surfaces require a fourth homogeneous coordinate, also
275 called the weight.
276
277 x y z are the x, y, and z coordinates for the vertex. These are
278 floating point numbers that define the position of the vertex in
279 three dimensions.
280
281 w is the weight required for rational curves and surfaces. It is
282 not required for non-rational curves and surfaces. If you do not
283 specify a value for w, the default is 1.0.
284
285 NOTE: A positive weight value is recommended. Using zero or
286 negative values may result in an undefined point in a curve or
287 surface.
288
289vp u v w
290
291 Free-form geometry statement.
292
293 Specifies a point in the parameter space of a curve or surface.
294
295 The usage determines how many coordinates are required. Special
296 points for curves require a 1D control point (u only) in the
297 parameter space of the curve. Special points for surfaces require a
298 2D point (u and v) in the parameter space of the surface. Control
299 points for non-rational trimming curves require u and v
300 coordinates. Control points for rational trimming curves require u,
301 v, and w (weight) coordinates.
302
303 u is the point in the parameter space of a curve or the first
304 coordinate in the parameter space of a surface.
305
306 v is the second coordinate in the parameter space of a surface.
307
308 w is the weight required for rational trimming curves. If you do
309 not specify a value for w, it defaults to 1.0.
310
311 NOTE: For additional information on parameter vertices, see the
312 curv2 and sp statements
313
314vn i j k
315
316 Polygonal and free-form geometry statement.
317
318 Specifies a normal vector with components i, j, and k.
319
320 Vertex normals affect the smooth-shading and rendering of geometry.
321 For polygons, vertex normals are used in place of the actual facet
322 normals. For surfaces, vertex normals are interpolated over the
323 entire surface and replace the actual analytic surface normal.
324
325 When vertex normals are present, they supersede smoothing groups.
326
327 i j k are the i, j, and k coordinates for the vertex normal. They
328 are floating point numbers.
329
330vt u v w
331
332 Vertex statement for both polygonal and free-form geometry.
333
334 Specifies a texture vertex and its coordinates. A 1D texture
335 requires only u texture coordinates, a 2D texture requires both u
336 and v texture coordinates, and a 3D texture requires all three
337 coordinates.
338
339 u is the value for the horizontal direction of the texture.
340
341 v is an optional argument.
342
343 v is the value for the vertical direction of the texture. The
344 default is 0.
345
346 w is an optional argument.
347
348 w is a value for the depth of the texture. The default is 0.
349
350Specifying free-form curves/surfaces
351
352There are three steps involved in specifying a free-form curve or
353surface element.
354
355o Specify the type of curve or surface (basis matrix, Bezier,
356 B-spline, Cardinal, or Taylor) using free-form curve/surface
357 attributes.
358
359o Describe the curve or surface with element statements.
360
361o Supply additional information, using free-form curve/surface
362 body statements
363
364The next three sections of this appendix provide detailed information
365on each of these steps.
366
367Data requirements for curves and surfaces
368
369All curves and surfaces require a certain set of data. This consists of
370the following:
371
372Free-form curve/surface attributes
373
374o All curves and surfaces require type data, which is given with
375 the cstype statement.
376
377o All curves and surfaces require degree data, which is given
378 with the deg statement.
379
380o Basis matrix curves or surfaces require a bmat statement.
381
382o Basis matrix curves or surfaces also require a step size, which
383 is given with the step statement.
384
385Elements
386
387o All curves and surfaces require control points, which are
388 referenced in the curv, curv2, or surf statements.
389
390o 3D curves and surfaces require a parameter range, which is
391 given in the curv and surf statements, respectively.
392
393Free-form curve/surface body statements
394
395o All curves and surfaces require a set of global parameters or a
396 knot vector, both of which are given with the parm statement.
397
398o All curves and surfaces body statements require an explicit end
399 statement.
400
401Error checks
402
403The above set of data starts out empty with no default values when
404reading of an .obj file begins. While the file is being read,
405statements are encountered, information is accumulated, and some errors
406may be reported.
407
408When the end statement is encountered, the following error checks,
409which involve consistency between various statements, are performed:
410
411o All required information is present.
412
413o The number of control points, number of parameter values
414 (knots), and degree are consistent with the curve or surface
415 type. If the type is bmatrix, the step size is also consistent.
416 (For more information, refer to the parameter vector equations
417 in the section, "Mathematics of free-form curves/ surfaces" at
418 the end of appendix B1.)
419
420o If the type is bmatrix and the degree is n, the size of the
421 basis matrix is (n + 1) x (n + 1).
422
423Note that any information given by the state-setting statements remains
424in effect from one curve or surface to the next. Information given
425within a curve or surface body is only effective for the curve or
426surface it is given with.
427
428
429
430Free-form curve/surface attributes
431
432Five types of free-form geometry are available in the .obj file
433format:
434
435o Bezier
436
437o basis matrix
438
439o B-spline
440
441o Cardinal
442
443o Taylor
444
445You can apply these types only to curves and surfaces. Each of these
446five types can be rational or non-rational.
447
448In addition to specifying the type, you must define the degree for the
449curve or surface. For basis matrix curve and surface elements, you must
450also specify the basis matrix and step size.
451
452All free-form curve and surface attribute statements are state-setting.
453This means that once an attribute statement is set, it applies to all
454elements that follow until it is reset to a different value.
455
456Syntax
457
458The following syntax statements are listed in order of use.
459
460cstype rat type
461
462 Free-form geometry statement.
463
464 Specifies the type of curve or surface and indicates a rational or
465 non-rational form.
466
467 rat is an optional argument.
468
469 rat specifies a rational form for the curve or surface type. If rat
470 is not included, the curve or surface is non-rational
471
472 type specifies the curve or surface type. Allowed types are:
473
474 bmatrix basis matrix
475
476 bezier Bezier
477
478 bspline B-spline
479
480 cardinal Cardinal
481
482 taylor Taylor
483
484 There is no default. A value must be supplied.
485
486deg degu degv
487
488 Free-form geometry statement.
489
490 Sets the polynomial degree for curves and surfaces.
491
492 degu is the degree in the u direction. It is required for both
493 curves and surfaces.
494
495 degv is the degree in the v direction. It is required only for
496 surfaces. For Bezier, B-spline, Taylor, and basis matrix, there is
497 no default; a value must be supplied. For Cardinal, the degree is
498 always 3. If some other value is given for Cardinal, it will be
499 ignored.
500
501bmat u matrix
502
503bmat v matrix
504
505 Free-form geometry statement.
506
507 Sets the basis matrices used for basis matrix curves and surfaces.
508 The u and v values must be specified in separate bmat statements.
509
510 NOTE: The deg statement must be given before the bmat statements
511 and the size of the matrix must be appropriate for the degree.
512
513 u specifies that the basis matrix is applied in the u direction.
514
515 v specifies that the basis matrix is applied in the v direction.
516
517 matrix lists the contents of the basis matrix with column subscript
518 j varying the fastest. If n is the degree in the given u or v
519 direction, the matrix (i,j) should be of size (n + 1) x (n + 1).
520
521 There is no default. A value must be supplied.
522
523 NOTE: The arrangement of the matrix is different from that commonly
524 found in other references. For more information, see the examples
525 at the end of this section and also the section, "Mathematics for
526 free-form curves and surfaces."
527
528step stepu stepv
529
530 Free-form geometry statement.
531
532 Sets the step size for curves and surfaces that use a basis
533 matrix.
534
535 stepu is the step size in the u direction. It is required for both
536 curves and surfaces that use a basis matrix.
537
538 stepv is the step size in the v direction. It is required only for
539 surfaces that use a basis matrix. There is no default. A value must
540 be supplied.
541
542 When a curve or surface is being evaluated and a transition from
543 one segment or patch to the next occurs, the set of control points
544 used is incremented by the step size. The appropriate step size
545 depends on the representation type, which is expressed through the
546 basis matrix, and on the degree.
547
548 That is, suppose we are given a curve with k control points:
549 {v , ... v }
550 1 k
551
552 If the curve is of degree n, then n + 1 control points are needed
553 for each polynomial segment. If the step size is given as s, then
554 the ith polynomial segment, where i = 0 is the first segment, will
555 use the control points:
556 {v ,...,v }
557 is+1 is+n+1
558
559 For example, for Bezier curves, s = n .
560
561 For surfaces, the above description applies independently to each
562 parametric direction.
563
564 When you create a file which uses the basis matrix type, be sure to
565 specify a step size appropriate for the current curve or surface
566 representation.
567
568Examples
569
5701. Cubic Bezier surface made with a basis matrix
571
572 To create a cubic Bezier surface:
573
574 cstype bmatrix
575 deg 3 3
576 step 3 3
577 bmat u 1 -3 3 -1 \
578 0 3 -6 3 \
579 0 0 3 -3 \
580 0 0 0 1
581 bmat v 1 -3 3 -1 \
582 0 3 -6 3 \
583 0 0 3 -3 \
584 0 0 0 1
585
5862. Hermite curve made with a basis matrix
587
588 To create a Hermite curve:
589
590 cstype bmatrix
591 deg 3
592 step 2
593 bmat u 1 0 -3 2 0 0 3 -2 \
594 0 1 -2 1 0 0 -1 1
595
5963. Bezier in u direction with B-spline in v direction;
597 made with a basis matrix
598
599 To create a surface with a cubic Bezier in the u direction and
600 cubic uniform B-spline in the v direction:
601
602 cstype bmatrix
603 deg 3 3
604 step 3 1
605 bmat u 1 -3 3 -1 \
606 0 3 -6 3 \
607 0 0 3 -3 \
608 0 0 0 1
609 bmat v 0.16666 -0.50000 0.50000 -0.16666 \
610 0.66666 0.00000 -1.00000 0.50000 \
611 0.16666 0.50000 0.50000 -0.50000 \
612 0.00000 0.00000 0.00000 0.16666
613
614
615
616Elements
617
618For polygonal geometry, the element types available in the .obj file
619are:
620
621o points
622
623o lines
624
625o faces
626
627For free-form geometry, the element types available in the .obj file
628are:
629
630o curve
631
632o 2D curve on a surface
633
634o surface
635
636All elements can be freely intermixed in the file.
637
638Referencing vertex data
639
640For all elements, reference numbers are used to identify geometric
641vertices, texture vertices, vertex normals, and parameter space
642vertices.
643
644Each of these types of vertices is numbered separately, starting with
6451. This means that the first geometric vertex in the file is 1, the
646second is 2, and so on. The first texture vertex in the file is 1, the
647second is 2, and so on. The numbering continues sequentially throughout
648the entire file. Frequently, files have multiple lists of vertex data.
649This numbering sequence continues even when vertex data is separated by
650other data.
651
652In addition to counting vertices down from the top of the first list in
653the file, you can also count vertices back up the list from an
654element's position in the file. When you count up the list from an
655element, the reference numbers are negative. A reference number of -1
656indicates the vertex immediately above the element. A reference number
657of -2 indicates two references above and so on.
658
659Referencing groups of vertices
660
661Some elements, such as faces and surfaces, may have a triplet of
662numbers that reference vertex data.These numbers are the reference
663numbers for a geometric vertex, a texture vertex, and a vertex normal.
664
665Each triplet of numbers specifies a geometric vertex, texture vertex,
666and vertex normal. The reference numbers must be in order and must
667separated by slashes (/).
668
669o The first reference number is the geometric vertex.
670
671o The second reference number is the texture vertex. It follows
672 the first slash.
673
674o The third reference number is the vertex normal. It follows the
675 second slash.
676
677There is no space between numbers and the slashes. There may be more
678than one series of geometric vertex/texture vertex/vertex normal
679numbers on a line.
680
681The following is a portion of a sample file for a four-sided face
682element:
683
684 f 1/1/1 2/2/2 3/3/3 4/4/4
685
686Using v, vt, and vn to represent geometric vertices, texture vertices,
687and vertex normals, the statement would read:
688
689 f v/vt/vn v/vt/vn v/vt/vn v/vt/vn
690
691If there are only vertices and vertex normals for a face element (no
692texture vertices), you would enter two slashes (//). For example, to
693specify only the vertex and vertex normal reference numbers, you would
694enter:
695
696 f 1//1 2//2 3//3 4//4
697
698When you are using a series of triplets, you must be consistent in the
699way you reference the vertex data. For example, it is illegal to give
700vertex normals for some vertices, but not all.
701
702The following is an example of an illegal statement.
703
704 f 1/1/1 2/2/2 3//3 4//4
705
706Syntax
707
708The following syntax statements are listed in order of complexity of
709geometry.
710
711p v1 v2 v3 . . .
712
713 Polygonal geometry statement.
714
715 Specifies a point element and its vertex. You can specify multiple
716 points with this statement. Although points cannot be shaded or
717 rendered, they are used by other Advanced Visualizer programs.
718
719 v is the vertex reference number for a point element. Each point
720 element requires one vertex. Positive values indicate absolute
721 vertex numbers. Negative values indicate relative vertex numbers.
722
723l v1/vt1 v2/vt2 v3/vt3 . . .
724
725 Polygonal geometry statement.
726
727 Specifies a line and its vertex reference numbers. You can
728 optionally include the texture vertex reference numbers. Although
729 lines cannot be shaded or rendered, they are used by other Advanced
730 Visualizer programs.
731
732 The reference numbers for the vertices and texture vertices must be
733 separated by a slash (/). There is no space between the number and
734 the slash.
735
736 v is a reference number for a vertex on the line. A minimum of two
737 vertex numbers are required. There is no limit on the maximum.
738 Positive values indicate absolute vertex numbers. Negative values
739 indicate relative vertex numbers.
740
741 vt is an optional argument.
742
743 vt is the reference number for a texture vertex in the line
744 element. It must always follow the first slash.
745
746f v1/vt1/vn1 v2/vt2/vn2 v3/vt3/vn3 . . .
747
748 Polygonal geometry statement.
749
750 Specifies a face element and its vertex reference number. You can
751 optionally include the texture vertex and vertex normal reference
752 numbers.
753
754 The reference numbers for the vertices, texture vertices, and
755 vertex normals must be separated by slashes (/). There is no space
756 between the number and the slash.
757
758 v is the reference number for a vertex in the face element. A
759 minimum of three vertices are required.
760
761 vt is an optional argument.
762
763 vt is the reference number for a texture vertex in the face
764 element. It always follows the first slash.
765
766 vn is an optional argument.
767
768 vn is the reference number for a vertex normal in the face element.
769 It must always follow the second slash.
770
771 Face elements use surface normals to indicate their orientation. If
772 vertices are ordered counterclockwise around the face, both the
773 face and the normal will point toward the viewer. If the vertex
774 ordering is clockwise, both will point away from the viewer. If
775 vertex normals are assigned, they should point in the general
776 direction of the surface normal, otherwise unpredictable results
777 may occur.
778
779 If a face has a texture map assigned to it and no texture vertices
780 are assigned in the f statement, the texture map is ignored when
781 the element is rendered.
782
783 NOTE: Any references to fo (face outline) are no longer valid as of
784 version 2.11. You can use f (face) to get the same results.
785 References to fo in existing .obj files will still be read,
786 however, they will be written out as f when the file is saved.
787
788curv u0 u1 v1 v2 . . .
789
790 Element statement for free-form geometry.
791
792 Specifies a curve, its parameter range, and its control vertices.
793 Although curves cannot be shaded or rendered, they are used by
794 other Advanced Visualizer programs.
795
796 u0 is the starting parameter value for the curve. This is a
797 floating point number.
798
799 u1 is the ending parameter value for the curve. This is a floating
800 point number.
801
802 v is the vertex reference number for a control point. You can
803 specify multiple control points. A minimum of two control points
804 are required for a curve.
805
806 For a non-rational curve, the control points must be 3D. For a
807 rational curve, the control points are 3D or 4D. The fourth
808 coordinate (weight) defaults to 1.0 if omitted.
809
810curv2 vp1 vp2 vp3. . .
811
812 Free-form geometry statement.
813
814 Specifies a 2D curve on a surface and its control points. A 2D
815 curve is used as an outer or inner trimming curve, as a special
816 curve, or for connectivity.
817
818 vp is the parameter vertex reference number for the control point.
819 You can specify multiple control points. A minimum of two control
820 points is required for a 2D curve.
821
822 The control points are parameter vertices because the curve must
823 lie in the parameter space of some surface. For a non-rational
824 curve, the control vertices can be 2D. For a rational curve, the
825 control vertices can be 2D or 3D. The third coordinate (weight)
826 defaults to 1.0 if omitted.
827
828surf s0 s1 t0 t1 v1/vt1/vn1 v2/vt2/vn2 . . .
829
830 Element statement for free-form geometry.
831
832 Specifies a surface, its parameter range, and its control vertices.
833 The surface is evaluated within the global parameter range from s0
834 to s1 in the u direction and t0 to t1 in the v direction.
835
836 s0 is the starting parameter value for the surface in the u
837 direction.
838
839 s1 is the ending parameter value for the surface in the u
840 direction.
841
842 t0 is the starting parameter value for the surface in the v
843 direction.
844
845 t1 is the ending parameter value for the surface in the v
846 direction.
847
848 v is the reference number for a control vertex in the surface.
849
850 vt is an optional argument.
851
852 vt is the reference number for a texture vertex in the surface. It
853 must always follow the first slash.
854
855 vn is an optional argument.
856
857 vn is the reference number for a vertex normal in the surface. It
858 must always follow the second slash.
859
860 For a non-rational surface, the control vertices are 3D. For a
861 rational surface the control vertices can be 3D or 4D. The fourth
862 coordinate (weight) defaults to 1.0 if ommitted.
863
864 NOTE: For more information on the ordering of control points for
865 survaces, refer to the section on surfaces and control points in
866 "mathematics of free-form curves/surfaces" at the end of this
867 appendix.
868
869
870
871
872Examples
873
874These are examples for polygonal geometry.
875
876For examples using free-form geometry, see the examples at the end of
877the next section, "Free-form curve/surface body statements."
878
8791. Square
880
881This example shows a square that measures two units on each side and
882faces in the positive direction (toward the camera). Note that the
883ordering of the vertices is counterclockwise. This ordering determines
884that the square is facing forward.
885
886 v 0.000000 2.000000 0.000000
887 v 0.000000 0.000000 0.000000
888 v 2.000000 0.000000 0.000000
889 v 2.000000 2.000000 0.000000
890 f 1 2 3 4
891
8922. Cube
893
894This is a cube that measures two units on each side. Each vertex is
895shared by three different faces.
896
897 v 0.000000 2.000000 2.000000
898 v 0.000000 0.000000 2.000000
899 v 2.000000 0.000000 2.000000
900 v 2.000000 2.000000 2.000000
901 v 0.000000 2.000000 0.000000
902 v 0.000000 0.000000 0.000000
903 v 2.000000 0.000000 0.000000
904 v 2.000000 2.000000 0.000000
905 f 1 2 3 4
906 f 8 7 6 5
907 f 4 3 7 8
908 f 5 1 4 8
909 f 5 6 2 1
910 f 2 6 7 3
911
9123. Cube with negative reference numbers
913
914This is a cube with negative vertex reference numbers. Each element
915references the vertices stored immediately above it in the file. Note
916that vertices are not shared.
917
918v 0.000000 2.000000 2.000000
919v 0.000000 0.000000 2.000000
920v 2.000000 0.000000 2.000000
921v 2.000000 2.000000 2.000000
922f -4 -3 -2 -1
923
924v 2.000000 2.000000 0.000000
925v 2.000000 0.000000 0.000000
926v 0.000000 0.000000 0.000000
927v 0.000000 2.000000 0.000000
928f -4 -3 -2 -1
929
930v 2.000000 2.000000 2.000000
931v 2.000000 0.000000 2.000000
932v 2.000000 0.000000 0.000000
933v 2.000000 2.000000 0.000000
934f -4 -3 -2 -1
935
936v 0.000000 2.000000 0.000000
937v 0.000000 2.000000 2.000000
938v 2.000000 2.000000 2.000000
939v 2.000000 2.000000 0.000000
940f -4 -3 -2 -1
941
942v 0.000000 2.000000 0.000000
943v 0.000000 0.000000 0.000000
944v 0.000000 0.000000 2.000000
945v 0.000000 2.000000 2.000000
946f -4 -3 -2 -1
947
948v 0.000000 0.000000 2.000000
949v 0.000000 0.000000 0.000000
950v 2.000000 0.000000 0.000000
951v 2.000000 0.000000 2.000000
952f -4 -3 -2 -1
953
954
955
956Free-form curve/surface body statements
957
958You can specify additional information for free-form curve and surface
959elements using a series of statements called body statements. The
960series is concluded by an end statement.
961
962Body statements are valid only when they appear between the free-form
963element statement (curv, curv2, surf) and the end statement. If they
964are anywhere else in the .obj file, they do not have any effect.
965
966You can use body statements to specify the following values:
967
968o parameter
969
970o knot vector
971
972o trimming loop
973
974o hole
975
976o special curve
977
978o special point
979
980You cannot use any other statements between the free-form curve or
981surface statement and the end statement. Using any other of type of
982statement may cause unpredictable results.
983
984This portion of a sample file shows the knot vector values for a
985rational B-spline surface with a trimming loop. Notice the end
986statement to conclude the body statements.
987
988 cstype rat bspline
989 deg 2 2
990 surf -1.0 2.5 -2.0 2.0 -9 -8 -7 -6 -5 -4 -3 -2 -1
991 parm u -1.00 -1.00 -1.00 2.50 2.50 2.50
992 parm v -2.00 -2.00 -2.00 -2.00 -2.00 -2.00
993 trim 0.0 2.0 1
994 end
995
996Parameter values and knot vectors
997
998All curve and surface elements require a set of parameter values.
999
1000For polynomial curves and surfaces, this specifies global parameter
1001values. For B-spline curves and surfaces, this specifies the knot
1002vectors.
1003
1004For surfaces, the parameter values must be specified for both the u and
1005v directions. For curves, the parameter values must be specified for
1006only the u direction.
1007
1008If multiple parameter value statements for the same parametric
1009direction are used inside a single curve or surface body, the last
1010statement is used.
1011
1012Trimming loops and holes
1013
1014The trimming loop statement builds a single outer trimming loop as a
1015sequence of curves which lie on a given surface.
1016
1017The hole statement builds a single inner trimming loop as a sequence of
1018curves which lie on a given surface. The inner loop creates a hole.
1019
1020The curves are referenced by number in the same way vertices are
1021referenced by face elements.
1022
1023The individual curves must lie end-to-end to form a closed loop which
1024does not intersect itself and which lies within the parameter range
1025specified for the surface. The loop as a whole may be oriented in
1026either direction (clockwise or counterclockwise).
1027
1028To cut one or more holes in a region, use a trim statement followed by
1029one or more hole statements. To introduce another trimmed region in the
1030same surface, use another trim statement followed by one or more hole
1031statements. The ordering that associates holes and the regions they cut
1032is important and must be maintained.
1033
1034If the first trim statement in the sequence is omitted, the enclosing
1035outer trimming loop is taken to be the parameter range of the surface.
1036If no trim or hole statements are specified, then the surface is
1037trimmed at its parameter range.
1038
1039This portion of a sample file shows a non-rational Bezier surface with
1040two regions, each with a single hole:
1041
1042 cstype bezier
1043 deg 1 1
1044 surf 0.0 2.0 0.0 2.0 1 2 3 4
1045 parm u 0.00 2.00
1046 parm v 0.00 2.00
1047 trim 0.0 4.0 1
1048 hole 0.0 4.0 2
1049 trim 0.0 4.0 3
1050 hole 0.0 4.0 4
1051 end
1052
1053Special curve
1054
1055A special curve statement builds a single special curve as a sequence
1056of curves which lie on a given surface.
1057
1058The curves are referenced by number in the same way vertices are
1059referenced by face elements.
1060
1061A special curve is guaranteed to be included in any triangulation of
1062the surface. This means that the line formed by approximating the
1063special curve with a sequence of straight line segments will actually
1064appear as a sequence of triangle edges in the final triangulation.
1065
1066Special point
1067
1068A special point statement specifies that special geometric points are
1069to be associated with a curve or surface. For space curves and trimming
1070curves, the parameter vertices must be 1D. For surfaces, the parameter
1071vertices must be 2D.
1072
1073These special points will be included in any linear approximation of
1074the curve or surface.
1075
1076For space curves, this means that the point corresponding to the given
1077curve parameter is included as one of the vertices in an approximation
1078consisting of a sequence of line segments.
1079
1080For surfaces, this means that the point corresponding to the given
1081surface parameters is included as a triangle vertex in the
1082triangulation.
1083
1084For trimming curves, the treatment is slightly different: a special
1085point on a trimming curve is essentially the same as a special point on
1086the surface it trims.
1087
1088The following portion of a sample files shows special points for a
1089rational Bezier 2D curve on a surface.
1090
1091 vp -0.675 1.850 3.000
1092 vp 0.915 1.930
1093 vp 2.485 0.470 2.000
1094 vp 2.485 -1.030
1095 vp 1.605 -1.890 10.700
1096 vp -0.745 -0.654 0.500
1097 cstype rat bezier
1098 curv2 -6 -5 -4 -3 -2 -1 -6
1099 parm u 0.00 1.00 2.00
1100 sp 2 3
1101 end
1102
1103Syntax
1104
1105The following syntax statement are listed in order of normal use.
1106
1107parm u p1 p2 p3. . .
1108
1109parm v p1 p2 p3 . . .
1110
1111 Body statement for free-form geometry.
1112
1113 Specifies global parameter values. For B-spline curves and
1114 surfaces, this specifies the knot vectors.
1115
1116 u is the u direction for the parameter values.
1117
1118 v is the v direction for the parameter values.
1119
1120 To set u and v values, use separate command lines.
1121
1122 p is the global parameter or knot value. You can specify multiple
1123 values. A minimum of two parameter values are required. Parameter
1124 values must increase monotonically. The type of surface and the
1125 degree dictate the number of values required.
1126
1127trim u0 u1 curv2d u0 u1 curv2d . . .
1128
1129 Body statement for free-form geometry.
1130
1131 Specifies a sequence of curves to build a single outer trimming
1132 loop.
1133
1134 u0 is the starting parameter value for the trimming curve curv2d.
1135
1136 u1 is the ending parameter value for the trimming curve curv2d.
1137
1138 curv2d is the index of the trimming curve lying in the parameter
1139 space of the surface. This curve must have been previously defined
1140 with the curv2 statement.
1141
1142hole u0 u1 curv2d u0 u1 curv2d . . .
1143
1144 Body statement for free-form geometry.
1145
1146 Specifies a sequence of curves to build a single inner trimming
1147 loop (hole).
1148
1149 u0 is the starting parameter value for the trimming curve curv2d.
1150
1151 u1 is the ending parameter value for the trimming curve curv2d.
1152
1153 curv2d is the index of the trimming curve lying in the parameter
1154 space of the surface. This curve must have been previously defined
1155 with the curv2 statement.
1156
1157scrv u0 u1 curv2d u0 u1 curv2d . . .
1158
1159 Body statement for free-form geometry.
1160
1161 Specifies a sequence of curves which lie on the given surface to
1162 build a single special curve.
1163
1164 u0 is the starting parameter value for the special curve curv2d.
1165
1166 u1 is the ending parameter value for the special curve curv2d.
1167
1168 curv2d is the index of the special curve lying in the parameter
1169 space of the surface. This curve must have been previously defined
1170 with the curv2 statement.
1171
1172sp vp1 vp. . .
1173
1174 Body statement for free-form geometry.
1175
1176 Specifies special geometric points to be associated with a curve or
1177 surface. For space curves and trimming curves, the parameter
1178 vertices must be 1D. For surfaces, the parameter vertices must be
1179 2D.
1180
1181 vp is the reference number for the parameter vertex of a special
1182 point to be associated with the parameter space point of the curve
1183 or surface.
1184
1185end
1186
1187 Body statement for free-form geometry.
1188
1189 Specifies the end of a curve or surface body begun by a curv,
1190 curv2, or surf statement.
1191
1192Examples
1193
11941. Taylor curve
1195
1196 For creating a single-segment Taylor polynomial curve of the form:
1197
1198 2 3 4
1199 x = 3.00 + 2.30t + 7.98t + 8.30t + 6.34t
1200
1201 2 3 4
1202 y = 1.00 - 10.10t + 5.40t - 4.70t + 2.03t
1203
1204 2 3 4
1205 z = -2.50 + 0.50t - 7.00t + 18.10t + 0.08t
1206
1207
1208and evaluated between the global parameters 0.5 and 1.6:
1209
1210 v 3.000 1.000 -2.500
1211 v 2.300 -10.100 0.500
1212 v 7.980 5.400 -7.000
1213 v 8.300 -4.700 18.100
1214 v 6.340 2.030 0.080
1215 cstype taylor
1216 deg 4
1217 curv 0.500 1.600 1 2 3 4 5
1218 parm u 0.000 2.000
1219 end
1220
12212. Bezier curve
1222
1223This example shows a non-rational Bezier curve with 13 control points.
1224
1225 v -2.300000 1.950000 0.000000
1226 v -2.200000 0.790000 0.000000
1227 v -2.340000 -1.510000 0.000000
1228 v -1.530000 -1.490000 0.000000
1229 v -0.720000 -1.470000 0.000000
1230 v -0.780000 0.230000 0.000000
1231 v 0.070000 0.250000 0.000000
1232 v 0.920000 0.270000 0.000000
1233 v 0.800000 -1.610000 0.000000
1234 v 1.620000 -1.590000 0.000000
1235 v 2.440000 -1.570000 0.000000
1236 v 2.690000 0.670000 0.000000
1237 v 2.900000 1.980000 0.000000
1238 # 13 vertices
1239
1240 cstype bezier
1241 ctech cparm 1.000000
1242 deg 3
1243 curv 0.000000 4.000000 1 2 3 4 5 6 7 8 9 10 \
1244 11 12 13
1245 parm u 0.000000 1.000000 2.000000 3.000000 \
1246 4.000000
1247 end
1248 # 1 element
1249
1250
1251
12523. B-spline surface
1253
1254This is an example of a cubic B-spline surface.
1255
1256 g bspatch
1257 v -5.000000 -5.000000 -7.808327
1258 v -5.000000 -1.666667 -7.808327
1259 v -5.000000 1.666667 -7.808327
1260 v -5.000000 5.000000 -7.808327
1261 v -1.666667 -5.000000 -7.808327
1262 v -1.666667 -1.666667 11.977780
1263 v -1.666667 1.666667 11.977780
1264 v -1.666667 5.000000 -7.808327
1265 v 1.666667 -5.000000 -7.808327
1266 v 1.666667 -1.666667 11.977780
1267 v 1.666667 1.666667 11.977780
1268 v 1.666667 5.000000 -7.808327
1269 v 5.000000 -5.000000 -7.808327
1270 v 5.000000 -1.666667 -7.808327
1271 v 5.000000 1.666667 -7.808327
1272 v 5.000000 5.000000 -7.808327
1273 # 16 vertices
1274
1275 cstype bspline
1276 stech curv 0.5 10.000000
1277 deg 3 3
1278 8surf 0.000000 1.000000 0.000000 1.000000 13 14 \ 15 16 9 10 11 12 5 6
1279 7 8 1 2 3 4
1280 parm u -3.000000 -2.000000 -1.000000 0.000000 \
1281 1.000000 2.000000 3.000000 4.000000
1282 parm v -3.000000 -2.000000 -1.000000 0.000000 \
1283 1.000000 2.000000 3.000000 4.000000
1284 end
1285 # 1 element
1286
1287
12884. Cardinal surface
1289
1290This example shows a Cardinal surface.
1291
1292 v -5.000000 -5.000000 0.000000
1293 v -5.000000 -1.666667 0.000000
1294 v -5.000000 1.666667 0.000000
1295 v -5.000000 5.000000 0.000000
1296 v -1.666667 -5.000000 0.000000
1297 v -1.666667 -1.666667 0.000000
1298 v -1.666667 1.666667 0.000000
1299 v -1.666667 5.000000 0.000000
1300 v 1.666667 -5.000000 0.000000
1301 v 1.666667 -1.666667 0.000000
1302 v 1.666667 1.666667 0.000000
1303 v 1.666667 5.000000 0.000000
1304 v 5.000000 -5.000000 0.000000
1305 v 5.000000 -1.666667 0.000000
1306 v 5.000000 1.666667 0.000000
1307 v 5.000000 5.000000 0.000000
1308 # 16 vertices
1309
1310 cstype cardinal
1311 stech cparma 1.000000 1.000000
1312 deg 3 3
1313 surf 0.000000 1.000000 0.000000 1.000000 13 14 \
1314 15 16 9 10 11 12 5 6 7 8 1 2 3 4
1315 parm u 0.000000 1.000000
1316 parm v 0.000000 1.000000
1317 end
1318 # 1 element
1319
1320
13215. Rational B-spline surface
1322
1323This example creates a second-degree, rational B-spline surface using
1324open, uniform knot vectors. A texture map is applied to the surface.
1325
1326 v -1.3 -1.0 0.0
1327 v 0.1 -1.0 0.4 7.6
1328 v 1.4 -1.0 0.0 2.3
1329 v -1.4 0.0 0.2
1330 v 0.1 0.0 0.9 0.5
1331 v 1.3 0.0 0.4 1.5
1332 v -1.4 1.0 0.0 2.3
1333 v 0.1 1.0 0.3 6.1
1334 v 1.1 1.0 0.0 3.3
1335 vt 0.0 0.0
1336 vt 0.5 0.0
1337 vt 1.0 0.0
1338 vt 0.0 0.5
1339 vt 0.5 0.5
1340 vt 1.0 0.5
1341 vt 0.0 1.0
1342 vt 0.5 1.0
1343 vt 1.0 1.0
1344 cstype rat bspline
1345 deg 2 2
1346 surf 0.0 1.0 0.0 1.0 1/1 2/2 3/3 4/4 5/5 6/6 \
1347 7/7 8/8 9/9
1348 parm u 0.0 0.0 0.0 1.0 1.0 1.0
1349 parm v 0.0 0.0 0.0 1.0 1.0 1.0
1350 end
1351
1352
13536. Trimmed NURB surface
1354
1355This is a complete example of a file containing a trimmed NURB surface
1356with negative reference numbers for vertices.
1357
1358 # trimming curve
1359 vp -0.675 1.850 3.000
1360 vp 0.915 1.930
1361 vp 2.485 0.470 2.000
1362 vp 2.485 -1.030
1363 vp 1.605 -1.890 10.700
1364 vp -0.745 -0.654 0.500
1365 cstype rat bezier
1366 deg 3
1367 curv2 -6 -5 -4 -3 -2 -1 -6
1368 parm u 0.00 1.00 2.00
1369 end
1370 # surface
1371 v -1.350 -1.030 0.000
1372 v 0.130 -1.030 0.432 7.600
1373 v 1.480 -1.030 0.000 2.300
1374 v -1.460 0.060 0.201
1375 v 0.120 0.060 0.915 0.500
1376 v 1.380 0.060 0.454 1.500
1377 v -1.480 1.030 0.000 2.300
1378 v 0.120 1.030 0.394 6.100
1379 v 1.170 1.030 0.000 3.300
1380 cstype rat bspline
1381 deg 2 2
1382 surf -1.0 2.5 -2.0 2.0 -9 -8 -7 -6 -5 -4 -3 -2 -1
1383 parm u -1.00 -1.00 -1.00 2.50 2.50 2.50
1384 parm v -2.00 -2.00 -2.00 -2.00 -2.00 -2.00
1385 trim 0.0 2.0 1
1386 end
1387
1388
13897. Two trimming regions with a hole
1390
1391This example shows a Bezier surface with two trimming regions, each
1392with a hole in them.
1393
1394 # outer loop of first region
1395 deg 1
1396 cstype bezier
1397 vp 0.100 0.100
1398 vp 0.900 0.100
1399 vp 0.900 0.900
1400 vp 0.100 0.900
1401 curv2 1 2 3 4 1
1402 parm u 0.00 1.00 2.00 3.00 4.00
1403 end
1404 # hole in first region
1405 vp 0.300 0.300
1406 vp 0.700 0.300
1407 vp 0.700 0.700
1408 vp 0.300 0.700
1409 curv2 5 6 7 8 5
1410 parm u 0.00 1.00 2.00 3.00 4.00
1411 end
1412 # outer loop of second region
1413 vp 1.100 1.100
1414 vp 1.900 1.100
1415 vp 1.900 1.900
1416 vp 1.100 1.900
1417 curv2 9 10 11 12 9
1418 parm u 0.00 1.00 2.00 3.00 4.00
1419 end
1420 # hole in second region
1421 vp 1.300 1.300
1422 vp 1.700 1.300
1423 vp 1.700 1.700
1424 vp 1.300 1.700
1425 curv2 13 14 15 16 13
1426 parm u 0.00 1.00 2.00 3.00 4.00
1427 end
1428 # surface
1429 v 0.000 0.000 0.000
1430 v 1.000 0.000 0.000
1431 v 0.000 1.000 0.000
1432 v 1.000 1.000 0.000
1433 deg 1 1
1434 cstype bezier
1435 surf 0.0 2.0 0.0 2.0 1 2 3 4
1436 parm u 0.00 2.00
1437 parm v 0.00 2.00
1438 trim 0.0 4.0 1
1439 hole 0.0 4.0 2
1440 trim 0.0 4.0 3
1441 hole 0.0 4.0 4
1442 end
1443
1444
14458. Trimming with a special curve
1446This example is similar to the trimmed NURB surface example (6), except
1447there is a special curve on the surface. This example uses negative
1448vertex numbers.
1449
1450 # trimming curve
1451 vp -0.675 1.850 3.000
1452 vp 0.915 1.930
1453 vp 2.485 0.470 2.000
1454 vp 2.485 -1.030
1455 vp 1.605 -1.890 10.700
1456 vp -0.745 -0.654 0.500
1457 cstype rat bezier
1458 deg 3
1459 curv2 -6 -5 -4 -3 -2 -1 -6
1460 parm u 0.00 1.00 2.00
1461 end
1462 # special curve
1463 vp -0.185 0.322
1464 vp 0.214 0.818
1465 vp 1.652 0.207
1466 vp 1.652 -0.455
1467 curv2 -4 -3 -2 -1
1468 parm u 2.00 10.00
1469 end
1470 # surface
1471 v -1.350 -1.030 0.000
1472 v 0.130 -1.030 0.432 7.600
1473 v 1.480 -1.030 0.000 2.300
1474 v -1.460 0.060 0.201
1475 v 0.120 0.060 0.915 0.500
1476 v 1.380 0.060 0.454 1.500
1477 v -1.480 1.030 0.000 2.300
1478 v 0.120 1.030 0.394 6.100
1479 v 1.170 1.030 0.000 3.300
1480 cstype rat bspline
1481 deg 2 2
1482 surf -1.0 2.5 -2.0 2.0 -9 -8 -7 -6 -5 -4 -3 -2 -1
1483 parm u -1.00 -1.00 -1.00 2.50 2.50 2.50
1484 parm v -2.00 -2.00 -2.00 2.00 2.00 2.00
1485 trim 0.0 2.0 1
1486 scrv 4.2 9.7 2
1487 end
1488
1489
14909. Trimming with special points
1491
1492This example extends the trimmed NURB surface example (6) to include
1493special points on both the trimming curve and surface. A space curve
1494with a special point is also included. This example uses negative
1495vertex numbers.
1496
1497 # special point and space curve data
1498 vp 0.500
1499 vp 0.700
1500 vp 1.100
1501 vp 0.200 0.950
1502 v 0.300 1.500 0.100
1503 v 0.000 0.000 0.000
1504 v 1.000 1.000 0.000
1505 v 2.000 1.000 0.000
1506 v 3.000 0.000 0.000
1507 cstype bezier
1508 deg 3
1509 curv 0.2 0.9 -4 -3 -2 -1
1510 sp 1
1511 parm u 0.00 1.00
1512 end
1513 # trimming curve
1514 vp -0.675 1.850 3.000
1515 vp 0.915 1.930
1516 vp 2.485 0.470 2.000
1517 vp 2.485 -1.030
1518 vp 1.605 -1.890 10.700
1519 vp -0.745 -0.654 0.500
1520 cstype rat bezier
1521 curv2 -6 -5 -4 -3 -2 -1 -6
1522 parm u 0.00 1.00 2.00
1523 sp 2 3
1524 end
1525 # surface
1526 v -1.350 -1.030 0.000
1527 v 0.130 -1.030 0.432 7.600
1528 v 1.480 -1.030 0.000 2.300
1529 v -1.460 0.060 0.201
1530 v 0.120 0.060 0.915 0.500
1531 v 1.380 0.060 0.454 1.500
1532 v -1.480 1.030 0.000 2.300
1533 v 0.120 1.030 0.394 6.100
1534 v 1.170 1.030 0.000 3.300
1535 cstype rat bspline
1536 deg 2 2
1537 surf -1.0 2.5 -2.0 2.0 -9 -8 -7 -6 -5 -4 -3 -2 -1
1538 parm u -1.00 -1.00 -1.00 2.50 2.50 2.50
1539 parm v -2.00 -2.00 -2.00 2.00 2.00 2.00
1540 trim 0.0 2.0 1
1541 sp 4
1542 end
1543
1544Connectivity between free-form surfaces
1545
1546Connectivity connects two surfaces along their trimming curves.
1547
1548The con statement specifies the first surface with its trimming curve
1549and the second surface with its trimming curve. This information is
1550useful for edge merging. Without this surface and curve data,
1551connectivity must be determined numerically at greater expense and with
1552reduced accuracy using the mg statement.
1553
1554Connectivity between surfaces in different merging groups is ignored.
1555Also, although connectivity which crosses points of C1discontinuity in
1556trimming curves is legal, it is not recommended. Instead, use two
1557connectivity statements which meet at the point of discontinuity.
1558
1559The two curves and their starting and ending parameters should all map
1560to the same curve and starting and ending points in object space.
1561
1562Syntax
1563
1564con surf_1 q0_1 q1_1 curv2d_1 surf_2 q0_2 q1_2 curv2d_2
1565
1566 Free-form geometry statement.
1567
1568 Specifies connectivity between two surfaces.
1569
1570 surf_1 is the index of the first surface.
1571
1572 q0_1 is the starting parameter for the curve referenced by
1573 curv2d_1.
1574
1575 q1_1 is the ending parameter for the curve referenced by curv2d_1.
1576
1577 curv2d_1 is the index of a curve on the first surface. This curve
1578 must have been previously defined with the curv2 statement.
1579
1580 surf_2 is the index of the second surface.
1581
1582 q0_2 is the starting parameter for the curve referenced by
1583 curv2d_2.
1584
1585 q1_2 is the ending parameter for the curve referenced by curv2d_2.
1586
1587 curv2d_2 is the index of a curve on the second surface. This curve
1588 must have been previously defined with the curv2 statement.
1589
1590Example
1591
15921. Connectivity between two surfaces
1593
1594This example shows the connectivity between two surfaces with trimming
1595curves.
1596
1597 cstype bezier
1598 deg 1 1
1599
1600 v 0 0 0
1601 v 1 0 0
1602 v 0 1 0
1603 v 1 1 0
1604
1605 vp 0 0
1606 vp 1 0
1607 vp 1 1
1608 vp 0 1
1609
1610 curv2 1 2 3 4 1
1611 parm u 0.0 1.0 2.0 3.0 4.0
1612 end
1613
1614 surf 0.0 1.0 0.0 1.0 1 2 3 4
1615 parm u 0.0 1.0
1616 parm v 0.0 1.0
1617 trim 0.0 4.0 1
1618 end
1619
1620 v 1 0 0
1621 v 2 0 0
1622 v 1 1 0
1623 v 2 1 0
1624
1625 surf 0.0 1.0 0.0 1.0 5 6 7 8
1626 parm u 0.0 1.0
1627 parm v 0.0 1.0
1628 trim 0.0 4.0 1
1629 end
1630
1631 con 1 2.0 2.0 1 2 4.0 3.0 1
1632
1633
1634Grouping
1635
1636There are four statements in the .obj file to help you manipulate groups
1637of elements:
1638
1639o Gropu name statements are used to organize collections of
1640 elements and simplify data manipulation for operations in
1641 Model.
1642
1643o Smoothing group statements let you identify elements over which
1644 normals are to be interpolated to give those elements a smooth,
1645 non-faceted appearance. This is a quick way to specify vertex
1646 normals.
1647
1648o Merging group statements are used to ideneify free-form elements
1649 that should be inspected for adjacency detection. You can also
1650 use merging groups to exclude surfaces which are close enough to
1651 be considered adjacent but should not be merged.
1652
1653o Object name statements let you assign a name to an entire object
1654 in a single file.
1655
1656All grouping statements are state-setting. This means that once a
1657group statement is set, it alpplies to all elements that follow
1658until the next group statement.
1659
1660This portion of a sample file shows a single element which belongs to
1661three groups. The smoothing group is turned off.
1662
1663 g square thing all
1664 s off
1665 f 1 2 3 4
1666
1667This example shows two surfaces in merging group 1 with a merge
1668resolution of 0.5.
1669
1670 mg 1 .5
1671 surf 0.0 1.0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
1672 surf 0.0 1.0 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
1673
1674Syntax
1675
1676g group_name1 group_name2 . . .
1677
1678 Polygonal and free-form geometry statement.
1679
1680 Specifies the group name for the elements that follow it. You can
1681 have multiple group names. If there are multiple groups on one
1682 line, the data that follows belong to all groups. Group information
1683 is optional.
1684
1685 group_name is the name for the group. Letters, numbers, and
1686 combinations of letters and numbers are accepted for group names.
1687 The default group name is default.
1688
1689s group_number
1690
1691 Polygonal and free-form geometry statement.
1692
1693 Sets the smoothing group for the elements that follow it. If you do
1694 not want to use a smoothing group, specify off or a value of 0.
1695
1696 To display with smooth shading in Model and PreView, you must
1697 create vertex normals after you have assigned the smoothing groups.
1698 You can create vertex normals with the vn statement or with the
1699 Model program.
1700
1701 To smooth polygonal geometry for rendering with Image, it is
1702 sufficient to put elements in some smoothing group. However, vertex
1703 normals override smoothing information for Image.
1704
1705 group_number is the smoothing group number. To turn off smoothing
1706 groups, use a value of 0 or off. Polygonal elements use group
1707 numbers to put elements in different smoothing groups. For
1708 free-form surfaces, smoothing groups are either turned on or off;
1709 there is no difference between values greater than 0.
1710
1711mg group_number res
1712
1713 Free-form geometry statement.
1714
1715 Sets the merging group and merge resolution for the free-form
1716 surfaces that follow it. If you do not want to use a merging group,
1717 specify off or a value of 0.
1718
1719 Adjacency detection is performed only within groups, never between
1720 groups. Connectivity between surfaces in different merging groups
1721 is not allowed. Surfaces in the same merging group are merged
1722 together along edges that are within the distance res apart.
1723
1724 NOTE: Adjacency detection is an expensive numerical comparison
1725 process. It is best to restrict this process to as small a domain
1726 as possible by using small merging groups.
1727
1728 group_number is the merging group number. To turn off adjacency
1729 detection, use a value of 0 or off.
1730
1731 res is the maximum distance between two surfaces that will be
1732 merged together. The resolution must be a value greater than 0.
1733 This is a required argument only when using merging groups.
1734
1735o object_name
1736
1737 Polygonal and free-form geometry statement.
1738
1739 Optional statement; it is not processed by any Wavefront programs.
1740 It specifies a user-defined object name for the elements defined
1741 after this statement.
1742
1743 object_name is the user-defined object name. There is no default.
1744
1745Examples
1746
17471. Cube with group names
1748
1749The following example is a cube with each of its faces placed in a
1750separate group. In addition, all elements belong to the group cube.
1751
1752 v 0.000000 2.000000 2.000000
1753 v 0.000000 0.000000 2.000000
1754 v 2.000000 0.000000 2.000000
1755 v 2.000000 2.000000 2.000000
1756 v 0.000000 2.000000 0.000000
1757 v 0.000000 0.000000 0.000000
1758 v 2.000000 0.000000 0.000000
1759 v 2.000000 2.000000 0.000000
1760 # 8 vertices
1761
1762 g front cube
1763 f 1 2 3 4
1764 g back cube
1765 f 8 7 6 5
1766 g right cube
1767 f 4 3 7 8
1768 g top cube
1769 f 5 1 4 8
1770 g left cube
1771 f 5 6 2 1
1772 g bottom cube
1773 f 2 6 7 3
1774 # 6 elements
1775
1776
17772. Two adjoining squares with a smoothing group
1778
1779This example shows two adjoining squares that share a common edge. The
1780squares are placed in a smoothing group to ensure that their common
1781edge will be smoothed when rendered with Image.
1782
1783 v 0.000000 2.000000 0.000000
1784 v 0.000000 0.000000 0.000000
1785 v 2.000000 0.000000 0.000000
1786 v 2.000000 2.000000 0.000000
1787 v 4.000000 0.000000 -1.255298
1788 v 4.000000 2.000000 -1.255298
1789 # 6 vertices
1790
1791 g all
1792 s 1
1793 f 1 2 3 4
1794 f 4 3 5 6
1795 # 2 elements
1796
1797
17983. Two adjoining squares with vertex normals
1799
1800This example also shows two squares that share a common edge. Vertex
1801normals have been added to the corners of each square to ensure that
1802their common edge will be smoothed during display in Model and PreView
1803and when rendered with Image.
1804
1805 v 0.000000 2.000000 0.000000
1806 v 0.000000 0.000000 0.000000
1807 v 2.000000 0.000000 0.000000
1808 v 2.000000 2.000000 0.000000
1809 v 4.000000 0.000000 -1.255298
1810 v 4.000000 2.000000 -1.255298
1811 vn 0.000000 0.000000 1.000000
1812 vn 0.000000 0.000000 1.000000
1813 vn 0.276597 0.000000 0.960986
1814 vn 0.276597 0.000000 0.960986
1815 vn 0.531611 0.000000 0.846988
1816 vn 0.531611 0.000000 0.846988
1817 # 6 vertices
1818
1819 # 6 normals
1820
1821 g all
1822 s 1
1823 f 1//1 2//2 3//3 4//4
1824 f 4//4 3//3 5//5 6//6
1825 # 2 elements
1826
1827
18284. Merging group
1829
1830This example shows two Bezier surfaces that meet at a common edge. They
1831have both been placed in the same merging group to ensure continuity at
1832the edge where they meet. This prevents "cracks" from appearing along
1833the seam between the two surfaces during rendering. Merging groups will
1834be ignored during flat-shading, smooth-shading, and material shading of
1835the surface.
1836
1837 v -4.949854 -5.000000 0.000000
1838 v -4.949854 -1.666667 0.000000
1839 v -4.949854 1.666667 0.000000
1840 v -4.949854 5.000000 0.000000
1841 v -1.616521 -5.000000 0.000000
1842 v -1.616521 -1.666667 0.000000
1843 v -1.616521 1.666667 0.000000
1844 v -1.616521 5.000000 0.000000
1845 v 1.716813 -5.000000 0.000000
1846 v 1.716813 -1.666667 0.000000
1847 v 1.716813 1.666667 0.000000
1848 v 1.716813 5.000000 0.000000
1849 v 5.050146 -5.000000 0.000000
1850 v 5.050146 -1.666667 0.000000
1851 v 5.050146 1.666667 0.000000
1852 v 5.050146 5.000000 0.000000
1853 v -15.015566 -4.974991 0.000000
1854 v -15.015566 -1.641658 0.000000
1855 v -15.015566 1.691675 0.000000
1856 v -15.015566 5.025009 0.000000
1857 v -11.682233 -4.974991 0.000000
1858 v -11.682233 -1.641658 0.000000
1859 v -11.682233 1.691675 0.000000
1860 v -11.682233 5.025009 0.000000
1861 v -8.348900 -4.974991 0.000000
1862 v -8.348900 -1.641658 0.000000
1863 v -8.348900 1.691675 0.000000
1864 v -8.348900 5.025009 0.000000
1865 v -5.015566 -4.974991 0.000000
1866 v -5.015566 -1.641658 0.000000
1867 v -5.015566 1.691675 0.000000
1868 v -5.015566 5.025009 0.000000
1869
1870 mg 1 0.500000
1871
1872 cstype bezier
1873 deg 3 3
1874 surf 0.000000 1.000000 0.000000 1.000000 13 14 \
1875 15 16 9 10 11 12 5 6 7 8 1 2 3 4
1876 parm u 0.000000 1.000000
1877 parm v 0.000000 1.000000
1878 end
1879 surf 0.000000 1.000000 0.000000 1.000000 29 30 31 32 25 26 27 28 21 22 \
1880 23 24 17 18 19 20
1881 parm u 0.000000 1.000000
1882 parm v 0.000000 1.000000
1883 end
1884
1885
1886Display/render attributes
1887
1888Display and render attributes describe how an object looks when
1889displayed in Model and PreView or when rendered with Image.
1890
1891Some attributes apply to both free-form and polygonal geometry, such as
1892material name and library, ray tracing, and shadow casting.
1893Interpolation attributes apply only to polygonal geometry. Curve and
1894surface resolutions are used for only free-form geometry.
1895
1896The following chart shows the display and render statements available
1897for polygonal and free-form geometry.
1898
1899Table B1-1. Display and render attributes
1900
1901polygonal only polygonal or free-form free-form only
1902-------------- ---------------------- --------------
1903bevel lod ctech
1904c_interp usemtl stech
1905d_interp mtllib
1906 shadow_obj
1907 trace_obj
1908
1909All display and render attribute statements are state-setting. This
1910means that once an attribute statement is set, it applies to all
1911elements that follow until it is reset to a different value.
1912
1913The following sample shows rendering and display statements for a face
1914element.:
1915
1916 s 1
1917 usemtl blue
1918 usemap marble
1919 f 1 2 3 4
1920
1921Syntax
1922
1923The following syntax statements are listed by the type of geometry.
1924First are statements for polygonal geometry. Second are statements for
1925both free-form and polygonal geometry. Third are statements for
1926free-form geometry only.
1927
1928bevel on/off
1929
1930 Polygonal geometry statement.
1931
1932 Sets bevel interpolation on or off. It works only with beveled
1933 objects, that is, objects with sides separated by beveled faces.
1934
1935 Bevel interpolation uses normal vector interpolation to give an
1936 illusion of roundness to a flat bevel. It does not affect the
1937 smoothing of non-bevelled faces.
1938
1939 Bevel interpolation does not alter the geometry of the original
1940 object.
1941
1942 on turns on bevel interpolation.
1943
1944 off turns off bevel interpolation. The default is off.
1945
1946 NOTE: Image cannot render bevel-interpolated elements that have
1947 vertex normals.
1948
1949c_interp on/off
1950
1951 Polygonal geometry statement.
1952
1953 Sets color interpolation on or off.
1954
1955 Color interpolation creates a blend across the surface of a polygon
1956 between the materials assigned to its vertices. This creates a
1957 blending of colors across a face element.
1958
1959 To support color interpolation, materials must be assigned per
1960 vertex, not per element. The illumination models for all materials
1961 of vertices attached to the polygon must be the same. Color
1962 interpolation applies to the values for ambient (Ka), diffuse (Kd),
1963 specular (Ks), and specular highlight (Ns) material properties.
1964
1965 on turns on color interpolation.
1966
1967 off turns off color interpolation. The default is off.
1968
1969d_interp on/off
1970
1971 Polygonal geometry statement.
1972
1973 Sets dissolve interpolation on or off.
1974
1975 Dissolve interpolation creates an interpolation or blend across a
1976 polygon between the dissolve (d) values of the materials assigned
1977 to its vertices. This feature is used to create effects exhibiting
1978 varying degrees of apparent transparency, as in glass or clouds.
1979
1980 To support dissolve interpolation, materials must be assigned per
1981 vertex, not per element. All the materials assigned to the vertices
1982 involved in the dissolve interpolation must contain a dissolve
1983 factor command to specify a dissolve.
1984
1985 on turns on dissolve interpolation.
1986
1987 off turns off dissolve interpolation. The default is off.
1988
1989lod level
1990
1991 Polygonal and free-form geometry statement.
1992
1993 Sets the level of detail to be displayed in a PreView animation.
1994 The level of detail feature lets you control which elements of an
1995 object are displayed while working in PreView.
1996
1997 level is the level of detail to be displayed. When you set the
1998 level of detail to 0 or omit the lod statement, all elements are
1999 displayed. Specifying an integer between 1 and 100 sets the level
2000 of detail to be displayed when reading the .obj file.
2001
2002maplib filename1 filename2 . . .
2003
2004 This is a rendering identifier that specifies the map library file
2005 for the texture map definitions set with the usemap identifier. You
2006 can specify multiple filenames with maplib. If multiple filenames
2007 are specified, the first file listed is searched first for the map
2008 definition, the second file is searched next, and so on.
2009
2010 When you assign a map library using the Model program, Model allows
2011 only one map library per .obj file. You can assign multiple
2012 libraries using a text editor.
2013
2014 filename is the name of the library file where the texture maps are
2015 defined. There is no default.
2016
2017usemap map_name/off
2018
2019 This is a rendering identifier that specifies the texture map name
2020 for the element following it. To turn off texture mapping, specify
2021 off instead of the map name.
2022
2023 If you specify texture mapping for a face without texture vertices,
2024 the texture map will be ignored.
2025
2026 map_name is the name of the texture map.
2027
2028 off turns off texture mapping. The default is off.
2029
2030usemtl material_name
2031
2032 Polygonal and free-form geometry statement.
2033
2034 Specifies the material name for the element following it. Once a
2035 material is assigned, it cannot be turned off; it can only be
2036 changed.
2037
2038 material_name is the name of the material. If a material name is
2039 not specified, a white material is used.
2040
2041mtllib filename1 filename2 . . .
2042
2043 Polygonal and free-form geometry statement.
2044
2045 Specifies the material library file for the material definitions
2046 set with the usemtl statement. You can specify multiple filenames
2047 with mtllib. If multiple filenames are specified, the first file
2048 listed is searched first for the material definition, the second
2049 file is searched next, and so on.
2050
2051 When you assign a material library using the Model program, only
2052 one map library per .obj file is allowed. You can assign multiple
2053 libraries using a text editor.
2054
2055 filename is the name of the library file that defines the
2056 materials. There is no default.
2057
2058shadow_obj filename
2059
2060 Polygonal and free-form geometry statement.
2061
2062 Specifies the shadow object filename. This object is used to cast
2063 shadows for the current object. Shadows are only visible in a
2064 rendered image; they cannot be seen using hardware shading. The
2065 shadow object is invisible except for its shadow.
2066
2067 An object will cast shadows only if it has a shadow object. You can
2068 use an object as its own shadow object. However, a simplified
2069 version of the original object is usually preferable for shadow
2070 objects, since shadow casting can greatly increase rendering time.
2071
2072 filename is the filename for the shadow object. You can enter any
2073 valid object filename for the shadow object. The object file can be
2074 an .obj or .mod file. If a filename is given without an extension,
2075 an extension of .obj is assumed.
2076
2077 Only one shadow object can be stored in a file. If more than one
2078 shadow object is specified, the last one specified will be used.
2079
2080trace_obj filename
2081
2082 Polygonal and free-form geometry statement.
2083
2084 Specifies the ray tracing object filename. This object will be used
2085 in generating reflections of the current object on reflective
2086 surfaces. Reflections are only visible in a rendered image; they
2087 cannot be seen using hardware shading.
2088
2089 An object will appear in reflections only if it has a trace object.
2090 You can use an object as its own trace object. However, a
2091 simplified version of the original object is usually preferable for
2092 trace objects, since ray tracing can greatly increase rendering
2093 time.
2094
2095 filename is the filename for the ray tracing object. You can enter
2096 any valid object filename for the trace object. You can enter any
2097 valid object filename for the shadow object. The object file can be
2098 an .obj or .mod file. If a filename is given without an extension,
2099 an extension of .obj is assumed.
2100
2101 Only one trace object can be stored in a file. If more than one is
2102 specified, the last one is used.
2103
2104ctech technique resolution
2105
2106 Free-form geometry statement.
2107
2108 Specifies a curve approximation technique. The arguments specify
2109 the technique and resolution for the curve.
2110
2111 You must select from one of the following three techniques.
2112
2113 ctech cparm res
2114
2115 Specifies a curve with constant parametric subdivision using
2116 one resolution parameter. Each polynomial segment of the curve
2117 is subdivided n times in parameter space, where n is the
2118 resolution parameter multiplied by the degree of the curve.
2119
2120 res is the resolution parameter. The larger the value, the
2121 finer the resolution. If res has a value of 0, each polynomial
2122 curve segment is represented by a single line segment.
2123
2124 ctech cspace maxlength
2125
2126 Specifies a curve with constant spatial subdivision. The curve
2127 is approximated by a series of line segments whose lengths in
2128 real space are less than or equal to the maxlength.
2129
2130 maxlength is the maximum length of the line segments. The
2131 smaller the value, the finer the resolution.
2132
2133 ctech curv maxdist maxangle
2134
2135 Specifies curvature-dependent subdivision using separate
2136 resolution parameters for the maximum distance and the maximum
2137 angle.
2138
2139 The curve is approximated by a series of line segments in which
2140 1) the distance in object space between a line segment and the
2141 actual curve must be less than the maxdist parameter and 2) the
2142 angle in degrees between tangent vectors at the ends of a line
2143 segment must be less than the maxangle parameter.
2144
2145 maxdist is the distance in real space between a line segment
2146 and the actual curve.
2147
2148 maxangle is the angle (in degrees) between tangent vectors at
2149 the ends of a line segment.
2150
2151 The smaller the values for maxdist and maxangle, the finer the
2152 resolution.
2153
2154 NOTE: Approximation information for trimming, hole, and special
2155 curves is stored in the corresponding surface. The ctech statement
2156 for the surface is used, not the ctech statement applied to the
2157 curv2 statement. Although untrimmed surfaces have no explicit
2158 trimming loop, a loop is constructed which bounds the legal
2159 parameter range. This implicit loop follows the same rules as any
2160 other loop and is approximated according to the ctech information
2161 for the surface.
2162
2163stech technique resolution
2164
2165 Free-form geometry statement.
2166
2167 Specifies a surface approximation technique. The arguments specify
2168 the technique and resolution for the surface.
2169
2170 You must select from one of the following techniques:
2171
2172 stech cparma ures vres
2173
2174 Specifies a surface with constant parametric subdivision using
2175 separate resolution parameters for the u and v directions. Each
2176 patch of the surface is subdivided n times in parameter space,
2177 where n is the resolution parameter multiplied by the degree of
2178 the surface.
2179
2180 ures is the resolution parameter for the u direction.
2181
2182 vres is the resolution parameter for the v direction.
2183
2184 The larger the values for ures and vres, the finer the
2185 resolution. If you enter a value of 0 for both ures and vres,
2186 each patch is approximated by two triangles.
2187
2188 stech cparmb uvres
2189
2190 Specifies a surface with constant parametric subdivision, with
2191 refinement using one resolution parameter for both the u and v
2192 directions.
2193
2194 An initial triangulation is performed using only the points on
2195 the trimming curves. This triangulation is then refined until
2196 all edges are of an appropriate length. The resulting triangles
2197 are not oriented along isoparametric lines as they are in the
2198 cparma technique.
2199
2200 uvres is the resolution parameter for both the u and v
2201 directions. The larger the value, the finer the resolution.
2202
2203 stech cspace maxlength
2204
2205 Specifies a surface with constant spatial subdivision.
2206
2207 The surface is subdivided in rectangular regions until the
2208 length in real space of any rectangle edge is less than the
2209 maxlength. These rectangular regions are then triangulated.
2210
2211 maxlength is the length in real space of any rectangle edge.
2212 The smaller the value, the finer the resolution.
2213
2214 stech curv maxdist maxangle
2215
2216 Specifies a surface with curvature-dependent subdivision using
2217 separate resolution parameters for the maximum distance and the
2218 maximum angle.
2219
2220 The surface is subdivided in rectangular regions until 1) the
2221 distance in real space between the approximating rectangle and
2222 the actual surface is less than the maxdist (approximately) and
2223 2) the angle in degrees between surface normals at the corners
2224 of the rectangle is less than the maxangle. Following
2225 subdivision, the regions are triangulated.
2226
2227 maxdist is the distance in real space between the approximating
2228 rectangle and the actual surface.
2229
2230 maxangle is the angle in degrees between surface normals at the
2231 corners of the rectangle.
2232
2233 The smaller the values for maxdist and maxangle, the finer the
2234 resolution.
2235
2236Examples
2237
22381. Cube with materials
2239
2240This cube has a different material applied to each of its faces.
2241
2242 mtllib master.mtl
2243
2244 v 0.000000 2.000000 2.000000
2245 v 0.000000 0.000000 2.000000
2246 v 2.000000 0.000000 2.000000
2247 v 2.000000 2.000000 2.000000
2248 v 0.000000 2.000000 0.000000
2249 v 0.000000 0.000000 0.000000
2250 v 2.000000 0.000000 0.000000
2251 v 2.000000 2.000000 0.000000
2252 # 8 vertices
2253
2254 g front
2255 usemtl red
2256 f 1 2 3 4
2257 g back
2258 usemtl blue
2259 f 8 7 6 5
2260 g right
2261 usemtl green
2262 f 4 3 7 8
2263 g top
2264 usemtl gold
2265 f 5 1 4 8
2266 g left
2267 usemtl orange
2268 f 5 6 2 1
2269 g bottom
2270 usemtl purple
2271 f 2 6 7 3
2272 # 6 elements
2273
2274
22752. Cube casting a shadow
2276
2277In this example, the cube casts a shadow on the other objects when it
2278is rendered with Image. The cube, which is stored in the file cube.obj,
2279references itself as the shadow object.
2280
2281 mtllib master.mtl
2282 shadow_obj cube.obj
2283
2284 v 0.000000 2.000000 2.000000
2285 v 0.000000 0.000000 2.000000
2286 v 2.000000 0.000000 2.000000
2287 v 2.000000 2.000000 2.000000
2288 v 0.000000 2.000000 0.000000
2289 v 0.000000 0.000000 0.000000
2290 v 2.000000 0.000000 0.000000
2291 v 2.000000 2.000000 0.000000
2292 # 8 vertices
2293
2294 g front
2295 usemtl red
2296 f 1 2 3 4
2297 g back
2298 usemtl blue
2299 f 8 7 6 5
2300 g right
2301 usemtl green
2302 f 4 3 7 8
2303 g top
2304 usemtl gold
2305 f 5 1 4 8
2306 g left
2307 usemtl orange
2308 f 5 6 2 1
2309 g bottom
2310 usemtl purple
2311 f 2 6 7 3
2312 # 6 elements
2313
2314
23153. Cube casting a reflection
2316
2317This cube casts its reflection on any reflective objects when it is
2318rendered with Image. The cube, which is stored in the file cube.obj,
2319references itself as the trace object.
2320
2321 mtllib master.mtl
2322 trace_obj cube.obj
2323
2324 v 0.000000 2.000000 2.000000
2325 v 0.000000 0.000000 2.000000
2326 v 2.000000 0.000000 2.000000
2327 v 2.000000 2.000000 2.000000
2328 v 0.000000 2.000000 0.000000
2329 v 0.000000 0.000000 0.000000
2330 v 2.000000 0.000000 0.000000
2331 v 2.000000 2.000000 0.000000
2332 # 8 vertices
2333
2334 g front
2335 usemtl red
2336 f 1 2 3 4
2337 g back
2338 usemtl blue
2339 f 8 7 6 5
2340 g right
2341 usemtl green
2342 f 4 3 7 8
2343 g top
2344 usemtl gold
2345 f 5 1 4 8
2346 g left
2347 usemtl orange
2348 f 5 6 2 1
2349 g bottom
2350 usemtl purple
2351 f 2 6 7 3
2352 # 6 elements
2353
2354
2355
23564. Texture-mapped square
2357
2358This example describes a 2 x 2 square. It is mapped with a 1 x 1 square
2359texture. The texture is stretched to fit the square exactly.
2360
2361mtllib master.mtl
2362
2363v 0.000000 2.000000 0.000000
2364v 0.000000 0.000000 0.000000
2365v 2.000000 0.000000 0.000000
2366v 2.000000 2.000000 0.000000
2367vt 0.000000 1.000000 0.000000
2368vt 0.000000 0.000000 0.000000
2369vt 1.000000 0.000000 0.000000
2370vt 1.000000 1.000000 0.000000
2371# 4 vertices
2372
2373usemtl wood
2374f 1/1 2/2 3/3 4/4
2375# 1 element
2376
23775. Approximation technique for a surface
2378
2379This example shows a B-spline surface which will be approximated using
2380curvature-dependent subdivision specified by the stech command.
2381
2382 g bspatch
2383 v -5.000000 -5.000000 -7.808327
2384 v -5.000000 -1.666667 -7.808327
2385 v -5.000000 1.666667 -7.808327
2386 v -5.000000 5.000000 -7.808327
2387 v -1.666667 -5.000000 -7.808327
2388 v -1.666667 -1.666667 11.977780
2389 v -1.666667 1.666667 11.977780
2390 v -1.666667 5.000000 -7.808327
2391 v 1.666667 -5.000000 -7.808327
2392 v 1.666667 -1.666667 11.977780
2393 v 1.666667 1.666667 11.977780
2394 v 1.666667 5.000000 -7.808327
2395 v 5.000000 -5.000000 -7.808327
2396 v 5.000000 -1.666667 -7.808327
2397 v 5.000000 1.666667 -7.808327
2398 v 5.000000 5.000000 -7.808327
2399 # 16 vertices
2400
2401 g bspatch
2402 cstype bspline
2403 stech curv 0.5 10.000000
2404 deg 3 3
2405 surf 0.000000 1.000000 0.000000 1.000000 13 14 \ 15 16 9 10 11 12 5 6 7
2406 8 1 2 3 4
2407 parm u -3.000000 -2.000000 -1.000000 0.000000 \
2408 1.000000 2.000000 3.000000 4.000000
2409 parm v -3.000000 -2.000000 -1.000000 0.000000 \
2410 1.000000 2.000000 3.000000 4.000000
2411 end
2412 # 1 element
2413
2414
2415
24166. Approximation technique for a curve
2417
2418This example shows a Bezier curve which will be approximated using
2419constant parametric subdivision specified by the ctech command.
2420
2421 v -2.300000 1.950000 0.000000
2422 v -2.200000 0.790000 0.000000
2423 v -2.340000 -1.510000 0.000000
2424 v -1.530000 -1.490000 0.000000
2425 v -0.720000 -1.470000 0.000000
2426 v -0.780000 0.230000 0.000000
2427 v 0.070000 0.250000 0.000000
2428 v 0.920000 0.270000 0.000000
2429 v 0.800000 -1.610000 0.000000
2430 v 1.620000 -1.590000 0.000000
2431 v 2.440000 -1.570000 0.000000
2432 v 2.690000 0.670000 0.000000
2433 v 2.900000 1.980000 0.000000
2434 # 13 vertices
2435
2436 g default
2437 cstype bezier
2438 ctech cparm 1.000000
2439 deg 3
2440 curv 0.000000 4.000000 1 2 3 4 5 6 7 8 9 10 \
2441 11 12 13
2442 parm u 0.000000 1.000000 2.000000 3.000000 \
2443 4.000000
2444 end
2445 # 1 element
2446
2447
2448
2449Comments
2450
2451Comments can appear anywhere in an .obj file. They are used to annotate
2452the file; they are not processed.
2453
2454Here is an example:
2455
2456 # this is a comment
2457
2458The Model program automatically inserts comments when it creates .obj
2459files. For example, it reports the number of geometric vertices,
2460texture vertices, and vertex normals in a file.
2461
2462 # 4 vertices
2463 # 4 texture vertices
2464 # 4 normals
2465
2466Mathematics for free-form curves/surfaces
2467
2468[I apologize but this section will make absolutely no sense whatsoever
2469 without the equations and diagrams and there was just no easy way to
2470 include them in a pure ASCII document. You should probably just skip
2471 ahead to the section "Superseded statements." -Jim]
2472
2473General forms
2474
2475Rational and non-rational curves and surfaces
2476
2477In general, any non-rational curve segment may be written as:
2478
2479where
2480
2481K + 1 is the number of control points
2482
2483di are the control points
2484
2485n is the degree of the curve
2486
2487Ni,n(t) are the degree n basis functions
2488
2489Extending this to the bivariate case, any non-rational surface patch
2490may be written as:
2491
2492where:
2493
2494K1 + 1 is the number of control points in the u direction
2495
2496K2 + 1 is the number of control points in the v direction
2497
2498di,j are the control points
2499
2500m is the degree of the surface in the u direction
2501
2502n is the degree of the surface in the v direction
2503
2504Ni,m(u) are the degree m basis functions in the u direction
2505
2506Nj,n(v) are the degree n basis functions in the v direction
2507
2508NOTE: The front of the surface is defined as the side where the u
2509parameter increases to the right and the v parameter increases upward.
2510
2511We may extend this curve to the rational case as:
2512
2513
2514
2515where wi are the weights associated with the control points di.
2516Similarly, a rational surface may be expressed as:
2517
2518where wi,j are the weights associated with the control points di,j.
2519
2520NOTE: If a curve or surface in an .obj file is rational, it must use
2521the rat option with the cstype statement and it requires some weight
2522values for each control point.
2523
2524
2525
2526The weights for the rational form are given as a third control point
2527coordinate (for trimming curves) or fourth coordinate (for space curves
2528and surfaces). These weights are optional and default to 1.0 if not
2529given.
2530
2531
2532
2533This default weight is only reasonable for curves and surfaces whose
2534basis functions sum to 1.0, such as Bezier, Cardinal, and NURB. It does
2535not make sense for Taylor and may or may not make sense for a
2536representation given in basis-matrix form.
2537
2538For all forms other than B-spline, the final curve or surface is
2539constructed by piecing together the individual curve segments or
2540surface patches. A global parameter space is then defined over the
2541entire composite curve or surface using the parameter vector given with
2542the parm statement.
2543
2544The parameter vector for a curve is a list of p global parameter values
2545{t1, . . . , tp}. If t1 t < ti+1 is a point in global parameter space,
2546then:
2547
2548is the corresponding point in local parameter space for the ith
2549polynomial segment. It is this t which is used when evaluating a given
2550segment of the piecewise curve. For surfaces, this mapping from global
2551to local parameter space is applied independently in both the u and v
2552parametric directions.
2553
2554B-splines require a knot vector rather than a parameter vector,
2555although this is also given with the parm statement. Refer to the
2556description of B-splines below.
2557
2558The following discussion of each type is expressed in terms of the
2559above definitions.
2560
2561NOTE: The maximum degree for all curve and surface types is currently
2562set at 20, which is high enough for most purposes.
2563
2564
2565
2566Free-form curve and surface types
2567
2568B-spline
2569
2570Type bspline specifies arbitrary degree non-uniform B-splines which are
2571commonly referred to as NURBs in their rational form. The basis
2572functions are defined by the Cox-deBoor recursion formulas as:
2573
2574and:
2575
2576where, by convention, 0/0 = 0.
2577
2578The xi {x0, . . . ,xq} form a set known as the knot vector which is
2579given by the parm statement. It is required that
2580
25811. xi xi + 1,
2582
25832. x0 < xn + 1,
2584
25853. xq -n -1 < xq,
2586
25874. xi < xi + n for 0 < i < q - n - 1,
2588
25895. xn t min < tmax xK+ 1, where [tmin, tmax] is the parameter
2590over which the B-spline is to be evaluated, and
2591
25926. K = q - n - 1.
2593
2594A knot is said to be of multiplicity r if its value is repeated r times
2595in the knot vector. The second through fourth conditions above restrict
2596knots to be of at most multiplicity n + 1 at the ends of the vector and
2597at most n everywhere else.
2598
2599The last condition requires that the number of control points is equal
2600to one less than the number of knots minus the degree. For surfaces,
2601all of the above conditions apply independently for the u and v
2602parametric directions.
2603
2604Bezier
2605
2606Type bezier specifies arbitrary degree Bezier curves and surfaces. This
2607basis function is defined as:
2608
2609where:
2610
2611When using type bezier, the number of global parameter values given
2612with the parm statement must be K/n + 1, where K is the number of
2613control points. For surfaces, this requirement applies independently
2614for the u and v parametric directions.
2615
2616Cardinal
2617
2618Type cardinal specifies a cubic, first derivative, continuous curve or
2619surface. For curves, this interpolates all but the first and last
2620control points. For surfaces, all but the first and last row and column
2621of control points are interpolated.
2622
2623Cardinal splines, also known as Catmull-Rom splines, are best
2624understood by considering the conversion from Cardinal to Bezier
2625control points for a single curve segment:
2626
2627Here, the ci variables are the Cardinal control points and the bi
2628variables are the Bezier control points. We see that the second and
2629third Cardinal points are the beginning and ending points for the
2630segment, respectively. Also, the beginning tangent lies along the
2631vector from the first to the third point, and the ending tangent along
2632the vector from the second to the last point.
2633
2634If we let Bi(t) be the cubic Bezier basis functions (i.e. what was
2635given above for Bezier as Ni,n(t) with n = 3), then we may write the
2636Cardinal basis functions as:
2637
2638Note that Cardinal splines are only defined for the cubic case.
2639
2640When using type cardinal, the number of global parameter values given
2641with the parm statement must be K - n + 2, where K is the number of
2642control points. For surfaces, this requirement applies independently
2643for the u and v parametric directions.
2644
2645Taylor
2646
2647Type taylor specifies arbitrary degree Taylor polynomial curves and
2648surfaces. The basis function is simply:
2649
2650NOTE: The control points in this case are the polynomial coefficients
2651and have no obvious geometric significance.
2652
2653When using type taylor, the number of global parameter values given
2654with the parm statement must be (K + 1)/(n + 1) + 1, where K is the
2655number of control points. For surfaces, this requirement applies
2656independently for the u and v parametric directions.
2657
2658Basis matrix
2659
2660Type bmatrix specifies general, arbitrary-degree curves defined through
2661the use of a basis matrix rather than an explicit type such as Bezier.
2662The basis functions are defined as:
2663
2664where the basis matrix is the bi,j. In order to make the matrix nature
2665of this more obvious, we may also write:
2666
2667When constructing basis matrices, you should keep this definition in
2668mind, as different authors write this in different ways. A more common
2669matrix representation is:
2670
2671To use such matrices in the .obj file, simply transpose the matrix and
2672reverse the column ordering.
2673
2674When using type basis, the number of global parameter values given with
2675the parm statement must be (K - n)/s + 2, where K is the number of
2676control points and s is the step size given with the step statement.
2677For surfaces, this requirement applies independently for the u and v
2678parametric directions.
2679
2680Surface vertex data
2681
2682Control points
2683
2684The control points for a surface consisting of a single patch are
2685listed in the order i = 0 to K1 for j = 0, followed by i = 0 to K1 for
2686j = 1, and so on until j = K2.
2687
2688For surfaces made up of many patches, which is the usual case, the
2689control points are ordered as if the surface were a single large patch.
2690For example, the control points for a bicubic Bezier surface consisting
2691of four patches would be arranged as follows:
2692
2693where (m, n) is the global parameter space of the surface and the
2694numbers indicate the ordering of the vertex indices in the surf
2695statement.
2696
2697Texture vertices and texture mapping
2698
2699When texture vertices are not supplied, the original surface
2700parameterization is used for texture mapping. However, if texture
2701vertices are supplied, they are interpreted as additional information
2702to be interpolated or approximated separately from, but using the same
2703interpolation functions as the control vertices.
2704
2705That is, whereas the surface itself, in the non-rational case, was
2706given in the section "Rational and non-rational curves and surfaces"
2707as:
2708
2709
2710
2711the texture vertices are interpolated or approximated by:
2712
2713where ti,j are the texture vertices and the basis functions are the
2714same as for S(u,v). It is T(u,v), rather than the surface
2715parameterization (u,v), which is used when a texture map is applied.
2716
2717Vertex normals and normal mapping
2718
2719Vertex normals are treated exactly like texture vertices. When vertex
2720normals are not supplied, the true surface normals are used. If vertex
2721normals are supplied, they are calculated as:
2722
2723where qi,j are the vertex normals and the basis functions are the same
2724as for S(u,v) and T(u,v).
2725
2726NOTE: Vertex normals do not affect the shape of the surface; they are
2727simply associated with the triangle vertices in the final
2728triangulation. As with faces, supplying vertex normals only affects
2729lighting calculations for the surface.
2730
2731The treatment of both texture vertices and vertex normals in the case
2732of rational surfaces is identical. It is important to notice that even
2733when the surface S(u,v) is rational, the texture and normal surfaces,
2734T(u,v) and Q(u,v), are not rational. This is because the control points
2735(the texture vertices and vertex normals) are never rational.
2736
2737Curve and surface operations
2738
2739Special points
2740
2741The following equations give a more precise description of special
2742points for space curves and discuss the extension to trimming curves
2743and surfaces.
2744
2745Let C(t) be a space curve with the global parameter t. We can
2746approximate this curve by a set of k-1 line segments which connect the
2747points:
2748
2749for some set of k global parameter values {t1,...,tk}
2750
2751Given a special point ts in the parameter space of the curve
2752(referenced by vp), we guarantee that ts {t1, . . . ,tk}. More
2753specifically, we approximate the curve by:
2754
2755where, at the point i where ts is inserted, we have ti ts < ti+1.
2756
2757Special curves
2758
2759The following equations give a more precise description of a special
2760curve.
2761
2762Let T(t) be a special curve with the global parameter t. We have:
2763
2764where (m,n) is a point in the global parameter space of a surface. We
2765can approximate this curve by a set of k-1 line segments which connect
2766the points:
2767
2768for some set of k global parameter values.
2769
2770Let S(m,n) be a surface with the global parameters m and n. We can
2771approximate this surface by a triangulation of a set of p points.
2772
2773which lie on the surface. We further define E as the set of all edges
2774such that ei,j E implies that S(mi,ni) and S(mj,nj) are connected in
2775the triangulation. Finally, we guarantee that there exists some subset
2776of E:
2777
2778such that the points:
2779
2780are connected in the triangulation.
2781
2782Connectivity
2783
2784Recall that the syntax of the con statement is:
2785
2786con surf_1 q0_1 q1_1 curv2d_1 surf_2 q0_2 q1_2 curv2d_2
2787
2788If we let:
2789
2790T1(t1) be the curve referenced by curv2d_1
2791
2792S1(m1, n1) be the surface referenced by surf1 on which T1(t1) lies
2793
2794T2(t2) be the curve referenced by curv2d_2
2795
2796S2(m2, n2) be the surface referenced by surf2 on which T2(t2) lies
2797
2798then S1(T1(t1)), S2(T2(t2)) must be identical up to reparameterization.
2799Moreover, it must be the case that:
2800
2801S1(T1(q0_1)) = S2(T2(q0_2))
2802
2803and:
2804
2805S1(T1(q1_1)) = S2(T2(q1_2))
2806
2807It is along the curve S1(T1(t1)) between t1 = q0_1 and t1 = q1_1, and
2808the curve S2(T2(t2)) between t2 = q0_2 and t2 = q1_2 that the surface
2809S1(m1, n1) is connected to the surface S2(m2, n2).
2810
2811
2812
2813Superseded statements
2814
2815The new .obj file format has eliminated the need for several patch and
2816curve statements. These statements have been replaced by free-form
2817geometry statements.
2818
2819In the 3.0 release, the following keywords have been superseded:
2820
2821o bsp
2822
2823o bzp
2824
2825o cdc
2826
2827o cdp
2828
2829o res
2830
2831You can still read these statements in this version 3.0, however, the
2832system will no longer write files in this format.
2833
2834This release is the last release that will read these statements. If
2835you want to save any data from this format, read in the file and write
2836it out. The system will convert the data to the new .obj format.
2837
2838For more information on the new syntax statements, see "Specifying
2839free-form curves and surfaces."
2840
2841Syntax
2842
2843The following syntax statements are for the superseded keywords.
2844
2845bsp v1 v2 . . . v16
2846
2847 Specifies a B-spline patch. B-spline patches have sixteen control
2848 points, defined as vertices. Only four of the control points are
2849 distributed over the surface of the patch; the remainder are
2850 distributed around the perimeter of the patch.
2851
2852 Patches must be tessellated in Model before they can be correctly
2853 shaded or rendered.
2854
2855 v is the vertex number for a control point. Sixteen vertex numbers
2856 are required. Positive values indicate absolute vertex numbers.
2857 Negative values indicate relative vertex numbers.
2858
2859bzp v1 v2 . . . v16
2860
2861 Specifies a Bezier patch. Bezier patches have sixteen control
2862 points, defined as vertices. The control points are distributed
2863 uniformly over its surface.
2864
2865 Patches must be tessellated in Model before they can be correctly
2866 shaded or rendered.
2867
2868 v is the vertex number for a control point. Sixteen vertex numbers
2869 are required. Positive values indicate absolute vertex numbers.
2870 Negative values indicate relative vertex numbers.
2871
2872cdc v1 v2 v3 v4 v5 . . .
2873
2874 Specifies a Cardinal curve. Cardinal curves have a minimum of four
2875 control points, defined as vertices.
2876
2877 Cardinal curves cannot be correctly shaded or rendered. They can be
2878 tessellated and then extruded in Model to create 3D shapes.
2879
2880 v is the vertex number for a control point. A minimum of four
2881 vertex numbers are required. There is no limit on the maximum.
2882 Positive values indicate absolute vertex numbers. Negative values
2883 indicate relative vertex numbers.
2884
2885cdp v1 v2 v3 . . . v16
2886
2887 Specifies a Cardinal patch. Cardinal patches have sixteen control
2888 points, defined as vertices. Four of the control points are
2889 attached to the corners of the patch.
2890
2891 Patches must be tessellated in Model before they can be correctly
2892 shaded or rendered.
2893
2894 v is the vertex number for a control point. Sixteen vertex numbers
2895 are required. Positive values indicate absolute vertex numbers.
2896 Negative values indicate relative vertex numbers.
2897
2898res useg vseg
2899
2900 Reference and display statement.
2901
2902 Sets the number of segments for Bezier, B-spline and Cardinal
2903 patches that follow it.
2904
2905 useg is the number of segments in the u direction (horizontal or x
2906 direction). The minimum setting is 3 and the maximum setting is
2907 120. The default is 4.
2908
2909 vseg is the number of segments in the v direction (vertical or y
2910 direction). The minimum setting is 3 and the maximum setting is
2911 120. The default is 4.
2912
2913Comparison of 2.11 and 3.0 syntax
2914
2915Cardinal curve
2916
2917The following example shows the 2.11 syntax and the 3.0 syntax for the
2918same Cardinal curve.
2919
29202.11 Cardinal curve
2921
2922 # 2.11 Cardinal Curve
2923
2924 v 2.570000 1.280000 0.000000
2925 v 0.940000 1.340000 0.000000
2926 v -0.670000 0.820000 0.000000
2927 v -0.770000 -0.940000 0.000000
2928 v 1.030000 -1.350000 0.000000
2929 v 3.070000 -1.310000 0.000000
2930 # 6 vertices
2931
2932 cdc 1 2 3 4 5 6
2933
2934
29353.0 Cardinal curve
2936
2937 # 3.0 Cardinal curve
2938
2939 v 2.570000 1.280000 0.000000
2940 v 0.940000 1.340000 0.000000
2941 v -0.670000 0.820000 0.000000
2942 v -0.770000 -0.940000 0.000000
2943 v 1.030000 -1.350000 0.000000
2944 v 3.070000 -1.310000 0.000000
2945 # 6 vertices
2946
2947 cstype cardinal
2948 deg 3
2949 curv 0.000000 3.000000 1 2 3 4 5 6
2950 parm u 0.000000 1.000000 2.000000 3.000000
2951 end
2952 # 1 element
2953
2954Bezier patch
2955
2956 The following example shows the 2.11 syntax and the 3.0 syntax for the
2957 same Bezier patch.
2958
29592.11 Bezier patch
2960
2961 # 2.11 Bezier Patch
2962 v -5.000000 -5.000000 0.000000
2963 v -5.000000 -1.666667 0.000000
2964 v -5.000000 1.666667 0.000000
2965 v -5.000000 5.000000 0.000000
2966 v -1.666667 -5.000000 0.000000
2967 v -1.666667 -1.666667 0.000000
2968 v -1.666667 1.666667 0.000000
2969 v -1.666667 5.000000 0.000000
2970 v 1.666667 -5.000000 0.000000
2971 v 1.666667 -1.666667 0.000000
2972 v 1.666667 1.666667 0.000000
2973 v 1.666667 5.000000 0.000000
2974 v 5.000000 -5.000000 0.000000
2975 v 5.000000 -1.666667 0.000000
2976 v 5.000000 1.666667 0.000000
2977 v 5.000000 5.000000 0.000000
2978 # 16 vertices
2979
2980 bzp 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
2981 # 1 element
2982
29833.0 Bezier patch
2984
2985 # 3.0 Bezier patch
2986
2987 v -5.000000 -5.000000 0.000000
2988 v -5.000000 -1.666667 0.000000
2989 v -5.000000 1.666667 0.000000
2990 v -5.000000 5.000000 0.000000
2991 v -1.666667 -5.000000 0.000000
2992 v -1.666667 -1.666667 0.000000
2993 v -1.666667 1.666667 0.000000
2994 v -1.666667 5.000000 0.000000
2995 v 1.666667 -5.000000 0.000000
2996 v 1.666667 -1.666667 0.000000
2997 v 1.666667 1.666667 0.000000
2998 v 1.666667 5.000000 0.000000
2999 v 5.000000 -5.000000 0.000000
3000 v 5.000000 -1.666667 0.000000
3001 v 5.000000 1.666667 0.000000
3002 v 5.000000 5.000000 0.000000
3003 # 16 vertices
3004
3005 cstype bezier
3006 deg 3 3
3007 surf 0.000000 1.000000 0.000000 1.000000 13 14 \
3008 15 16 9 10 11 12 5 6 7 8 1 2 3 4
3009 parm u 0.000000 1.000000
3010 parm v 0.000000 1.000000
3011 end
3012 # 1 element
3013