コード例 #1
0
ファイル: frustum_test.py プロジェクト: hotgloupi/8cube
 def test_plane_position(self):
     for p in frustum.PlanePosition.values.values():
         self.assertLessEqual(self.frustum.plane(p).distance(vec3d(0, 0, -1)), 0)
         self.assertLessEqual(self.frustum.plane(p).distance(vec3d(10, 10, -100)), 0)
コード例 #2
0
ファイル: frustum.py プロジェクト: hotgloupi/8cube
from cube.gl import frustum, vec3il, vec3f, Sphereil, vec3d, vector

fov = 45
ratio = 640 / 480
near_dist = 1
far_dist = 300

f = frustum.Frustumil(fov, ratio, near_dist, far_dist)

pos = vec3il(10,12,12)
up = vec3f(0,1,0)
front = vec3f(0,0,-1)
f.update(pos, front, up)

for p in frustum.PlanePosition.values.values():
    print(f.plane(p).distance(vec3d(10, 12, 11)))
    assert f.plane(p).distance(vec3d(10, 12, 11)) <= 0
    assert f.plane(p).distance(vec3d(10, 10, -100)) <= 0

pos = vec3il(10,12,11)

print(f.contains(pos))
assert f.contains(pos)


s = Sphereil(pos, 12)
assert f.intersect(s)

pos = vec3il(10,15,11)
s = Sphereil(pos, 12)
assert f.intersect(s)