Esempio n. 1
0
func (s *Scene) Trace() {
	for y := 0; y < s.Canvas.Size.Y; y++ {
		for x := 0; x < s.Canvas.Size.X; x++ {
			//create ray
			ray := s.Ray(vec.I(x, y))
			s.Canvas.Pixels[x+y*s.Res.X] = s.traceRay(ray, recursion)
		}
	}
	s.Canvas.Exposures++
}
Esempio n. 2
0
func test() {
	canv := trace.NewCanvas(vec.I(100, 100))
	scene := trace.NewScene(canv)

	/*tri := trace.Tri{vec.D(-5.0, 5.0, 5.0), vec.D(0.0, -5.0, 5.0), vec.D(5.0, 5.0, 5.0)}
	obj := trace.Obj{Color: vec.C(0.0, 1.0, 0.0)}
	obj.Tris = make([]trace.Tri, 0, 1)
	obj.Tris = append(obj.Tris, tri)
	scene.Objs = append(scene.Objs, obj)*/

	start := time.Now()
	trace.Parse("cubes.obj", scene)
	fmt.Println("Parsing took", time.Now().Sub(start))

	start = time.Now()
	scene.Trace()
	fmt.Println("Tracing took", time.Now().Sub(start))

	start = time.Now()
	save(canv, "test.png")
	fmt.Println("Exporting took", time.Now().Sub(start))
}