def test_hash_node(self): a = set({Node(gl.vec3il(1,2,3), 10)}) self.assertIn(Node(gl.vec3il(1,2,3), 10), a) self.assertNotIn(Node(gl.vec3il(0,2,3), 10), a) self.assertNotIn(Node(gl.vec3il(1,2,3), 11), a)
# -*- encoding: utf-8 -*- 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)
def test_init_node(self): n = Node(gl.vec3il(1,2,3), 10) self.assertEqual(n.origin, gl.vec3il(1,2,3)) self.assertEqual(n.size, 10)