X3D OBJ FILE FORMAT

1) What is the x3d version 2.0 .obj file format?

Example:

        
       +---+
      /   /| 
     +___+ |
     |   | +
     |   |/
     +___+


     consider a simple cube with faces:

# top

  0 255   0 # green

 1000  1000  1000
-1000  1000  1000
 1000 -1000  1000
-1000 -1000  1000

# bottom

  0   0 255 # blue 

 1000  1000 -1000
-1000  1000 -1000
 1000 -1000 -1000
-1000 -1000 -1000

# right side 

255   0   0 # red 

 1000  1000  1000
 1000  1000 -1000
 1000 -1000  1000
 1000 -1000 -1000

# left side 

255 255 255 # white

-1000  1000  1000
-1000  1000 -1000
-1000 -1000  1000
-1000 -1000 -1000

# back 

128   0 255 # purple

 1000  1000  1000
 1000  1000 -1000
-1000  1000  1000
-1000  1000 -1000

# front 

255 128   0 # orange

 1000 -1000  1000
 1000 -1000 -1000
-1000 -1000  1000
-1000 -1000 -1000



The corresponding .obj file generated by the hull utility would be:



# x3d 2.0 object file generated by hull using cube.poly

# number of colors used in object

6

# colors used in object (color number red green blue)

0   0 255 0
1   0 0 255
2   255 0 0
3   255 255 255
4   128 0 255
5   255 128 0

# number of points used in object

8

# points used in object (point number x y z)

0   -1000.000000 -1000.000000 -1000.000000
1   -1000.000000 -1000.000000 1000.000000
2   -1000.000000 1000.000000 -1000.000000
3   -1000.000000 1000.000000 1000.000000
4   1000.000000 -1000.000000 -1000.000000
5   1000.000000 -1000.000000 1000.000000
6   1000.000000 1000.000000 -1000.000000
7   1000.000000 1000.000000 1000.000000

# number segments used in object

12

# segments used in object (segment number color p q)

0   0   5 7
1   0   7 3
2   1   6 2
3   1   4 6
4   3   2 3
5   3   0 2
6   3   1 0
7   3   3 1
8   4   6 7
9   5   0 4
10   5   5 1
11   5   4 5

# number of polygons used in object

6

# polygons used in object (polygon number color
# number of segments in polygon s0 s1 s2 ... sn)

0   0   4   1 7 10 0
1   1   4   2 5 9 3
2   2   4   0 11 3 8
3   3   4   7 6 5 4
4   4   4   1 4 2 8
5   5   4   10 6 9 11



Things to note:

   Polygons are specified as sets of coplaner points that specify a 
   convex polygon.  If the points are not coplaner or do not form a 
   convex polygon the hull utility will still generate output anyway
   but my programs might generate wrong answers when the information 
   is used.

   Colors have been added to x3d 2.0, every segment and polygon gets
   a single color associated with it.  The colors are used in various
   new display modes.

   The hull utility attempts to reduce the number of points and
   segments used to represent the object.  It should only keep one
   copy of identical points and segments.  It does not merge colinear
   line segments. 

   The "#" character may now be used to start comment lines in all files
   x3d and hull use.



2) How did I generate my .obj files?

  Each object has a comment indicating its source at its beginning. 
  Some of the objects I included with x3d were created with
  an animation/renderer interpreter that a friend of mine, Abe Megahed, and
  I are working on.

  In the /pub/rendered_objs on castlab (144.92.60.140) are a few examples of
  the images that were made with a previous renderd Abe wrote (xdart).
  They are all in miff format and require the ImageMagick image manipulation
  software which is found as /pub/ImageMagick2.0.tar.Z  which is my favorite
  set of image utilities.

  The binaries for xdart are available for serveral machines types on castlab
  as well.
  
  I really encourage you to at least try TOYS2_SS.miff out, particularly
  if you have a 24 bit display.

