Crates.io | tessellation |
lib.rs | tessellation |
version | 0.8.2 |
source | src |
created_at | 2018-05-06 07:02:07.327659 |
updated_at | 2020-10-19 14:23:29.685691 |
description | 3d tessellation library. |
homepage | |
repository | https://github.com/hmeyer/tessellation |
max_upload_size | |
id | 63965 |
size | 93,150 |
Tessellation is a library for 3d tessellation, e.g. it will create a set of triangles from any implicit function of volume. Tessellation implements Manifold Dual Contouring.
Create a unit sphere and tessellate it:
use nalgebra as na;
//!
struct UnitSphere {
bbox : tessellation::BoundingBox<f64>
}
//!
impl UnitSphere {
fn new() -> UnitSphere {
UnitSphere {
bbox: tessellation::BoundingBox::new(&na::Point3::new(-1., -1., -1.),
&na::Point3::new( 1., 1., 1.)) }
}
}
impl tessellation::ImplicitFunction<f64> for UnitSphere {
fn bbox(&self) -> &tessellation::BoundingBox<f64> {
&self.bbox
}
fn value(&self, p: &na::Point3<f64>) -> f64 {
return na::Vector3::new(p.x, p.y, p.z).norm() - 1.0;
}
fn normal(&self, p: &na::Point3<f64>) -> na::Vector3<f64> {
return na::Vector3::new(p.x, p.y, p.z).normalize();
}
}
let sphere = UnitSphere::new();
let mut mdc = tessellation::ManifoldDualContouring::new(&sphere, 0.2, 0.1);
let triangles = mdc.tessellate().unwrap();