-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathobj.txt
3045 lines (2182 loc) · 90.2 KB
/
obj.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
B1. Object Files (.obj)
Object files define the geometry and other properties for objects in
Wavefront's Advanced Visualizer. Object files can also be used to
transfer geometric data back and forth between the Advanced Visualizer
and other applications.
Object files can be in ASCII format (.obj) or binary format (.mod).
This appendix describes the ASCII format for object files. These files
must have the extension .obj.
In this release, the .obj file format supports both polygonal objects
and free-form objects. Polygonal geometry uses points, lines, and faces
to define objects while free-form geometry uses curves and surfaces.
About this section
The .obj appendix is for those who want to use the .obj format to
translate geometric data from other software applications to Wavefront
products. It also provides information for Advanced Visualizer users
who want detailed information on the Wavefront .obj file format.
If you are a 2.11 user and want to understand the significance of the
3.0 release and how it affects your existing files, you may be
especially interested in the section called "Superseded statements" at
the end of the appendix. The section, "Patches and free-form surfaces,"
gives examples of how 2.11 patches look in 3.0.
How this section is organized
Most of this appendix describes the different parts of an .obj file and
how those parts are arranged in the file. The three sections at the end
of the appendix provide background information on the 3.0 release of
the .obj format.
The .obj appendix includes the following sections:
o File structure
o General statement
o Vertex data
o Specifying free-form curves/surfaces
o Free-form curve/surface attributes
o Elements
o Free-form curve/surface body statements
o Connectivity between free-form surfaces
o Grouping
o Display/render attributes
o Comments
o Mathematics for free-form curves/surfaces
o Superseded statements
o Patches and free-form surfaces
---------------
The curve and surface extensions to the .obj file format were
developed in conjunction with mental images GmbH&Co.KG, Berlin,
Germany, as part of a joint development project to incorporate
free-form surfaces into Wavefront's Advanced Visualizer.
File structure
The following types of data may be included in an .obj file. In this
list, the keyword (in parentheses) follows the data type.
Vertex data
o geometric vertices (v)
o texture vertices (vt)
o vertex normals (vn)
o parameter space vertices (vp)
Free-form curve/surface attributes
o rational or non-rational forms of curve or surface type:
basis matrix, Bezier, B-spline, Cardinal, Taylor (cstype)
o degree (deg)
o basis matrix (bmat)
o step size (step)
Elements
o point (p)
o line (l)
o face (f)
o curve (curv)
o 2D curve (curv2)
o surface (surf)
Free-form curve/surface body statements
o parameter values (parm)
o outer trimming loop (trim)
o inner trimming loop (hole)
o special curve (scrv)
o special point (sp)
o end statement (end)
Connectivity between free-form surfaces
o connect (con)
Grouping
o group name (g)
o smoothing group (s)
o merging group (mg)
o object name (o)
Display/render attributes
o bevel interpolation (bevel)
o color interpolation (c_interp)
o dissolve interpolation (d_interp)
o level of detail (lod)
o material name (usemtl)
o material library (mtllib)
o shadow casting (shadow_obj)
o ray tracing (trace_obj)
o curve approximation technique (ctech)
o surface approximation technique (stech)
The following diagram shows how these parts fit together in a typical
.obj file.
|--------------------------------------|
| grouping |
| display/render attributes |
| |
|--------------------------------------| |
| vertex data |
| |
|--------------------------------------| |
| free-form attributes |
| |
|--------------------------------------| |
| elements |
| body statements |
| |
|--------------------------------------| |
| grouping/attribute data |
| |
|--------------------------------------| |
| element data . . . |
| |
| |
| . |
| . |
| . |
| |
| |
|--------------------------------------|
Figure B1-1. Typical .obj file structure
General statement
call filename.ext arg1 arg2 . . .
Reads the contents of the specified .obj or .mod file at this
location. The call statement can be inserted into .obj files using
a text editor.
filename.ext is the name of the .obj or .mod file to be read. You
must include the extension with the filename.
arg1 arg2 . . . specifies a series of optional integer arguments
that are passed to the called file. There is no limit to the number
of nested calls that can be made.
Arguments passed to the called file are substituted in the same way
as in UNIX scripts; for example, $1 in the called file is replaced
by arg1, $2 in the called file is replaced by arg2, and so on.
If the frame number is needed in the called file for variable
substitution, "$1" must be used as the first argument in the call
statement. For example:
call filename.obj $1
Then the statement in the called file,
scmp filename.pv $1
will work as expected. For more information on the scmp statement,
see appendix C, Variable Substitution for more information.
Another method to do the same thing is:
scmp filename.pv $1
call filename.obj
Using this method, the scmp statement provides the .pv file for all
subsequently called .obj or .mod files.
csh command
csh -command
Executes the requested UNIX command. If the UNIX command returns an
error, the parser flags an error during parsing.
If a dash (-) precedes the UNIX command, the error is ignored.
command is the UNIX command.
Vertex data
Vertex data provides coordinates for:
o geometric vertices
o texture vertices
o vertex normals
For free-form objects, the vertex data also provides:
o parameter space vertices
The vertex data is represented by four vertex lists; one for each type
of vertex coordinate. A right-hand coordinate system is used to specify
the coordinate locations.
The following sample is a portion of an .obj file that contains the
four types of vertex information.
v -5.000000 5.000000 0.000000
v -5.000000 -5.000000 0.000000
v 5.000000 -5.000000 0.000000
v 5.000000 5.000000 0.000000
vt -5.000000 5.000000 0.000000
vt -5.000000 -5.000000 0.000000
vt 5.000000 -5.000000 0.000000
vt 5.000000 5.000000 0.000000
vn 0.000000 0.000000 1.000000
vn 0.000000 0.000000 1.000000
vn 0.000000 0.000000 1.000000
vn 0.000000 0.000000 1.000000
vp 0.210000 3.590000
vp 0.000000 0.000000
vp 1.000000 0.000000
vp 0.500000 0.500000
When vertices are loaded into the Advanced Visualizer, they are
sequentially numbered, starting with 1. These reference numbers are
used in element statements.
Syntax
The following syntax statements are listed in order of complexity.
v x y z w
Polygonal and free-form geometry statement.
Specifies a geometric vertex and its x y z coordinates. Rational
curves and surfaces require a fourth homogeneous coordinate, also
called the weight.
x y z are the x, y, and z coordinates for the vertex. These are
floating point numbers that define the position of the vertex in
three dimensions.
w is the weight required for rational curves and surfaces. It is
not required for non-rational curves and surfaces. If you do not
specify a value for w, the default is 1.0.
NOTE: A positive weight value is recommended. Using zero or
negative values may result in an undefined point in a curve or
surface.
vp u v w
Free-form geometry statement.
Specifies a point in the parameter space of a curve or surface.
The usage determines how many coordinates are required. Special
points for curves require a 1D control point (u only) in the
parameter space of the curve. Special points for surfaces require a
2D point (u and v) in the parameter space of the surface. Control
points for non-rational trimming curves require u and v
coordinates. Control points for rational trimming curves require u,
v, and w (weight) coordinates.
u is the point in the parameter space of a curve or the first
coordinate in the parameter space of a surface.
v is the second coordinate in the parameter space of a surface.
w is the weight required for rational trimming curves. If you do
not specify a value for w, it defaults to 1.0.
NOTE: For additional information on parameter vertices, see the
curv2 and sp statements
vn i j k
Polygonal and free-form geometry statement.
Specifies a normal vector with components i, j, and k.
Vertex normals affect the smooth-shading and rendering of geometry.
For polygons, vertex normals are used in place of the actual facet
normals. For surfaces, vertex normals are interpolated over the
entire surface and replace the actual analytic surface normal.
When vertex normals are present, they supersede smoothing groups.
i j k are the i, j, and k coordinates for the vertex normal. They
are floating point numbers.
vt u v w
Vertex statement for both polygonal and free-form geometry.
Specifies a texture vertex and its coordinates. A 1D texture
requires only u texture coordinates, a 2D texture requires both u
and v texture coordinates, and a 3D texture requires all three
coordinates.
u is the value for the horizontal direction of the texture.
v is an optional argument.
v is the value for the vertical direction of the texture. The
default is 0.
w is an optional argument.
w is a value for the depth of the texture. The default is 0.
Specifying free-form curves/surfaces
There are three steps involved in specifying a free-form curve or
surface element.
o Specify the type of curve or surface (basis matrix, Bezier,
B-spline, Cardinal, or Taylor) using free-form curve/surface
attributes.
o Describe the curve or surface with element statements.
o Supply additional information, using free-form curve/surface
body statements
The next three sections of this appendix provide detailed information
on each of these steps.
Data requirements for curves and surfaces
All curves and surfaces require a certain set of data. This consists of
the following:
Free-form curve/surface attributes
o All curves and surfaces require type data, which is given with
the cstype statement.
o All curves and surfaces require degree data, which is given
with the deg statement.
o Basis matrix curves or surfaces require a bmat statement.
o Basis matrix curves or surfaces also require a step size, which
is given with the step statement.
Elements
o All curves and surfaces require control points, which are
referenced in the curv, curv2, or surf statements.
o 3D curves and surfaces require a parameter range, which is
given in the curv and surf statements, respectively.
Free-form curve/surface body statements
o All curves and surfaces require a set of global parameters or a
knot vector, both of which are given with the parm statement.
o All curves and surfaces body statements require an explicit end
statement.
Error checks
The above set of data starts out empty with no default values when
reading of an .obj file begins. While the file is being read,
statements are encountered, information is accumulated, and some errors
may be reported.
When the end statement is encountered, the following error checks,
which involve consistency between various statements, are performed:
o All required information is present.
o The number of control points, number of parameter values
(knots), and degree are consistent with the curve or surface
type. If the type is bmatrix, the step size is also consistent.
(For more information, refer to the parameter vector equations
in the section, "Mathematics of free-form curves/ surfaces" at
the end of appendix B1.)
o If the type is bmatrix and the degree is n, the size of the
basis matrix is (n + 1) x (n + 1).
Note that any information given by the state-setting statements remains
in effect from one curve or surface to the next. Information given
within a curve or surface body is only effective for the curve or
surface it is given with.
Free-form curve/surface attributes
Five types of free-form geometry are available in the .obj file
format:
o Bezier
o basis matrix
o B-spline
o Cardinal
o Taylor
You can apply these types only to curves and surfaces. Each of these
five types can be rational or non-rational.
In addition to specifying the type, you must define the degree for the
curve or surface. For basis matrix curve and surface elements, you must
also specify the basis matrix and step size.
All free-form curve and surface attribute statements are state-setting.
This means that once an attribute statement is set, it applies to all
elements that follow until it is reset to a different value.
Syntax
The following syntax statements are listed in order of use.
cstype rat type
Free-form geometry statement.
Specifies the type of curve or surface and indicates a rational or
non-rational form.
rat is an optional argument.
rat specifies a rational form for the curve or surface type. If rat
is not included, the curve or surface is non-rational
type specifies the curve or surface type. Allowed types are:
bmatrix basis matrix
bezier Bezier
bspline B-spline
cardinal Cardinal
taylor Taylor
There is no default. A value must be supplied.
deg degu degv
Free-form geometry statement.
Sets the polynomial degree for curves and surfaces.
degu is the degree in the u direction. It is required for both
curves and surfaces.
degv is the degree in the v direction. It is required only for
surfaces. For Bezier, B-spline, Taylor, and basis matrix, there is
no default; a value must be supplied. For Cardinal, the degree is
always 3. If some other value is given for Cardinal, it will be
ignored.
bmat u matrix
bmat v matrix
Free-form geometry statement.
Sets the basis matrices used for basis matrix curves and surfaces.
The u and v values must be specified in separate bmat statements.
NOTE: The deg statement must be given before the bmat statements
and the size of the matrix must be appropriate for the degree.
u specifies that the basis matrix is applied in the u direction.
v specifies that the basis matrix is applied in the v direction.
matrix lists the contents of the basis matrix with column subscript
j varying the fastest. If n is the degree in the given u or v
direction, the matrix (i,j) should be of size (n + 1) x (n + 1).
There is no default. A value must be supplied.
NOTE: The arrangement of the matrix is different from that commonly
found in other references. For more information, see the examples
at the end of this section and also the section, "Mathematics for
free-form curves and surfaces."
step stepu stepv
Free-form geometry statement.
Sets the step size for curves and surfaces that use a basis
matrix.
stepu is the step size in the u direction. It is required for both
curves and surfaces that use a basis matrix.
stepv is the step size in the v direction. It is required only for
surfaces that use a basis matrix. There is no default. A value must
be supplied.
When a curve or surface is being evaluated and a transition from
one segment or patch to the next occurs, the set of control points
used is incremented by the step size. The appropriate step size
depends on the representation type, which is expressed through the
basis matrix, and on the degree.
That is, suppose we are given a curve with k control points:
{v , ... v }
1 k
If the curve is of degree n, then n + 1 control points are needed
for each polynomial segment. If the step size is given as s, then
the ith polynomial segment, where i = 0 is the first segment, will
use the control points:
{v ,...,v }
is+1 is+n+1
For example, for Bezier curves, s = n .
For surfaces, the above description applies independently to each
parametric direction.
When you create a file which uses the basis matrix type, be sure to
specify a step size appropriate for the current curve or surface
representation.
Examples
1. Cubic Bezier surface made with a basis matrix
To create a cubic Bezier surface:
cstype bmatrix
deg 3 3
step 3 3
bmat u 1 -3 3 -1 \
0 3 -6 3 \
0 0 3 -3 \
0 0 0 1
bmat v 1 -3 3 -1 \
0 3 -6 3 \
0 0 3 -3 \
0 0 0 1
2. Hermite curve made with a basis matrix
To create a Hermite curve:
cstype bmatrix
deg 3
step 2
bmat u 1 0 -3 2 0 0 3 -2 \
0 1 -2 1 0 0 -1 1
3. Bezier in u direction with B-spline in v direction;
made with a basis matrix
To create a surface with a cubic Bezier in the u direction and
cubic uniform B-spline in the v direction:
cstype bmatrix
deg 3 3
step 3 1
bmat u 1 -3 3 -1 \
0 3 -6 3 \
0 0 3 -3 \
0 0 0 1
bmat v 0.16666 -0.50000 0.50000 -0.16666 \
0.66666 0.00000 -1.00000 0.50000 \
0.16666 0.50000 0.50000 -0.50000 \
0.00000 0.00000 0.00000 0.16666
Elements
For polygonal geometry, the element types available in the .obj file
are:
o points
o lines
o faces
For free-form geometry, the element types available in the .obj file
are:
o curve
o 2D curve on a surface
o surface
All elements can be freely intermixed in the file.
Referencing vertex data
For all elements, reference numbers are used to identify geometric
vertices, texture vertices, vertex normals, and parameter space
vertices.
Each of these types of vertices is numbered separately, starting with
1. This means that the first geometric vertex in the file is 1, the
second is 2, and so on. The first texture vertex in the file is 1, the
second is 2, and so on. The numbering continues sequentially throughout
the entire file. Frequently, files have multiple lists of vertex data.
This numbering sequence continues even when vertex data is separated by
other data.
In addition to counting vertices down from the top of the first list in
the file, you can also count vertices back up the list from an
element's position in the file. When you count up the list from an
element, the reference numbers are negative. A reference number of -1
indicates the vertex immediately above the element. A reference number
of -2 indicates two references above and so on.
Referencing groups of vertices
Some elements, such as faces and surfaces, may have a triplet of
numbers that reference vertex data.These numbers are the reference
numbers for a geometric vertex, a texture vertex, and a vertex normal.
Each triplet of numbers specifies a geometric vertex, texture vertex,
and vertex normal. The reference numbers must be in order and must
separated by slashes (/).
o The first reference number is the geometric vertex.
o The second reference number is the texture vertex. It follows
the first slash.
o The third reference number is the vertex normal. It follows the
second slash.
There is no space between numbers and the slashes. There may be more
than one series of geometric vertex/texture vertex/vertex normal
numbers on a line.
The following is a portion of a sample file for a four-sided face
element:
f 1/1/1 2/2/2 3/3/3 4/4/4
Using v, vt, and vn to represent geometric vertices, texture vertices,
and vertex normals, the statement would read:
f v/vt/vn v/vt/vn v/vt/vn v/vt/vn
If there are only vertices and vertex normals for a face element (no
texture vertices), you would enter two slashes (//). For example, to
specify only the vertex and vertex normal reference numbers, you would
enter:
f 1//1 2//2 3//3 4//4
When you are using a series of triplets, you must be consistent in the
way you reference the vertex data. For example, it is illegal to give
vertex normals for some vertices, but not all.
The following is an example of an illegal statement.
f 1/1/1 2/2/2 3//3 4//4
Syntax
The following syntax statements are listed in order of complexity of
geometry.
p v1 v2 v3 . . .
Polygonal geometry statement.
Specifies a point element and its vertex. You can specify multiple
points with this statement. Although points cannot be shaded or
rendered, they are used by other Advanced Visualizer programs.
v is the vertex reference number for a point element. Each point
element requires one vertex. Positive values indicate absolute
vertex numbers. Negative values indicate relative vertex numbers.
l v1/vt1 v2/vt2 v3/vt3 . . .
Polygonal geometry statement.
Specifies a line and its vertex reference numbers. You can
optionally include the texture vertex reference numbers. Although
lines cannot be shaded or rendered, they are used by other Advanced
Visualizer programs.
The reference numbers for the vertices and texture vertices must be
separated by a slash (/). There is no space between the number and
the slash.
v is a reference number for a vertex on the line. A minimum of two
vertex numbers are required. There is no limit on the maximum.
Positive values indicate absolute vertex numbers. Negative values
indicate relative vertex numbers.
vt is an optional argument.
vt is the reference number for a texture vertex in the line
element. It must always follow the first slash.
f v1/vt1/vn1 v2/vt2/vn2 v3/vt3/vn3 . . .
Polygonal geometry statement.
Specifies a face element and its vertex reference number. You can
optionally include the texture vertex and vertex normal reference
numbers.
The reference numbers for the vertices, texture vertices, and
vertex normals must be separated by slashes (/). There is no space
between the number and the slash.
v is the reference number for a vertex in the face element. A
minimum of three vertices are required.
vt is an optional argument.
vt is the reference number for a texture vertex in the face
element. It always follows the first slash.
vn is an optional argument.
vn is the reference number for a vertex normal in the face element.
It must always follow the second slash.
Face elements use surface normals to indicate their orientation. If
vertices are ordered counterclockwise around the face, both the
face and the normal will point toward the viewer. If the vertex
ordering is clockwise, both will point away from the viewer. If
vertex normals are assigned, they should point in the general
direction of the surface normal, otherwise unpredictable results
may occur.
If a face has a texture map assigned to it and no texture vertices
are assigned in the f statement, the texture map is ignored when
the element is rendered.
NOTE: Any references to fo (face outline) are no longer valid as of
version 2.11. You can use f (face) to get the same results.
References to fo in existing .obj files will still be read,
however, they will be written out as f when the file is saved.
curv u0 u1 v1 v2 . . .
Element statement for free-form geometry.
Specifies a curve, its parameter range, and its control vertices.
Although curves cannot be shaded or rendered, they are used by
other Advanced Visualizer programs.
u0 is the starting parameter value for the curve. This is a
floating point number.
u1 is the ending parameter value for the curve. This is a floating
point number.
v is the vertex reference number for a control point. You can
specify multiple control points. A minimum of two control points
are required for a curve.
For a non-rational curve, the control points must be 3D. For a
rational curve, the control points are 3D or 4D. The fourth
coordinate (weight) defaults to 1.0 if omitted.
curv2 vp1 vp2 vp3. . .
Free-form geometry statement.
Specifies a 2D curve on a surface and its control points. A 2D
curve is used as an outer or inner trimming curve, as a special
curve, or for connectivity.
vp is the parameter vertex reference number for the control point.
You can specify multiple control points. A minimum of two control
points is required for a 2D curve.
The control points are parameter vertices because the curve must
lie in the parameter space of some surface. For a non-rational
curve, the control vertices can be 2D. For a rational curve, the
control vertices can be 2D or 3D. The third coordinate (weight)
defaults to 1.0 if omitted.
surf s0 s1 t0 t1 v1/vt1/vn1 v2/vt2/vn2 . . .
Element statement for free-form geometry.
Specifies a surface, its parameter range, and its control vertices.
The surface is evaluated within the global parameter range from s0
to s1 in the u direction and t0 to t1 in the v direction.
s0 is the starting parameter value for the surface in the u
direction.
s1 is the ending parameter value for the surface in the u
direction.
t0 is the starting parameter value for the surface in the v
direction.
t1 is the ending parameter value for the surface in the v
direction.
v is the reference number for a control vertex in the surface.
vt is an optional argument.
vt is the reference number for a texture vertex in the surface. It
must always follow the first slash.
vn is an optional argument.
vn is the reference number for a vertex normal in the surface. It
must always follow the second slash.
For a non-rational surface, the control vertices are 3D. For a
rational surface the control vertices can be 3D or 4D. The fourth
coordinate (weight) defaults to 1.0 if ommitted.
NOTE: For more information on the ordering of control points for
survaces, refer to the section on surfaces and control points in
"mathematics of free-form curves/surfaces" at the end of this
appendix.
Examples
These are examples for polygonal geometry.
For examples using free-form geometry, see the examples at the end of
the next section, "Free-form curve/surface body statements."
1. Square
This example shows a square that measures two units on each side and
faces in the positive direction (toward the camera). Note that the
ordering of the vertices is counterclockwise. This ordering determines
that the square is facing forward.
v 0.000000 2.000000 0.000000
v 0.000000 0.000000 0.000000
v 2.000000 0.000000 0.000000
v 2.000000 2.000000 0.000000
f 1 2 3 4
2. Cube
This is a cube that measures two units on each side. Each vertex is
shared by three different faces.
v 0.000000 2.000000 2.000000
v 0.000000 0.000000 2.000000
v 2.000000 0.000000 2.000000
v 2.000000 2.000000 2.000000
v 0.000000 2.000000 0.000000
v 0.000000 0.000000 0.000000
v 2.000000 0.000000 0.000000
v 2.000000 2.000000 0.000000
f 1 2 3 4
f 8 7 6 5
f 4 3 7 8
f 5 1 4 8
f 5 6 2 1
f 2 6 7 3
3. Cube with negative reference numbers
This is a cube with negative vertex reference numbers. Each element
references the vertices stored immediately above it in the file. Note
that vertices are not shared.
v 0.000000 2.000000 2.000000
v 0.000000 0.000000 2.000000
v 2.000000 0.000000 2.000000
v 2.000000 2.000000 2.000000
f -4 -3 -2 -1
v 2.000000 2.000000 0.000000
v 2.000000 0.000000 0.000000
v 0.000000 0.000000 0.000000
v 0.000000 2.000000 0.000000
f -4 -3 -2 -1
v 2.000000 2.000000 2.000000
v 2.000000 0.000000 2.000000
v 2.000000 0.000000 0.000000
v 2.000000 2.000000 0.000000
f -4 -3 -2 -1
v 0.000000 2.000000 0.000000
v 0.000000 2.000000 2.000000
v 2.000000 2.000000 2.000000
v 2.000000 2.000000 0.000000
f -4 -3 -2 -1
v 0.000000 2.000000 0.000000
v 0.000000 0.000000 0.000000
v 0.000000 0.000000 2.000000
v 0.000000 2.000000 2.000000
f -4 -3 -2 -1
v 0.000000 0.000000 2.000000
v 0.000000 0.000000 0.000000
v 2.000000 0.000000 0.000000
v 2.000000 0.000000 2.000000
f -4 -3 -2 -1
Free-form curve/surface body statements
You can specify additional information for free-form curve and surface
elements using a series of statements called body statements. The
series is concluded by an end statement.
Body statements are valid only when they appear between the free-form
element statement (curv, curv2, surf) and the end statement. If they
are anywhere else in the .obj file, they do not have any effect.
You can use body statements to specify the following values:
o parameter
o knot vector