当前位置: 首页>>代码示例>>Golang>>正文


Golang Scene.SetColor方法代码示例

本文整理汇总了Golang中github.com/kirillrdy/pt/pt.Scene.SetColor方法的典型用法代码示例。如果您正苦于以下问题:Golang Scene.SetColor方法的具体用法?Golang Scene.SetColor怎么用?Golang Scene.SetColor使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在github.com/kirillrdy/pt/pt.Scene的用法示例。


在下文中一共展示了Scene.SetColor方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: main

func main() {
	scene := pt.Scene{}
	scene.SetColor(pt.Color{1, 1, 1})
	meshes := []*pt.Mesh{
		CreateBrick(1),  // white
		CreateBrick(21), // bright red
		CreateBrick(23), // bright blue
		CreateBrick(24), // bright yellow
		CreateBrick(26), // black
		CreateBrick(28), // dark green
	}
	for x := -30; x <= 50; x += 2 {
		for y := -50; y <= 20; y += 4 {
			h := rand.Intn(5) + 1
			for i := 0; i < h; i++ {
				dy := 0
				if (x/2+i)%2 == 0 {
					dy = 2
				}
				z := float64(i) * H
				mesh := meshes[rand.Intn(len(meshes))]
				m := pt.Translate(pt.Vector{float64(x), float64(y + dy), z})
				scene.Add(pt.NewTransformedShape(mesh, m))
			}
		}
	}
	// light := pt.LightMaterial(pt.Color{0.2, 0.2, 0.2}, 10, pt.QuadraticAttenuation(0.01))
	// scene.Add(pt.NewSphere(pt.Vector{0, 0, 25}, 1, light))
	camera := pt.LookAt(pt.Vector{-23, 13, 20}, pt.Vector{0, 0, 0}, pt.Vector{0, 0, 1}, 45)
	pt.RenderToWindow(pt.Render(&scene, &camera))
}
开发者ID:kirillrdy,项目名称:pt,代码行数:31,代码来源:toybrick.go

示例2: main

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))
}
开发者ID:kirillrdy,项目名称:pt,代码行数:17,代码来源:dragon.go


注:本文中的github.com/kirillrdy/pt/pt.Scene.SetColor方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。