-
Notifications
You must be signed in to change notification settings - Fork 0
/
ri_test.go
82 lines (59 loc) · 1.8 KB
/
ri_test.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
package rigo
import (
"testing"
. "github.com/mae-global/rigo2/ri"
. "github.com/mae-global/rigo2/ri/core"
. "github.com/smartystreets/goconvey/convey"
)
/* These simple tests are used as default examples */
func Test_Examples(t *testing.T) {
Convey("Unit Cube Example", t, func() {
ri := New(nil)
ri.Option("driver",RtToken("strict"),RtBoolean(true))
ri.Begin("out/examples/unitcube.rib")
ri.AttributeBegin()
ri.Attribute("identifier", RtToken("name"), RtToken("unitcube"))
ri.Bound(RtBound{-.5, .5, -.5, .5, -.5, .5})
ri.TransformBegin()
points := RtFloatArray{.5, .5, .5, -.5, .5, .5, -.5, -.5, .5, .5, -.5, .5}
ri.ArchiveRecord(COMMENT, "far face")
ri.Polygon(4, P, points)
ri.Rotate(90, 0, 1, 0)
ri.ArchiveRecord(COMMENT, "right face")
ri.Polygon(4, P, points)
ri.Rotate(90, 0, 1, 0)
ri.ArchiveRecord(COMMENT, "near face")
ri.Polygon(4, P, points)
ri.Rotate(90, 0, 1, 0)
ri.ArchiveRecord(COMMENT, "left face")
ri.Polygon(4, P, points)
ri.TransformEnd()
ri.TransformBegin()
ri.ArchiveRecord(COMMENT, "bottom face")
ri.Rotate(90, 1, 0, 0)
ri.Polygon(4, P, points)
ri.TransformEnd()
ri.TransformBegin()
ri.ArchiveRecord(COMMENT, "top face")
ri.Rotate(-90, 1, 0, 0)
ri.Polygon(4, P, points)
ri.TransformEnd()
ri.AttributeEnd()
ri.End()
})
Convey("Simple Sphere Example", t, func() {
ri := New(nil)
ri.Option("driver",RtToken("strict"),RtBoolean(true))
ri.Begin("out/examples/simplesphere.rib")
ri.Display("simplesphere.tiff", "file", "rgba")
ri.Format(320, 240, 1)
ri.Projection(PERSPECTIVE, RtToken("float fov"), RtFloat(30))
ri.Translate(0, 0, 6)
ri.WorldBegin()
ri.Light("PxrEnvDayLight", "-", RtToken("float intensity"), RtFloat(0.5))
ri.Color(RtColor{1, 0, 0})
ri.Sphere(1, -1, 1, 360)
ri.WorldEnd()
ri.End()
})
}