-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscene.go
97 lines (77 loc) · 1.92 KB
/
scene.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
package raytrace
import (
"fmt"
)
type Scene struct {
samplingQuality int
rayDepth int
renderDiffuse bool
renderHighlights bool
renderShadow bool
renderReflection bool
renderRefraction bool
background *Background
camera *Camera
shapes []IShape
lights []*Light
}
func (s *Scene) SamplingQuality() int {
return s.samplingQuality
}
func (s *Scene) RayDepth() int {
return s.rayDepth
}
func (s *Scene) Camera() *Camera {
return s.camera
}
func (s *Scene) SetCamera(value *Camera) {
s.camera = value
}
func (s *Scene) Background() *Background {
return s.background
}
func (s *Scene) Lights() []*Light {
return s.lights
}
func (s *Scene) AddLight(light *Light) {
s.lights = append(s.lights, light)
}
func (s *Scene) Shapes() []IShape {
return s.shapes
}
func (s *Scene) AddShape(shape IShape) {
s.shapes = append(s.shapes, shape)
}
func (s *Scene) RenderDiffuse() bool {
return s.renderDiffuse
}
func (s *Scene) RenderHighlights() bool {
return s.renderHighlights
}
func (s *Scene) RenderReflection() bool {
return s.renderReflection
}
func (s *Scene) RenderRefraction() bool {
return s.renderRefraction
}
func (s *Scene) RenderShadow() bool {
return s.renderShadow
}
func CreateScene() *Scene {
return &Scene{
samplingQuality: 0,
rayDepth: 3,
renderDiffuse: true,
renderHighlights: true,
renderShadow: true,
renderReflection: true,
renderRefraction: true,
camera: CreateCameraDefaultUp(Vector{0, 0, -5}, Vector{0, 0, 1}),
background: CreateBackground(DoubleColor{0, 0, .5}, 0.2)}
}
func (s *Scene) String() string {
str := fmt.Sprintf("Scene: Diffuse(%v) Highlights(%v) Reflections(%v) Refraction(%v) Shadow (%v) NumLights (%d) NumShapes (%d)",
s.RenderDiffuse(), s.RenderHighlights(), s.RenderReflection(), s.RenderRefraction(), s.RenderShadow(), len(s.Lights()), len(s.Shapes()))
str += fmt.Sprintf(" Camera (%v)", s.Camera())
return str
}