Newer
Older
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
require 'test/unit'
require 'fox16'
require 'fox16/glshapes'
include Fox
class TC_FXMaterial < Test::Unit::TestCase
DELTA = 1.0e-6
def setup
@mat = FXMaterial.new
end
def test_ambient
@mat.ambient = [0.5, 0.6, 0.7, 0.8]
assert_in_delta(0.5, @mat.ambient[0], DELTA)
assert_in_delta(0.6, @mat.ambient[1], DELTA)
assert_in_delta(0.7, @mat.ambient[2], DELTA)
assert_in_delta(0.8, @mat.ambient[3], DELTA)
@mat.ambient = FXVec4f.new(0.5, 0.6, 0.7, 0.8)
assert_in_delta(0.5, @mat.ambient[0], DELTA)
assert_in_delta(0.6, @mat.ambient[1], DELTA)
assert_in_delta(0.7, @mat.ambient[2], DELTA)
assert_in_delta(0.8, @mat.ambient[3], DELTA)
end
def test_diffuse
@mat.diffuse = [0.5, 0.6, 0.7, 0.8]
assert_in_delta(0.5, @mat.diffuse[0], DELTA)
assert_in_delta(0.6, @mat.diffuse[1], DELTA)
assert_in_delta(0.7, @mat.diffuse[2], DELTA)
assert_in_delta(0.8, @mat.diffuse[3], DELTA)
@mat.diffuse = FXVec4f.new(0.5, 0.6, 0.7, 0.8)
assert_in_delta(0.5, @mat.diffuse[0], DELTA)
assert_in_delta(0.6, @mat.diffuse[1], DELTA)
assert_in_delta(0.7, @mat.diffuse[2], DELTA)
assert_in_delta(0.8, @mat.diffuse[3], DELTA)
end
def test_emission
@mat.emission = [0.5, 0.6, 0.7, 0.8]
assert_in_delta(0.5, @mat.emission[0], DELTA)
assert_in_delta(0.6, @mat.emission[1], DELTA)
assert_in_delta(0.7, @mat.emission[2], DELTA)
assert_in_delta(0.8, @mat.emission[3], DELTA)
@mat.emission = FXHVec.new(0.5, 0.6, 0.7, 0.8)
assert_in_delta(0.5, @mat.emission[0], DELTA)
assert_in_delta(0.6, @mat.emission[1], DELTA)
assert_in_delta(0.7, @mat.emission[2], DELTA)
assert_in_delta(0.8, @mat.emission[3], DELTA)
end
def test_shininess
@mat.shininess = 0.5
assert_in_delta(0.5, @mat.shininess, DELTA)
end
def test_bug
cube = FXGLCube.new(0, 0, 0, 0, 0)
mat = FXMaterial.new
mat.diffuse = FXVec4f.new(0, 0, 0, 0)
mat.specular = FXVec4f.new(0, 0, 0, 0)
mat.ambient = FXVec4f.new(0, 0, 0, 0)
cube.setMaterial(0, mat)
mat2 = cube.getMaterial(0)
assert_instance_of(FXVec4f, mat2.ambient)
assert_instance_of(FXVec4f, mat2.specular)
assert_instance_of(FXVec4f, mat2.diffuse)
end
end