func main() { white := pt.DiffuseMaterial(pt.Color{0.740, 0.742, 0.734}) red := pt.DiffuseMaterial(pt.Color{0.366, 0.037, 0.042}) green := pt.DiffuseMaterial(pt.Color{0.163, 0.409, 0.083}) light := pt.LightMaterial(pt.Color{0.780, 0.780, 0.776}, 10, pt.QuadraticAttenuation(0.1)) scene := pt.Scene{} n := 10.0 scene.Add(pt.NewCube(pt.Vector{-n, -11, -n}, pt.Vector{n, -10, n}, white)) scene.Add(pt.NewCube(pt.Vector{-n, 10, -n}, pt.Vector{n, 11, n}, white)) scene.Add(pt.NewCube(pt.Vector{-n, -n, 10}, pt.Vector{n, n, 11}, white)) scene.Add(pt.NewCube(pt.Vector{-11, -n, -n}, pt.Vector{-10, n, n}, red)) scene.Add(pt.NewCube(pt.Vector{10, -n, -n}, pt.Vector{11, n, n}, green)) scene.Add(pt.NewSphere(pt.Vector{3, -7, -3}, 3, white)) cube := pt.NewCube(pt.Vector{-3, -4, -3}, pt.Vector{3, 4, 3}, white) transform := pt.Rotate(pt.Vector{0, 1, 0}, pt.Radians(30)).Translate(pt.Vector{-3, -6, 4}) scene.Add(pt.NewTransformedShape(cube, transform)) scene.Add(pt.NewCube(pt.Vector{-2, 9.8, -2}, pt.Vector{2, 10, 2}, light)) camera := pt.LookAt(pt.Vector{0, 0, -20}, pt.Vector{0, 0, 1}, pt.Vector{0, 1, 0}, 65) pt.RenderToWindow(pt.Render(&scene, &camera)) }
func main() { scene := pt.Scene{} material := pt.DiffuseMaterial(pt.HexColor(0xFCFAE1)) scene.Add(pt.NewCube(pt.Vector{-1000, -1, -1000}, pt.Vector{1000, 0, 1000}, material)) for x := -20; x <= 20; x++ { for z := -20; z <= 20; z++ { if (x+z)%2 == 0 { continue } s := 0.1 min := pt.Vector{float64(x) - s, 0, float64(z) - s} max := pt.Vector{float64(x) + s, 2, float64(z) + s} scene.Add(pt.NewCube(min, max, material)) } } scene.Add(pt.NewCube(pt.Vector{-5, 10, -5}, pt.Vector{5, 11, 5}, pt.LightMaterial(pt.Color{1, 1, 1}, 5, pt.QuadraticAttenuation(0.05)))) camera := pt.LookAt(pt.Vector{20, 10, 0}, pt.Vector{8, 0, 0}, pt.Vector{0, 1, 0}, 45) pt.RenderToWindow(pt.Render(&scene, &camera)) }