Skip to content

Wavefront OBJ & MTL parser and visualize it in the 3D graphics module VPython

License

Notifications You must be signed in to change notification settings

StefanJohnsen/pyOBJExplorer

Repository files navigation

pyOBJExplorer

Explore 3D visualization of Wavefront OBJ models with pyOBJParser, a showcase of how to integrate VPython and pyOBJParser. pyOBJExplorer offers an intuitive and straightforward solution, allowing users to delve into the intricate details of textures, materials, and geometries within OBJ files.

VPython (Visual Python)

VPython is a lightweight and simple Python library for creating interactive 3D visualizations and simulations, often used in education to teach concepts like physics and computer science. Testing Wavefront OBJ files larger than 10 MB for simulation is not recommended.

OBJExplorer

Following files is included

  • Explorer.py The main file to run. It can also be executed from the command line with a specified OBJ file.
  • WavefrontOBJ.py source: pyOBJParser
  • WavefrontMTL.py source: pyOBJParser
  • Triangulate.py source: pyTriangulate

Dependencies

Install vpython

pip install vpython

Usage

From the command line, simply enter 'explorer.py' followed by the file name.
Please ensure to close the browser upon completion to restore command line control.

python Explorer.py .\objFiles\rubikcube.obj

rubikcube
Rubik's cube with standard color

python Explorer.py -w .\objFiles\rubikcube.obj

rubikcube
Rubik's cube with wireframe

python Explorer.py -b .\objFiles\drill.obj

rubikcube
Drill with texture and axis align bounding box

VPython Controls Guide

Mouse controls only

  • Rotate: Click and drag with the right mouse button to rotate the scene.
  • Zoom: Scroll the middle mouse wheel to zoom in and out.

Mouse Controls and Keyboard

  • Rotate: Ctrl + click and drag with the left mouse button to rotate the scene.
  • Pan: Shift + click and drag with the left mouse button to pan the scene.

License

This software is released under the MIT License terms.