[comp.graphics] 3D Object files; 3cad file format

milholla@eniac.seas.upenn.edu.UUCP (Matt Considine) (06/16/89)

Does anyone know of an anonymous ftp site for 3D object files
*other* than the albanycs.albany.edu site?? Ideally, such a
site would have files other than those found on the albany site).
For example, I recall an article about a year ago from Steve Udell(sp?)
which said he was uploading a number of UUEncoded files containing
images of chess pieces, the Enterprise, etc.  Does anyone know
where those files can be found??
Also, does anyone know what the format is for 3Cad files?? This
is the format that Mr. Udell's files were in - I believe.

Any help would be appreciated.  Thanks...

brian@hpfcdj.HP.COM (Brian Rauchfuss) (06/20/89)

    I would appreciate information on 3d databases too!
Could the information be posted?

Brian Rauchfuss

greg@bilbo (Greg Wageman) (06/23/89)

In article <470005@hpfcdj.HP.COM> brian@hpfcdj.HP.COM (Brian Rauchfuss) writes:
>
>    I would appreciate information on 3d databases too!
>Could the information be posted?

OK, here goes:

Notes:

CAD-3D was written for the Atari ST, which uses a Motorola 68000
processor.  Hence, all multi-byte values are stored MSByte to LSByte.

The 40 object limit has been raised to 80 in version 2.0.1.

The "BIOS" format for color palette information is 3 bits per gun,
right-justified and nybble aligned:

        MSB  0 0 0 0  0 r r r  0 g g g  0 b b b  LSB

Since the Atari ST has 16 color palette registers in low resolution
mode, references to "colors 0-15" actually refer to the current
contents of the appropriate palette entry.

---------------------------- CUT HERE ----------------------------------



         CAD-3D THREE-DIMENSIONAL OBJECT FILE

         CAD-3D 2.0 stores its 3D objects in a file which can hold up
         to 40 objects, and contains all the information about the
         objects, including the lighting and color palette used by the
         objects.

         The file is similar to the older file format, but no longer
         relies on the Motorola Fast Floating Point library (LIBF) for
         the storage of vertex coordinates.  The new version stores
         each coordinate in a two-byte word instead of a four-byte
         floating-point value, saving a considerable amount of
         storage, as well as making the file usable more easily by
         programs written with different floating-point formats.

         The CAD-3D 2.0 3D object file uses an extension of .3D2, and
         is composed of two parts.  The first section is a 256-byte
         header, which tells how many objects are included in the
         file, the light settings and the color information.  The
         second section of the file contains a repeating structure of
         data which defines the 3D objects in the file.

         The header is structured as follows:


         WORD -- File ID -- $3D02

         WORD -- Count of objects in file (1-40)

         WORD -- Light source A on/off indicator (0=off, 1=on)
         WORD -- Light source B on/off indicator (0=off, 1=on)
         WORD -- Light source C on/off indicator (0=off, 1=on)

         WORD -- Light source A brightness (0-7)
         WORD -- Light source B brightness (0-7)
         WORD -- Light source C brightness (0-7)
         WORD -- Ambient light brightness (0-7)

         WORD -- Light source A Z position (-50 through +50)
         WORD -- Light source B Z position (-50 through +50)
         WORD -- Light source C Z position (-50 through +50)

         WORD -- Light source A Y position (-50 through +50)
         WORD -- Light source B Y position (-50 through +50)
         WORD -- Light source C Y position (-50 through +50)

         WORD -- Light source A X position (-50 through +50)
         WORD -- Light source B X position (-50 through +50)
         WORD -- Light source C X position (-50 through +50)

         16 WORDs -- Object color palette (BIOS format)
         16 WORDs -- Color group base array

         In order for the palette to be useful, it must be accompanied











         by the color group base array.  This array indicates the
         index of the first color in the group to which that color
         belongs.  In the following example palette, which contains a
         background color of black, followed by five reds, five greens
         and five blues, you can see how the palette base array is
         used to group the colors together.  The reds start at color
         index 1, the greens at color index 6, and the blues at color
         index 11.

         INDEX    COLOR     BASE
         -----    -----     ----
            0      000        0
            1      100        1
            2      200        1
            3      300        1
            4      400        1
            5      500        1
            6      010        6
            7      020        6
            8      030        6
            9      040        6
           10      050        6
           11      001       11
           12      002       11
           13      003       11
           14      004       11
           15      005       11

         The base value is used when performing shading operations,
         and if incorrectly set will result in odd-looking images.

         WORD -- Color palette type (0=Seven-shade, 1=Fourteen shade,
         2=Custom)

         WORD -- Wireframe line color (1-15)

         WORD -- Outline line color (0-15)

         150 BYTEs -- Filler for future expansion


         The object data is a variable-sized section which depends on
         the complexity of the object.  The section repeats for each
         object in the file, and is structured as follows:

         9 BYTEs -- Object name (8 characters max) with null
         terminator.

         WORD -- Number of vertices in object (15000 maximum)

         The following structure defines the X, Y and Z coordinates
         for each vertex of the object.  It is made up of three words
         and repeats the number of times specified by the vertex count
         word above.












         WORD -- X coordinate of vertex, stored in the standard CAD-3D
         fixed-point format.  For example, an X coordinate of 23.69 is
         stored as an integer value of 2369.  When reading this value,
         simply convert it to a floating-point variable and divide by
         100.

         WORD -- Y coordinate of vertex, also in fixed-point format.
         See above for description of format.

         WORD -- Z coordinate of vertex, also in fixed-point format.
         See above for description of the format.


         After all the vertices' coordinates have been read in, the
         next part of the file describes the triangular faces which
         make up the object.

         WORD -- Number of triangular faces in the object (30000
         maximum)

         The following structure tells the face structure of the
         object.  It is made up of four words and is repeated once for
         every face in the object, specified by the face count above.
         Each face is triangular, and defined by three vertices, or
         points, referred to as A, B and C.  When looking at the face
         of the triangle facing outward, the A-B-C order of the
         vertices is counterclockwise.  This allows for quick
         calculation of whether or not a face is visible.  Each face,
         in addition to having the three vertices of the triangle
         defined, has a color and edge-flag word.  This word tells the
         color of the face and whether or not the line of one of the
         three edges (A-B, B-C, C-A) is to be drawn in edges-only
         mode.

         WORD -- Number of first vertex in the face, termed point A.
         This value can range from zero to the number of vertices in
         the object, and corresponds to the vertices read from the
         file earlier.

         WORD -- Number of second vertex in the face, termed point B.
         This value can range from zero to the number of vertices in
         the object, and corresponds to the vertices read from the
         file earlier.

         WORD -- Number of the third vertex in the face, termed point
         C.  This value can range from zero to the number of vertices
         in the object, and corresponds to the vertices read from the
         file earlier.

         WORD -- Color/edge flag indicator.  The low byte of this
         value is a number from 1 to 15 and tells the color used for
         that face when drawing.  This value is used by the object
         shading routine to determine the color group within the
         palette used by this face.  The upper byte is used to tell
         the program which edges are to be shown by a line segment











         when drawing in "edges only" mode.  The three low-order bits
         in this byte are used as flags for this purpose; a zero in
         the bit indicates that no line is to be drawn, a one in the
         bit indicates that the edge is to be drawn.  The bit
         assignments are:

             Bit 2: Line segment A-B
             Bit 1: Line segment B-C
             Bit 0: Line segment C-A

         The face data repeats until all faces have been defined.
         This is the end of the file.

         Questions about the CAD-3D .3D2 file format may be directed
         to Tom Hudson/.  His Compuserve ID is 76703,4224.


-------------------------------CUT HERE------------------------------
Longish .signature follows.  Skip now.

Greg Wageman			DOMAIN: greg@sj.ate.slb.com
Schlumberger Technologies	UUCP:   ...!uunet!sjsca4!greg
1601 Technology Drive		BIX:    gwage
San Jose, CA 95110-1397		CIS:    74016,352
(408) 437-5198			GEnie:  G.WAGEMAN
------------------
"Live Free; Die Anyway."
------------------
Opinions expressed herein are solely the responsibility of the author.