OBJ_Reader can read files and OBJ_Writer can write files in Wavefront OBJ file format.
The reader can read files with external .mtl (material library) files, files with both multiple and single parts. In the case of multiple parts they are created as roots of the resulting model (ModelData_Model).
Import | Export |
---|---|
|
|
Below table shows how OBJ content are mapped into CAD Exchanger entities after import.
OBJ tag | Description | CAD Exchanger Entity | Note |
---|---|---|---|
v | vertex data | ModelData_Part | All accumulated data between "g" tags maps directly to ModelData_IndexedTriangleSet. |
vn | vertex normals data | ||
vt | texture coordinates data | ||
f | face data | ||
o | object name | ||
g | group name | ||
matlib | external .mtl file name | ||
usemlt | specifies the material name for the element following it |
Below table shows how CAD Exchanger entities are mapped into OBJ entities after export. Note that OBJ could not store the hierarchy therefore all polygonal data of every instance of part will be bake in the world coordinate system.
CAD Exchanger Entity | OBJ tag | Note |
---|---|---|
ModelData_Assembly | v / vn / vt / f / g / o / matlib / usemlt | |
ModelData_Part | Every body of part will map to OBJ-group (surrounded with "g" tag) | |
ModelData_Instance |
The OBJ import parameters are controlled by OBJ_ReaderParameters. The following table contains a list of parameters for OBJ import:
Parameter | Default value | Description |
---|---|---|
SetLengthUnit (Base_LengthUnit LengthUnit) | Base_LU_Millimeters | See Base_ReaderParameters::SetLengthUnit(Base_LengthUnit LengthUnit). |
The OBJ export parameters are controlled by OBJ_WriterParameters. The following table contains a list of parameters for OBJ export:
Parameter | Default value | Description |
---|---|---|
ToGenerateMtlFile() | true | Specifies whether a separate .mtl file (with material library) should be created. If the value is true then an .mtl file is created. The .mtl file will have the same base file name as the resulting .obj file. If the value is false then no colors will be stored and no .mtl file will be created. |
WriteNormals() | true | Specifies whether vertex normals should be saved in a resulting .obj file. If the value is true then normals are stored in the file. In this case, third-party viewers may display 3D models in smooth shading. If the value is false then normals are not stored in the .obj file, and the third-party viewers may display 3D models in flat shading. |
OverrideDuplicateNames() | true | Specifies whether original names of parts should be supplemented with suffixes. If the value is true the name of every part encountered twice or more during export will be supplemented with a suffix to make the name unique. This is done to avoid merging of geometries with same name during import by receiving CAD applications. If the value is false every part will be exported with its original name. This may cause geometric objects with the same name to be merged by receiving CAD applications into one geometric object. |
ReplaceSpacesInNames() | false | Specifies whether original names should be overridden by names without space characters. If the value is true then the space characters in parts' names will replaced by "_" characters for better compatibility with receiving systems. If the value is false every part will be exported with its original name. |
LengthUnit() | Base_LU_Millimeters | See Base_WriterParameters::LengthUnit(). |