Пример #1
0
func main() {
	scene := pt.Scene{}
	scene.Add(pt.NewSphere(pt.Vector{-2, 5, -3}, 0.5, pt.LightMaterial(pt.Color{1, 1, 1}, 1, pt.NoAttenuation)))
	scene.Add(pt.NewSphere(pt.Vector{5, 5, -3}, 0.5, pt.LightMaterial(pt.Color{1, 1, 1}, 1, pt.NoAttenuation)))
	scene.Add(pt.NewCube(pt.Vector{-30, -1, -30}, pt.Vector{30, 0, 30}, pt.SpecularMaterial(pt.HexColor(0xFCFAE1), 2)))
	mesh, err := pt.LoadOBJ("examples/teapot.obj", pt.SpecularMaterial(pt.HexColor(0xB9121B), 2))
	if err != nil {
		log.Fatalln("LoadOBJ error:", err)
	}
	scene.Add(mesh)
	camera := pt.LookAt(pt.Vector{2, 5, -6}, pt.Vector{0.5, 1, 0}, pt.Vector{0, 1, 0}, 45)
	pt.RenderToWindow(pt.Render(&scene, &camera))
}
Пример #2
0
func main() {
	scene := pt.Scene{}
	material := pt.GlossyMaterial(pt.HexColor(0xFCFAE1), 1.5, pt.Radians(20))
	mesh, err := pt.LoadOBJ("examples/dabrovic-sponza/sponza.obj", material)
	if err != nil {
		log.Fatalln("LoadOBJ error:", err)
	}
	mesh.MoveTo(pt.Vector{}, pt.Vector{0.5, 0, 0.5})
	scene.Add(mesh)
	scene.Add(pt.NewSphere(pt.Vector{0, 20, 0}, 3, pt.LightMaterial(pt.Color{1, 1, 1}, 1, pt.NoAttenuation)))
	camera := pt.LookAt(pt.Vector{-10, 2, 0}, pt.Vector{0, 4, 0}, pt.Vector{0, 1, 0}, 45)
	pt.RenderToWindow(pt.Render(&scene, &camera))
}
Пример #3
0
func main() {
	scene := pt.Scene{}
	material := pt.DiffuseMaterial(pt.HexColor(0x334D5C))
	scene.Add(pt.NewSphere(pt.Vector{0.5, 1, 3}, 0.5, pt.LightMaterial(pt.Color{1, 1, 1}, 1, pt.NoAttenuation)))
	scene.Add(pt.NewSphere(pt.Vector{1.5, 1, 3}, 0.5, pt.LightMaterial(pt.Color{1, 1, 1}, 1, pt.NoAttenuation)))
	scene.Add(pt.NewCube(pt.Vector{-5, -5, -2}, pt.Vector{5, 5, -1}, material))
	mesh, err := pt.LoadOBJ("examples/suzanne.obj", pt.SpecularMaterial(pt.HexColor(0xEFC94C), 2))
	if err != nil {
		log.Fatalln("LoadOBJ error:", err)
	}
	scene.Add(mesh)
	camera := pt.LookAt(pt.Vector{1, -0.45, 4}, pt.Vector{1, -0.6, 0.4}, pt.Vector{0, 1, 0}, 45)
	pt.RenderToWindow(pt.Render(&scene, &camera))
}
Пример #4
0
func main() {
	scene := pt.Scene{}
	wall := pt.SpecularMaterial(pt.HexColor(0xFCFAE1), 2)
	scene.Add(pt.NewSphere(pt.Vector{4, 7, 3}, 2, pt.LightMaterial(pt.Color{1, 1, 1}, 1, pt.NoAttenuation)))
	scene.Add(pt.NewCube(pt.Vector{-30, -1, -30}, pt.Vector{-8, 10, 30}, wall))
	scene.Add(pt.NewCube(pt.Vector{-30, -1, -30}, pt.Vector{30, 0.376662, 30}, wall))
	material := pt.GlossyMaterial(pt.Color{}, 1.5, pt.Radians(30))
	mesh, err := pt.LoadOBJ("examples/gopher.obj", material)
	if err != nil {
		log.Fatalln("LoadOBJ error:", err)
	}
	mesh.SmoothNormals()
	scene.Add(mesh)
	camera := pt.LookAt(pt.Vector{8, 3, 0.5}, pt.Vector{-1, 2.5, 0.5}, pt.Vector{0, 1, 0}, 45)
	pt.RenderToWindow(pt.Render(&scene, &camera))
}
Пример #5
0
// https://graphics.stanford.edu/~mdfisher/Data/Meshes/bunny.obj
func main() {
	scene := pt.Scene{}
	material := pt.GlossyMaterial(pt.HexColor(0xF2EBC7), 1.5, pt.Radians(0))
	mesh, err := pt.LoadOBJ("examples/bunny.obj", material)
	if err != nil {
		panic(err)
	}
	mesh.SmoothNormalsThreshold(pt.Radians(20))
	mesh.FitInside(pt.Box{pt.Vector{-1, 0, -1}, pt.Vector{1, 2, 1}}, pt.Vector{0.5, 0, 0.5})
	scene.Add(mesh)
	floor := pt.GlossyMaterial(pt.HexColor(0x33332D), 1.2, pt.Radians(20))
	scene.Add(pt.NewCube(pt.Vector{-10000, -10000, -10000}, pt.Vector{10000, 0, 10000}, floor))
	scene.Add(pt.NewSphere(pt.Vector{0, 5, 0}, 1, pt.LightMaterial(pt.Color{1, 1, 1}, 1, pt.NoAttenuation)))
	scene.Add(pt.NewSphere(pt.Vector{4, 5, 4}, 1, pt.LightMaterial(pt.Color{1, 1, 1}, 1, pt.NoAttenuation)))
	camera := pt.LookAt(pt.Vector{-1, 2, 3}, pt.Vector{0, 0.75, 0}, pt.Vector{0, 1, 0}, 50)
	pt.RenderToWindow(pt.Render(&scene, &camera))
}
Пример #6
0
func main() {
	scene := pt.Scene{}
	scene.SetColor(pt.HexColor(0xFEE7E0))
	// material := pt.GlossyMaterial(pt.HexColor(0x5C832F), 1.5, pt.Radians(20))
	material := pt.TransparentMaterial(pt.HexColor(0xFFFFFF), 2, pt.Radians(20), 0)
	mesh, err := pt.LoadOBJ("examples/dragon.obj", material)
	if err != nil {
		panic(err)
	}
	mesh.FitInside(pt.Box{pt.Vector{-1, 0, -1}, pt.Vector{1, 2, 1}}, pt.Vector{0.5, 0, 0.5})
	scene.Add(mesh)
	floor := pt.GlossyMaterial(pt.HexColor(0xD8CAA8), 1.2, pt.Radians(20))
	scene.Add(pt.NewCube(pt.Vector{-1000, -1000, -1000}, pt.Vector{1000, 0, 1000}, floor))
	scene.Add(pt.NewSphere(pt.Vector{0, 10, 0}, 1, pt.LightMaterial(pt.Color{1, 1, 1}, 1, pt.NoAttenuation)))
	camera := pt.LookAt(pt.Vector{-3, 2, -1}, pt.Vector{0, 0.5, 0}, pt.Vector{0, 1, 0}, 35)
	pt.RenderToWindow(pt.Render(&scene, &camera))
}