June 16, 1997
Copyright Michael Wimmer
Many models you can download from the Internet are in a very bad shape: they are usually two-sided, slowing down rendering quite a bit, and their face normal vectors point in arbitrary directions. Refining such models is often a tedious task. 3DXExp is a small plugin for the modeling-package 3D Studio MAX which can be used for two purposes:
The following data is exported in the ASCII-file:
Some useful modifications can be applied to the object data before exporting them:
The plugin consists of two separate parts:
Optionally, a scene description-file can be created with some rudimentary information about the lighting of the scene.
There is also a viewer for the .3DX file-format available from the author which works for cards equipped with the 3DFX Voodoo-chipset.
All you need to run 3DXExp is a running 3DS MAX installation. The plugin was written with Version 1.1 of 3DS MAX, yet there is no specific 1.1-code in it and it should also work with 1.0 (please mail me if you encounter troubles).
Installation of 3DXExp is very simple: just copy the file 3dxexp.dle to the directory "3dsmax\plugins", or "3dsmax\stdplugs", if you like. The next time you start 3DS MAX, both the utility-panel and the export-filter will be available.
Using the Exporter
Step by step instructions
Using the Utility-Panel
Step by step instructions
Description of all available options
Options specific to the "3DX Export Options" dialog-box:
By default, all objects in the scene are exported. If this checkbox is checked, only the objects currently selected are exported.
Select whether you want to export face normals. If you donít want normals, the number of normals indicated in the file will be "0" and no normals are saved. Otherwise, the number of normals will read "1", and each face will have a normal vector attached.
Checking this checkbox will cause all information necessary for texture-mapping to be exported. This includes texture vertices with u/v-coordinates, texture faces for each face with indices into the texture vertex array and the name of the texture bitmap in the material info.
This name can have three different meanings:
Whether all exported objects should be centered around the bounding box surrounding those objects
Should material information be exported? If checked, each object will have a list of materials specifying their diffuse and specular (optional) RGB color and the type of their texture. If an object has more than one material, the material to be used for each face is specified after the face itself.
Selects whether also the specular information should be saved for each material: RGB color, shininess (size of highlight), shining strength (strength of highlight)
If this option is checked, a file with the extension .scn is also created which represents a minimal scene database, especially including lighting. See in the file format description for details.
By default, all modifications you select in the dialog box are only applied to the exported file. By checking this box, you can decide to also apply the modifications to the scene loaded in 3DS MAX (most times it is easier to do this with the utility-panel, though).
Options specific to the "3DX Utility"-panel:
With this option, you can decide whether to apply the selected modifications to all objects in the scene or only to the selected ones.
Options in both panels:
This will declare all (selected) materials as one-sided, meaning backface culling may be applied. Two-sided materials will slow down rendering considerably because backface-culling cannot be applied, as even the backside of a face might be visible.
For most imported objects, it is worth trying this out and looking whether the result still looks the same. If some faces really need the two-sidedness, the two-sided property can be applied selectively to those faces.
If some objects need two-sidedness, declare them as such with this option.
Some meshes simply have all normals defined the wrong way and will look funny. This option can be used to repair them.
This is probably one of the most important features for imported meshes: it will try to make all normal vectors belonging to a surface point to the correct side of that surface. In some imported meshes, every other normal is pointing the wrong way and the result will look very funny Ė this option usually repairs this, although a little bit of hand-tweaking might be necessary.
Remove any faces which only represent a point or a line (i.e., which have no area)
Smooth flat-shaded objects based upon the angle between adjacent faces: all faces which have an angle below the threshold angle between each other will belong to the same surface and will be drawn smoothly. All faces of a sphere will belong to the same surface (or smoothing-group), for example. The angle should not be higher than 90 degrees, or almost anything will be smoothed, even if there should actually be sharp edges.
Reduce the complexity of a mesh by removing faces. The "Normals threshold" parameter specifies the angle (in degrees) below which faces adjacent to each other may be collapsed into one face. The "Edge threshold" specifies the same parameter for faces that have "open" edges, i.e., edges with only one face attached. Increasing the Bias (between 0 and 1) reduces the number of degenerate (long, thin) faces.
This is an experimental function which should apply a u/v-mapping to the selected objects. This is necessary for texture mapping, so that texture-vertices with u/v-coordinates can be generated. You can specify the number and direction of tiles in both u and v-direction. At the moment, only the "Cylindrical"-mapping works, so I would suggest not using this function and using the appropriate 3DS MAX modifier instead.
Description of the 3DX file-format
The 3DX file-format is completely in ASCII and easily machine-readable. The file is case-sensitive. Each line can contain either some specified data at the beginning of the line, be completely empty (newline) or contain some comment after one of the following comment characters: " " (space), ":", "#" and ";". I will describe the file-format by placing comments in a sample file:
; Compulsory header:
3DX File 1.0
; Number of objects in the file:
; First object description (includes 3DS MAX-name):
Object 0: Box01
; Object properties:
Vertices: 8 TVertices: 0 Faces: 2 Materials: 1 Normals: 0
; number of vertices, number of texture vertices (if this is
; >0, also texture faces will be in the file), number of
; materials (if >1, each face will have a material index),
; info whether face normals are stored in the file ([0|1])
; ---------------------------------------- Material section
; The following material-section appears only if materials>0:
; One material info, including 3DS MAX name:
Material 0: graymtl
; Diffuse R/G/B-color and Alpha (=opacity) value:
Diffuse: R: 0,333333 G: 0,313726 B: 0,309804 A: 1,000000
; specular component only if selected in Export Options:
Specular: R: 0,298039 G: 0,298039 B: 0,298039 Shininess: 0,110000 Shiningstrength: 0,170000
; R/G/B color of specular component. Shininess specifies size
; of highlight (it is the x in (N.H)^x), Shiningstrength
; specifies the strength of the highlight
; Is this material two-sided or not ([1|0]) (i.e., is backface
; culling allowed?)
; the Texture can be a valid bitmap-filename,
; "NODIFFUSE" if there is no diffuse map at all, and
; "NOBITMAP" if the map is no bitmap (e.g., a procedural map)
; ... insert other materials here
; -------------------------------------------- Vertex section
; One vertex information:
Vertex 0: X: -31,090403 Y: -31,958305 Z: -23,771324
; X/Y/Z information comes with 6 digits of precisions (more
; doesnít make sense, as 3DS MAX uses float)
; ... insert other vertices here
; The Texture-Vertex section will be only inserted if
; TVertices > 0:
; U/V coordinates for one Texture Vertex:
TVertex 0: U: 0,300000 V: 0,400000
; ... insert other TVertices here
; ----------------------------------------------- Face section
; One face information:
Face 0: A: 3 B: 0 C: 1 AB: 1 BC: 1 CA: 0
; A/B/C are indices into the vertex list. AB/BC/CA specify
; whether the corresponding edge should be drawn or not
; (interior edges will have 0 here)
; a 32-bit integer containing the bitwise OR of the 32
; possible smoothing groups for that face (so "3" would
; indicate that the face belongs to group 1 and 2). "0"
; specifies that the face should be flat-shaded.
; the following Texture Faces appears only after each face
; if TVertices > 0:
TVFace 0: TA: 0 TB: 2 TC: 1
; TA/TB/TC are indices into the Texture Vertex list
; the material index is only inserted if Materials > 1:
; the index can be > Materials, it will simply be wrapped
; (taken modulo Materials)
; ... insert other faces (+tvfaces) (+material indices) here
; ------------------------------ End of one object definition
; ... insert other object definitions here
; ------------------------------ End of 3DX file
Description of the .SCN file-format
The .scn file-format is mainly used by my other interactive previewer, View3DFX, to provide information about the contents of a scene. It has information about:
On demand, the 3DX exporter can generate a standard .SCN-file which sets the camera at an initial location, specifies a default global ambient light, contains all the lights in the 3DS MAX scene (but not with all their properties), and contains exactly one actor, which is the .3DX-file currently exported. I will again describe the file format via an annotated example.
Again, the file is case sensitive, comment rules are the same as for the .3DX file-format. Some of the lines are optional, but if they appear, they must be in the order shown (i.e., you cannot exchange to optional lines).
; Compulsory header:
; Optional: path to .3DX and texture bitmap files.
; this path can be relative
; Optional: a global specularity factor to multiply with
; each individual material specularity to obtain the specular
; exponent. The default value for this is 400
; Optional: global ambient color (R/G/B values):
Ambient Color: R: 1 G: 1 B: 1
; Optional: global ambient color intensity. If a color is also
; specified, this is a multiplier. If not, it is interpreted
; as monochromatic global ambient color:
; Compulsory: Number of actors and number of Lights:
Actors: 1 Lights: 2
; Compulsory: initial camera location. Will be set to
; the following by the 3DX exporter:
Camera: X: 0 Y: -1000 Z: 0
; ------------------------------------------ Light section
; Compulsory (even if Lights == 0): light list:
; One light description (including 3DS MAX name):
Light 0: Light01
; The Type can be one of the following:
; DIRECTIONAL: monochromatic, directional light
; OMNI: monochromatic, not attenuated light
; (those two are not generated by the exporter Ė they
; allow for faster rendering, but are not as flexible)
; GLDIRECTIONAL: OpenGL-like directional light with
; optional color and intensity
; GLOMNI: OpenGL-like point light source with optional
; color, intensity and compulsory attenuation
; GLSPOTLIGHT: OpenGL-like spot light source with all
; properties of GLOMNI, plus a direction, Cutoff angle
; and spotlight exponent
; for OMNI, GLOMNI and GLSPOTLIGHT: light position:
Position: X: 0 Y: 0 Z: 0
; for DIRECTIONAL, GLDIRECTIONAL and GLSPOTLIGHT: light
; direction (need not be normalized):
Direction: X: 0 Y: 0 Z: 1
; for GLOMNI and GLSPOTLIGHT: Attenuation and bounding sphere:
; A/B/C specify the constant/linear/quadratic attenuation for
; the following formula, if d is the distance to the light:
; "attenuation = 1 / (A + B * d + C * d^2)", which will be
; multiplied to the lighting factor. "Radius" specifies a
; bounding sphere for the light, any objects farther away
; are not lit by this light.
; NOTE: 3DS MAX attenuation is not mimicked! You can only
; export the "Radius" by specifying a valid "Attenuation End
; Range" in 3DS MAX and "Use Attenuation". A/B/C will have
; the following default values in any case:
Attenuation: A: 1.0 B: 0 C: 0 Radius: 5000
; for GLSPOTLIGHT: Cutoff angle (in degrees) and spotlight
; exponent. Any vertex which deviates more than the cutoff
; angle from the light direction will not be lit. This defines
; the spotlight cone. The spotlight exponent specifies how
; bright the spotlight is in the center and at the border:
; "factor = (cosine of angle between light direction
; and vertex) raised to the power of Spotexponent"
; View3DFX only calculates this accurately for powers of 2,
; (0, 1, 2, 4, 8, ...), for other values a (fast)
; approximation is used.
; NOTE: 3DS MAX spotlights are not mimicked! You can only
; export the "Falloff Size" (which translates to "Cutoff"),
; but not the "Hotspot Size"!
; The spotexponent will have the following default value:
Cutoff: 30 Spotexponent: 1
; Optional for any GL-light: RGB-color
Color: R: 0.3 G: 0.3 B: 0
; Optional for any light: Intensity (if no color specified,
; monochromatic light is assumed).
; NOTE: the Intensity of a light may assume NEGATIVE values!
; this allows to specifies areas of darkness!
; optional for any light: should this light be enabled or not
; ... insert other lights here
; ---------------------------------------- Actor section
; Compulsory keyword:
; one Actor definition, including initial position:
Actor 1: X: 0 Y: 0 Z: 500
; Filename for the Actor 3DX-file (including extension):
; Optional: Specify an RGB-diffuse color for this actor,
; which is used if it contains no materials. Also the
; Alpha-value (= opacity) must be specified, then.
; The following default will be used if it is not specified:
Color: R: 0.5 G: 1 B: 1 A: 1
; Optional: Specify an RGB-specular color for this Actor
; which will be used if it contains no materials.
; The following default will be used if it is not specified:
Specular: R: 0.7 G: 0.7 B: 0.7
; Optional: Specify a scale for the object with which all
; Vertex coordinates are multiplied when loading
; Optional: specify whether all normals should be reversed
; when loading this actor ([0|1]):
; Optional: Specific to the program View3DFX, this specifies
; that a BSP-tree should be generated on startup for this
; actor. This is mainly to allow antialiasing. The number
; controls the accuracy (and the computing time) for the
; BSP tree. 0.1 usually is quite fast, but will have errors,
; 0.01 is slow but will be correct almost always. Anything
; lower than 0.01 will take forever if the mesh is complicated
; ... insert other actors here
; Compulsory end of file:
Whatís new in this release (v1.1, June 16, 1997)?
The main improvement of this release compared to the one available on the Web for some time (v1.0, May 2, 1997) is the addition of a possibility to create a default scene file including lighting information. One checkbox to allow this has been added to the Export Options dialog box. Please see the description of the .scn file-format for usage and restrictions of this feature!
Under no circumstances will Michael Wimmer be liable for any damages or losses arising from the use or misuse of this software. If you use this software, you agree to these terms.
This production is the intellectual property of Michael Wimmer with the following exceptions:
3D Studio MAX by Kinetix
All trademarks are the copyright of their respective owners.
This production is freeware, and must be distributed freely through public information exchange mediums like BBSs and Internet provided it is unmodified and distributed along with all accompanying files. No monetary gain is allowed through the distribution of this production. Distribution on CD-ROMs or any other forms sold for money requires special permission granted by Michael Wimmer.