OBJ (.obj)
Background & Context
-
- 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 & Export
- Import["file.obj"] imports an OBJ file as a MeshRegion object representing the surface.
- Import["file.obj",elem] imports the specified element from an OBJ file.
- The import format can be specified with Import["file","OBJ"] or Import["file",{"OBJ",elem,…}].
- Export["file.obj",expr] exports a 3D mesh-based geometric region to a binary OBJ file. The expr can be any region that is ConstantRegionQ or a Graphics3D object.
- Export["file.obj",expr,{opt1->val1,…}] exports expr with the specified options for the file format.
- The export format can be specified with Export["file",expr,"OBJ"] or Export["file",expr,{"OBJ",opt1->val1,…}].
- See the following reference pages for full general information:
-
Import, Export import from or export to a file CloudImport, CloudExport import from or export to a cloud object ImportString, ExportString import from or export to a string ImportByteArray, ExportByteArray import from or export to a byte array
Import Elements
- General Import elements:
-
"Elements" list of elements and options available in this file "Summary" summary of the file "Rules" list of rules for all available elements - Data format representation elements:
-
"VertexData" list of vertex coordinates "PolygonData" the polygon elements in indexed form "VertexNormals" normal vectors corresponding to the vertices - Geometry representation elements:
-
"BoundaryMeshRegion" boundary mesh representation of the solid "MeshRegion" mesh representation of the surface - Graphics representation elements:
-
"Graphics3D" OBJ file represented as a Graphics3D object "GraphicsComplex" OBJ file as a GraphicsComplex object "PolygonObjects" list of polygon primitives given in absolute coordinates - Import and Export use the "MeshRegion" element by default for OBJ files.
Examples
open all close allBasic Examples (2)
Import a 3D model from OBJ as a MeshRegion object:
Import["ExampleData/seashell.obj"]Summary properties of the model:
Import["ExampleData/seashell.obj", "Summary"]Export a 3D model with transparent faces:
Export["model.obj", [image]]Print the raw textual contents of the file:
FilePrint[%]Scope (11)
Import (6)
Import works on an ASCII OBJ file:
Import["ExampleData/seashell.obj"]Import["http://exampledata.wolfram.com/vase.obj"]str = OpenRead["ExampleData/chain.obj"]Import[str]Close[str]Import automatically detects OBJ files:
Import["http://exampledata.wolfram.com/gear.3"]Import provides access to elements in the OBJ file:
Import["ExampleData/seashell.obj", "Elements"]Import works on large files:
Import["http://exampledata.wolfram.com/turtle.obj"] // MeshCellCount//AbsoluteTimingExport (5)
Export works on 3D graphics:
Export["model.obj", [image]]Export["sphere.obj", Sphere[]]Export["ball.obj", ImplicitRegion[x ^ 2 + y ^ 2 + z ^ 2 ≤ 1, {x, y, z}]]Export["pyramid.obj", MeshRegion[{{-1, -1, 0}, {1, -1, 0}, {1, 1, 0}, {-1, 1, 0}, {0, 0, 1}}, Pyramid[{1, 2, 3, 4, 5}]]]Export["model.obj", [image]]Import Elements (10)
"BoundaryMeshRegion" (1)
"CoordinateTransform" (1)
"Graphics3D" (1)
Give the Graphics3D object:
Import["ExampleData/chain.obj", "Graphics3D"]"GraphicsComplex" (1)
Give the GraphicsComplex object:
Import["ExampleData/chain.obj", "GraphicsComplex"]//Short"MeshRegion" (1)
"PolygonData" (1)
"PolygonObjects" (1)
Give the list of Polygon primitives given in absolute coordinates:
Import["ExampleData/chain.obj", "PolygonObjects"]"Summary" (1)
"VertexData" (1)
History
Introduced in 2007 (6.0) | Updated in 2015 (10.2)