コード例 #1
0
ファイル: craft.go プロジェクト: noscripter/pt
func main() {
	scene := pt.Scene{}
	texture, err := pt.LoadTexture("examples/texture.png")
	if err != nil {
		panic(err)
	}
	material := pt.GlossyMaterial(pt.HexColor(0xFCFAE1), 1.1, pt.Radians(20))
	material.Texture = texture
	var triangles []*pt.Triangle
	for x := -10; x <= 10; x++ {
		for z := -10; z <= 10; z++ {
			h := rand.Intn(4)
			for y := 0; y <= h; y++ {
				p := pt.Vector{float64(x), float64(y), float64(z)}
				tiles := Dirt
				if y == h {
					tiles = Grass
				}
				cube := Cube(p, material, tiles)
				triangles = append(triangles, cube...)
			}
		}
	}
	mesh := pt.NewMesh(triangles)
	scene.Add(mesh)
	camera := pt.LookAt(pt.Vector{-13, 11, -7}, pt.Vector{0, 0, 0}, pt.Vector{0, 1, 0}, 45)
	pt.IterativeRender("out%03d.png", 1000, &scene, &camera, 2560/2, 1440/2, -1, 4, 4)
}
コード例 #2
0
ファイル: counties.go プロジェクト: kirillrdy/pt
func main() {
	rand.Seed(6)
	floor := pt.GlossyMaterial(pt.HexColor(0xFCFFF5), 1.5, pt.Radians(20))
	light := pt.LightMaterial(pt.HexColor(0xFFFFFF), 1, pt.QuadraticAttenuation(0.002))
	triangles := LoadTriangles("examples/counties.csv")
	mesh := pt.NewMesh(triangles)
	mesh.FitInside(pt.Box{pt.Vector{-1, -1, 0}, pt.Vector{1, 1, 1}}, pt.Vector{0.5, 0.5, 0})
	scene := pt.Scene{}
	scene.Add(mesh)
	scene.Add(pt.NewCube(pt.Vector{-100, -100, -1}, pt.Vector{100, 100, 0.03}, floor))
	scene.Add(pt.NewSphere(pt.Vector{0, 4, 10}, 4, light))
	camera := pt.LookAt(pt.Vector{0, -0.25, 2}, pt.Vector{0, 0, 0}, pt.Vector{0, 0, 1}, 35)
	pt.IterativeRender("out%03d.png", 1000, &scene, &camera, 2560/2, 1440/2, -1, 4, 4)
}