| |
---|
| | return[p1, p2] |
---|
| | |
---|
| | |
---|
| | # new functions |
---|
| | def generate_cam_matrix(rx_D: int, ry_D: int, rz_D: int, player_pos): |
---|
| | #rx = math.radians(rx_D) |
---|
| | rx = 0 |
---|
| | ry = math.radians(rx_D) |
---|
| | rz = math.radians(rz_D) |
---|
| | |
---|
| | rotation_matrix = numpy.array( |
---|
| | [[math.cos(ry)*math.cos(rz), math.sin(rx)*math.sin(ry)*math.cos(rz) - math.cos(rx)*math.sin(rz), math.cos(rx)*math.sin(ry)*math.cos(rz) + math.sin(rx)*math.sin(rz), 0], |
---|
| | [math.cos(ry)*math.sin(rz), math.sin(rx)*math.sin(ry)*math.sin(rz) + math.cos(rx)*math.cos(rz), math.cos(rx)*math.sin(ry)*math.sin(rz) - math.sin(rx)*math.sin(rz), 0], |
---|
| | [-math.sin(ry), math.sin(rx)*math.cos(ry), math.cos(rx)*math.cos(ry), 0], |
---|
| | [0, 0, 0, 1]] |
---|
| | ) |
---|
| | def generate_cam_matrix(rx_d: int, ry_d: int, rz_d: int, player_pos): |
---|
| | rx = math.radians(rx_d) |
---|
| | ry = math.radians(ry_d) |
---|
| | rz = math.radians(rz_d) |
---|
| | |
---|
| | x_rot = numpy.array([[1, 0, 0, 0], |
---|
| | [0, math.cos(rx), math.sin(rx), 0], |
---|
| | [0, -math.sin(rx), math.cos(rx), 0], |
---|
| | [0, 0, 0, 1]]) |
---|
| | |
---|
| | y_rot = numpy.array([[math.cos(ry), 0, -math.sin(ry), 0], |
---|
| | [0, 1, 0, 0], |
---|
| | [math.sin(ry), 0, math.cos(ry), 0], |
---|
| | [0, 0, 0, 1]]) |
---|
| | |
---|
| | z_rot = numpy.array([[math.cos(rz), math.sin(rz), 0, 0], |
---|
| | [-math.sin(rz), math.cos(rz), 0, 0], |
---|
| | [0, 0, 1, 0], |
---|
| | [0, 0, 0, 1]]) |
---|
| | rotation_matrix = x_rot.dot(y_rot).dot(z_rot) |
---|
| | |
---|
| | translation_matrix = numpy.array( |
---|
| | [[1, 0, 0, player_pos.x], |
---|
| | [0, 1, 0, player_pos.y], |
---|
| | [0, 0, 1, player_pos.z], |
---|
| | [0, 0, 0, 1]] |
---|
| | ) |
---|
| | # todo |
---|
| | # make this thing |
---|
| | # generates a transformation matrix for the current camera |
---|
| | # should only be run once per frame (hopefully a performance improvement?) |
---|
| | # return translation_matrix.dot(rotation_matrix) |
---|
| | # return numpy.matmul(translation_matrix, rotation_matrix) |
---|
| | return numpy.matmul(translation_matrix, rotation_matrix) |
---|
| | # return numpy.multiply(translation_matrix, rotation_matrix) |
---|
| | return rotation_matrix.dot(translation_matrix) |
---|
| | |
---|
| | |
---|
| | def gen_inv_rot_matrix(rx_d, ry_d, rz_d): |
---|
| | rx = math.radians(-rx_d) |
---|
| | ry = math.radians(rx_d) |
---|
| | rz = math.radians(-rz_d - 90) |
---|
| | |
---|
| | x_rot = numpy.array([[1, 0, 0, 0], |
---|
| | [0, math.cos(rx), math.sin(rx), 0], |
---|
| | [0, -math.sin(rx), math.cos(rx), 0], |
---|
| | [0, 0, 0, 1]]) |
---|
| | |
---|
| | y_rot = numpy.array([[math.cos(ry), 0, -math.sin(ry), 0], |
---|
| | [0, 1, 0, 0], |
---|
| | [math.sin(ry), 0, math.cos(ry), 0], |
---|
| | [0, 0, 0, 1]]) |
---|
| | |
---|
| | z_rot = numpy.array([[math.cos(rz), math.sin(rz), 0, 0], |
---|
| | [-math.sin(rz), math.cos(rz), 0, 0], |
---|
| | [0, 0, 1, 0], |
---|
| | [0, 0, 0, 1]]) |
---|
| | return z_rot.dot(y_rot).dot(x_rot) |
---|
| | |
---|
| | |
---|
| | def draw_face(face: Face, cam_matrix: numpy.array, fp_dis): |
---|
| | if type(face) is TexturedFace: |
---|
| |
---|
| | |
|