示例#1
0
func main() {
	scene := pt.Scene{}
	r := 0.4
	var material pt.Material

	material = pt.DiffuseMaterial(pt.HexColor(0x334D5C))
	scene.Add(pt.NewSphere(pt.Vector{-2, r, 0}, r, material))

	material = pt.SpecularMaterial(pt.HexColor(0x334D5C), 2)
	scene.Add(pt.NewSphere(pt.Vector{-1, r, 0}, r, material))

	material = pt.GlossyMaterial(pt.HexColor(0x334D5C), 2, pt.Radians(50))
	scene.Add(pt.NewSphere(pt.Vector{0, r, 0}, r, material))

	material = pt.TransparentMaterial(pt.HexColor(0x334D5C), 2, pt.Radians(20), 1)
	scene.Add(pt.NewSphere(pt.Vector{1, r, 0}, r, material))

	material = pt.ClearMaterial(2, 0)
	scene.Add(pt.NewSphere(pt.Vector{2, r, 0}, r, material))

	material = pt.SpecularMaterial(pt.HexColor(0xFFFFFF), 1000)
	scene.Add(pt.NewSphere(pt.Vector{0, 1.5, -4}, 1.5, material))

	scene.Add(pt.NewCube(pt.Vector{-1000, -1, -1000}, pt.Vector{1000, 0, 1000}, pt.GlossyMaterial(pt.HexColor(0xFFFFFF), 1.4, pt.Radians(20))))
	scene.Add(pt.NewSphere(pt.Vector{0, 5, 0}, 1, pt.LightMaterial(pt.Color{1, 1, 1}, 3, pt.LinearAttenuation(0.4))))
	camera := pt.LookAt(pt.Vector{0, 3, 6}, pt.Vector{0, 1, 0}, pt.Vector{0, 1, 0}, 30)
	pt.IterativeRender("out%03d.png", 1000, &scene, &camera, 2560/2, 1440/2, -1, 16, 16)
}
示例#2
0
文件: dragon.go 项目: noscripter/pt
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.IterativeRender("out%03d.png", 1000, &scene, &camera, 2560/4, 1440/4, -1, 4, 4)
}