Exemple #1
0
 def get_height(self):
     p = x, y, z = self.wasd.position
     x, z = int(round(x / STEP)), int(round(z / STEP))
     for i in xrange(x - 1, x + 2):
         for j in xrange(z - 1, z + 2):
             for v1, v2, v3 in self.lookup[(i, j)]:
                 t = pg.ray_triangle_intersection(v1, v2, v3, p, (0, -1, 0))
                 if t:
                     return t
                 t = pg.ray_triangle_intersection(v1, v2, v3, p, (0, 1, 0))
                 if t:
                     return -t
     return None
Exemple #2
0
 def adjust_height(self):
     o = x, y, z = self.wasd.position
     d = (0, -1, 0)
     x, z = int(round(x)), int(round(z))
     for i in xrange(x - 1, x + 2):
         for j in xrange(z - 1, z + 2):
             for v1, v2, v3 in self.lookup[(i, j)]:
                 t = pg.ray_triangle_intersection(v1, v2, v3, o, d)
                 if t and t < 1:
                     self.wasd.y += 1 - t
                     return
Exemple #3
0
 def adjust_height(self):
     o = x, y, z = self.wasd.position
     d = (0, -1, 0)
     x, z = int(round(x)), int(round(z))
     for i in xrange(x - 1, x + 2):
         for j in xrange(z - 1, z + 2):
             for v1, v2, v3 in self.lookup[(i, j)]:
                 t = pg.ray_triangle_intersection(v1, v2, v3, o, d)
                 if t and t < 1:
                     self.wasd.y += 1 - t
                     return