OBJ (.obj)

BackgroundBackground

    Wavefront OBJ format.
    3D geometry format.
    Used for storage and exchange of 3D geometry definitions.
    Native format of the Wavefront application.
    Stores a geometry as a collection of line, point, and polygon primitives and their properties.
    Can store face color information.
    ASCII format.
    Developed by Alias Wavefront.
    Stores a single geometry.

Import and ExportImport and Export

  • Import["file.obj"] imports an OBJ file Graphics3D object.
  • Export["file.obj",expr] exports a Graphics3D expression to an OBJ file.
  • Import["file.obj"] returns an expression of the form Graphics3D[ GraphicsComplex[vertices,primitives,opts]].
  • Import["file.obj",elem] imports the specified element from an OBJ file.
  • Import["file.obj",{elem,suba,subb,}] imports a subelement.
  • Import["file.obj",{{elem1,elem2,}}] imports multiple elements.
  • The import format can be specified with Import["file","OBJ"] or Import["file",{"OBJ",elem,}].
  • Export["file.obj",expr,elem] creates an OBJ file by treating expr as specifying element elem.
  • Export["file.obj",{expr1,expr2,},{{elem1,elem2,}}] treats each as specifying the corresponding .
  • Export["file.obj",expr,opt1->val1,] exports expr with the specified option elements taken to have the specified values.
  • Export["file.obj",{elem1->expr1,elem2->expr2,},"Rules"] uses rules to specify the elements to be exported.
  • See the reference pages for full general information on Import and Export.
  • ImportString and ExportString support the OBJ format.

ElementsElements

  • General Import elements:
  • "Elements"list of elements and options available in this file
    "Rules"full list of rules for each element and option
    "Options"list of rules for options, properties, and settings
  • Data representation elements:
  • "Graphics3D"OBJ file represented as a Graphics3D object
    "GraphicsComplex"GraphicsComplex object, representing the geometry stored in the file
    "LineData"lines represented as lists of indices, referencing the vertices as given by the element
    "LineObjects"list of Line primitives given in absolute coordinates
    "PointData"point data in indexed form
    "PointObjects"list of Point primitives given in absolute coordinates
    "PolygonData"polygon data in indexed form
    "PolygonColors"face color information for each polygon
    "PolygonObjects"list of Polygon primitives given in absolute coordinates
    "VertexData"list of vertex coordinates
    "VertexNormals"normal vectors corresponding to the vertices given by
  • Import and Export use the element by default for OBJ files.
  • The element corresponds to the first argument of GraphicsComplex.
  • When rendering an OBJ color model, Import automatically uses the setting Lighting->"Neutral".

OptionsOptions

  • General Import options:
  • BackgroundAutomaticwhat background color to use
    ImageSizeAutomaticoverall size of the graphics to display
    LightingAutomaticwhat simulated lighting to use in coloring 3D surfaces
  • All options of Graphics3D can be given when importing from OBJ.
  • Advanced options:
  • "InvertNormals"Falsewhether to invert the orientation of vertex normals
    "VerticalAxis"{0,0,1}orientation to assume for the coordinate system used in the file
  • By default, the Wolfram Language assumes that in the coordinate system used by the OBJ format the vertical axis corresponds to the third coordinate.
  • With the setting , the Wolfram Language will apply the transformation to all graphics coordinates when importing from OBJ, and the inverse transformation when exporting to OBJ.

ExamplesExamplesopen allclose all

Basic Examples  (3)Basic Examples  (3)

Import an OBJ example file:

In[1]:=
Click for copyable input
Out[1]=

Show the Import elements available in this file:

In[2]:=
Click for copyable input
Out[2]=

Import and count the polygons stored in this file:

In[3]:=
Click for copyable input
Out[3]=

Export a 3D model with transparent faces:

In[1]:=
Click for copyable input
Out[1]=

Compute a 3D geometry using ParametricPlot3D:

In[1]:=
Click for copyable input
Out[1]=

Export it to OBJ:

In[2]:=
Click for copyable input
Out[2]=
Introduced in 2007
(6.0)
| Updated in 2010
(8.0)