Skip to content

OBJ File

Alpha Limitations

OBJ file import is a convenience utility provided by the SDK for loading simple 3D models. It supports a limited subset of the Wavefront OBJ format and is designed for low-polygon objects only. Performance on the glasses display is directly affected by vertex count - keep models as simple as possible. Always test on actual hardware to verify acceptable frame rates.

Overview

The SDK can load Wavefront OBJ files via M2ArFactory3D and convert them into M2ArMesh drawables. This is useful for importing simple pre-built 3D assets such as icons, markers, or indicators.

Recommendations

  • Keep vertex counts low. The glasses have limited rendering bandwidth. Aim for models with up to a few hundred vertices - typical working models use 8–200 vertices (e.g. a simple cube has 8, a character model around 100–170).
  • Triangulate all faces. The SDK expects triangle-based meshes. Make sure your export tool triangulates the model before saving.
  • Verify normals. Face normals should point outward (counter-clockwise winding order) for correct lighting and visibility.
  • UV mapping range. If using textures, UV coordinates should be in the 0–1 range. Note that some 3D editors use bottom-left UV origin while PNG images use top-left - flip the texture vertically if the mapping appears inverted.
  • Optimize before export. Use your 3D tool's decimation or simplification features to reduce polygon count before exporting.

Loading OBJ Files

// Load OBJ with material (MTL) file
val scene = M2ArFactory3D.fromObjFile("model.obj")

// Load OBJ with PNG texture from a directory
val meshes = M2ArFactory3D.fromObjFileSimple("models/myModel")

For building meshes programmatically (recommended for best performance), see 3D Geometry.