Beispiel #1
0
func main() {
	scene := ln.Scene{}
	n := 20
	for x := -n; x <= n; x++ {
		for y := -n; y <= n; y++ {
			// z := rand.Float64() * 3
			// scene.Add(cube(float64(x), float64(y), float64(z)))
			// scene.Add(cube(float64(x), float64(y), float64(z+1)))
			// scene.Add(cube(float64(x), float64(y), float64(z+2)))
		}
	}
	n = 8
	for x := -n; x <= n; x++ {
		for y := -n; y <= n; y++ {
			scene.Add(ln.NewSphere(ln.Vector{float64(x), float64(y), 0}, 0.45))
		}
	}
	// scene.Add(ln.NewSphere(ln.Vector{0, 4, 0}, 4))
	// scene.Add(ln.NewSphere(ln.Vector{-7, 0, 0}, 4))
	// scene.Add(ln.NewSphere(ln.Vector{7, 0, 0}, 4))
	eye := ln.Vector{8, 8, 1}
	center := ln.Vector{0, 0, -4.25}
	up := ln.Vector{0, 0, 1}
	width := 1024.0
	height := 1024.0
	paths := scene.Render(eye, center, up, width, height, 50, 0.1, 100, 0.01)
	paths.WriteToPNG("out.png", width, height)
	// paths.Print()
}
Beispiel #2
0
func Render(lines ln.Paths, matrix ln.Matrix) ln.Paths {
	scene := ln.Scene{}
	sphere := ln.NewSphere(ln.Vector{}, 1)
	earth := Earth{sphere, lines}
	shape := ln.NewTransformedShape(&earth, matrix)
	scene.Add(shape)
	eye := ln.LatLngToXYZ(35.7806, -78.6389, 1).Normalize().MulScalar(2.46)
	center := ln.Vector{}
	up := ln.Vector{0, 0, 1}
	return scene.Render(eye, center, up, 60, 1, 0.1, 100, 0.01)
}
Beispiel #3
0
func main() {
	shape := ln.NewDifference(
		ln.NewIntersection(
			ln.NewSphere(ln.Vector{}, 1),
			ln.NewCube(ln.Vector{-0.8, -0.8, -0.8}, ln.Vector{0.8, 0.8, 0.8}),
		),
		ln.NewCylinder(0.4, -2, 2),
		ln.NewTransformedShape(ln.NewCylinder(0.4, -2, 2), ln.Rotate(ln.Vector{1, 0, 0}, ln.Radians(90))),
		ln.NewTransformedShape(ln.NewCylinder(0.4, -2, 2), ln.Rotate(ln.Vector{0, 1, 0}, ln.Radians(90))),
	)
	for i := 0; i < 90; i += 2 {
		fmt.Println(i)
		scene := ln.Scene{}
		m := ln.Rotate(ln.Vector{0, 0, 1}, ln.Radians(float64(i)))
		scene.Add(ln.NewTransformedShape(shape, m))
		eye := ln.Vector{0, 6, 2}
		center := ln.Vector{0, 0, 0}
		up := ln.Vector{0, 0, 1}
		width := 750.0
		height := 750.0
		paths := scene.Render(eye, center, up, width, height, 20, 0.1, 100, 0.01)
		paths.WriteToPNG(fmt.Sprintf("out%03d.png", i), width, height)
	}
}