Exemple #1
0
func main() {
	scene := ln.Scene{}
	mesh, err := ln.LoadOBJ("examples/suzanne.obj")
	if err != nil {
		panic(err)
	}
	mesh.UnitCube()
	scene.Add(ln.NewTransformedShape(mesh, ln.Rotate(ln.Vector{0, 1, 0}, 0.5)))
	// scene.Add(mesh)
	eye := ln.Vector{-0.5, 0.5, 2}
	center := ln.Vector{}
	up := ln.Vector{0, 1, 0}
	width := 1024.0
	height := 1024.0
	paths := scene.Render(eye, center, up, width, height, 35, 0.1, 100, 0.01)
	paths.WriteToPNG("out.png", width, height)
}
Exemple #2
0
func main() {
	// mesh, err := ln.LoadBinarySTL("bowser.stl")
	mesh, err := ln.LoadOBJ("examples/suzanne.obj")
	if err != nil {
		panic(err)
	}
	mesh.FitInside(ln.Box{ln.Vector{-1, -1, -1}, ln.Vector{1, 1, 1}}, ln.Vector{0.5, 0.5, 0.5})
	for i := 0; i < Slices; i++ {
		fmt.Printf("slice%04d\n", i)
		p := (float64(i)/(Slices-1))*2 - 1
		point := ln.Vector{0, 0, p}
		plane := ln.Plane{point, ln.Vector{0, 0, 1}}
		paths := plane.IntersectMesh(mesh)
		paths = paths.Transform(ln.Scale(ln.Vector{Size / 2, Size / 2, 1}).Translate(ln.Vector{Size / 2, Size / 2, 0}))
		paths.WriteToPNG(fmt.Sprintf("slice%04d.png", i), Size, Size)
		// paths.WriteToSVG(fmt.Sprintf("slice%04d.svg", i), Size, Size)
	}
}