Skip to content

koshkokoshka/model-tetrahedralizer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 

Repository files navigation

Model Tetrahedralizer

A Python tool for generating a set of tetrahedrons representing the volume of a 3D model.

Usage

python tetrahedralize.py [-h] [-o OUTPUT] [--skip-validation] [--inward] input

positional arguments:
  input                Input .obj file

options:
  -o, --output OUTPUT  Output file (default: tetras.txt)
  --skip-validation    Skip final result validation
  --inward             Generate tetrahedrons covering the closed space of a model (if your model is a room)

Overview

The Idea

Model tetrahedralization is the process of decomposing a non-convex 3D model into a set of tetrahedra.

Just as the shape of 3D model is represented by triangles, volume can be represented by tetrahedrons.

Tetrahedrons can be quite useful:

  • They are always convex, which makes them easier to work with
  • They are well-suited for collision detection algorithms such as GJK
  • They can be used for space partitioning (similar to BSP trees)
  • Theoretically, skeletal animation can be applied to tetrahedral meshes in the same way as we animate 3D models

The Problem

However, the model tetrahedralization - is a complex problem which has no reliable solution yet.

Existing approaches like Delaunay tetrahedralization generate many unnecessary tetrahedra, which makes them less usable for video games and realtime simulations.

The Solution

My approach for building tetrahedral mesh is:

  1. Select an arbitrary triangle on the 3D model - this is the initial face of our tetrahedral mesh
  2. "Grow" it into a tetrahedron by finding the closest vertex to the face center
  3. Repeat the process recursively for newly formed faces until all closed

Disclaimer

Please note that all code in this repository is not production-ready solution. This approach is not sufficiently tested and optimized to be reliable and stable for every possible geometry. I'm just experimenting and sharing the results in public domain.

About

A Python tool for generating a set of tetrahedrons representing the volume of a 3D model.

Topics

Resources

Stars

Watchers

Forks

Contributors

Languages