diff --git a/community/block_type.py b/community/block_type.py index 2142433f..9a692401 100644 --- a/community/block_type.py +++ b/community/block_type.py @@ -3,7 +3,6 @@ import models.cube # default model class Block_type: - # new optional model argument (cube model by default) def __init__(self, texture_manager, name = "unknown", block_face_textures = {"all": "cobblestone"}, model = models.cube): self.name = name self.block_face_textures = block_face_textures @@ -12,6 +11,7 @@ def __init__(self, texture_manager, name = "unknown", block_face_textures = {"al # create members based on model attributes self.transparent = model.transparent + self.transparency = model.transparency self.is_cube = model.is_cube self.glass = model.glass self.translucent = model.translucent @@ -23,7 +23,7 @@ def __init__(self, texture_manager, name = "unknown", block_face_textures = {"al for _collider in model.colliders: self.colliders.append(collider.Collider(*_collider)) - # replace data contained in numbers.py with model specific data + # get model specific data self.vertex_positions = model.vertex_positions self.tex_coords = model.tex_coords # to deprecate @@ -32,8 +32,10 @@ def __init__(self, texture_manager, name = "unknown", block_face_textures = {"al def set_block_face(face, texture): # make sure we don't add inexistent face + if face > len(self.tex_coords) - 1: return + self.tex_indices[face] = texture for face in block_face_textures: diff --git a/community/chunk.py b/community/chunk.py index ae351415..0d99093f 100644 --- a/community/chunk.py +++ b/community/chunk.py @@ -3,7 +3,7 @@ import pyglet.gl as gl -import subchunk +import subchunk import options @@ -14,8 +14,7 @@ class Chunk: def __init__(self, world, chunk_position): self.world = world - self.shader_chunk_offset_location = self.world.shader.find_uniform(b"u_ChunkPosition") - + self.modified = False self.chunk_position = chunk_position @@ -23,7 +22,7 @@ def __init__(self, world, chunk_position): self.chunk_position[0] * CHUNK_WIDTH, self.chunk_position[1] * CHUNK_HEIGHT, self.chunk_position[2] * CHUNK_LENGTH) - + self.blocks = [[[0 for z in range(CHUNK_LENGTH)] for y in range(CHUNK_HEIGHT)] for x in range(CHUNK_WIDTH)] @@ -31,10 +30,10 @@ def __init__(self, world, chunk_position): self.lightmap = [[[0 for z in range(CHUNK_LENGTH)] for y in range(CHUNK_HEIGHT)] for x in range(CHUNK_WIDTH)] - + self.subchunks = {} self.chunk_update_queue = deque() - + for x in range(int(CHUNK_WIDTH / subchunk.SUBCHUNK_WIDTH)): for y in range(int(CHUNK_HEIGHT / subchunk.SUBCHUNK_HEIGHT)): for z in range(int(CHUNK_LENGTH / subchunk.SUBCHUNK_LENGTH)): @@ -53,48 +52,48 @@ def __init__(self, world, chunk_position): self.vao = gl.GLuint(0) gl.glGenVertexArrays(1, self.vao) gl.glBindVertexArray(self.vao) - + self.vbo = gl.GLuint(0) gl.glGenBuffers(1, self.vbo) gl.glBindBuffer(gl.GL_ARRAY_BUFFER, self.vbo) gl.glBufferData(gl.GL_ARRAY_BUFFER, ctypes.sizeof(gl.GLfloat * CHUNK_WIDTH * CHUNK_HEIGHT * CHUNK_LENGTH * 7), None, gl.GL_DYNAMIC_DRAW) - gl.glVertexAttribPointer(0, 3, gl.GL_FLOAT, + gl.glVertexAttribPointer(0, 3, gl.GL_FLOAT, gl.GL_FALSE, 7 * ctypes.sizeof(gl.GLfloat), 0) gl.glEnableVertexAttribArray(0) - gl.glVertexAttribPointer(1, 1, gl.GL_FLOAT, + gl.glVertexAttribPointer(1, 1, gl.GL_FLOAT, gl.GL_FALSE, 7 * ctypes.sizeof(gl.GLfloat), 3 * ctypes.sizeof(gl.GLfloat)) gl.glEnableVertexAttribArray(1) - gl.glVertexAttribPointer(2, 1, gl.GL_FLOAT, + gl.glVertexAttribPointer(2, 1, gl.GL_FLOAT, gl.GL_FALSE, 7 * ctypes.sizeof(gl.GLfloat), 4 * ctypes.sizeof(gl.GLfloat)) gl.glEnableVertexAttribArray(2) - gl.glVertexAttribPointer(3, 1, gl.GL_FLOAT, + gl.glVertexAttribPointer(3, 1, gl.GL_FLOAT, gl.GL_FALSE, 7 * ctypes.sizeof(gl.GLfloat), 5 * ctypes.sizeof(gl.GLfloat)) gl.glEnableVertexAttribArray(3) - gl.glVertexAttribPointer(4, 1, gl.GL_FLOAT, + gl.glVertexAttribPointer(4, 1, gl.GL_FLOAT, gl.GL_FALSE, 7 * ctypes.sizeof(gl.GLfloat), 6 * ctypes.sizeof(gl.GLfloat)) gl.glEnableVertexAttribArray(4) - + gl.glBindBuffer(gl.GL_ELEMENT_ARRAY_BUFFER, world.ibo) - + if self.world.options.INDIRECT_RENDERING: self.indirect_command_buffer = gl.GLuint(0) gl.glGenBuffers(1, self.indirect_command_buffer) gl.glBindBuffer(gl.GL_DRAW_INDIRECT_BUFFER, self.indirect_command_buffer) gl.glBufferData( - gl.GL_DRAW_INDIRECT_BUFFER, + gl.GL_DRAW_INDIRECT_BUFFER, ctypes.sizeof(gl.GLuint * 10), None, gl.GL_DYNAMIC_DRAW - ) + ) self.draw_commands = [] self.occlusion_query = gl.GLuint(0) gl.glGenQueries(1, self.occlusion_query) - + def __del__(self): gl.glDeleteQueries(1, self.occlusion_query) @@ -132,20 +131,20 @@ def get_transparency(self, position): if not block_type: return 2 - + return block_type.transparent def is_opaque_block(self, position): # get block type and check if it's opaque or not # air counts as a transparent block, so test for that too - + block_type = self.world.block_types[self.get_block_number(position)] - + if not block_type: return False - + return not block_type.transparent - + def update_subchunk_meshes(self): self.chunk_update_queue.clear() for subchunk in self.subchunks.values(): @@ -193,7 +192,7 @@ def process_chunk_updates(self): def update_mesh(self): # combine all the small subchunk meshes into one big chunk mesh - + for subchunk in self.subchunks.values(): self.mesh += subchunk.mesh self.translucent_mesh += subchunk.translucent_mesh @@ -208,7 +207,7 @@ def update_mesh(self): self.mesh = [] self.translucent_mesh = [] - + def send_mesh_data_to_gpu(self): # pass mesh data to gpu if not self.mesh_quad_count: return @@ -217,8 +216,8 @@ def send_mesh_data_to_gpu(self): # pass mesh data to gpu gl.glBindBuffer(gl.GL_ARRAY_BUFFER, self.vbo) gl.glBufferData(gl.GL_ARRAY_BUFFER, # Orphaning - ctypes.sizeof(gl.GLfloat * CHUNK_WIDTH * CHUNK_HEIGHT * CHUNK_LENGTH * 7), - None, + ctypes.sizeof(gl.GLfloat * CHUNK_WIDTH * CHUNK_HEIGHT * CHUNK_LENGTH * 7), + None, gl.GL_DYNAMIC_DRAW ) gl.glBufferSubData( @@ -236,7 +235,7 @@ def send_mesh_data_to_gpu(self): # pass mesh data to gpu if not self.world.options.INDIRECT_RENDERING: return - + self.draw_commands = [ # Index Count Instance Count Base Index Base Vertex Base Instance self.mesh_quad_count * 6, 1, 0, 0, 0, # Opaque mesh commands @@ -255,7 +254,7 @@ def draw_direct(self, mode): if not self.mesh_quad_count: return gl.glBindVertexArray(self.vao) - gl.glUniform2i(self.shader_chunk_offset_location, self.chunk_position[0], self.chunk_position[2]) + gl.glUniform2i(self.world.block_shader_chunk_offset_location, self.chunk_position[0], self.chunk_position[2]) gl.glDrawElements( mode, self.mesh_quad_count * 6, @@ -269,7 +268,7 @@ def draw_indirect(self, mode): gl.glBindVertexArray(self.vao) gl.glBindBuffer(gl.GL_DRAW_INDIRECT_BUFFER, self.indirect_command_buffer) - gl.glUniform2i(self.shader_chunk_offset_location, self.chunk_position[0], self.chunk_position[2]) + gl.glUniform2i(self.world.block_shader_chunk_offset_location, self.chunk_position[0], self.chunk_position[2]) gl.glDrawElementsIndirect( mode, @@ -282,7 +281,7 @@ def draw_direct_advanced(self, mode): return gl.glBindVertexArray(self.vao) - gl.glUniform2i(self.shader_chunk_offset_location, self.chunk_position[0], self.chunk_position[2]) + gl.glUniform2i(self.world.block_shader_chunk_offset_location, self.chunk_position[0], self.chunk_position[2]) gl.glBeginQuery(gl.GL_ANY_SAMPLES_PASSED, self.occlusion_query) gl.glDrawElements( @@ -293,7 +292,7 @@ def draw_direct_advanced(self, mode): ) gl.glEndQuery(gl.GL_ANY_SAMPLES_PASSED) - + gl.glBeginConditionalRender(self.occlusion_query, gl.GL_QUERY_BY_REGION_WAIT) gl.glDrawElements( mode, @@ -309,7 +308,7 @@ def draw_indirect_advanced(self, mode): gl.glBindVertexArray(self.vao) gl.glBindBuffer(gl.GL_DRAW_INDIRECT_BUFFER, self.indirect_command_buffer) - gl.glUniform2i(self.shader_chunk_offset_location, self.chunk_position[0], self.chunk_position[2]) + gl.glUniform2i(self.world.block_shader_chunk_offset_location, self.chunk_position[0], self.chunk_position[2]) gl.glBeginQuery(gl.GL_ANY_SAMPLES_PASSED, self.occlusion_query) gl.glDrawElementsIndirect( @@ -319,7 +318,7 @@ def draw_indirect_advanced(self, mode): ) gl.glEndQuery(gl.GL_ANY_SAMPLES_PASSED) - + gl.glBeginConditionalRender(self.occlusion_query, gl.GL_QUERY_BY_REGION_WAIT) gl.glDrawElementsIndirect( mode, @@ -335,9 +334,9 @@ def draw_indirect_advanced(self, mode): def draw_translucent_direct(self, mode): if not self.mesh_quad_count: return - + gl.glBindVertexArray(self.vao) - gl.glUniform2i(self.shader_chunk_offset_location, self.chunk_position[0], self.chunk_position[2]) + gl.glUniform2i(self.world.block_shader_chunk_offset_location, self.chunk_position[0], self.chunk_position[2]) gl.glDrawElementsBaseVertex( mode, @@ -350,10 +349,10 @@ def draw_translucent_direct(self, mode): def draw_translucent_indirect(self, mode): if not self.translucent_quad_count: return - + gl.glBindVertexArray(self.vao) gl.glBindBuffer(gl.GL_DRAW_INDIRECT_BUFFER, self.indirect_command_buffer) - gl.glUniform2i(self.shader_chunk_offset_location, self.chunk_position[0], self.chunk_position[2]) + gl.glUniform2i(self.world.block_shader_chunk_offset_location, self.chunk_position[0], self.chunk_position[2]) gl.glMemoryBarrier(gl.GL_COMMAND_BARRIER_BIT) @@ -364,4 +363,4 @@ def draw_translucent_indirect(self, mode): ) draw_translucent = draw_translucent_indirect if options.INDIRECT_RENDERING else draw_translucent_direct - + diff --git a/community/controller.py b/community/controller.py index a3a433c2..6fde7f4f 100644 --- a/community/controller.py +++ b/community/controller.py @@ -2,6 +2,7 @@ import player import chunk import hit +import mob from enum import IntEnum @@ -21,6 +22,7 @@ class MiscMode(IntEnum): TELEPORT = 6 TOGGLE_F3 = 7 TOGGLE_AO = 8 + SPAWN = 9 class MoveMode(IntEnum): LEFT = 0 @@ -54,6 +56,14 @@ def hit_callback(current_block, next_block): def misc(self, mode): if mode == self.MiscMode.RANDOM: self.game.holding = random.randint(1, len(self.game.world.block_types) - 1) + + elif mode == self.MiscMode.SPAWN: + # _mob = mob.Mob(self.game.world, random.choice([*self.game.world.entity_types.values()])) + _mob = mob.Mob(self.game.world, random.choice([self.game.world.entity_types["Zombie"], self.game.world.entity_types["Creeper"], self.game.world.entity_types["Skeleton"]])) + self.game.world.entities.append(_mob) + + _mob.teleport(self.game.player.position) + elif mode == self.MiscMode.SAVE: self.game.world.save.save() elif mode == self.MiscMode.ESCAPE: diff --git a/community/data/entities.mcpy b/community/data/entities.mcpy new file mode 100644 index 00000000..1f9176db --- /dev/null +++ b/community/data/entities.mcpy @@ -0,0 +1,7 @@ +Player: name "Player", width 0.6, height 1.8, model models.pig, texture pig +Pig: name "Pig", width 0.9, height 0.9, model models.pig, texture pig +Zombie: name "Zombie", width 0.6, height 1.95, model models.zombie, texture zombie +Skeleton: name "Skeleton", width 0.6, height 1.99, model models.skeleton, texture skeleton +Creeper: name "Creeper", width 0.6, height 1.7, model models.creeper, texture creeper +Cow: name "Cow", width 0.9, height 1.3, model models.cow, texture cow +Curry: name "Curry", width 0.9, height 1.8, model models.curry, texture curry diff --git a/community/entity.py b/community/entity.py index 27ab70ae..0854fdff 100644 --- a/community/entity.py +++ b/community/entity.py @@ -1,10 +1,16 @@ import math +import random + +import glm + import collider +import chunk + FLYING_ACCEL = (0, 0, 0) GRAVITY_ACCEL = (0, -32, 0) -# these values all come (losely) from Minecraft, but are multiplied by 20 (since Minecraft runs at 20 TPS) +# these values all come (loosely) from Minecraft, but are multiplied by 20 (since Minecraft runs at 20 TPS) FRICTION = ( 20, 20, 20) @@ -13,13 +19,17 @@ DRAG_FALL = (1.8, 0.4, 1.8) class Entity: - def __init__(self, world): + def __init__(self, world, entity_type): self.world = world + self.entity_type = entity_type + + self.age = 0 # physical variables self.jump_height = 1.25 self.flying = False + self.ghost = False self.position = [0, 80, 0] self.rotation = [-math.tau / 4, 0] @@ -34,23 +44,22 @@ def __init__(self, world): # collision variables - self.width = 0.6 - self.height = 1.8 - self.collider = collider.Collider() + self.grounded = False + self.wall = False def update_collider(self): x, y, z = self.position - self.collider.x1 = x - self.width / 2 - self.collider.x2 = x + self.width / 2 + self.collider.x1 = x - self.entity_type.width / 2 + self.collider.x2 = x + self.entity_type.width / 2 self.collider.y1 = y - self.collider.y2 = y + self.height + self.collider.y2 = y + self.entity_type.height - self.collider.z1 = z - self.width / 2 - self.collider.z2 = z + self.width / 2 + self.collider.z1 = z - self.entity_type.width / 2 + self.collider.z2 = z + self.entity_type.width / 2 def teleport(self, pos): self.position = list(pos) @@ -65,7 +74,40 @@ def jump(self, height = None): if height is None: height = self.jump_height - self.velocity[1] = math.sqrt(2 * height * -GRAVITY_ACCEL[1]) + self.velocity[1] = math.sqrt(-2 * GRAVITY_ACCEL[1] * height) + + def reset(self): + # how large is the world? + + max_y = 0 + + max_x, max_z = (0, 0) + min_x, min_z = (0, 0) + + for pos in self.world.chunks: + x, y, z = pos + + max_y = max(max_y, (y + 1) * chunk.CHUNK_HEIGHT) + + max_x = max(max_x, (x + 1) * chunk.CHUNK_WIDTH) + min_x = min(min_x, x * chunk.CHUNK_WIDTH) + + max_z = max(max_z, (z + 1) * chunk.CHUNK_LENGTH) + min_z = min(min_z, z * chunk.CHUNK_LENGTH) + + # get random X & Z coordinates to teleport the player to + + x = random.randint(min_x, max_x) + z = random.randint(min_z, max_z) + + # find height at which to teleport to, by finding the first non-air block from the top of the world + + for y in range(chunk.CHUNK_HEIGHT - 1, -1, -1): + if not self.world.get_block_number((x, y, z)): + continue + + self.teleport((x, y + 1, z)) + break @property def friction(self): @@ -80,10 +122,72 @@ def friction(self): return DRAG_FALL + def resolve_collision(self, delta_time): + adjusted_velocity = [v * delta_time for v in self.velocity] + vx, vy, vz = adjusted_velocity + + # find all the blocks we could potentially be colliding with + # this step is known as "broad-phasing" + + step_x = 1 if vx > 0 else -1 + step_y = 1 if vy > 0 else -1 + step_z = 1 if vz > 0 else -1 + + steps_xz = int(self.entity_type.width / 2) + steps_y = int(self.entity_type.height) + + x, y, z = map(int, self.position) + cx, cy, cz = [int(p + v) for p, v in zip(self.position, adjusted_velocity)] + + potential_collisions = [] + + for i in range(x - step_x * (steps_xz + 1), cx + step_x * (steps_xz + 2), step_x): + for j in range(y - step_y * (steps_y + 2), cy + step_y * (steps_y + 3), step_y): + for k in range(z - step_z * (steps_xz + 1), cz + step_z * (steps_xz + 2), step_z): + pos = (i, j, k) + num = self.world.get_block_number(pos) + + if not num: + continue + + for _collider in self.world.block_types[num].colliders: + entry_time, normal = self.collider.collide(_collider + pos, adjusted_velocity) + + if normal is None: + continue + + potential_collisions.append((entry_time, normal)) + + # get first collision + + if not potential_collisions: + return + + entry_time, normal = min(potential_collisions, key = lambda x: x[0]) + entry_time -= 0.001 + + if normal[0]: + self.velocity[0] = 0 + self.position[0] += vx * entry_time + + if normal[1]: + self.velocity[1] = 0 + self.position[1] += vy * entry_time + + if normal[2]: + self.velocity[2] = 0 + self.position[2] += vz * entry_time + + if normal[0] or normal[2]: + self.wall = True + + if normal[1] == 1: + self.grounded = True + def update(self, delta_time): self.step = 1 self.old_position = tuple(self.position) - + # apply input acceleration, and adjust for friction/drag self.velocity = [v + a * f * delta_time for v, a, f in zip(self.velocity, self.accel, self.friction)] @@ -92,78 +196,62 @@ def update(self, delta_time): # compute collisions self.update_collider() - self.grounded = False - - for _ in range(3): - adjusted_velocity = [v * delta_time for v in self.velocity] - vx, vy, vz = adjusted_velocity - # find all the blocks we could potentially be colliding with - # this step is known as "broad-phasing" + self.grounded = False + self.wall = False - step_x = 1 if vx > 0 else -1 - step_y = 1 if vy > 0 else -1 - step_z = 1 if vz > 0 else -1 + if not self.ghost: + for _ in range(3): + self.resolve_collision(delta_time) - steps_xz = int(self.width / 2) - steps_y = int(self.height) + self.position = [x + v * delta_time for x, v in zip(self.position, self.velocity)] - x, y, z = map(int, self.position) - cx, cy, cz = [int(x + v) for x, v in zip(self.position, adjusted_velocity)] + # apply gravity acceleration - potential_collisions = [] + gravity = FLYING_ACCEL if self.flying else GRAVITY_ACCEL + self.velocity = [v + a * delta_time for v, a in zip(self.velocity, gravity)] - for i in range(x - step_x * (steps_xz + 1), cx + step_x * (steps_xz + 2), step_x): - for j in range(y - step_y * (steps_y + 2), cy + step_y * (steps_y + 3), step_y): - for k in range(z - step_z * (steps_xz + 1), cz + step_z * (steps_xz + 2), step_z): - pos = (i, j, k) - num = self.world.get_block_number(pos) + # apply friction/drag - if not num: - continue + self.velocity = [v - min(v * f * delta_time, v, key = abs) for v, f in zip(self.velocity, self.friction)] - for _collider in self.world.block_types[num].colliders: - entry_time, normal = self.collider.collide(_collider + pos, adjusted_velocity) + # make sure we can rely on the entity's collider outside of this function - if normal is None: - continue + self.update_collider() - potential_collisions.append((entry_time, normal)) + # animate the entity - # get first collision + dx = self.position[0] - self.old_position[0] + dz = self.position[2] - self.old_position[2] - if not potential_collisions: - break + speed = math.sqrt(dx ** 2 + dz ** 2) + self.age += delta_time + self.entity_type.animate(self.age, speed / delta_time, self.position, self.rotation) - entry_time, normal = min(potential_collisions, key = lambda x: x[0]) - entry_time -= 0.001 + def draw(self): + # compute MVP matrix - if normal[0]: - self.velocity[0] = 0 - self.position[0] += vx * entry_time - - if normal[1]: - self.velocity[1] = 0 - self.position[1] += vy * entry_time + mvp = glm.mat4(self.world.mvp_matrix) - if normal[2]: - self.velocity[2] = 0 - self.position[2] += vz * entry_time + mvp = glm.translate(mvp, glm.vec3(*self.position)) + mvp = glm.rotate(mvp, self.rotation[0], glm.vec3(0, 1, 0)) - if normal[1] == 1: - self.grounded = True + # compute inverse transformation matrix - self.position = [x + v * delta_time for x, v in zip(self.position, self.velocity)] + inverse = glm.rotate(glm.mat4(1), -self.rotation[0], glm.vec3(0, 1, 0)) - # apply gravity acceleration + # lighting stuff - gravity = (GRAVITY_ACCEL, FLYING_ACCEL)[self.flying] - self.velocity = [v + a * delta_time for v, a in zip(self.velocity, gravity)] + skylight = self.world.get_skylight(tuple(map(round, self.position))) + light = self.world.get_light(tuple(map(round, self.position))) - # apply friction/drag + # actually draw entity - self.velocity = [v - min(v * f * delta_time, v, key = abs) for v, f in zip(self.velocity, self.friction)] + self.world.entity_shader.uniform_matrix(self.world.entity_shader_inverse_transform_matrix_location, inverse) + self.world.entity_shader.uniform_matrix(self.world.entity_shader_matrix_location, mvp) - # make sure we can rely on the entity's collider outside of this function + self.world.entity_shader.uniform_float(self.world.entity_shader_lighting_location, + max(0.8 ** (15 - skylight * self.world.daylight / 1800), 0.8 ** (15 - light)) + ) - self.update_collider() \ No newline at end of file + self.entity_type.draw() diff --git a/community/entity_type.py b/community/entity_type.py new file mode 100644 index 00000000..581f5ad6 --- /dev/null +++ b/community/entity_type.py @@ -0,0 +1,230 @@ +import ctypes +import math + +import glm +import pyglet + +import pyglet.gl as gl + +import models.pig # default model + +class Entity_type: + def __init__(self, world, name = "unknown", texture = "pig", model = models.pig, width = 0.6, height = 1.8): + self.world = world + + self.name = name + self.model = model + + self.width = width + self.height = height + + # load texture image + + texture_image = pyglet.image.load(f"textures/{texture}.png").get_image_data() + + self.texture_width = texture_image.width + self.texture_height = texture_image.height + + # create texture + + self.texture = gl.GLuint(0) + gl.glGenTextures(1, self.texture) + gl.glBindTexture(gl.GL_TEXTURE_2D, self.texture) + + gl.glTexParameteri(gl.GL_TEXTURE_2D, gl.GL_TEXTURE_MIN_FILTER, gl.GL_NEAREST) + gl.glTexParameteri(gl.GL_TEXTURE_2D, gl.GL_TEXTURE_MAG_FILTER, gl.GL_NEAREST) + + gl.glTexImage2D( + gl.GL_TEXTURE_2D, 0, gl.GL_RGBA, + self.texture_width, self.texture_height, + 0, gl.GL_RGBA, gl.GL_UNSIGNED_BYTE, + texture_image.get_data("RGBA", self.texture_width * 4)) + + gl.glGenerateMipmap(gl.GL_TEXTURE_2D) + + # get total size of the models so we can create vertex buffers + + vertex_count = 0 + tex_coord_count = 0 + + for bone in model.bones: + vertex_count += len(sum(bone["vertices"], [])) // 3 + tex_coord_count += len(sum(bone["tex_coords"], [])) // 2 + + # create VAO/VBO/IBO + + self.vao = gl.GLuint(0) + gl.glGenVertexArrays(1, self.vao) + gl.glBindVertexArray(self.vao) + + # vertex positions & normals + # we'll combine these two (6 floats per vertex, first 3 for position, next 3 for normal) + + self.vertices_vbo = gl.GLuint(0) + gl.glGenBuffers(1, self.vertices_vbo) + + gl.glBindBuffer(gl.GL_ARRAY_BUFFER, self.vertices_vbo) + gl.glBufferData(gl.GL_ARRAY_BUFFER, + ctypes.sizeof(gl.GLfloat * vertex_count * 6), + 0, gl.GL_STREAM_DRAW) + + size = ctypes.sizeof(gl.GLfloat * 3) + + gl.glVertexAttribPointer(0, 3, gl.GL_FLOAT, gl.GL_FALSE, size * 2, size * 0) + gl.glEnableVertexAttribArray(0) + + gl.glVertexAttribPointer(1, 3, gl.GL_FLOAT, gl.GL_FALSE, size * 2, size * 1) + gl.glEnableVertexAttribArray(1) + + # texture coordinates + # these can be filled in straight away as they won't change + + self.tex_coords_vbo = gl.GLuint(0) + gl.glGenBuffers(1, self.tex_coords_vbo) + + gl.glBindBuffer(gl.GL_ARRAY_BUFFER, self.tex_coords_vbo) + gl.glBufferData(gl.GL_ARRAY_BUFFER, ctypes.sizeof(gl.GLfloat * tex_coord_count * 2), 0, gl.GL_STATIC_DRAW) + + offset = 0 + + for bone in self.model.bones: + tex_coords = sum(bone["tex_coords"], []) + + type_ = gl.GLfloat * len(tex_coords) + size = ctypes.sizeof(type_) + + gl.glBufferSubData( + gl.GL_ARRAY_BUFFER, offset, + size, (type_) (*tex_coords)) + + offset += size + + gl.glVertexAttribPointer(2, 2, gl.GL_FLOAT, gl.GL_FALSE, 0, 0) + gl.glEnableVertexAttribArray(2) + + # compute indices + + self.indices = [] + + for i in range(vertex_count): + self.indices.extend(x + i * 4 for x in (0, 1, 2, 0, 2, 3)) + + # indices + # these can be filled in straight away as they won't change + + self.ibo = gl.GLuint(0) + gl.glGenBuffers(1, self.ibo) + + gl.glBindBuffer(gl.GL_ELEMENT_ARRAY_BUFFER, self.ibo) + gl.glBufferData( + gl.GL_ELEMENT_ARRAY_BUFFER, + ctypes.sizeof(gl.GLuint * len(self.indices)), + (gl.GLuint * len(self.indices)) (*self.indices), + gl.GL_STATIC_DRAW) + + def animate(self, age, speed, position, rotation): + gl.glBindVertexArray(self.vao) + + # compute & upload vertex positions + + gl.glBindBuffer(gl.GL_ARRAY_BUFFER, self.vertices_vbo) + offset = 0 + + for bone in self.model.bones: + name = bone["name"] + pivot = bone["pivot"] + vertices = sum(bone["vertices"], []) + buffer = vertices * 2 # we want our buffer to hold both vertex positions & normals + + # compute animation transformation matrix + + anim = glm.translate(glm.mat4(1), glm.vec3(*pivot)) + kind = None + + if name == "head": + kind = "head" + + elif name[:3] == "leg": + kind = "odd_" * (int(name[3:]) in (1, 2)) + "leg" + + elif name == "rightLeg": + kind = "leg" + + elif name == "leftLeg": + kind = "odd_leg" + + elif name == "rightArm": + kind = "arm" + + elif name == "leftArm": + kind = "odd_arm" + + if kind is not None: + odd = "odd" in kind + + if kind == "head": + x, y, z = self.world.player.position + + dx = x - position[0] + dy = y - position[1] + dz = z - position[2] + + theta = -rotation[0] - math.atan2(dz, dx) - math.tau / 4 + iota = math.atan2(dy, math.sqrt(dx ** 2 + dz ** 2)) + + anim = glm.rotate(anim, theta, glm.vec3(0, 1, 0)) + anim = glm.rotate(anim, iota, glm.vec3(1, 0, 0)) + + if "leg" in kind: + phase = math.tau / 2 * odd + anim = glm.rotate(anim, -math.sin(age * 7 + phase) / 5 * speed, glm.vec3(1, 0, 0)) + + if "arm" in kind: + theta = (-age if odd else age) * 2 + phase = math.tau / 2 * odd + + anim = glm.rotate(anim, math.sin(theta + phase) / 8, glm.vec3(0, 1, 0)) + anim = glm.rotate(anim, -math.cos(theta + phase) / 8 + math.tau / 4, glm.vec3(1, 0, 0)) + + anim = glm.translate(anim, -glm.vec3(*pivot)) + + for i in range(0, len(vertices), 3): + vector = glm.vec4(*vertices[i: i + 3], 1) + buffer[i * 2: i * 2 + 3] = tuple(anim * vector)[:3] + + # compute normals + + for i in range(0, len(buffer), 24): + # take the cross product between two vectors we know are on the plane the face belongs to + + u = glm.vec3(buffer[i + 0] - buffer[i + 6], buffer[i + 1] - buffer[i + 7], buffer[i + 2] - buffer[i + 8]) + v = glm.vec3(buffer[i + 0] - buffer[i + 12], buffer[i + 1] - buffer[i + 13], buffer[i + 2] - buffer[i + 14]) + n = glm.cross(u, v) + + # each vertex of a face will have the same normal, so we can simply copy it 4 times + + for j in range(4): + buffer[i + j * 6 + 3: i + j * 6 + 6] = n + + # upload vertex buffer section + + type_ = gl.GLfloat * len(buffer) + size = ctypes.sizeof(type_) + + gl.glBufferSubData( + gl.GL_ARRAY_BUFFER, offset, + size, (type_) (*buffer)) + + offset += size + + def draw(self): + # bind textures + + gl.glActiveTexture(gl.GL_TEXTURE0) + gl.glBindTexture(gl.GL_TEXTURE_2D, self.texture) + gl.glUniform1i(self.world.entity_shader_sampler_location, 0) + + # draw entity + + gl.glBindVertexArray(self.vao) + gl.glDrawElements(gl.GL_TRIANGLES, len(self.indices), gl.GL_UNSIGNED_INT, None) diff --git a/community/keyboard_mouse.py b/community/keyboard_mouse.py index c1146707..fbed18bc 100644 --- a/community/keyboard_mouse.py +++ b/community/keyboard_mouse.py @@ -14,6 +14,9 @@ def __init__(self, game): self.game.on_key_press = self.on_key_press self.game.on_key_release = self.on_key_release + self.w_pressed = False + self.ctrl_pressed = False + def on_mouse_press(self, x, y, button, modifiers): if not self.game.mouse_captured: self.game.mouse_captured = True @@ -43,13 +46,21 @@ def on_key_press(self, key, modifiers): if key == pyglet.window.key.D: self.start_move(self.MoveMode.RIGHT) elif key == pyglet.window.key.A: self.start_move(self.MoveMode.LEFT) - elif key == pyglet.window.key.W: self.start_move(self.MoveMode.FORWARD) + elif key == pyglet.window.key.W: + self.w_pressed = True + self.start_move(self.MoveMode.FORWARD) + if self.ctrl_pressed: + self.start_modifier(self.ModifierMode.SPRINT) elif key == pyglet.window.key.S: self.start_move(self.MoveMode.BACKWARD) elif key == pyglet.window.key.SPACE : self.start_move(self.MoveMode.UP) elif key == pyglet.window.key.LSHIFT: self.start_move(self.MoveMode.DOWN) - elif key == pyglet.window.key.LCTRL : self.start_modifier(self.ModifierMode.SPRINT) + elif key == pyglet.window.key.LCTRL: + self.ctrl_pressed = True + if self.w_pressed: + self.start_modifier(self.ModifierMode.SPRINT) + elif key == pyglet.window.key.E: self.misc(self.MiscMode.SPAWN) elif key == pyglet.window.key.F: self.misc(self.MiscMode.FLY) elif key == pyglet.window.key.G: self.misc(self.MiscMode.RANDOM) elif key == pyglet.window.key.O: self.misc(self.MiscMode.SAVE) @@ -66,9 +77,15 @@ def on_key_release(self, key, modifiers): if key == pyglet.window.key.D: self.end_move(self.MoveMode.RIGHT) elif key == pyglet.window.key.A: self.end_move(self.MoveMode.LEFT) - elif key == pyglet.window.key.W: self.end_move(self.MoveMode.FORWARD) + elif key == pyglet.window.key.W: + self.w_pressed = False + self.end_move(self.MoveMode.FORWARD) + self.end_modifier(self.ModifierMode.SPRINT) elif key == pyglet.window.key.S: self.end_move(self.MoveMode.BACKWARD) elif key == pyglet.window.key.SPACE : self.end_move(self.MoveMode.UP) elif key == pyglet.window.key.LSHIFT: self.end_move(self.MoveMode.DOWN) - elif key == pyglet.window.key.LCTRL : self.end_modifier(self.ModifierMode.SPRINT) \ No newline at end of file + elif key == pyglet.window.key.LCTRL: + self.ctrl_pressed = False + if not self.w_pressed: + self.end_modifier(self.ModifierMode.SPRINT) diff --git a/community/main.py b/community/main.py index aaf34b2c..90109dc6 100644 --- a/community/main.py +++ b/community/main.py @@ -1,5 +1,6 @@ import platform import ctypes +import math import logging import random import time @@ -13,7 +14,6 @@ pyglet.options["audio"] = ("openal", "pulse", "directsound", "xaudio2", "silent") import pyglet.gl as gl -import shader import player import texture_manager @@ -42,7 +42,6 @@ def __init__(self, options): self.COLORED_LIGHTING = options.COLORED_LIGHTING self.ANTIALIASING = options.ANTIALIASING - class Window(pyglet.window.Window): def __init__(self, **args): super().__init__(**args) @@ -52,9 +51,9 @@ def __init__(self, **args): if self.options.INDIRECT_RENDERING and not gl.gl_info.have_version(4, 2): raise RuntimeError("""Indirect Rendering is not supported on your hardware - This feature is only supported on OpenGL 4.2+, but your driver doesnt seem to support it, + This feature is only supported on OpenGL 4.2+, but your driver doesnt seem to support it, Please disable "INDIRECT_RENDERING" in options.py""") - + # F3 Debug Screen self.show_f3 = False @@ -67,19 +66,10 @@ def __init__(self, **args): self.system_info = f"""Python: {platform.python_implementation()} {platform.python_version()} System: {platform.machine()} {platform.system()} {platform.release()} {platform.version()} CPU: {platform.processor()} -Display: {gl.gl_info.get_renderer()} +Display: {gl.gl_info.get_renderer()} {gl.gl_info.get_version()}""" logging.info(f"System Info: {self.system_info}") - # create shader - - logging.info("Compiling Shaders") - if not self.options.COLORED_LIGHTING: - self.shader = shader.Shader("shaders/alpha_lighting/vert.glsl", "shaders/alpha_lighting/frag.glsl") - else: - self.shader = shader.Shader("shaders/colored_lighting/vert.glsl", "shaders/colored_lighting/frag.glsl") - self.shader_sampler_location = self.shader.find_uniform(b"u_TextureArraySampler") - self.shader.use() # create textures logging.info("Creating Texture Array") @@ -87,12 +77,12 @@ def __init__(self, **args): # create world - self.world = world.World(self.shader, None, self.texture_manager, self.options) + self.world = world.World(None, self.texture_manager, self.options) # player stuff logging.info("Setting up player & camera") - self.player = player.Player(self.world, self.shader, self.width, self.height) + self.player = player.Player(self.world, self.width, self.height) self.world.player = self.player # pyglet stuff @@ -104,18 +94,11 @@ def __init__(self, **args): self.holding = 50 - # bind textures - - gl.glActiveTexture(gl.GL_TEXTURE0) - gl.glBindTexture(gl.GL_TEXTURE_2D_ARRAY, self.world.texture_manager.texture_array) - gl.glUniform1i(self.shader_sampler_location, 0) - # enable cool stuff gl.glEnable(gl.GL_DEPTH_TEST) - gl.glEnable(gl.GL_CULL_FACE) gl.glBlendFunc(gl.GL_SRC_ALPHA, gl.GL_ONE_MINUS_SRC_ALPHA) - + if self.options.ANTIALIASING: gl.glEnable(gl.GL_MULTISAMPLE) gl.glEnable(gl.GL_SAMPLE_ALPHA_TO_COVERAGE) @@ -151,7 +134,7 @@ def __init__(self, **args): # GPU command syncs self.fences = deque() - + def toggle_fullscreen(self): self.set_fullscreen(not self.fullscreen) @@ -176,6 +159,7 @@ def update_f3(self, delta_time): f""" {round(1 / delta_time)} FPS ({self.world.chunk_update_counter} Chunk Updates) {"inf" if not self.options.VSYNC else "vsync"}{"ao" if self.options.SMOOTH_LIGHTING else ""} C: {visible_chunk_count} / {chunk_count} pC: {self.world.pending_chunk_update_count} pU: {len(self.world.chunk_building_queue)} aB: {chunk_count} +E: {self.world.visible_entities} / {len(self.world.entities)} Client Singleplayer @{round(delta_time * 1000)} ms tick {round(1 / delta_time)} TPS XYZ: ( X: {round(self.player.position[0], 3)} / Y: {round(self.player.position[1], 3)} / Z: {round(self.player.position[2], 3)} ) @@ -187,13 +171,13 @@ def update_f3(self, delta_time): Renderer: {"OpenGL 3.3 VAOs" if not self.options.INDIRECT_RENDERING else "OpenGL 4.0 VAOs Indirect"} {"Conditional" if self.options.ADVANCED_OPENGL else ""} Buffers: {chunk_count} -Vertex Data: {round(quad_count * 28 * ctypes.sizeof(gl.GLfloat) / 1048576, 3)} MiB ({quad_count} Quads) -Visible Quads: {visible_quad_count} +Chunk Vertex Data: {round(quad_count * 28 * ctypes.sizeof(gl.GLfloat) / 1048576, 3)} MiB ({quad_count} Quads) +Chunk Visible Quads: {visible_quad_count} Buffer Uploading: Direct (glBufferSubData) """ def update(self, delta_time): - """Every tick""" + # Every tick if self.show_f3: self.update_f3(delta_time) @@ -214,9 +198,13 @@ def update(self, delta_time): self.world.tick(delta_time) + # update other entities + + for entity in self.world.entities: + entity.update(delta_time) + def on_draw(self): gl.glEnable(gl.GL_DEPTH_TEST) - self.shader.use() self.player.update_matrices() while len(self.fences) > self.options.MAX_CPU_AHEAD_FRAMES: @@ -261,8 +249,6 @@ def __init__(self): def run(self): pyglet.app.run(interval = 0) - - def init_logger(): log_folder = "logs/" log_filename = f"{time.time()}.log" @@ -274,12 +260,9 @@ def init_logger(): with open(log_path, 'x') as file: file.write("[LOGS]\n") - logging.basicConfig(level=logging.INFO, filename=log_path, + logging.basicConfig(level=logging.INFO, filename=log_path, format="[%(asctime)s] [%(processName)s/%(threadName)s/%(levelname)s] (%(module)s.py/%(funcName)s) %(message)s") - - - def main(): init_logger() game = Game() diff --git a/community/mob.py b/community/mob.py new file mode 100644 index 00000000..47253cfb --- /dev/null +++ b/community/mob.py @@ -0,0 +1,50 @@ +import random +import math + +import entity + +class Mob(entity.Entity): + def __init__(self, world, entity_type): + super().__init__(world, entity_type) + + self.heading = 0 + self.select_target() + + self.reset() + + def select_target(self): + self.target = [x + random.randint(-10, 10) for x in self.position] + + def update(self, delta_time): + if not random.randint(0, int(3 / delta_time)): # change target every 3 seconds on average + self.select_target() + + delta_x = self.position[0] - self.target[0] + delta_y = self.position[2] - self.target[2] + + self.heading = -math.atan2(delta_y, delta_x) + math.tau / 4 + self.heading += math.modf((self.rotation[0] - math.tau / 4) / math.tau)[1] * math.tau + + if delta_time * 5 > 1: + self.rotation[0] = self.heading + + else: + self.rotation[0] += (self.heading - self.rotation[0]) * delta_time * 5 + + target_dist = math.sqrt(delta_x ** 2 + delta_y ** 2) + + if target_dist > 1: + self.accel[0] = math.cos(self.rotation[0] + math.tau / 4) * 3 + self.accel[2] = -math.sin(self.rotation[0] + math.tau / 4) * 3 + + super().update(delta_time) + + if self.wall and self.grounded: + if random.randint(0, 3): + self.jump() + + else: + self.select_target() + + if self.position[1] < 0: + self.teleport((0, 80, 0)) diff --git a/community/models/__init__.py b/community/models/__init__.py index 10395346..472191d7 100644 --- a/community/models/__init__.py +++ b/community/models/__init__.py @@ -22,8 +22,13 @@ "button", "snow", "cactus", - "tinted_glass" + "tinted_glass", + "pig", + "zombie", + "skeleton", + "creeper", + "cow", + "curry", ] from . import * - diff --git a/community/models/button.py b/community/models/button.py index 3f7f6584..87f38e7d 100644 --- a/community/models/button.py +++ b/community/models/button.py @@ -1,7 +1,8 @@ -translucent = False -transparent = 2 +transparent = True +transparency = 2 is_cube = False glass = False +translucent = False colliders = [] @@ -30,4 +31,4 @@ [0.4, 0.4, 0.4, 0.4], [0.8, 0.8, 0.8, 0.8], [0.8, 0.8, 0.8, 0.8], -] \ No newline at end of file +] diff --git a/community/models/cactus.py b/community/models/cactus.py index 8f04ef2d..4e919573 100644 --- a/community/models/cactus.py +++ b/community/models/cactus.py @@ -1,7 +1,8 @@ -translucent = False -transparent = 1 +transparent = True +transparency = 2 is_cube = False glass = False +translucent = False colliders = [ [ @@ -35,4 +36,4 @@ [0.4, 0.4, 0.4, 0.4], [0.8, 0.8, 0.8, 0.8], [0.8, 0.8, 0.8, 0.8], -] \ No newline at end of file +] diff --git a/community/models/cow.py b/community/models/cow.py new file mode 100644 index 00000000..d88f904d --- /dev/null +++ b/community/models/cow.py @@ -0,0 +1,8 @@ + +transparent = True +is_cube = False +glass = False + +colliders = [] + +bones = [{'name':'body','pivot':[0.0, 1.1875, 0.125],'vertices':[[-0.3749999701976776, 0.7499999403953552, 0.625, -0.3749999701976776, 0.7499999403953552, -0.5, 0.3749999701976776, 0.7499999403953552, -0.5, 0.3749999701976776, 0.7499999403953552, 0.625], [0.3749999701976776, 1.375, 0.625, 0.3749999701976776, 1.3749998807907104, -0.5, -0.3749999701976776, 1.3749998807907104, -0.5, -0.3749999701976776, 1.375, 0.625], [-0.3749999701976776, 0.7499999403953552, -0.5, -0.3749999701976776, 1.3749998807907104, -0.5, 0.3749999701976776, 1.3749998807907104, -0.5, 0.3749999701976776, 0.7499999403953552, -0.5], [0.3749999701976776, 0.7499999403953552, 0.625, 0.3749999701976776, 1.375, 0.625, -0.3749999701976776, 1.375, 0.625, -0.3749999701976776, 0.7499999403953552, 0.625], [0.3749999701976776, 0.7499999403953552, 0.625, 0.3749999701976776, 0.7499999403953552, -0.5, 0.3749999701976776, 1.3749998807907104, -0.5, 0.3749999701976776, 1.375, 0.625], [-0.3749999701976776, 1.375, 0.625, -0.3749999701976776, 1.3749998807907104, -0.5, -0.3749999701976776, 0.7499999403953552, -0.5, -0.3749999701976776, 0.7499999403953552, 0.625], [-0.1249999925494194, 0.6874999403953552, 0.625, -0.1249999925494194, 0.6874999403953552, 0.25, 0.1249999925494194, 0.6874999403953552, 0.25, 0.1249999925494194, 0.6874999403953552, 0.625], [0.1249999925494194, 0.7499999403953552, 0.625, 0.1249999925494194, 0.7499999403953552, 0.25, -0.1249999925494194, 0.7499999403953552, 0.25, -0.1249999925494194, 0.7499999403953552, 0.625], [-0.1249999925494194, 0.6874999403953552, 0.25, -0.1249999925494194, 0.7499999403953552, 0.25, 0.1249999925494194, 0.7499999403953552, 0.25, 0.1249999925494194, 0.6874999403953552, 0.25], [0.1249999925494194, 0.6874999403953552, 0.625, 0.1249999925494194, 0.7499999403953552, 0.625, -0.1249999925494194, 0.7499999403953552, 0.625, -0.1249999925494194, 0.6874999403953552, 0.625], [0.1249999925494194, 0.6874999403953552, 0.625, 0.1249999925494194, 0.6874999403953552, 0.25, 0.1249999925494194, 0.7499999403953552, 0.25, 0.1249999925494194, 0.7499999403953552, 0.625], [-0.1249999925494194, 0.7499999403953552, 0.625, -0.1249999925494194, 0.7499999403953552, 0.25, -0.1249999925494194, 0.6874999403953552, 0.25, -0.1249999925494194, 0.6874999403953552, 0.625]],'tex_coords':[[0.06493506493506493, 0.0, 0.06493506493506493, 0.6428571428571428, 0.14285714285714285, 0.6428571428571428, 0.14285714285714285, 0.0], [0.2077922077922078, 0.0, 0.2077922077922078, 0.6428571428571428, 0.2857142857142857, 0.6428571428571428, 0.2857142857142857, 0.0], [0.06493506493506493, 0.6428571428571428, 0.06493506493506493, 1.0, 0.14285714285714285, 1.0, 0.14285714285714285, 0.6428571428571428], [0.14285714285714285, 0.6428571428571428, 0.14285714285714285, 1.0, 0.22077922077922077, 1.0, 0.22077922077922077, 0.6428571428571428], [0.14285714285714285, 0.0, 0.14285714285714285, 0.6428571428571428, 0.2077922077922078, 0.6428571428571428, 0.2077922077922078, 0.0], [0.0, 0.0, 0.0, 0.6428571428571428, 0.06493506493506493, 0.6428571428571428, 0.06493506493506493, 0.0], [0.2922077922077922, 0.75, 0.2922077922077922, 0.9642857142857143, 0.3181818181818182, 0.9642857142857143, 0.3181818181818182, 0.75], [0.3246753246753247, 0.75, 0.3246753246753247, 0.9642857142857143, 0.35064935064935066, 0.9642857142857143, 0.35064935064935066, 0.75], [0.2922077922077922, 0.9642857142857143, 0.2922077922077922, 1.0, 0.3181818181818182, 1.0, 0.3181818181818182, 0.9642857142857143], [0.3181818181818182, 0.9642857142857143, 0.3181818181818182, 1.0, 0.34415584415584416, 1.0, 0.34415584415584416, 0.9642857142857143], [0.3181818181818182, 0.75, 0.3181818181818182, 0.9642857142857143, 0.3246753246753247, 0.9642857142857143, 0.3246753246753247, 0.75], [0.2857142857142857, 0.75, 0.2857142857142857, 0.9642857142857143, 0.2922077922077922, 0.9642857142857143, 0.2922077922077922, 0.75]],'shading_values':[[1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0]]}, {'name':'head','pivot':[0.0, 1.25, -0.5],'vertices':[[-0.25, 1.0, -0.875, -0.25, 1.5, -0.875, 0.25, 1.5, -0.875, 0.25, 1.0, -0.875], [0.25, 1.0, -0.5, 0.25, 1.5, -0.5, -0.25, 1.5, -0.5, -0.25, 1.0, -0.5], [-0.25, 1.5, -0.875, -0.25, 1.5, -0.5, 0.25, 1.5, -0.5, 0.25, 1.5, -0.875], [0.25, 1.0, -0.875, 0.25, 1.0, -0.5, -0.25, 1.0, -0.5, -0.25, 1.0, -0.875], [0.25, 1.0, -0.875, 0.25, 1.5, -0.875, 0.25, 1.5, -0.5, 0.25, 1.0, -0.5], [-0.25, 1.0, -0.5, -0.25, 1.5, -0.5, -0.25, 1.5, -0.875, -0.25, 1.0, -0.875], [-0.3125, 1.375, -0.75, -0.3125, 1.5625, -0.75, -0.25, 1.5625, -0.75, -0.25, 1.375, -0.75], [-0.25, 1.375, -0.6875, -0.25, 1.5625, -0.6875, -0.3125, 1.5625, -0.6875, -0.3125, 1.375, -0.6875], [-0.3125, 1.5625, -0.75, -0.3125, 1.5625, -0.6875, -0.25, 1.5625, -0.6875, -0.25, 1.5625, -0.75], [-0.25, 1.375, -0.75, -0.25, 1.375, -0.6875, -0.3125, 1.375, -0.6875, -0.3125, 1.375, -0.75], [-0.25, 1.375, -0.75, -0.25, 1.5625, -0.75, -0.25, 1.5625, -0.6875, -0.25, 1.375, -0.6875], [-0.3125, 1.375, -0.6875, -0.3125, 1.5625, -0.6875, -0.3125, 1.5625, -0.75, -0.3125, 1.375, -0.75], [0.25, 1.375, -0.75, 0.25, 1.5625, -0.75, 0.3125, 1.5625, -0.75, 0.3125, 1.375, -0.75], [0.3125, 1.375, -0.6875, 0.3125, 1.5625, -0.6875, 0.25, 1.5625, -0.6875, 0.25, 1.375, -0.6875], [0.25, 1.5625, -0.75, 0.25, 1.5625, -0.6875, 0.3125, 1.5625, -0.6875, 0.3125, 1.5625, -0.75], [0.3125, 1.375, -0.75, 0.3125, 1.375, -0.6875, 0.25, 1.375, -0.6875, 0.25, 1.375, -0.75], [0.3125, 1.375, -0.75, 0.3125, 1.5625, -0.75, 0.3125, 1.5625, -0.6875, 0.3125, 1.375, -0.6875], [0.25, 1.375, -0.6875, 0.25, 1.5625, -0.6875, 0.25, 1.5625, -0.75, 0.25, 1.375, -0.75]],'tex_coords':[[0.38961038961038963, 0.5, 0.38961038961038963, 0.7857142857142857, 0.44155844155844154, 0.7857142857142857, 0.44155844155844154, 0.5], [0.4805194805194805, 0.5, 0.4805194805194805, 0.7857142857142857, 0.5324675324675324, 0.7857142857142857, 0.5324675324675324, 0.5], [0.38961038961038963, 0.7857142857142857, 0.38961038961038963, 1.0, 0.44155844155844154, 1.0, 0.44155844155844154, 0.7857142857142857], [0.44155844155844154, 0.7857142857142857, 0.44155844155844154, 1.0, 0.4935064935064935, 1.0, 0.4935064935064935, 0.7857142857142857], [0.44155844155844154, 0.5, 0.44155844155844154, 0.7857142857142857, 0.4805194805194805, 0.7857142857142857, 0.4805194805194805, 0.5], [0.35064935064935066, 0.5, 0.35064935064935066, 0.7857142857142857, 0.38961038961038963, 0.7857142857142857, 0.38961038961038963, 0.5], [0.538961038961039, 0.8571428571428572, 0.538961038961039, 0.9642857142857143, 0.5454545454545454, 0.9642857142857143, 0.5454545454545454, 0.8571428571428572], [0.551948051948052, 0.8571428571428572, 0.551948051948052, 0.9642857142857143, 0.5584415584415584, 0.9642857142857143, 0.5584415584415584, 0.8571428571428572], [0.538961038961039, 0.9642857142857143, 0.538961038961039, 1.0, 0.5454545454545454, 1.0, 0.5454545454545454, 0.9642857142857143], [0.5454545454545454, 0.9642857142857143, 0.5454545454545454, 1.0, 0.551948051948052, 1.0, 0.551948051948052, 0.9642857142857143], [0.5454545454545454, 0.8571428571428572, 0.5454545454545454, 0.9642857142857143, 0.551948051948052, 0.9642857142857143, 0.551948051948052, 0.8571428571428572], [0.5324675324675324, 0.8571428571428572, 0.5324675324675324, 0.9642857142857143, 0.538961038961039, 0.9642857142857143, 0.538961038961039, 0.8571428571428572], [0.564935064935065, 0.8571428571428572, 0.564935064935065, 0.9642857142857143, 0.5714285714285714, 0.9642857142857143, 0.5714285714285714, 0.8571428571428572], [0.577922077922078, 0.8571428571428572, 0.577922077922078, 0.9642857142857143, 0.5844155844155844, 0.9642857142857143, 0.5844155844155844, 0.8571428571428572], [0.564935064935065, 0.9642857142857143, 0.564935064935065, 1.0, 0.5714285714285714, 1.0, 0.5714285714285714, 0.9642857142857143], [0.5714285714285714, 0.9642857142857143, 0.5714285714285714, 1.0, 0.577922077922078, 1.0, 0.577922077922078, 0.9642857142857143], [0.5714285714285714, 0.8571428571428572, 0.5714285714285714, 0.9642857142857143, 0.577922077922078, 0.9642857142857143, 0.577922077922078, 0.8571428571428572], [0.5584415584415584, 0.8571428571428572, 0.5584415584415584, 0.9642857142857143, 0.564935064935065, 0.9642857142857143, 0.564935064935065, 0.8571428571428572]],'shading_values':[[1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0]]}, {'name':'leg0','pivot':[-0.25, 0.75, 0.4375],'vertices':[[-0.3125, 0.0, 0.3125, -0.3125, 0.75, 0.3125, -0.0625, 0.75, 0.3125, -0.0625, 0.0, 0.3125], [-0.0625, 0.0, 0.5625, -0.0625, 0.75, 0.5625, -0.3125, 0.75, 0.5625, -0.3125, 0.0, 0.5625], [-0.3125, 0.75, 0.3125, -0.3125, 0.75, 0.5625, -0.0625, 0.75, 0.5625, -0.0625, 0.75, 0.3125], [-0.0625, 0.0, 0.3125, -0.0625, 0.0, 0.5625, -0.3125, 0.0, 0.5625, -0.3125, 0.0, 0.3125], [-0.0625, 0.0, 0.3125, -0.0625, 0.75, 0.3125, -0.0625, 0.75, 0.5625, -0.0625, 0.0, 0.5625], [-0.3125, 0.0, 0.5625, -0.3125, 0.75, 0.5625, -0.3125, 0.75, 0.3125, -0.3125, 0.0, 0.3125]],'tex_coords':[[0.6103896103896104, 0.4285714285714286, 0.6103896103896104, 0.8571428571428572, 0.6363636363636364, 0.8571428571428572, 0.6363636363636364, 0.4285714285714286], [0.6623376623376623, 0.4285714285714286, 0.6623376623376623, 0.8571428571428572, 0.6883116883116883, 0.8571428571428572, 0.6883116883116883, 0.4285714285714286], [0.6103896103896104, 0.8571428571428572, 0.6103896103896104, 1.0, 0.6363636363636364, 1.0, 0.6363636363636364, 0.8571428571428572], [0.6363636363636364, 0.8571428571428572, 0.6363636363636364, 1.0, 0.6623376623376623, 1.0, 0.6623376623376623, 0.8571428571428572], [0.6363636363636364, 0.4285714285714286, 0.6363636363636364, 0.8571428571428572, 0.6623376623376623, 0.8571428571428572, 0.6623376623376623, 0.4285714285714286], [0.5844155844155844, 0.4285714285714286, 0.5844155844155844, 0.8571428571428572, 0.6103896103896104, 0.8571428571428572, 0.6103896103896104, 0.4285714285714286]],'shading_values':[[1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0]]}, {'name':'leg1','pivot':[0.25, 0.75, 0.4375],'vertices':[[0.0625, 0.0, 0.3125, 0.0625, 0.75, 0.3125, 0.3125, 0.75, 0.3125, 0.3125, 0.0, 0.3125], [0.3125, 0.0, 0.5625, 0.3125, 0.75, 0.5625, 0.0625, 0.75, 0.5625, 0.0625, 0.0, 0.5625], [0.0625, 0.75, 0.3125, 0.0625, 0.75, 0.5625, 0.3125, 0.75, 0.5625, 0.3125, 0.75, 0.3125], [0.3125, 0.0, 0.3125, 0.3125, 0.0, 0.5625, 0.0625, 0.0, 0.5625, 0.0625, 0.0, 0.3125], [0.3125, 0.0, 0.3125, 0.3125, 0.75, 0.3125, 0.3125, 0.75, 0.5625, 0.3125, 0.0, 0.5625], [0.0625, 0.0, 0.5625, 0.0625, 0.75, 0.5625, 0.0625, 0.75, 0.3125, 0.0625, 0.0, 0.3125]],'tex_coords':[[0.7142857142857143, 0.4285714285714286, 0.7142857142857143, 0.8571428571428572, 0.7402597402597403, 0.8571428571428572, 0.7402597402597403, 0.4285714285714286], [0.7662337662337663, 0.4285714285714286, 0.7662337662337663, 0.8571428571428572, 0.7922077922077922, 0.8571428571428572, 0.7922077922077922, 0.4285714285714286], [0.7142857142857143, 0.8571428571428572, 0.7142857142857143, 1.0, 0.7402597402597403, 1.0, 0.7402597402597403, 0.8571428571428572], [0.7402597402597403, 0.8571428571428572, 0.7402597402597403, 1.0, 0.7662337662337663, 1.0, 0.7662337662337663, 0.8571428571428572], [0.7402597402597403, 0.4285714285714286, 0.7402597402597403, 0.8571428571428572, 0.7662337662337663, 0.8571428571428572, 0.7662337662337663, 0.4285714285714286], [0.6883116883116883, 0.4285714285714286, 0.6883116883116883, 0.8571428571428572, 0.7142857142857143, 0.8571428571428572, 0.7142857142857143, 0.4285714285714286]],'shading_values':[[1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0]]}, {'name':'leg2','pivot':[-0.25, 0.75, -0.375],'vertices':[[-0.3125, 0.0, -0.4375, -0.3125, 0.75, -0.4375, -0.0625, 0.75, -0.4375, -0.0625, 0.0, -0.4375], [-0.0625, 0.0, -0.1875, -0.0625, 0.75, -0.1875, -0.3125, 0.75, -0.1875, -0.3125, 0.0, -0.1875], [-0.3125, 0.75, -0.4375, -0.3125, 0.75, -0.1875, -0.0625, 0.75, -0.1875, -0.0625, 0.75, -0.4375], [-0.0625, 0.0, -0.4375, -0.0625, 0.0, -0.1875, -0.3125, 0.0, -0.1875, -0.3125, 0.0, -0.4375], [-0.0625, 0.0, -0.4375, -0.0625, 0.75, -0.4375, -0.0625, 0.75, -0.1875, -0.0625, 0.0, -0.1875], [-0.3125, 0.0, -0.1875, -0.3125, 0.75, -0.1875, -0.3125, 0.75, -0.4375, -0.3125, 0.0, -0.4375]],'tex_coords':[[0.8181818181818182, 0.4285714285714286, 0.8181818181818182, 0.8571428571428572, 0.8441558441558441, 0.8571428571428572, 0.8441558441558441, 0.4285714285714286], [0.8701298701298701, 0.4285714285714286, 0.8701298701298701, 0.8571428571428572, 0.8961038961038961, 0.8571428571428572, 0.8961038961038961, 0.4285714285714286], [0.8181818181818182, 0.8571428571428572, 0.8181818181818182, 1.0, 0.8441558441558441, 1.0, 0.8441558441558441, 0.8571428571428572], [0.8441558441558441, 0.8571428571428572, 0.8441558441558441, 1.0, 0.8701298701298701, 1.0, 0.8701298701298701, 0.8571428571428572], [0.8441558441558441, 0.4285714285714286, 0.8441558441558441, 0.8571428571428572, 0.8701298701298701, 0.8571428571428572, 0.8701298701298701, 0.4285714285714286], [0.7922077922077922, 0.4285714285714286, 0.7922077922077922, 0.8571428571428572, 0.8181818181818182, 0.8571428571428572, 0.8181818181818182, 0.4285714285714286]],'shading_values':[[1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0]]}, {'name':'leg3','pivot':[0.25, 0.75, -0.375],'vertices':[[0.0625, 0.0, -0.4375, 0.0625, 0.75, -0.4375, 0.3125, 0.75, -0.4375, 0.3125, 0.0, -0.4375], [0.3125, 0.0, -0.1875, 0.3125, 0.75, -0.1875, 0.0625, 0.75, -0.1875, 0.0625, 0.0, -0.1875], [0.0625, 0.75, -0.4375, 0.0625, 0.75, -0.1875, 0.3125, 0.75, -0.1875, 0.3125, 0.75, -0.4375], [0.3125, 0.0, -0.4375, 0.3125, 0.0, -0.1875, 0.0625, 0.0, -0.1875, 0.0625, 0.0, -0.4375], [0.3125, 0.0, -0.4375, 0.3125, 0.75, -0.4375, 0.3125, 0.75, -0.1875, 0.3125, 0.0, -0.1875], [0.0625, 0.0, -0.1875, 0.0625, 0.75, -0.1875, 0.0625, 0.75, -0.4375, 0.0625, 0.0, -0.4375]],'tex_coords':[[0.922077922077922, 0.4285714285714286, 0.922077922077922, 0.8571428571428572, 0.948051948051948, 0.8571428571428572, 0.948051948051948, 0.4285714285714286], [0.974025974025974, 0.4285714285714286, 0.974025974025974, 0.8571428571428572, 1.0, 0.8571428571428572, 1.0, 0.4285714285714286], [0.922077922077922, 0.8571428571428572, 0.922077922077922, 1.0, 0.948051948051948, 1.0, 0.948051948051948, 0.8571428571428572], [0.948051948051948, 0.8571428571428572, 0.948051948051948, 1.0, 0.974025974025974, 1.0, 0.974025974025974, 0.8571428571428572], [0.948051948051948, 0.4285714285714286, 0.948051948051948, 0.8571428571428572, 0.974025974025974, 0.8571428571428572, 0.974025974025974, 0.4285714285714286], [0.8961038961038961, 0.4285714285714286, 0.8961038961038961, 0.8571428571428572, 0.922077922077922, 0.8571428571428572, 0.922077922077922, 0.4285714285714286]],'shading_values':[[1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0]]}] diff --git a/community/models/creeper.py b/community/models/creeper.py new file mode 100644 index 00000000..f6860aa7 --- /dev/null +++ b/community/models/creeper.py @@ -0,0 +1,8 @@ + +transparent = True +is_cube = False +glass = False + +colliders = [] + +bones = [{'name':'body','pivot':[0.0, 0.0, 0.0],'vertices':[[-0.25, 0.375, -0.125, -0.25, 1.125, -0.125, 0.25, 1.125, -0.125, 0.25, 0.375, -0.125], [0.25, 0.375, 0.125, 0.25, 1.125, 0.125, -0.25, 1.125, 0.125, -0.25, 0.375, 0.125], [-0.25, 1.125, -0.125, -0.25, 1.125, 0.125, 0.25, 1.125, 0.125, 0.25, 1.125, -0.125], [0.25, 0.375, -0.125, 0.25, 0.375, 0.125, -0.25, 0.375, 0.125, -0.25, 0.375, -0.125], [0.25, 0.375, -0.125, 0.25, 1.125, -0.125, 0.25, 1.125, 0.125, 0.25, 0.375, 0.125], [-0.25, 0.375, 0.125, -0.25, 1.125, 0.125, -0.25, 1.125, -0.125, -0.25, 0.375, -0.125]],'tex_coords':[[0.03333333333333333, 0.0, 0.03333333333333333, 0.75, 0.1, 0.75, 0.1, 0.0], [0.13333333333333333, 0.0, 0.13333333333333333, 0.75, 0.2, 0.75, 0.2, 0.0], [0.03333333333333333, 0.75, 0.03333333333333333, 1.0, 0.1, 1.0, 0.1, 0.75], [0.1, 0.75, 0.1, 1.0, 0.16666666666666666, 1.0, 0.16666666666666666, 0.75], [0.1, 0.0, 0.1, 0.75, 0.13333333333333333, 0.75, 0.13333333333333333, 0.0], [0.0, 0.0, 0.0, 0.75, 0.03333333333333333, 0.75, 0.03333333333333333, 0.0]],'shading_values':[[1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0]]}, {'name':'head','pivot':[0.0, 1.125, 0.0],'vertices':[[-0.25, 1.125, -0.25, -0.25, 1.625, -0.25, 0.25, 1.625, -0.25, 0.25, 1.125, -0.25], [0.25, 1.125, 0.25, 0.25, 1.625, 0.25, -0.25, 1.625, 0.25, -0.25, 1.125, 0.25], [-0.25, 1.625, -0.25, -0.25, 1.625, 0.25, 0.25, 1.625, 0.25, 0.25, 1.625, -0.25], [0.25, 1.125, -0.25, 0.25, 1.125, 0.25, -0.25, 1.125, 0.25, -0.25, 1.125, -0.25], [0.25, 1.125, -0.25, 0.25, 1.625, -0.25, 0.25, 1.625, 0.25, 0.25, 1.125, 0.25], [-0.25, 1.125, 0.25, -0.25, 1.625, 0.25, -0.25, 1.625, -0.25, -0.25, 1.125, -0.25]],'tex_coords':[[0.26666666666666666, 0.0, 0.26666666666666666, 0.5, 0.3333333333333333, 0.5, 0.3333333333333333, 0.0], [0.4, 0.0, 0.4, 0.5, 0.4666666666666667, 0.5, 0.4666666666666667, 0.0], [0.26666666666666666, 0.5, 0.26666666666666666, 1.0, 0.3333333333333333, 1.0, 0.3333333333333333, 0.5], [0.3333333333333333, 0.5, 0.3333333333333333, 1.0, 0.4, 1.0, 0.4, 0.5], [0.3333333333333333, 0.0, 0.3333333333333333, 0.5, 0.4, 0.5, 0.4, 0.0], [0.2, 0.0, 0.2, 0.5, 0.26666666666666666, 0.5, 0.26666666666666666, 0.0]],'shading_values':[[1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0]]}, {'name':'leg0','pivot':[-0.125, 0.375, 0.25],'vertices':[[-0.25, 0.0, 0.125, -0.25, 0.375, 0.125, 0.0, 0.375, 0.125, 0.0, 0.0, 0.125], [0.0, 0.0, 0.375, 0.0, 0.375, 0.375, -0.25, 0.375, 0.375, -0.25, 0.0, 0.375], [-0.25, 0.375, 0.125, -0.25, 0.375, 0.375, 0.0, 0.375, 0.375, 0.0, 0.375, 0.125], [0.0, 0.0, 0.125, 0.0, 0.0, 0.375, -0.25, 0.0, 0.375, -0.25, 0.0, 0.125], [0.0, 0.0, 0.125, 0.0, 0.375, 0.125, 0.0, 0.375, 0.375, 0.0, 0.0, 0.375], [-0.25, 0.0, 0.375, -0.25, 0.375, 0.375, -0.25, 0.375, 0.125, -0.25, 0.0, 0.125]],'tex_coords':[[0.5, 0.375, 0.5, 0.75, 0.5333333333333333, 0.75, 0.5333333333333333, 0.375], [0.5666666666666667, 0.375, 0.5666666666666667, 0.75, 0.6, 0.75, 0.6, 0.375], [0.5, 0.75, 0.5, 1.0, 0.5333333333333333, 1.0, 0.5333333333333333, 0.75], [0.5333333333333333, 0.75, 0.5333333333333333, 1.0, 0.5666666666666667, 1.0, 0.5666666666666667, 0.75], [0.5333333333333333, 0.375, 0.5333333333333333, 0.75, 0.5666666666666667, 0.75, 0.5666666666666667, 0.375], [0.4666666666666667, 0.375, 0.4666666666666667, 0.75, 0.5, 0.75, 0.5, 0.375]],'shading_values':[[1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0]]}, {'name':'leg1','pivot':[0.125, 0.375, 0.25],'vertices':[[0.0, 0.0, 0.125, 0.0, 0.375, 0.125, 0.25, 0.375, 0.125, 0.25, 0.0, 0.125], [0.25, 0.0, 0.375, 0.25, 0.375, 0.375, 0.0, 0.375, 0.375, 0.0, 0.0, 0.375], [0.0, 0.375, 0.125, 0.0, 0.375, 0.375, 0.25, 0.375, 0.375, 0.25, 0.375, 0.125], [0.25, 0.0, 0.125, 0.25, 0.0, 0.375, 0.0, 0.0, 0.375, 0.0, 0.0, 0.125], [0.25, 0.0, 0.125, 0.25, 0.375, 0.125, 0.25, 0.375, 0.375, 0.25, 0.0, 0.375], [0.0, 0.0, 0.375, 0.0, 0.375, 0.375, 0.0, 0.375, 0.125, 0.0, 0.0, 0.125]],'tex_coords':[[0.6333333333333333, 0.375, 0.6333333333333333, 0.75, 0.6666666666666666, 0.75, 0.6666666666666666, 0.375], [0.7, 0.375, 0.7, 0.75, 0.7333333333333333, 0.75, 0.7333333333333333, 0.375], [0.6333333333333333, 0.75, 0.6333333333333333, 1.0, 0.6666666666666666, 1.0, 0.6666666666666666, 0.75], [0.6666666666666666, 0.75, 0.6666666666666666, 1.0, 0.7, 1.0, 0.7, 0.75], [0.6666666666666666, 0.375, 0.6666666666666666, 0.75, 0.7, 0.75, 0.7, 0.375], [0.6, 0.375, 0.6, 0.75, 0.6333333333333333, 0.75, 0.6333333333333333, 0.375]],'shading_values':[[1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0]]}, {'name':'leg2','pivot':[-0.125, 0.375, -0.25],'vertices':[[-0.25, 0.0, -0.375, -0.25, 0.375, -0.375, 0.0, 0.375, -0.375, 0.0, 0.0, -0.375], [0.0, 0.0, -0.125, 0.0, 0.375, -0.125, -0.25, 0.375, -0.125, -0.25, 0.0, -0.125], [-0.25, 0.375, -0.375, -0.25, 0.375, -0.125, 0.0, 0.375, -0.125, 0.0, 0.375, -0.375], [0.0, 0.0, -0.375, 0.0, 0.0, -0.125, -0.25, 0.0, -0.125, -0.25, 0.0, -0.375], [0.0, 0.0, -0.375, 0.0, 0.375, -0.375, 0.0, 0.375, -0.125, 0.0, 0.0, -0.125], [-0.25, 0.0, -0.125, -0.25, 0.375, -0.125, -0.25, 0.375, -0.375, -0.25, 0.0, -0.375]],'tex_coords':[[0.7666666666666667, 0.375, 0.7666666666666667, 0.75, 0.8, 0.75, 0.8, 0.375], [0.8333333333333334, 0.375, 0.8333333333333334, 0.75, 0.8666666666666667, 0.75, 0.8666666666666667, 0.375], [0.7666666666666667, 0.75, 0.7666666666666667, 1.0, 0.8, 1.0, 0.8, 0.75], [0.8, 0.75, 0.8, 1.0, 0.8333333333333334, 1.0, 0.8333333333333334, 0.75], [0.8, 0.375, 0.8, 0.75, 0.8333333333333334, 0.75, 0.8333333333333334, 0.375], [0.7333333333333333, 0.375, 0.7333333333333333, 0.75, 0.7666666666666667, 0.75, 0.7666666666666667, 0.375]],'shading_values':[[1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0]]}, {'name':'leg3','pivot':[0.125, 0.375, -0.25],'vertices':[[0.0, 0.0, -0.375, 0.0, 0.375, -0.375, 0.25, 0.375, -0.375, 0.25, 0.0, -0.375], [0.25, 0.0, -0.125, 0.25, 0.375, -0.125, 0.0, 0.375, -0.125, 0.0, 0.0, -0.125], [0.0, 0.375, -0.375, 0.0, 0.375, -0.125, 0.25, 0.375, -0.125, 0.25, 0.375, -0.375], [0.25, 0.0, -0.375, 0.25, 0.0, -0.125, 0.0, 0.0, -0.125, 0.0, 0.0, -0.375], [0.25, 0.0, -0.375, 0.25, 0.375, -0.375, 0.25, 0.375, -0.125, 0.25, 0.0, -0.125], [0.0, 0.0, -0.125, 0.0, 0.375, -0.125, 0.0, 0.375, -0.375, 0.0, 0.0, -0.375]],'tex_coords':[[0.9, 0.375, 0.9, 0.75, 0.9333333333333333, 0.75, 0.9333333333333333, 0.375], [0.9666666666666667, 0.375, 0.9666666666666667, 0.75, 1.0, 0.75, 1.0, 0.375], [0.9, 0.75, 0.9, 1.0, 0.9333333333333333, 1.0, 0.9333333333333333, 0.75], [0.9333333333333333, 0.75, 0.9333333333333333, 1.0, 0.9666666666666667, 1.0, 0.9666666666666667, 0.75], [0.9333333333333333, 0.375, 0.9333333333333333, 0.75, 0.9666666666666667, 0.75, 0.9666666666666667, 0.375], [0.8666666666666667, 0.375, 0.8666666666666667, 0.75, 0.9, 0.75, 0.9, 0.375]],'shading_values':[[1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0]]}] diff --git a/community/models/crop.py b/community/models/crop.py index d0326697..c8d29610 100644 --- a/community/models/crop.py +++ b/community/models/crop.py @@ -1,4 +1,5 @@ -transparent = 2 +transparent = True +transparency = 2 is_cube = False glass = False translucent = False @@ -36,4 +37,4 @@ [0.8, 0.8, 0.8, 0.8], [0.8, 0.8, 0.8, 0.8], [0.8, 0.8, 0.8, 0.8], -] \ No newline at end of file +] diff --git a/community/models/cube.py b/community/models/cube.py index 2de79983..50c204f7 100644 --- a/community/models/cube.py +++ b/community/models/cube.py @@ -1,7 +1,8 @@ -transparent = 0 +transparent = False +transparency = 0 +translucent = False is_cube = True glass = False -translucent = False colliders = [ [ @@ -19,7 +20,6 @@ [ 0.5, 0.5, -0.5, 0.5, -0.5, -0.5, -0.5, -0.5, -0.5, -0.5, 0.5, -0.5], # back ] -# Deprecating tex_coords = [ [0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 1.0, 0.0], [0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 1.0, 0.0], @@ -36,4 +36,4 @@ [0.4, 0.4, 0.4, 0.4], [0.8, 0.8, 0.8, 0.8], [0.8, 0.8, 0.8, 0.8], -] \ No newline at end of file +] diff --git a/community/models/curry.py b/community/models/curry.py new file mode 100644 index 00000000..dabce985 --- /dev/null +++ b/community/models/curry.py @@ -0,0 +1,8 @@ + +transparent = True +is_cube = False +glass = False + +colliders = [] + +bones = [{'name':'body','pivot':[0.0, 1.5, 0.0],'vertices':[[-0.25, 0.75, -0.125, -0.25, 1.5, -0.125, 0.25, 1.5, -0.125, 0.25, 0.75, -0.125], [0.25, 0.75, 0.125, 0.25, 1.5, 0.125, -0.25, 1.5, 0.125, -0.25, 0.75, 0.125], [-0.25, 1.5, -0.125, -0.25, 1.5, 0.125, 0.25, 1.5, 0.125, 0.25, 1.5, -0.125], [0.25, 0.75, -0.125, 0.25, 0.75, 0.125, -0.25, 0.75, 0.125, -0.25, 0.75, -0.125], [0.25, 0.75, -0.125, 0.25, 1.5, -0.125, 0.25, 1.5, 0.125, 0.25, 0.75, 0.125], [-0.25, 0.75, 0.125, -0.25, 1.5, 0.125, -0.25, 1.5, -0.125, -0.25, 0.75, -0.125]],'tex_coords':[[0.018867924528301886, 0.0, 0.018867924528301886, 0.75, 0.05660377358490566, 0.75, 0.05660377358490566, 0.0], [0.07547169811320754, 0.0, 0.07547169811320754, 0.75, 0.11320754716981132, 0.75, 0.11320754716981132, 0.0], [0.018867924528301886, 0.75, 0.018867924528301886, 1.0, 0.05660377358490566, 1.0, 0.05660377358490566, 0.75], [0.05660377358490566, 0.75, 0.05660377358490566, 1.0, 0.09433962264150944, 1.0, 0.09433962264150944, 0.75], [0.05660377358490566, 0.0, 0.05660377358490566, 0.75, 0.07547169811320754, 0.75, 0.07547169811320754, 0.0], [0.0, 0.0, 0.0, 0.75, 0.018867924528301886, 0.75, 0.018867924528301886, 0.0]],'shading_values':[[1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0]]}, {'name':'head','pivot':[0.0, 1.5, 0.0],'vertices':[[-0.2536456286907196, 1.497308611869812, -0.23161627352237701, -0.2536456286907196, 1.997308611869812, -0.23161627352237701, 0.2463543713092804, 1.997308611869812, -0.23161627352237701, 0.2463543713092804, 1.497308611869812, -0.23161627352237701], [0.2463543713092804, 1.497308611869812, 0.2683837413787842, 0.2463543713092804, 1.997308611869812, 0.2683837413787842, -0.2536456286907196, 1.997308611869812, 0.2683837413787842, -0.2536456286907196, 1.497308611869812, 0.2683837413787842], [-0.2536456286907196, 1.997308611869812, -0.23161627352237701, -0.2536456286907196, 1.997308611869812, 0.2683837413787842, 0.2463543713092804, 1.997308611869812, 0.2683837413787842, 0.2463543713092804, 1.997308611869812, -0.23161627352237701], [0.2463543713092804, 1.497308611869812, -0.23161627352237701, 0.2463543713092804, 1.497308611869812, 0.2683837413787842, -0.2536456286907196, 1.497308611869812, 0.2683837413787842, -0.2536456286907196, 1.497308611869812, -0.23161627352237701], [0.2463543713092804, 1.497308611869812, -0.23161627352237701, 0.2463543713092804, 1.997308611869812, -0.23161627352237701, 0.2463543713092804, 1.997308611869812, 0.2683837413787842, 0.2463543713092804, 1.497308611869812, 0.2683837413787842], [-0.2536456286907196, 1.497308611869812, 0.2683837413787842, -0.2536456286907196, 1.997308611869812, 0.2683837413787842, -0.2536456286907196, 1.997308611869812, -0.23161627352237701, -0.2536456286907196, 1.497308611869812, -0.23161627352237701], [0.2316092699766159, 0.8962944149971008, -0.21831698715686798, 0.2316092699766159, 1.396294355392456, -0.21831698715686798, 0.7316092848777771, 1.396294355392456, -0.21831698715686798, 0.7316092848777771, 0.8962944149971008, -0.21831698715686798], [0.7316092848777771, 0.8962944149971008, 0.2816829979419708, 0.7316092848777771, 1.396294355392456, 0.2816829979419708, 0.2316092699766159, 1.396294355392456, 0.2816829979419708, 0.2316092699766159, 0.8962944149971008, 0.2816829979419708], [0.2316092699766159, 1.396294355392456, -0.21831698715686798, 0.2316092699766159, 1.396294355392456, 0.2816829979419708, 0.7316092848777771, 1.396294355392456, 0.2816829979419708, 0.7316092848777771, 1.396294355392456, -0.21831698715686798], [0.7316092848777771, 0.8962944149971008, -0.21831698715686798, 0.7316092848777771, 0.8962944149971008, 0.2816829979419708, 0.2316092699766159, 0.8962944149971008, 0.2816829979419708, 0.2316092699766159, 0.8962944149971008, -0.21831698715686798], [0.7316092848777771, 0.8962944149971008, -0.21831698715686798, 0.7316092848777771, 1.396294355392456, -0.21831698715686798, 0.7316092848777771, 1.396294355392456, 0.2816829979419708, 0.7316092848777771, 0.8962944149971008, 0.2816829979419708], [0.2316092699766159, 0.8962944149971008, 0.2816829979419708, 0.2316092699766159, 1.396294355392456, 0.2816829979419708, 0.2316092699766159, 1.396294355392456, -0.21831698715686798, 0.2316092699766159, 0.8962944149971008, -0.21831698715686798]],'tex_coords':[[0.1509433962264151, 0.0, 0.1509433962264151, 0.5, 0.18867924528301888, 0.5, 0.18867924528301888, 0.0], [0.22641509433962265, 0.0, 0.22641509433962265, 0.5, 0.2641509433962264, 0.5, 0.2641509433962264, 0.0], [0.1509433962264151, 0.5, 0.1509433962264151, 1.0, 0.18867924528301888, 1.0, 0.18867924528301888, 0.5], [0.18867924528301888, 0.5, 0.18867924528301888, 1.0, 0.22641509433962265, 1.0, 0.22641509433962265, 0.5], [0.18867924528301888, 0.0, 0.18867924528301888, 0.5, 0.22641509433962265, 0.5, 0.22641509433962265, 0.0], [0.11320754716981132, 0.0, 0.11320754716981132, 0.5, 0.1509433962264151, 0.5, 0.1509433962264151, 0.0], [0.3018867924528302, 0.0, 0.3018867924528302, 0.5, 0.33962264150943394, 0.5, 0.33962264150943394, 0.0], [0.37735849056603776, 0.0, 0.37735849056603776, 0.5, 0.41509433962264153, 0.5, 0.41509433962264153, 0.0], [0.3018867924528302, 0.5, 0.3018867924528302, 1.0, 0.33962264150943394, 1.0, 0.33962264150943394, 0.5], [0.33962264150943394, 0.5, 0.33962264150943394, 1.0, 0.37735849056603776, 1.0, 0.37735849056603776, 0.5], [0.33962264150943394, 0.0, 0.33962264150943394, 0.5, 0.37735849056603776, 0.5, 0.37735849056603776, 0.0], [0.2641509433962264, 0.0, 0.2641509433962264, 0.5, 0.3018867924528302, 0.5, 0.3018867924528302, 0.0]],'shading_values':[[1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0]]}, {'name':'hat','pivot':[0.0, 1.5, 0.0],'vertices':[[-0.25, 1.5, -0.25, -0.25, 2.0, -0.25, 0.25, 2.0, -0.25, 0.25, 1.5, -0.25], [0.25, 1.5, 0.25, 0.25, 2.0, 0.25, -0.25, 2.0, 0.25, -0.25, 1.5, 0.25], [-0.25, 2.0, -0.25, -0.25, 2.0, 0.25, 0.25, 2.0, 0.25, 0.25, 2.0, -0.25], [0.25, 1.5, -0.25, 0.25, 1.5, 0.25, -0.25, 1.5, 0.25, -0.25, 1.5, -0.25], [0.25, 1.5, -0.25, 0.25, 2.0, -0.25, 0.25, 2.0, 0.25, 0.25, 1.5, 0.25], [-0.25, 1.5, 0.25, -0.25, 2.0, 0.25, -0.25, 2.0, -0.25, -0.25, 1.5, -0.25]],'tex_coords':[[0.4528301886792453, 0.0, 0.4528301886792453, 0.5, 0.49056603773584906, 0.5, 0.49056603773584906, 0.0], [0.5283018867924528, 0.0, 0.5283018867924528, 0.5, 0.5660377358490566, 0.5, 0.5660377358490566, 0.0], [0.4528301886792453, 0.5, 0.4528301886792453, 1.0, 0.49056603773584906, 1.0, 0.49056603773584906, 0.5], [0.49056603773584906, 0.5, 0.49056603773584906, 1.0, 0.5283018867924528, 1.0, 0.5283018867924528, 0.5], [0.49056603773584906, 0.0, 0.49056603773584906, 0.5, 0.5283018867924528, 0.5, 0.5283018867924528, 0.0], [0.41509433962264153, 0.0, 0.41509433962264153, 0.5, 0.4528301886792453, 0.5, 0.4528301886792453, 0.0]],'shading_values':[[1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0]]}, {'name':'rightArm','pivot':[-0.3125, 1.375, 0.0],'vertices':[[-0.5, 0.75, -0.125, -0.5, 1.5, -0.125, -0.25, 1.5, -0.125, -0.25, 0.75, -0.125], [-0.25, 0.75, 0.125, -0.25, 1.5, 0.125, -0.5, 1.5, 0.125, -0.5, 0.75, 0.125], [-0.5, 1.5, -0.125, -0.5, 1.5, 0.125, -0.25, 1.5, 0.125, -0.25, 1.5, -0.125], [-0.25, 0.75, -0.125, -0.25, 0.75, 0.125, -0.5, 0.75, 0.125, -0.5, 0.75, -0.125], [-0.25, 0.75, -0.125, -0.25, 1.5, -0.125, -0.25, 1.5, 0.125, -0.25, 0.75, 0.125], [-0.5, 0.75, 0.125, -0.5, 1.5, 0.125, -0.5, 1.5, -0.125, -0.5, 0.75, -0.125]],'tex_coords':[[0.5849056603773585, 0.0, 0.5849056603773585, 0.75, 0.6037735849056604, 0.75, 0.6037735849056604, 0.0], [0.6226415094339622, 0.0, 0.6226415094339622, 0.75, 0.6415094339622641, 0.75, 0.6415094339622641, 0.0], [0.5849056603773585, 0.75, 0.5849056603773585, 1.0, 0.6037735849056604, 1.0, 0.6037735849056604, 0.75], [0.6037735849056604, 0.75, 0.6037735849056604, 1.0, 0.6226415094339622, 1.0, 0.6226415094339622, 0.75], [0.6037735849056604, 0.0, 0.6037735849056604, 0.75, 0.6226415094339622, 0.75, 0.6226415094339622, 0.0], [0.5660377358490566, 0.0, 0.5660377358490566, 0.75, 0.5849056603773585, 0.75, 0.5849056603773585, 0.0]],'shading_values':[[1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0]]}, {'name':'leftArm','pivot':[0.3125, 1.375, 0.0],'vertices':[[0.7019792795181274, 0.748781681060791, -0.02643335424363613, 0.7019792795181274, 1.498781681060791, -0.02643335424363613, 0.9519792795181274, 1.498781681060791, -0.02643335424363613, 0.9519792795181274, 0.748781681060791, -0.02643335424363613], [0.9519792795181274, 0.748781681060791, 0.22356665134429932, 0.9519792795181274, 1.498781681060791, 0.22356665134429932, 0.7019792795181274, 1.498781681060791, 0.22356665134429932, 0.7019792795181274, 0.748781681060791, 0.22356665134429932], [0.7019792795181274, 1.498781681060791, -0.02643335424363613, 0.7019792795181274, 1.498781681060791, 0.22356665134429932, 0.9519792795181274, 1.498781681060791, 0.22356665134429932, 0.9519792795181274, 1.498781681060791, -0.02643335424363613], [0.9519792795181274, 0.748781681060791, -0.02643335424363613, 0.9519792795181274, 0.748781681060791, 0.22356665134429932, 0.7019792795181274, 0.748781681060791, 0.22356665134429932, 0.7019792795181274, 0.748781681060791, -0.02643335424363613], [0.9519792795181274, 0.748781681060791, -0.02643335424363613, 0.9519792795181274, 1.498781681060791, -0.02643335424363613, 0.9519792795181274, 1.498781681060791, 0.22356665134429932, 0.9519792795181274, 0.748781681060791, 0.22356665134429932], [0.7019792795181274, 0.748781681060791, 0.22356665134429932, 0.7019792795181274, 1.498781681060791, 0.22356665134429932, 0.7019792795181274, 1.498781681060791, -0.02643335424363613, 0.7019792795181274, 0.748781681060791, -0.02643335424363613], [0.09342791140079498, 1.3167552947998047, -0.06984145194292068, 0.09342791140079498, 1.5042552947998047, -0.06984145194292068, 0.7184278964996338, 1.5042552947998047, -0.06984145194292068, 0.7184278964996338, 1.3167552947998047, -0.06984145194292068], [0.7184278964996338, 1.3167552947998047, 0.18015854060649872, 0.7184278964996338, 1.5042552947998047, 0.18015854060649872, 0.09342791140079498, 1.5042552947998047, 0.18015854060649872, 0.09342791140079498, 1.3167552947998047, 0.18015854060649872], [0.09342791140079498, 1.5042552947998047, -0.06984145194292068, 0.09342791140079498, 1.5042552947998047, 0.18015854060649872, 0.7184278964996338, 1.5042552947998047, 0.18015854060649872, 0.7184278964996338, 1.5042552947998047, -0.06984145194292068], [0.7184278964996338, 1.3167552947998047, -0.06984145194292068, 0.7184278964996338, 1.3167552947998047, 0.18015854060649872, 0.09342791140079498, 1.3167552947998047, 0.18015854060649872, 0.09342791140079498, 1.3167552947998047, -0.06984145194292068], [0.7184278964996338, 1.3167552947998047, -0.06984145194292068, 0.7184278964996338, 1.5042552947998047, -0.06984145194292068, 0.7184278964996338, 1.5042552947998047, 0.18015854060649872, 0.7184278964996338, 1.3167552947998047, 0.18015854060649872], [0.09342791140079498, 1.3167552947998047, 0.18015854060649872, 0.09342791140079498, 1.5042552947998047, 0.18015854060649872, 0.09342791140079498, 1.5042552947998047, -0.06984145194292068, 0.09342791140079498, 1.3167552947998047, -0.06984145194292068]],'tex_coords':[[0.660377358490566, 0.0, 0.660377358490566, 0.75, 0.6792452830188679, 0.75, 0.6792452830188679, 0.0], [0.6981132075471698, 0.0, 0.6981132075471698, 0.75, 0.7169811320754716, 0.75, 0.7169811320754716, 0.0], [0.660377358490566, 0.75, 0.660377358490566, 1.0, 0.6792452830188679, 1.0, 0.6792452830188679, 0.75], [0.6792452830188679, 0.75, 0.6792452830188679, 1.0, 0.6981132075471698, 1.0, 0.6981132075471698, 0.75], [0.6792452830188679, 0.0, 0.6792452830188679, 0.75, 0.6981132075471698, 0.75, 0.6981132075471698, 0.0], [0.6415094339622641, 0.0, 0.6415094339622641, 0.75, 0.660377358490566, 0.75, 0.660377358490566, 0.0], [0.7358490566037735, 0.5625, 0.7358490566037735, 0.75, 0.7830188679245284, 0.75, 0.7830188679245284, 0.5625], [0.8018867924528302, 0.5625, 0.8018867924528302, 0.75, 0.8490566037735849, 0.75, 0.8490566037735849, 0.5625], [0.7358490566037735, 0.75, 0.7358490566037735, 1.0, 0.7830188679245284, 1.0, 0.7830188679245284, 0.75], [0.7830188679245284, 0.75, 0.7830188679245284, 1.0, 0.8301886792452831, 1.0, 0.8301886792452831, 0.75], [0.7830188679245284, 0.5625, 0.7830188679245284, 0.75, 0.8018867924528302, 0.75, 0.8018867924528302, 0.5625], [0.7169811320754716, 0.5625, 0.7169811320754716, 0.75, 0.7358490566037735, 0.75, 0.7358490566037735, 0.5625]],'shading_values':[[1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0]]}, {'name':'rightLeg','pivot':[-0.11875, 0.75, 0.0],'vertices':[[-0.24375000596046448, 0.0, -0.125, -0.24375000596046448, 0.75, -0.125, 0.0062500000931322575, 0.75, -0.125, 0.0062500000931322575, 0.0, -0.125], [0.0062500000931322575, 0.0, 0.125, 0.0062500000931322575, 0.75, 0.125, -0.24375000596046448, 0.75, 0.125, -0.24375000596046448, 0.0, 0.125], [-0.24375000596046448, 0.75, -0.125, -0.24375000596046448, 0.75, 0.125, 0.0062500000931322575, 0.75, 0.125, 0.0062500000931322575, 0.75, -0.125], [0.0062500000931322575, 0.0, -0.125, 0.0062500000931322575, 0.0, 0.125, -0.24375000596046448, 0.0, 0.125, -0.24375000596046448, 0.0, -0.125], [0.0062500000931322575, 0.0, -0.125, 0.0062500000931322575, 0.75, -0.125, 0.0062500000931322575, 0.75, 0.125, 0.0062500000931322575, 0.0, 0.125], [-0.24375000596046448, 0.0, 0.125, -0.24375000596046448, 0.75, 0.125, -0.24375000596046448, 0.75, -0.125, -0.24375000596046448, 0.0, -0.125]],'tex_coords':[[0.8679245283018868, 0.0, 0.8679245283018868, 0.75, 0.8867924528301887, 0.75, 0.8867924528301887, 0.0], [0.9056603773584906, 0.0, 0.9056603773584906, 0.75, 0.9245283018867925, 0.75, 0.9245283018867925, 0.0], [0.8679245283018868, 0.75, 0.8679245283018868, 1.0, 0.8867924528301887, 1.0, 0.8867924528301887, 0.75], [0.8867924528301887, 0.75, 0.8867924528301887, 1.0, 0.9056603773584906, 1.0, 0.9056603773584906, 0.75], [0.8867924528301887, 0.0, 0.8867924528301887, 0.75, 0.9056603773584906, 0.75, 0.9056603773584906, 0.0], [0.8490566037735849, 0.0, 0.8490566037735849, 0.75, 0.8679245283018868, 0.75, 0.8679245283018868, 0.0]],'shading_values':[[1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0]]}, {'name':'leftLeg','pivot':[0.11875, 0.75, 0.0],'vertices':[[-0.0062500000931322575, 0.0, -0.125, -0.0062500000931322575, 0.75, -0.125, 0.24375000596046448, 0.75, -0.125, 0.24375000596046448, 0.0, -0.125], [0.24375000596046448, 0.0, 0.125, 0.24375000596046448, 0.75, 0.125, -0.0062500000931322575, 0.75, 0.125, -0.0062500000931322575, 0.0, 0.125], [-0.0062500000931322575, 0.75, -0.125, -0.0062500000931322575, 0.75, 0.125, 0.24375000596046448, 0.75, 0.125, 0.24375000596046448, 0.75, -0.125], [0.24375000596046448, 0.0, -0.125, 0.24375000596046448, 0.0, 0.125, -0.0062500000931322575, 0.0, 0.125, -0.0062500000931322575, 0.0, -0.125], [0.24375000596046448, 0.0, -0.125, 0.24375000596046448, 0.75, -0.125, 0.24375000596046448, 0.75, 0.125, 0.24375000596046448, 0.0, 0.125], [-0.0062500000931322575, 0.0, 0.125, -0.0062500000931322575, 0.75, 0.125, -0.0062500000931322575, 0.75, -0.125, -0.0062500000931322575, 0.0, -0.125]],'tex_coords':[[0.9433962264150944, 0.0, 0.9433962264150944, 0.75, 0.9622641509433962, 0.75, 0.9622641509433962, 0.0], [0.9811320754716981, 0.0, 0.9811320754716981, 0.75, 1.0, 0.75, 1.0, 0.0], [0.9433962264150944, 0.75, 0.9433962264150944, 1.0, 0.9622641509433962, 1.0, 0.9622641509433962, 0.75], [0.9622641509433962, 0.75, 0.9622641509433962, 1.0, 0.9811320754716981, 1.0, 0.9811320754716981, 0.75], [0.9622641509433962, 0.0, 0.9622641509433962, 0.75, 0.9811320754716981, 0.75, 0.9811320754716981, 0.0], [0.9245283018867925, 0.0, 0.9245283018867925, 0.75, 0.9433962264150944, 0.75, 0.9433962264150944, 0.0]],'shading_values':[[1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0]]}] diff --git a/community/models/door.py b/community/models/door.py index 80646339..74bcb7bb 100644 --- a/community/models/door.py +++ b/community/models/door.py @@ -1,4 +1,5 @@ -transparent = 0 +transparent = False +transparency = 0 is_cube = True glass = False translucent = False @@ -30,4 +31,4 @@ [0.4, 0.4, 0.4, 0.4], [0.8, 0.8, 0.8, 0.8], [0.8, 0.8, 0.8, 0.8], -] \ No newline at end of file +] diff --git a/community/models/fire.py b/community/models/fire.py index 226d0f58..84edeec7 100644 --- a/community/models/fire.py +++ b/community/models/fire.py @@ -1,4 +1,5 @@ -transparent = 2 +transparent = True +transparency = 2 is_cube = False glass = False translucent = False @@ -24,4 +25,4 @@ [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], -] \ No newline at end of file +] diff --git a/community/models/flat.py b/community/models/flat.py index 4e6f824b..75f8cfdd 100644 --- a/community/models/flat.py +++ b/community/models/flat.py @@ -1,4 +1,5 @@ -transparent = 2 +transparent = True +transparency = 2 is_cube = False glass = False translucent = False @@ -18,4 +19,4 @@ shading_values = [ [1.0, 1.0, 1.0, 1.0], [0.4, 0.4, 0.4, 0.4], -] \ No newline at end of file +] diff --git a/community/models/glass.py b/community/models/glass.py index 847a51da..a204622e 100644 --- a/community/models/glass.py +++ b/community/models/glass.py @@ -1,4 +1,5 @@ -transparent = 2 +transparent = True +transparency = 2 is_cube = True glass = True translucent = False @@ -35,4 +36,4 @@ [0.4, 0.4, 0.4, 0.4], [0.8, 0.8, 0.8, 0.8], [0.8, 0.8, 0.8, 0.8], -] \ No newline at end of file +] diff --git a/community/models/ladder.py b/community/models/ladder.py index 226d0f58..84edeec7 100644 --- a/community/models/ladder.py +++ b/community/models/ladder.py @@ -1,4 +1,5 @@ -transparent = 2 +transparent = True +transparency = 2 is_cube = False glass = False translucent = False @@ -24,4 +25,4 @@ [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], -] \ No newline at end of file +] diff --git a/community/models/leaves.py b/community/models/leaves.py index bf05836d..3e0c2b91 100644 --- a/community/models/leaves.py +++ b/community/models/leaves.py @@ -1,4 +1,5 @@ -transparent = 1 +transparent = True +transparency = 1 is_cube = True glass = False translucent = False @@ -35,4 +36,4 @@ [0.4, 0.4, 0.4, 0.4], [0.8, 0.8, 0.8, 0.8], [0.8, 0.8, 0.8, 0.8], -] \ No newline at end of file +] diff --git a/community/models/lever.py b/community/models/lever.py index 4f7eb5ab..87f38e7d 100644 --- a/community/models/lever.py +++ b/community/models/lever.py @@ -1,4 +1,5 @@ transparent = True +transparency = 2 is_cube = False glass = False translucent = False @@ -30,4 +31,4 @@ [0.4, 0.4, 0.4, 0.4], [0.8, 0.8, 0.8, 0.8], [0.8, 0.8, 0.8, 0.8], -] \ No newline at end of file +] diff --git a/community/models/liquid.py b/community/models/liquid.py index d8f58426..ed42871c 100644 --- a/community/models/liquid.py +++ b/community/models/liquid.py @@ -1,10 +1,10 @@ # in the end, it'd be nice to have it so that liquids fill up the whole block when they have a block above them # this would avoid the problems this solution has - -translucent = True -transparent = 1 +transparent = True +transparency = 1 is_cube = True glass = True +translucent = True colliders = [] @@ -26,7 +26,6 @@ [0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 1.0, 0.0], ] - shading_values = [ [0.6, 0.6, 0.6, 0.6], [0.6, 0.6, 0.6, 0.6], diff --git a/community/models/pig.py b/community/models/pig.py new file mode 100644 index 00000000..eddfc53d --- /dev/null +++ b/community/models/pig.py @@ -0,0 +1,8 @@ + +transparent = True +is_cube = False +glass = False + +colliders = [] + +bones = [{'name':'body','pivot':[0.0, 0.8125, 0.125],'vertices':[[-0.3124999701976776, 0.3750000298023224, 0.5, -0.3124999701976776, 0.375, -0.5, 0.3124999701976776, 0.375, -0.5, 0.3124999701976776, 0.3750000298023224, 0.5], [0.3124999701976776, 0.8750000596046448, 0.5, 0.3124999701976776, 0.875, -0.5, -0.3124999701976776, 0.875, -0.5, -0.3124999701976776, 0.8750000596046448, 0.5], [-0.3124999701976776, 0.375, -0.5, -0.3124999701976776, 0.875, -0.5, 0.3124999701976776, 0.875, -0.5, 0.3124999701976776, 0.375, -0.5], [0.3124999701976776, 0.3750000298023224, 0.5, 0.3124999701976776, 0.8750000596046448, 0.5, -0.3124999701976776, 0.8750000596046448, 0.5, -0.3124999701976776, 0.3750000298023224, 0.5], [0.3124999701976776, 0.3750000298023224, 0.5, 0.3124999701976776, 0.375, -0.5, 0.3124999701976776, 0.875, -0.5, 0.3124999701976776, 0.8750000596046448, 0.5], [-0.3124999701976776, 0.8750000596046448, 0.5, -0.3124999701976776, 0.875, -0.5, -0.3124999701976776, 0.375, -0.5, -0.3124999701976776, 0.3750000298023224, 0.5]],'tex_coords':[[0.056338028169014086, 0.0, 0.056338028169014086, 0.6666666666666667, 0.1267605633802817, 0.6666666666666667, 0.1267605633802817, 0.0], [0.18309859154929578, 0.0, 0.18309859154929578, 0.6666666666666667, 0.2535211267605634, 0.6666666666666667, 0.2535211267605634, 0.0], [0.056338028169014086, 0.6666666666666667, 0.056338028169014086, 1.0, 0.1267605633802817, 1.0, 0.1267605633802817, 0.6666666666666667], [0.1267605633802817, 0.6666666666666667, 0.1267605633802817, 1.0, 0.19718309859154928, 1.0, 0.19718309859154928, 0.6666666666666667], [0.1267605633802817, 0.0, 0.1267605633802817, 0.6666666666666667, 0.18309859154929578, 0.6666666666666667, 0.18309859154929578, 0.0], [0.0, 0.0, 0.0, 0.6666666666666667, 0.056338028169014086, 0.6666666666666667, 0.056338028169014086, 0.0]],'shading_values':[[1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0]]}, {'name':'head','pivot':[0.0, 0.75, -0.375],'vertices':[[-0.25, 0.5, -0.875, -0.25, 1.0, -0.875, 0.25, 1.0, -0.875, 0.25, 0.5, -0.875], [0.25, 0.5, -0.375, 0.25, 1.0, -0.375, -0.25, 1.0, -0.375, -0.25, 0.5, -0.375], [-0.25, 1.0, -0.875, -0.25, 1.0, -0.375, 0.25, 1.0, -0.375, 0.25, 1.0, -0.875], [0.25, 0.5, -0.875, 0.25, 0.5, -0.375, -0.25, 0.5, -0.375, -0.25, 0.5, -0.875], [0.25, 0.5, -0.875, 0.25, 1.0, -0.875, 0.25, 1.0, -0.375, 0.25, 0.5, -0.375], [-0.25, 0.5, -0.375, -0.25, 1.0, -0.375, -0.25, 1.0, -0.875, -0.25, 0.5, -0.875], [-0.125, 0.5625, -0.9375, -0.125, 0.75, -0.9375, 0.125, 0.75, -0.9375, 0.125, 0.5625, -0.9375], [0.125, 0.5625, -0.875, 0.125, 0.75, -0.875, -0.125, 0.75, -0.875, -0.125, 0.5625, -0.875], [-0.125, 0.75, -0.9375, -0.125, 0.75, -0.875, 0.125, 0.75, -0.875, 0.125, 0.75, -0.9375], [0.125, 0.5625, -0.9375, 0.125, 0.5625, -0.875, -0.125, 0.5625, -0.875, -0.125, 0.5625, -0.9375], [0.125, 0.5625, -0.9375, 0.125, 0.75, -0.9375, 0.125, 0.75, -0.875, 0.125, 0.5625, -0.875], [-0.125, 0.5625, -0.875, -0.125, 0.75, -0.875, -0.125, 0.75, -0.9375, -0.125, 0.5625, -0.9375]],'tex_coords':[[0.30985915492957744, 0.33333333333333337, 0.30985915492957744, 0.6666666666666667, 0.36619718309859156, 0.6666666666666667, 0.36619718309859156, 0.33333333333333337], [0.4225352112676056, 0.33333333333333337, 0.4225352112676056, 0.6666666666666667, 0.4788732394366197, 0.6666666666666667, 0.4788732394366197, 0.33333333333333337], [0.30985915492957744, 0.6666666666666667, 0.30985915492957744, 1.0, 0.36619718309859156, 1.0, 0.36619718309859156, 0.6666666666666667], [0.36619718309859156, 0.6666666666666667, 0.36619718309859156, 1.0, 0.4225352112676056, 1.0, 0.4225352112676056, 0.6666666666666667], [0.36619718309859156, 0.33333333333333337, 0.36619718309859156, 0.6666666666666667, 0.4225352112676056, 0.6666666666666667, 0.4225352112676056, 0.33333333333333337], [0.2535211267605634, 0.33333333333333337, 0.2535211267605634, 0.6666666666666667, 0.30985915492957744, 0.6666666666666667, 0.30985915492957744, 0.33333333333333337], [0.4859154929577465, 0.8333333333333334, 0.4859154929577465, 0.9583333333333334, 0.5140845070422535, 0.9583333333333334, 0.5140845070422535, 0.8333333333333334], [0.5211267605633803, 0.8333333333333334, 0.5211267605633803, 0.9583333333333334, 0.5492957746478874, 0.9583333333333334, 0.5492957746478874, 0.8333333333333334], [0.4859154929577465, 0.9583333333333334, 0.4859154929577465, 1.0, 0.5140845070422535, 1.0, 0.5140845070422535, 0.9583333333333334], [0.5140845070422535, 0.9583333333333334, 0.5140845070422535, 1.0, 0.5422535211267606, 1.0, 0.5422535211267606, 0.9583333333333334], [0.5140845070422535, 0.8333333333333334, 0.5140845070422535, 0.9583333333333334, 0.5211267605633803, 0.9583333333333334, 0.5211267605633803, 0.8333333333333334], [0.4788732394366197, 0.8333333333333334, 0.4788732394366197, 0.9583333333333334, 0.4859154929577465, 0.9583333333333334, 0.4859154929577465, 0.8333333333333334]],'shading_values':[[1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0]]}, {'name':'leg0','pivot':[-0.1875, 0.375, 0.4375],'vertices':[[-0.3125, 0.0, 0.3125, -0.3125, 0.375, 0.3125, -0.0625, 0.375, 0.3125, -0.0625, 0.0, 0.3125], [-0.0625, 0.0, 0.5625, -0.0625, 0.375, 0.5625, -0.3125, 0.375, 0.5625, -0.3125, 0.0, 0.5625], [-0.3125, 0.375, 0.3125, -0.3125, 0.375, 0.5625, -0.0625, 0.375, 0.5625, -0.0625, 0.375, 0.3125], [-0.0625, 0.0, 0.3125, -0.0625, 0.0, 0.5625, -0.3125, 0.0, 0.5625, -0.3125, 0.0, 0.3125], [-0.0625, 0.0, 0.3125, -0.0625, 0.375, 0.3125, -0.0625, 0.375, 0.5625, -0.0625, 0.0, 0.5625], [-0.3125, 0.0, 0.5625, -0.3125, 0.375, 0.5625, -0.3125, 0.375, 0.3125, -0.3125, 0.0, 0.3125]],'tex_coords':[[0.5774647887323944, 0.5833333333333333, 0.5774647887323944, 0.8333333333333334, 0.6056338028169014, 0.8333333333333334, 0.6056338028169014, 0.5833333333333333], [0.6338028169014085, 0.5833333333333333, 0.6338028169014085, 0.8333333333333334, 0.6619718309859155, 0.8333333333333334, 0.6619718309859155, 0.5833333333333333], [0.5774647887323944, 0.8333333333333334, 0.5774647887323944, 1.0, 0.6056338028169014, 1.0, 0.6056338028169014, 0.8333333333333334], [0.6056338028169014, 0.8333333333333334, 0.6056338028169014, 1.0, 0.6338028169014085, 1.0, 0.6338028169014085, 0.8333333333333334], [0.6056338028169014, 0.5833333333333333, 0.6056338028169014, 0.8333333333333334, 0.6338028169014085, 0.8333333333333334, 0.6338028169014085, 0.5833333333333333], [0.5492957746478874, 0.5833333333333333, 0.5492957746478874, 0.8333333333333334, 0.5774647887323944, 0.8333333333333334, 0.5774647887323944, 0.5833333333333333]],'shading_values':[[1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0]]}, {'name':'leg1','pivot':[0.1875, 0.375, 0.4375],'vertices':[[0.0625, 0.0, 0.3125, 0.0625, 0.375, 0.3125, 0.3125, 0.375, 0.3125, 0.3125, 0.0, 0.3125], [0.3125, 0.0, 0.5625, 0.3125, 0.375, 0.5625, 0.0625, 0.375, 0.5625, 0.0625, 0.0, 0.5625], [0.0625, 0.375, 0.3125, 0.0625, 0.375, 0.5625, 0.3125, 0.375, 0.5625, 0.3125, 0.375, 0.3125], [0.3125, 0.0, 0.3125, 0.3125, 0.0, 0.5625, 0.0625, 0.0, 0.5625, 0.0625, 0.0, 0.3125], [0.3125, 0.0, 0.3125, 0.3125, 0.375, 0.3125, 0.3125, 0.375, 0.5625, 0.3125, 0.0, 0.5625], [0.0625, 0.0, 0.5625, 0.0625, 0.375, 0.5625, 0.0625, 0.375, 0.3125, 0.0625, 0.0, 0.3125]],'tex_coords':[[0.6901408450704225, 0.5833333333333333, 0.6901408450704225, 0.8333333333333334, 0.7183098591549296, 0.8333333333333334, 0.7183098591549296, 0.5833333333333333], [0.7464788732394366, 0.5833333333333333, 0.7464788732394366, 0.8333333333333334, 0.7746478873239436, 0.8333333333333334, 0.7746478873239436, 0.5833333333333333], [0.6901408450704225, 0.8333333333333334, 0.6901408450704225, 1.0, 0.7183098591549296, 1.0, 0.7183098591549296, 0.8333333333333334], [0.7183098591549296, 0.8333333333333334, 0.7183098591549296, 1.0, 0.7464788732394366, 1.0, 0.7464788732394366, 0.8333333333333334], [0.7183098591549296, 0.5833333333333333, 0.7183098591549296, 0.8333333333333334, 0.7464788732394366, 0.8333333333333334, 0.7464788732394366, 0.5833333333333333], [0.6619718309859155, 0.5833333333333333, 0.6619718309859155, 0.8333333333333334, 0.6901408450704225, 0.8333333333333334, 0.6901408450704225, 0.5833333333333333]],'shading_values':[[1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0]]}, {'name':'leg2','pivot':[-0.1875, 0.375, -0.3125],'vertices':[[-0.3125, 0.0, -0.4375, -0.3125, 0.375, -0.4375, -0.0625, 0.375, -0.4375, -0.0625, 0.0, -0.4375], [-0.0625, 0.0, -0.1875, -0.0625, 0.375, -0.1875, -0.3125, 0.375, -0.1875, -0.3125, 0.0, -0.1875], [-0.3125, 0.375, -0.4375, -0.3125, 0.375, -0.1875, -0.0625, 0.375, -0.1875, -0.0625, 0.375, -0.4375], [-0.0625, 0.0, -0.4375, -0.0625, 0.0, -0.1875, -0.3125, 0.0, -0.1875, -0.3125, 0.0, -0.4375], [-0.0625, 0.0, -0.4375, -0.0625, 0.375, -0.4375, -0.0625, 0.375, -0.1875, -0.0625, 0.0, -0.1875], [-0.3125, 0.0, -0.1875, -0.3125, 0.375, -0.1875, -0.3125, 0.375, -0.4375, -0.3125, 0.0, -0.4375]],'tex_coords':[[0.8028169014084507, 0.5833333333333333, 0.8028169014084507, 0.8333333333333334, 0.8309859154929577, 0.8333333333333334, 0.8309859154929577, 0.5833333333333333], [0.8591549295774648, 0.5833333333333333, 0.8591549295774648, 0.8333333333333334, 0.8873239436619719, 0.8333333333333334, 0.8873239436619719, 0.5833333333333333], [0.8028169014084507, 0.8333333333333334, 0.8028169014084507, 1.0, 0.8309859154929577, 1.0, 0.8309859154929577, 0.8333333333333334], [0.8309859154929577, 0.8333333333333334, 0.8309859154929577, 1.0, 0.8591549295774648, 1.0, 0.8591549295774648, 0.8333333333333334], [0.8309859154929577, 0.5833333333333333, 0.8309859154929577, 0.8333333333333334, 0.8591549295774648, 0.8333333333333334, 0.8591549295774648, 0.5833333333333333], [0.7746478873239436, 0.5833333333333333, 0.7746478873239436, 0.8333333333333334, 0.8028169014084507, 0.8333333333333334, 0.8028169014084507, 0.5833333333333333]],'shading_values':[[1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0]]}, {'name':'leg3','pivot':[0.1875, 0.375, -0.3125],'vertices':[[0.0625, 0.0, -0.4375, 0.0625, 0.375, -0.4375, 0.3125, 0.375, -0.4375, 0.3125, 0.0, -0.4375], [0.3125, 0.0, -0.1875, 0.3125, 0.375, -0.1875, 0.0625, 0.375, -0.1875, 0.0625, 0.0, -0.1875], [0.0625, 0.375, -0.4375, 0.0625, 0.375, -0.1875, 0.3125, 0.375, -0.1875, 0.3125, 0.375, -0.4375], [0.3125, 0.0, -0.4375, 0.3125, 0.0, -0.1875, 0.0625, 0.0, -0.1875, 0.0625, 0.0, -0.4375], [0.3125, 0.0, -0.4375, 0.3125, 0.375, -0.4375, 0.3125, 0.375, -0.1875, 0.3125, 0.0, -0.1875], [0.0625, 0.0, -0.1875, 0.0625, 0.375, -0.1875, 0.0625, 0.375, -0.4375, 0.0625, 0.0, -0.4375]],'tex_coords':[[0.9154929577464789, 0.5833333333333333, 0.9154929577464789, 0.8333333333333334, 0.9436619718309859, 0.8333333333333334, 0.9436619718309859, 0.5833333333333333], [0.971830985915493, 0.5833333333333333, 0.971830985915493, 0.8333333333333334, 1.0, 0.8333333333333334, 1.0, 0.5833333333333333], [0.9154929577464789, 0.8333333333333334, 0.9154929577464789, 1.0, 0.9436619718309859, 1.0, 0.9436619718309859, 0.8333333333333334], [0.9436619718309859, 0.8333333333333334, 0.9436619718309859, 1.0, 0.971830985915493, 1.0, 0.971830985915493, 0.8333333333333334], [0.9436619718309859, 0.5833333333333333, 0.9436619718309859, 0.8333333333333334, 0.971830985915493, 0.8333333333333334, 0.971830985915493, 0.5833333333333333], [0.8873239436619719, 0.5833333333333333, 0.8873239436619719, 0.8333333333333334, 0.9154929577464789, 0.8333333333333334, 0.9154929577464789, 0.5833333333333333]],'shading_values':[[1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0]]}] diff --git a/community/models/plant.py b/community/models/plant.py index 226d0f58..9aa6a127 100644 --- a/community/models/plant.py +++ b/community/models/plant.py @@ -1,7 +1,8 @@ -transparent = 2 +transparent = True +transparency = 2 +translucent = False is_cube = False glass = False -translucent = False colliders = [] @@ -24,4 +25,4 @@ [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], -] \ No newline at end of file +] diff --git a/community/models/pressure_plate.py b/community/models/pressure_plate.py index 4e6f824b..75f8cfdd 100644 --- a/community/models/pressure_plate.py +++ b/community/models/pressure_plate.py @@ -1,4 +1,5 @@ -transparent = 2 +transparent = True +transparency = 2 is_cube = False glass = False translucent = False @@ -18,4 +19,4 @@ shading_values = [ [1.0, 1.0, 1.0, 1.0], [0.4, 0.4, 0.4, 0.4], -] \ No newline at end of file +] diff --git a/community/models/sign.py b/community/models/sign.py index 226d0f58..84edeec7 100644 --- a/community/models/sign.py +++ b/community/models/sign.py @@ -1,4 +1,5 @@ -transparent = 2 +transparent = True +transparency = 2 is_cube = False glass = False translucent = False @@ -24,4 +25,4 @@ [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], -] \ No newline at end of file +] diff --git a/community/models/sign_post.py b/community/models/sign_post.py index 226d0f58..84edeec7 100644 --- a/community/models/sign_post.py +++ b/community/models/sign_post.py @@ -1,4 +1,5 @@ -transparent = 2 +transparent = True +transparency = 2 is_cube = False glass = False translucent = False @@ -24,4 +25,4 @@ [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], -] \ No newline at end of file +] diff --git a/community/models/skeleton.py b/community/models/skeleton.py new file mode 100644 index 00000000..003cd6c2 --- /dev/null +++ b/community/models/skeleton.py @@ -0,0 +1,8 @@ + +transparent = True +is_cube = False +glass = False + +colliders = [] + +bones = [{'name':'body','pivot':[0.0, 1.5, 0.0],'vertices':[[-0.25, 0.75, -0.125, -0.25, 1.5, -0.125, 0.25, 1.5, -0.125, 0.25, 0.75, -0.125], [0.25, 0.75, 0.125, 0.25, 1.5, 0.125, -0.25, 1.5, 0.125, -0.25, 0.75, 0.125], [-0.25, 1.5, -0.125, -0.25, 1.5, 0.125, 0.25, 1.5, 0.125, 0.25, 1.5, -0.125], [0.25, 0.75, -0.125, 0.25, 0.75, 0.125, -0.25, 0.75, 0.125, -0.25, 0.75, -0.125], [0.25, 0.75, -0.125, 0.25, 1.5, -0.125, 0.25, 1.5, 0.125, 0.25, 0.75, 0.125], [-0.25, 0.75, 0.125, -0.25, 1.5, 0.125, -0.25, 1.5, -0.125, -0.25, 0.75, -0.125]],'tex_coords':[[0.03333333333333333, 0.0, 0.03333333333333333, 0.75, 0.1, 0.75, 0.1, 0.0], [0.13333333333333333, 0.0, 0.13333333333333333, 0.75, 0.2, 0.75, 0.2, 0.0], [0.03333333333333333, 0.75, 0.03333333333333333, 1.0, 0.1, 1.0, 0.1, 0.75], [0.1, 0.75, 0.1, 1.0, 0.16666666666666666, 1.0, 0.16666666666666666, 0.75], [0.1, 0.0, 0.1, 0.75, 0.13333333333333333, 0.75, 0.13333333333333333, 0.0], [0.0, 0.0, 0.0, 0.75, 0.03333333333333333, 0.75, 0.03333333333333333, 0.0]],'shading_values':[[1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0]]}, {'name':'head','pivot':[0.0, 1.5, 0.0],'vertices':[[-0.25, 1.5, -0.25, -0.25, 2.0, -0.25, 0.25, 2.0, -0.25, 0.25, 1.5, -0.25], [0.25, 1.5, 0.25, 0.25, 2.0, 0.25, -0.25, 2.0, 0.25, -0.25, 1.5, 0.25], [-0.25, 2.0, -0.25, -0.25, 2.0, 0.25, 0.25, 2.0, 0.25, 0.25, 2.0, -0.25], [0.25, 1.5, -0.25, 0.25, 1.5, 0.25, -0.25, 1.5, 0.25, -0.25, 1.5, -0.25], [0.25, 1.5, -0.25, 0.25, 2.0, -0.25, 0.25, 2.0, 0.25, 0.25, 1.5, 0.25], [-0.25, 1.5, 0.25, -0.25, 2.0, 0.25, -0.25, 2.0, -0.25, -0.25, 1.5, -0.25]],'tex_coords':[[0.26666666666666666, 0.0, 0.26666666666666666, 0.5, 0.3333333333333333, 0.5, 0.3333333333333333, 0.0], [0.4, 0.0, 0.4, 0.5, 0.4666666666666667, 0.5, 0.4666666666666667, 0.0], [0.26666666666666666, 0.5, 0.26666666666666666, 1.0, 0.3333333333333333, 1.0, 0.3333333333333333, 0.5], [0.3333333333333333, 0.5, 0.3333333333333333, 1.0, 0.4, 1.0, 0.4, 0.5], [0.3333333333333333, 0.0, 0.3333333333333333, 0.5, 0.4, 0.5, 0.4, 0.0], [0.2, 0.0, 0.2, 0.5, 0.26666666666666666, 0.5, 0.26666666666666666, 0.0]],'shading_values':[[1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0]]}, {'name':'hat','pivot':[0.0, 1.5, 0.0],'vertices':[[-0.25, 1.5, -0.25, -0.25, 2.0, -0.25, 0.25, 2.0, -0.25, 0.25, 1.5, -0.25], [0.25, 1.5, 0.25, 0.25, 2.0, 0.25, -0.25, 2.0, 0.25, -0.25, 1.5, 0.25], [-0.25, 2.0, -0.25, -0.25, 2.0, 0.25, 0.25, 2.0, 0.25, 0.25, 2.0, -0.25], [0.25, 1.5, -0.25, 0.25, 1.5, 0.25, -0.25, 1.5, 0.25, -0.25, 1.5, -0.25], [0.25, 1.5, -0.25, 0.25, 2.0, -0.25, 0.25, 2.0, 0.25, 0.25, 1.5, 0.25], [-0.25, 1.5, 0.25, -0.25, 2.0, 0.25, -0.25, 2.0, -0.25, -0.25, 1.5, -0.25]],'tex_coords':[[0.5333333333333333, 0.0, 0.5333333333333333, 0.5, 0.6, 0.5, 0.6, 0.0], [0.6666666666666666, 0.0, 0.6666666666666666, 0.5, 0.7333333333333333, 0.5, 0.7333333333333333, 0.0], [0.5333333333333333, 0.5, 0.5333333333333333, 1.0, 0.6, 1.0, 0.6, 0.5], [0.6, 0.5, 0.6, 1.0, 0.6666666666666666, 1.0, 0.6666666666666666, 0.5], [0.6, 0.0, 0.6, 0.5, 0.6666666666666666, 0.5, 0.6666666666666666, 0.0], [0.4666666666666667, 0.0, 0.4666666666666667, 0.5, 0.5333333333333333, 0.5, 0.5333333333333333, 0.0]],'shading_values':[[1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0]]}, {'name':'rightArm','pivot':[-0.3125, 1.375, 0.0],'vertices':[[-0.375, 0.75, -0.0625, -0.375, 1.5, -0.0625, -0.25, 1.5, -0.0625, -0.25, 0.75, -0.0625], [-0.25, 0.75, 0.0625, -0.25, 1.5, 0.0625, -0.375, 1.5, 0.0625, -0.375, 0.75, 0.0625], [-0.375, 1.5, -0.0625, -0.375, 1.5, 0.0625, -0.25, 1.5, 0.0625, -0.25, 1.5, -0.0625], [-0.25, 0.75, -0.0625, -0.25, 0.75, 0.0625, -0.375, 0.75, 0.0625, -0.375, 0.75, -0.0625], [-0.25, 0.75, -0.0625, -0.25, 1.5, -0.0625, -0.25, 1.5, 0.0625, -0.25, 0.75, 0.0625], [-0.375, 0.75, 0.0625, -0.375, 1.5, 0.0625, -0.375, 1.5, -0.0625, -0.375, 0.75, -0.0625]],'tex_coords':[[0.75, 0.125, 0.75, 0.875, 0.7666666666666667, 0.875, 0.7666666666666667, 0.125], [0.7833333333333333, 0.125, 0.7833333333333333, 0.875, 0.8, 0.875, 0.8, 0.125], [0.75, 0.875, 0.75, 1.0, 0.7666666666666667, 1.0, 0.7666666666666667, 0.875], [0.7666666666666667, 0.875, 0.7666666666666667, 1.0, 0.7833333333333333, 1.0, 0.7833333333333333, 0.875], [0.7666666666666667, 0.125, 0.7666666666666667, 0.875, 0.7833333333333333, 0.875, 0.7833333333333333, 0.125], [0.7333333333333333, 0.125, 0.7333333333333333, 0.875, 0.75, 0.875, 0.75, 0.125]],'shading_values':[[1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0]]}, {'name':'leftArm','pivot':[0.3125, 1.375, 0.0],'vertices':[[0.25, 0.75, -0.0625, 0.25, 1.5, -0.0625, 0.375, 1.5, -0.0625, 0.375, 0.75, -0.0625], [0.375, 0.75, 0.0625, 0.375, 1.5, 0.0625, 0.25, 1.5, 0.0625, 0.25, 0.75, 0.0625], [0.25, 1.5, -0.0625, 0.25, 1.5, 0.0625, 0.375, 1.5, 0.0625, 0.375, 1.5, -0.0625], [0.375, 0.75, -0.0625, 0.375, 0.75, 0.0625, 0.25, 0.75, 0.0625, 0.25, 0.75, -0.0625], [0.375, 0.75, -0.0625, 0.375, 1.5, -0.0625, 0.375, 1.5, 0.0625, 0.375, 0.75, 0.0625], [0.25, 0.75, 0.0625, 0.25, 1.5, 0.0625, 0.25, 1.5, -0.0625, 0.25, 0.75, -0.0625]],'tex_coords':[[0.8166666666666667, 0.125, 0.8166666666666667, 0.875, 0.8333333333333334, 0.875, 0.8333333333333334, 0.125], [0.85, 0.125, 0.85, 0.875, 0.8666666666666667, 0.875, 0.8666666666666667, 0.125], [0.8166666666666667, 0.875, 0.8166666666666667, 1.0, 0.8333333333333334, 1.0, 0.8333333333333334, 0.875], [0.8333333333333334, 0.875, 0.8333333333333334, 1.0, 0.85, 1.0, 0.85, 0.875], [0.8333333333333334, 0.125, 0.8333333333333334, 0.875, 0.85, 0.875, 0.85, 0.125], [0.8, 0.125, 0.8, 0.875, 0.8166666666666667, 0.875, 0.8166666666666667, 0.125]],'shading_values':[[1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0]]}, {'name':'rightLeg','pivot':[-0.125, 0.75, 0.0],'vertices':[[-0.1875, 0.0, -0.0625, -0.1875, 0.75, -0.0625, -0.0625, 0.75, -0.0625, -0.0625, 0.0, -0.0625], [-0.0625, 0.0, 0.0625, -0.0625, 0.75, 0.0625, -0.1875, 0.75, 0.0625, -0.1875, 0.0, 0.0625], [-0.1875, 0.75, -0.0625, -0.1875, 0.75, 0.0625, -0.0625, 0.75, 0.0625, -0.0625, 0.75, -0.0625], [-0.0625, 0.0, -0.0625, -0.0625, 0.0, 0.0625, -0.1875, 0.0, 0.0625, -0.1875, 0.0, -0.0625], [-0.0625, 0.0, -0.0625, -0.0625, 0.75, -0.0625, -0.0625, 0.75, 0.0625, -0.0625, 0.0, 0.0625], [-0.1875, 0.0, 0.0625, -0.1875, 0.75, 0.0625, -0.1875, 0.75, -0.0625, -0.1875, 0.0, -0.0625]],'tex_coords':[[0.8833333333333333, 0.125, 0.8833333333333333, 0.875, 0.9, 0.875, 0.9, 0.125], [0.9166666666666666, 0.125, 0.9166666666666666, 0.875, 0.9333333333333333, 0.875, 0.9333333333333333, 0.125], [0.8833333333333333, 0.875, 0.8833333333333333, 1.0, 0.9, 1.0, 0.9, 0.875], [0.9, 0.875, 0.9, 1.0, 0.9166666666666666, 1.0, 0.9166666666666666, 0.875], [0.9, 0.125, 0.9, 0.875, 0.9166666666666666, 0.875, 0.9166666666666666, 0.125], [0.8666666666666667, 0.125, 0.8666666666666667, 0.875, 0.8833333333333333, 0.875, 0.8833333333333333, 0.125]],'shading_values':[[1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0]]}, {'name':'leftLeg','pivot':[0.125, 0.75, 0.0],'vertices':[[0.0625, 0.0, -0.0625, 0.0625, 0.75, -0.0625, 0.1875, 0.75, -0.0625, 0.1875, 0.0, -0.0625], [0.1875, 0.0, 0.0625, 0.1875, 0.75, 0.0625, 0.0625, 0.75, 0.0625, 0.0625, 0.0, 0.0625], [0.0625, 0.75, -0.0625, 0.0625, 0.75, 0.0625, 0.1875, 0.75, 0.0625, 0.1875, 0.75, -0.0625], [0.1875, 0.0, -0.0625, 0.1875, 0.0, 0.0625, 0.0625, 0.0, 0.0625, 0.0625, 0.0, -0.0625], [0.1875, 0.0, -0.0625, 0.1875, 0.75, -0.0625, 0.1875, 0.75, 0.0625, 0.1875, 0.0, 0.0625], [0.0625, 0.0, 0.0625, 0.0625, 0.75, 0.0625, 0.0625, 0.75, -0.0625, 0.0625, 0.0, -0.0625]],'tex_coords':[[0.95, 0.125, 0.95, 0.875, 0.9666666666666667, 0.875, 0.9666666666666667, 0.125], [0.9833333333333333, 0.125, 0.9833333333333333, 0.875, 1.0, 0.875, 1.0, 0.125], [0.95, 0.875, 0.95, 1.0, 0.9666666666666667, 1.0, 0.9666666666666667, 0.875], [0.9666666666666667, 0.875, 0.9666666666666667, 1.0, 0.9833333333333333, 1.0, 0.9833333333333333, 0.875], [0.9666666666666667, 0.125, 0.9666666666666667, 0.875, 0.9833333333333333, 0.875, 0.9833333333333333, 0.125], [0.9333333333333333, 0.125, 0.9333333333333333, 0.875, 0.95, 0.875, 0.95, 0.125]],'shading_values':[[1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0]]}] diff --git a/community/models/slab.py b/community/models/slab.py index 14eacc5d..794cc01e 100644 --- a/community/models/slab.py +++ b/community/models/slab.py @@ -1,4 +1,5 @@ -transparent = 2 +transparent = True +transparency = 2 is_cube = False glass = False translucent = False @@ -35,4 +36,4 @@ [0.4, 0.4, 0.4, 0.4], [0.8, 0.8, 0.8, 0.8], [0.8, 0.8, 0.8, 0.8], -] \ No newline at end of file +] diff --git a/community/models/snow.py b/community/models/snow.py index 12cff385..4a2bab4e 100644 --- a/community/models/snow.py +++ b/community/models/snow.py @@ -1,4 +1,5 @@ -transparent = 2 +transparent = True +transparency = 2 is_cube = False glass = False translucent = False @@ -23,4 +24,4 @@ shading_values = [ [1.0, 1.0, 1.0, 1.0], [0.4, 0.4, 0.4, 0.4], -] \ No newline at end of file +] diff --git a/community/models/soil.py b/community/models/soil.py index 90643cac..b54d522e 100644 --- a/community/models/soil.py +++ b/community/models/soil.py @@ -1,4 +1,5 @@ -transparent = 2 +transparent = True +transparency = 2 is_cube = False glass = False translucent = False @@ -35,4 +36,4 @@ [0.4, 0.4, 0.4, 0.4], [0.8, 0.8, 0.8, 0.8], [0.8, 0.8, 0.8, 0.8], -] \ No newline at end of file +] diff --git a/community/models/stairs.py b/community/models/stairs.py index 14eacc5d..794cc01e 100644 --- a/community/models/stairs.py +++ b/community/models/stairs.py @@ -1,4 +1,5 @@ -transparent = 2 +transparent = True +transparency = 2 is_cube = False glass = False translucent = False @@ -35,4 +36,4 @@ [0.4, 0.4, 0.4, 0.4], [0.8, 0.8, 0.8, 0.8], [0.8, 0.8, 0.8, 0.8], -] \ No newline at end of file +] diff --git a/community/models/tinted_glass.py b/community/models/tinted_glass.py index 1a7e14c3..c5b6daee 100644 --- a/community/models/tinted_glass.py +++ b/community/models/tinted_glass.py @@ -1,4 +1,5 @@ -transparent = 1 +transparent = True +transparency = 1 is_cube = True glass = True translucent = True @@ -35,4 +36,4 @@ [0.4, 0.4, 0.4, 0.4], [0.8, 0.8, 0.8, 0.8], [0.8, 0.8, 0.8, 0.8], -] \ No newline at end of file +] diff --git a/community/models/torch.py b/community/models/torch.py index 6b0482ff..37d47795 100644 --- a/community/models/torch.py +++ b/community/models/torch.py @@ -1,4 +1,5 @@ -transparent = 2 +transparent = True +transparency = 2 is_cube = False glass = False translucent = False diff --git a/community/models/zombie.py b/community/models/zombie.py new file mode 100644 index 00000000..d1650af9 --- /dev/null +++ b/community/models/zombie.py @@ -0,0 +1,8 @@ + +transparent = True +is_cube = False +glass = False + +colliders = [] + +bones = [{'name':'body','pivot':[0.0, 1.5, 0.0],'vertices':[[-0.25, 0.75, -0.125, -0.25, 1.5, -0.125, 0.25, 1.5, -0.125, 0.25, 0.75, -0.125], [0.25, 0.75, 0.125, 0.25, 1.5, 0.125, -0.25, 1.5, 0.125, -0.25, 0.75, 0.125], [-0.25, 1.5, -0.125, -0.25, 1.5, 0.125, 0.25, 1.5, 0.125, 0.25, 1.5, -0.125], [0.25, 0.75, -0.125, 0.25, 0.75, 0.125, -0.25, 0.75, 0.125, -0.25, 0.75, -0.125], [0.25, 0.75, -0.125, 0.25, 1.5, -0.125, 0.25, 1.5, 0.125, 0.25, 0.75, 0.125], [-0.25, 0.75, 0.125, -0.25, 1.5, 0.125, -0.25, 1.5, -0.125, -0.25, 0.75, -0.125]],'tex_coords':[[0.02631578947368421, 0.0, 0.02631578947368421, 0.75, 0.07894736842105263, 0.75, 0.07894736842105263, 0.0], [0.10526315789473684, 0.0, 0.10526315789473684, 0.75, 0.15789473684210525, 0.75, 0.15789473684210525, 0.0], [0.02631578947368421, 0.75, 0.02631578947368421, 1.0, 0.07894736842105263, 1.0, 0.07894736842105263, 0.75], [0.07894736842105263, 0.75, 0.07894736842105263, 1.0, 0.13157894736842105, 1.0, 0.13157894736842105, 0.75], [0.07894736842105263, 0.0, 0.07894736842105263, 0.75, 0.10526315789473684, 0.75, 0.10526315789473684, 0.0], [0.0, 0.0, 0.0, 0.75, 0.02631578947368421, 0.75, 0.02631578947368421, 0.0]],'shading_values':[[1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0]]}, {'name':'head','pivot':[0.0, 1.5, 0.0],'vertices':[[-0.25, 1.5, -0.25, -0.25, 2.0, -0.25, 0.25, 2.0, -0.25, 0.25, 1.5, -0.25], [0.25, 1.5, 0.25, 0.25, 2.0, 0.25, -0.25, 2.0, 0.25, -0.25, 1.5, 0.25], [-0.25, 2.0, -0.25, -0.25, 2.0, 0.25, 0.25, 2.0, 0.25, 0.25, 2.0, -0.25], [0.25, 1.5, -0.25, 0.25, 1.5, 0.25, -0.25, 1.5, 0.25, -0.25, 1.5, -0.25], [0.25, 1.5, -0.25, 0.25, 2.0, -0.25, 0.25, 2.0, 0.25, 0.25, 1.5, 0.25], [-0.25, 1.5, 0.25, -0.25, 2.0, 0.25, -0.25, 2.0, -0.25, -0.25, 1.5, -0.25]],'tex_coords':[[0.21052631578947367, 0.0, 0.21052631578947367, 0.5, 0.2631578947368421, 0.5, 0.2631578947368421, 0.0], [0.3157894736842105, 0.0, 0.3157894736842105, 0.5, 0.3684210526315789, 0.5, 0.3684210526315789, 0.0], [0.21052631578947367, 0.5, 0.21052631578947367, 1.0, 0.2631578947368421, 1.0, 0.2631578947368421, 0.5], [0.2631578947368421, 0.5, 0.2631578947368421, 1.0, 0.3157894736842105, 1.0, 0.3157894736842105, 0.5], [0.2631578947368421, 0.0, 0.2631578947368421, 0.5, 0.3157894736842105, 0.5, 0.3157894736842105, 0.0], [0.15789473684210525, 0.0, 0.15789473684210525, 0.5, 0.21052631578947367, 0.5, 0.21052631578947367, 0.0]],'shading_values':[[1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0]]}, {'name':'hat','pivot':[0.0, 1.5, 0.0],'vertices':[[-0.25, 1.5, -0.25, -0.25, 2.0, -0.25, 0.25, 2.0, -0.25, 0.25, 1.5, -0.25], [0.25, 1.5, 0.25, 0.25, 2.0, 0.25, -0.25, 2.0, 0.25, -0.25, 1.5, 0.25], [-0.25, 2.0, -0.25, -0.25, 2.0, 0.25, 0.25, 2.0, 0.25, 0.25, 2.0, -0.25], [0.25, 1.5, -0.25, 0.25, 1.5, 0.25, -0.25, 1.5, 0.25, -0.25, 1.5, -0.25], [0.25, 1.5, -0.25, 0.25, 2.0, -0.25, 0.25, 2.0, 0.25, 0.25, 1.5, 0.25], [-0.25, 1.5, 0.25, -0.25, 2.0, 0.25, -0.25, 2.0, -0.25, -0.25, 1.5, -0.25]],'tex_coords':[[0.42105263157894735, 0.0, 0.42105263157894735, 0.5, 0.47368421052631576, 0.5, 0.47368421052631576, 0.0], [0.5263157894736842, 0.0, 0.5263157894736842, 0.5, 0.5789473684210527, 0.5, 0.5789473684210527, 0.0], [0.42105263157894735, 0.5, 0.42105263157894735, 1.0, 0.47368421052631576, 1.0, 0.47368421052631576, 0.5], [0.47368421052631576, 0.5, 0.47368421052631576, 1.0, 0.5263157894736842, 1.0, 0.5263157894736842, 0.5], [0.47368421052631576, 0.0, 0.47368421052631576, 0.5, 0.5263157894736842, 0.5, 0.5263157894736842, 0.0], [0.3684210526315789, 0.0, 0.3684210526315789, 0.5, 0.42105263157894735, 0.5, 0.42105263157894735, 0.0]],'shading_values':[[1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0]]}, {'name':'rightArm','pivot':[-0.3125, 1.375, 0.0],'vertices':[[-0.5, 0.75, -0.125, -0.5, 1.5, -0.125, -0.25, 1.5, -0.125, -0.25, 0.75, -0.125], [-0.25, 0.75, 0.125, -0.25, 1.5, 0.125, -0.5, 1.5, 0.125, -0.5, 0.75, 0.125], [-0.5, 1.5, -0.125, -0.5, 1.5, 0.125, -0.25, 1.5, 0.125, -0.25, 1.5, -0.125], [-0.25, 0.75, -0.125, -0.25, 0.75, 0.125, -0.5, 0.75, 0.125, -0.5, 0.75, -0.125], [-0.25, 0.75, -0.125, -0.25, 1.5, -0.125, -0.25, 1.5, 0.125, -0.25, 0.75, 0.125], [-0.5, 0.75, 0.125, -0.5, 1.5, 0.125, -0.5, 1.5, -0.125, -0.5, 0.75, -0.125]],'tex_coords':[[0.6052631578947368, 0.0, 0.6052631578947368, 0.75, 0.631578947368421, 0.75, 0.631578947368421, 0.0], [0.6578947368421053, 0.0, 0.6578947368421053, 0.75, 0.6842105263157895, 0.75, 0.6842105263157895, 0.0], [0.6052631578947368, 0.75, 0.6052631578947368, 1.0, 0.631578947368421, 1.0, 0.631578947368421, 0.75], [0.631578947368421, 0.75, 0.631578947368421, 1.0, 0.6578947368421053, 1.0, 0.6578947368421053, 0.75], [0.631578947368421, 0.0, 0.631578947368421, 0.75, 0.6578947368421053, 0.75, 0.6578947368421053, 0.0], [0.5789473684210527, 0.0, 0.5789473684210527, 0.75, 0.6052631578947368, 0.75, 0.6052631578947368, 0.0]],'shading_values':[[1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0]]}, {'name':'leftArm','pivot':[0.3125, 1.375, 0.0],'vertices':[[0.25, 0.75, -0.125, 0.25, 1.5, -0.125, 0.5, 1.5, -0.125, 0.5, 0.75, -0.125], [0.5, 0.75, 0.125, 0.5, 1.5, 0.125, 0.25, 1.5, 0.125, 0.25, 0.75, 0.125], [0.25, 1.5, -0.125, 0.25, 1.5, 0.125, 0.5, 1.5, 0.125, 0.5, 1.5, -0.125], [0.5, 0.75, -0.125, 0.5, 0.75, 0.125, 0.25, 0.75, 0.125, 0.25, 0.75, -0.125], [0.5, 0.75, -0.125, 0.5, 1.5, -0.125, 0.5, 1.5, 0.125, 0.5, 0.75, 0.125], [0.25, 0.75, 0.125, 0.25, 1.5, 0.125, 0.25, 1.5, -0.125, 0.25, 0.75, -0.125]],'tex_coords':[[0.7105263157894737, 0.0, 0.7105263157894737, 0.75, 0.7368421052631579, 0.75, 0.7368421052631579, 0.0], [0.7631578947368421, 0.0, 0.7631578947368421, 0.75, 0.7894736842105263, 0.75, 0.7894736842105263, 0.0], [0.7105263157894737, 0.75, 0.7105263157894737, 1.0, 0.7368421052631579, 1.0, 0.7368421052631579, 0.75], [0.7368421052631579, 0.75, 0.7368421052631579, 1.0, 0.7631578947368421, 1.0, 0.7631578947368421, 0.75], [0.7368421052631579, 0.0, 0.7368421052631579, 0.75, 0.7631578947368421, 0.75, 0.7631578947368421, 0.0], [0.6842105263157895, 0.0, 0.6842105263157895, 0.75, 0.7105263157894737, 0.75, 0.7105263157894737, 0.0]],'shading_values':[[1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0]]}, {'name':'rightLeg','pivot':[-0.11875, 0.75, 0.0],'vertices':[[-0.24375000596046448, 0.0, -0.125, -0.24375000596046448, 0.75, -0.125, 0.0062500000931322575, 0.75, -0.125, 0.0062500000931322575, 0.0, -0.125], [0.0062500000931322575, 0.0, 0.125, 0.0062500000931322575, 0.75, 0.125, -0.24375000596046448, 0.75, 0.125, -0.24375000596046448, 0.0, 0.125], [-0.24375000596046448, 0.75, -0.125, -0.24375000596046448, 0.75, 0.125, 0.0062500000931322575, 0.75, 0.125, 0.0062500000931322575, 0.75, -0.125], [0.0062500000931322575, 0.0, -0.125, 0.0062500000931322575, 0.0, 0.125, -0.24375000596046448, 0.0, 0.125, -0.24375000596046448, 0.0, -0.125], [0.0062500000931322575, 0.0, -0.125, 0.0062500000931322575, 0.75, -0.125, 0.0062500000931322575, 0.75, 0.125, 0.0062500000931322575, 0.0, 0.125], [-0.24375000596046448, 0.0, 0.125, -0.24375000596046448, 0.75, 0.125, -0.24375000596046448, 0.75, -0.125, -0.24375000596046448, 0.0, -0.125]],'tex_coords':[[0.8157894736842105, 0.0, 0.8157894736842105, 0.75, 0.8421052631578947, 0.75, 0.8421052631578947, 0.0], [0.868421052631579, 0.0, 0.868421052631579, 0.75, 0.8947368421052632, 0.75, 0.8947368421052632, 0.0], [0.8157894736842105, 0.75, 0.8157894736842105, 1.0, 0.8421052631578947, 1.0, 0.8421052631578947, 0.75], [0.8421052631578947, 0.75, 0.8421052631578947, 1.0, 0.868421052631579, 1.0, 0.868421052631579, 0.75], [0.8421052631578947, 0.0, 0.8421052631578947, 0.75, 0.868421052631579, 0.75, 0.868421052631579, 0.0], [0.7894736842105263, 0.0, 0.7894736842105263, 0.75, 0.8157894736842105, 0.75, 0.8157894736842105, 0.0]],'shading_values':[[1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0]]}, {'name':'leftLeg','pivot':[0.11875, 0.75, 0.0],'vertices':[[-0.0062500000931322575, 0.0, -0.125, -0.0062500000931322575, 0.75, -0.125, 0.24375000596046448, 0.75, -0.125, 0.24375000596046448, 0.0, -0.125], [0.24375000596046448, 0.0, 0.125, 0.24375000596046448, 0.75, 0.125, -0.0062500000931322575, 0.75, 0.125, -0.0062500000931322575, 0.0, 0.125], [-0.0062500000931322575, 0.75, -0.125, -0.0062500000931322575, 0.75, 0.125, 0.24375000596046448, 0.75, 0.125, 0.24375000596046448, 0.75, -0.125], [0.24375000596046448, 0.0, -0.125, 0.24375000596046448, 0.0, 0.125, -0.0062500000931322575, 0.0, 0.125, -0.0062500000931322575, 0.0, -0.125], [0.24375000596046448, 0.0, -0.125, 0.24375000596046448, 0.75, -0.125, 0.24375000596046448, 0.75, 0.125, 0.24375000596046448, 0.0, 0.125], [-0.0062500000931322575, 0.0, 0.125, -0.0062500000931322575, 0.75, 0.125, -0.0062500000931322575, 0.75, -0.125, -0.0062500000931322575, 0.0, -0.125]],'tex_coords':[[0.9210526315789473, 0.0, 0.9210526315789473, 0.75, 0.9473684210526315, 0.75, 0.9473684210526315, 0.0], [0.9736842105263158, 0.0, 0.9736842105263158, 0.75, 1.0, 0.75, 1.0, 0.0], [0.9210526315789473, 0.75, 0.9210526315789473, 1.0, 0.9473684210526315, 1.0, 0.9473684210526315, 0.75], [0.9473684210526315, 0.75, 0.9473684210526315, 1.0, 0.9736842105263158, 1.0, 0.9736842105263158, 0.75], [0.9473684210526315, 0.0, 0.9473684210526315, 0.75, 0.9736842105263158, 0.75, 0.9736842105263158, 0.0], [0.8947368421052632, 0.0, 0.8947368421052632, 0.75, 0.9210526315789473, 0.75, 0.9210526315789473, 0.0]],'shading_values':[[1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0]]}] diff --git a/community/options.py b/community/options.py index deed5e31..2dbc6fdf 100644 --- a/community/options.py +++ b/community/options.py @@ -29,6 +29,7 @@ # Higher values gives higher framerate but causes framerate instability and higher frame spikes # Lower values causes average lower framerate but gives smoother framerate # Recommended values are between 0 and 9 + # Usually 3 - 4 in most rendering scenarios # Legacy Smooth FPS SMOOTH_FPS = False # Legacy way to force the flushing of command buffer and forces the CPU to wait for the GPU to finish rendering. @@ -40,8 +41,8 @@ # Ambient Occlusion and Smooth Lighting SMOOTH_LIGHTING = True # Smooth Lighting smoothes the light of each vertex to achieve a linear interpolation # of light on each fragment, hence creating a smoother light effect - # It also adds ambient occlusion, to simulate light blocked by opaqua objects - # Chunk updates / building will be severely affecteds by this feature + # It also adds ambient occlusion, to simulate light blocked by opaque objects + # Chunk updates / building will be severely affected by this feature # Better Translucency blending FANCY_TRANSLUCENCY = True diff --git a/community/player.py b/community/player.py index 3e27c02d..f9fd1e58 100644 --- a/community/player.py +++ b/community/player.py @@ -3,6 +3,8 @@ import glm import options import chunk +from enum import IntEnum +import collider WALKING_SPEED = 4.317 SPRINTING_SPEED = 7 # faster than in Minecraft, feels better @@ -15,32 +17,24 @@ class Frustum: near = glm.vec4(1.0) far = glm.vec4(1.0) +class FrustumCheckResult(IntEnum): + OUTSIDE = 0 + INTERSECTS = 1 + INSIDE = 2 + def normalize(plane): return plane / glm.length(plane.xyz) - class Player(entity.Entity): - def __init__(self, world, shader, width, height): - super().__init__(world) + def __init__(self, world, width, height): + super().__init__(world, world.entity_types["Player"]) self.view_width = width self.view_height = height - # create matrices - - self.mv_matrix = glm.mat4() - self.p_matrix = glm.mat4() - - # shaders - - self.shader = shader - - self.mvp_matrix_location = self.shader.find_uniform(b"u_MVPMatrix") - - # camera variables - self.eyelevel = self.height - 0.2 + self.eyelevel = self.entity_type.height - 0.2 self.input = [0, 0, 0] self.target_speed = WALKING_SPEED @@ -53,7 +47,7 @@ def __init__(self, world, shader, width, height): def update(self, delta_time): # process input - self.view_ray = glm.vec3(glm.cos(self.rotation[0]) * glm.cos(self.rotation[1]), + self.view_ray = glm.vec3(glm.cos(self.rotation[0]) * glm.cos(self.rotation[1]), glm.sin(self.rotation[1]), glm.sin(self.rotation[0]) * glm.cos(self.rotation[1])) @@ -82,98 +76,82 @@ def update(self, delta_time): super().update(delta_time) self.rounded_position = [round(i) for i in self.position] - + def update_interpolation(self, delta_time): self.interpolated_position = glm.mix(glm.vec3(self.position), glm.vec3(self.old_position), self.step) self.step -= delta_time - def update_frustum(self, mat): - mat = glm.transpose(mat) - for i in range(4): + def update_frustum(self): + mat = glm.transpose(self.world.mvp_matrix) + for i in range(4): Frustum.left[i] = mat[3][i] + mat[0][i] Frustum.right[i] = mat[3][i] - mat[0][i] Frustum.bottom[i] = mat[3][i] + mat[1][i] Frustum.top[i] = mat[3][i] - mat[1][i] Frustum.near[i] = mat[3][i] + mat[2][i] Frustum.far[i] = mat[3][i] - mat[2][i] - + Frustum.left = normalize(Frustum.left) Frustum.right = normalize(Frustum.right) Frustum.bottom = normalize(Frustum.bottom) Frustum.top = normalize(Frustum.top) Frustum.near = normalize(Frustum.near) Frustum.far = normalize(Frustum.far) - - def check_in_frustum(self, chunk_pos): - """Frustum check of each chunk. If the chunk is not in the view frustum, it is discarded""" - planes = (Frustum.left, Frustum.right, Frustum.bottom, Frustum.top, Frustum.near, Frustum.far) - result = 2 - center = glm.vec3(chunk_pos * glm.ivec3(chunk.CHUNK_WIDTH, 0, chunk.CHUNK_LENGTH) - + glm.ivec3(chunk.CHUNK_WIDTH / 2, - chunk.CHUNK_HEIGHT / 2, - chunk.CHUNK_LENGTH / 2)) + def check_in_frustum(self, collider): + # Frustum check for AABB boxes + + if (collider.x1 is None or collider.y1 is None or collider.z1 is None or + collider.x2 is None or collider.y2 is None or collider.z2 is None): + + return 0 + + planes = (Frustum.left, Frustum.right, Frustum.bottom, Frustum.top, Frustum.near, Frustum.far) + result = FrustumCheckResult.INSIDE for plane in planes: - _in = 0 - _out = 0 - normal = plane.xyz - w = plane.w - if glm.dot(normal, center + glm.vec3(chunk.CHUNK_WIDTH / 2, chunk.CHUNK_HEIGHT / 2, chunk.CHUNK_LENGTH / 2)) + w < 0: - _out += 1 - else: - _in += 1 - if glm.dot(normal, center + glm.vec3(-chunk.CHUNK_WIDTH / 2, chunk.CHUNK_HEIGHT / 2, chunk.CHUNK_LENGTH / 2)) + w < 0: - _out += 1 - else: - _in += 1 - if glm.dot(normal, center + glm.vec3(chunk.CHUNK_WIDTH / 2, chunk.CHUNK_HEIGHT / 2, -chunk.CHUNK_LENGTH / 2)) + w < 0: - _out += 1 - else: - _in += 1 - if glm.dot(normal, center + glm.vec3(-chunk.CHUNK_WIDTH / 2, chunk.CHUNK_HEIGHT / 2, -chunk.CHUNK_LENGTH / 2)) + w < 0: - _out += 1 - else: - _in += 1 - if glm.dot(normal, center + glm.vec3(chunk.CHUNK_WIDTH / 2, -chunk.CHUNK_HEIGHT / 2, chunk.CHUNK_LENGTH / 2)) + w < 0: - _out += 1 - else: - _in += 1 - if glm.dot(normal, center + glm.vec3(-chunk.CHUNK_WIDTH / 2, -chunk.CHUNK_HEIGHT / 2, chunk.CHUNK_LENGTH / 2)) + w < 0: - _out += 1 - else: - _in += 1 - if glm.dot(normal, center + glm.vec3(chunk.CHUNK_WIDTH / 2, -chunk.CHUNK_HEIGHT / 2, -chunk.CHUNK_LENGTH / 2)) + w < 0: - _out += 1 - else: - _in += 1 - if glm.dot(normal, center + glm.vec3(-chunk.CHUNK_WIDTH / 2, -chunk.CHUNK_HEIGHT / 2, -chunk.CHUNK_LENGTH / 2)) + w < 0: - _out += 1 - else: - _in += 1 - - if not _in: - return 0 - elif _out: - result = 1 + out = map( + lambda v: glm.dot(plane.xyz, v) < -plane.w, + [ + glm.vec3(collider.x1, collider.y1, collider.z1), + glm.vec3(collider.x2, collider.y1, collider.z1), + glm.vec3(collider.x2, collider.y2, collider.z1), + glm.vec3(collider.x1, collider.y2, collider.z1), + glm.vec3(collider.x1, collider.y2, collider.z2), + glm.vec3(collider.x1, collider.y1, collider.z2), + glm.vec3(collider.x2, collider.y1, collider.z2), + glm.vec3(collider.x2, collider.y2, collider.z2) + ] + ) + if all(out): + return FrustumCheckResult.OUTSIDE + if any(out): + result = FrustumCheckResult.INTERSECTS return result + def check_chunk_in_frustum(self, chunk_pos): + chunk_collider = collider.Collider( + chunk_pos * glm.ivec3(chunk.CHUNK_WIDTH, 0, chunk.CHUNK_LENGTH), + chunk_pos * glm.ivec3(chunk.CHUNK_WIDTH, 0, chunk.CHUNK_LENGTH) + glm.ivec3(chunk.CHUNK_WIDTH, chunk.CHUNK_HEIGHT, chunk.CHUNK_LENGTH) + ) + return self.check_in_frustum(chunk_collider) + def update_matrices(self): # create projection matrix - - self.p_matrix = glm.perspective( + + self.world.p_matrix = glm.perspective( glm.radians(options.FOV + 10 * (self.speed - WALKING_SPEED) / (SPRINTING_SPEED - WALKING_SPEED)), float(self.view_width) / self.view_height, 0.1, 500) # create modelview matrix - self.mv_matrix = glm.mat4(1.0) - self.mv_matrix = glm.rotate(self.mv_matrix, self.rotation[1], -glm.vec3(1.0, 0.0, 0.0)) - self.mv_matrix = glm.rotate(self.mv_matrix, self.rotation[0] + math.tau / 4, glm.vec3(0.0, 1.0, 0.0)) + self.world.mv_matrix = glm.mat4(1.0) + self.world.mv_matrix = glm.rotate(self.world.mv_matrix, self.rotation[1], -glm.vec3(1.0, 0.0, 0.0)) + self.world.mv_matrix = glm.rotate(self.world.mv_matrix, self.rotation[0] + math.tau / 4, glm.vec3(0.0, 1.0, 0.0)) - self.mv_matrix = glm.translate(self.mv_matrix, -glm.vec3(*self.interpolated_position) - glm.vec3(0, self.eyelevel, 0)) + self.world.mv_matrix = glm.translate(self.world.mv_matrix, -self.interpolated_position - glm.vec3(0, self.eyelevel, 0)) # modelviewprojection matrix - self.shader.uniform_matrix(self.mvp_matrix_location, self.p_matrix * self.mv_matrix) - self.update_frustum(self.p_matrix * self.mv_matrix) \ No newline at end of file + self.world.mvp_matrix = self.world.p_matrix * self.world.mv_matrix + self.update_frustum() diff --git a/community/save.py b/community/save.py index 3483accb..52b4c63f 100644 --- a/community/save.py +++ b/community/save.py @@ -9,25 +9,25 @@ class Save: def __init__(self, world, path = "save"): self.world = world self.path = path - + def chunk_position_to_path(self, chunk_position): x, _, z = chunk_position chunk_path = '/'.join((self.path, base36.dumps(x % 64), base36.dumps(z % 64), f"c.{base36.dumps(x)}.{base36.dumps(z)}.dat")) - + return chunk_path def load_chunk(self, chunk_position): logging.debug(f"Loading chunk at position {chunk_position}") # load the chunk file - + chunk_path = self.chunk_position_to_path(chunk_position) try: chunk_blocks = nbt.load(chunk_path)["Level"]["Blocks"] - + except FileNotFoundError: return @@ -46,7 +46,7 @@ def load_chunk(self, chunk_position): def save_chunk(self, chunk_position): logging.debug(f"Saving chunk at position {chunk_position}") x, y, z = chunk_position - + # try to load the chunk file # if it doesn't exist, create a new one @@ -54,10 +54,10 @@ def save_chunk(self, chunk_position): try: chunk_data = nbt.load(chunk_path) - + except FileNotFoundError: chunk_data = nbt.File({"": nbt.Compound({"Level": nbt.Compound()})}) - + chunk_data["Level"]["xPos"] = x chunk_data["Level"]["zPos"] = z @@ -72,7 +72,7 @@ def save_chunk(self, chunk_position): x * chunk.CHUNK_LENGTH * chunk.CHUNK_HEIGHT + z * chunk.CHUNK_HEIGHT + y] = self.world.chunks[chunk_position].blocks[x][y][z] - + # save the chunk file chunk_data["Level"]["Blocks"] = chunk_blocks @@ -89,9 +89,9 @@ def load(self): for y in range(-4, 4): self.load_chunk((x, 0, y)) - # for x in range(-1, 1): - # for y in range(-1, 1): - # self.load_chunk((x, 0, y)) + for x in range(-1, 1): + for y in range(-1, 1): + self.load_chunk((x, 0, y)) for chunk_position, unlit_chunk in self.world.chunks.items(): for x in range(chunk.CHUNK_WIDTH): @@ -110,7 +110,7 @@ def save(self): for chunk_position in self.world.chunks: if chunk_position[1] != 0: # reject all chunks above and below the world limit continue - + chunk = self.world.chunks[chunk_position] if chunk.modified: diff --git a/community/shader.py b/community/shader.py index 1d571aa5..134e2e77 100644 --- a/community/shader.py +++ b/community/shader.py @@ -12,7 +12,7 @@ def create_shader(target, source_path): with open(source_path, "rb") as source_file: source = source_file.read() - + source_length = ctypes.c_int(len(source) + 1) source_buffer = ctypes.create_string_buffer(source) @@ -20,7 +20,7 @@ def create_shader(target, source_path): buffer_pointer = ctypes.cast( ctypes.pointer(ctypes.pointer(source_buffer)), ctypes.POINTER(ctypes.POINTER(ctypes.c_char))) - + # compile shader gl.glShaderSource(target, 1, buffer_pointer, ctypes.byref(source_length)) @@ -59,16 +59,19 @@ def __init__(self, vert_path, frag_path): gl.glDeleteShader(self.vert_shader) gl.glDeleteShader(self.frag_shader) - + def __del__(self): gl.glDeleteProgram(self.program) def find_uniform(self, name): return gl.glGetUniformLocation(self.program, ctypes.create_string_buffer(name)) - + def uniform_matrix(self, location, matrix): gl.glUniformMatrix4fv(location, 1, gl.GL_FALSE, glm.value_ptr(matrix)) + def uniform_float(self, location, value): + gl.glUniform1f(location, value) + def use(self): gl.glUseProgram(self.program) diff --git a/community/shaders/entity/frag.glsl b/community/shaders/entity/frag.glsl new file mode 100644 index 00000000..1c87c427 --- /dev/null +++ b/community/shaders/entity/frag.glsl @@ -0,0 +1,18 @@ +#version 330 + +out vec4 fragment_colour; + +uniform sampler2D texture_sampler; + +in vec3 local_position; +in vec3 interpolated_tex_coords; +in float shading; + +void main(void) { + vec4 texture_colour = texture(texture_sampler, interpolated_tex_coords.xy); + fragment_colour = texture_colour * shading; + + if (texture_colour.a == 0.0) { // discard if texel's alpha component is 0 (texel is transparent) + discard; + } +} diff --git a/community/shaders/entity/vert.glsl b/community/shaders/entity/vert.glsl new file mode 100644 index 00000000..b3339810 --- /dev/null +++ b/community/shaders/entity/vert.glsl @@ -0,0 +1,29 @@ +#version 330 + +layout(location = 0) in vec3 vertex_position; +layout(location = 1) in vec3 normal; +layout(location = 2) in vec3 tex_coords; + +out vec3 local_position; +out vec3 interpolated_tex_coords; +out float shading; + +uniform mat4 inverse_transform_matrix; +uniform mat4 matrix; +uniform float lighting; + +void main(void) { + local_position = vertex_position; + + interpolated_tex_coords = tex_coords; + + vec3 transformed_normal = (vec4(normal, 1.0) * inverse_transform_matrix).xyz; + vec3 sunlight = vec3(0.0, 2.0, 1.0); + + vec3 xz_absolute_normal = vec3(abs(transformed_normal.x), transformed_normal.y, abs(transformed_normal.z)); + float facing = dot(normalize(xz_absolute_normal), normalize(sunlight)); + + shading = max(0.4, (1. + facing) / 2) * lighting; + + gl_Position = matrix * vec4(vertex_position, 1.0); +} diff --git a/community/textures/cow.png b/community/textures/cow.png new file mode 100644 index 00000000..f5ebec71 Binary files /dev/null and b/community/textures/cow.png differ diff --git a/community/textures/creeper.png b/community/textures/creeper.png new file mode 100644 index 00000000..25015dff Binary files /dev/null and b/community/textures/creeper.png differ diff --git a/community/textures/curry.png b/community/textures/curry.png new file mode 100644 index 00000000..3991d0fd Binary files /dev/null and b/community/textures/curry.png differ diff --git a/community/textures/pig.png b/community/textures/pig.png new file mode 100644 index 00000000..e3e7fdcb Binary files /dev/null and b/community/textures/pig.png differ diff --git a/community/textures/skeleton.png b/community/textures/skeleton.png new file mode 100644 index 00000000..7e3f0957 Binary files /dev/null and b/community/textures/skeleton.png differ diff --git a/community/textures/zombie.png b/community/textures/zombie.png new file mode 100644 index 00000000..81ec3d12 Binary files /dev/null and b/community/textures/zombie.png differ diff --git a/community/world.py b/community/world.py index f9b2b8f1..104dff86 100644 --- a/community/world.py +++ b/community/world.py @@ -1,5 +1,4 @@ import chunk -import subchunk import ctypes import math import logging @@ -12,8 +11,13 @@ import pyglet.gl as gl import block_type +import entity_type + import models + +import shader import save + from util import DIRECTIONS def get_chunk_position(position): @@ -24,45 +28,39 @@ def get_chunk_position(position): (y // chunk.CHUNK_HEIGHT), (z // chunk.CHUNK_LENGTH)) - def get_local_position(position): x, y, z = position - + return glm.ivec3( int(x % chunk.CHUNK_WIDTH), int(y % chunk.CHUNK_HEIGHT), int(z % chunk.CHUNK_LENGTH)) - class World: - def __init__(self, shader, player, texture_manager, options): + def __init__(self, player, texture_manager, options): self.options = options - self.shader = shader self.player = player self.texture_manager = texture_manager self.block_types = [None] + self.entity_types = {} - self.shader_daylight_location = shader.find_uniform(b"u_Daylight") self.daylight = 1800 self.incrementer = 0 self.time = 0 - self.c = 0 - + # Compat self.get_chunk_position = get_chunk_position self.get_local_position = get_local_position # parse block type data file - blocks_data_file = open("data/blocks.mcpy") - blocks_data = blocks_data_file.readlines() - blocks_data_file.close() + with open("data/blocks.mcpy") as f: + blocks_data = f.readlines() - logging.info("Loading block models") for block in blocks_data: if block[0] in ['\n', '#']: # skip if empty line or comment continue - + number, props = block.split(':', 1) number = int(number) @@ -84,31 +82,74 @@ def __init__(self, shader, player, texture_manager, options): name = self.block_types[sameas_number].name texture = self.block_types[sameas_number].block_face_textures model = self.block_types[sameas_number].model - + elif prop[0] == "name": name = eval(prop[1]) - + elif prop[0][:7] == "texture": _, side = prop[0].split('.') texture[side] = prop[1].strip() elif prop[0] == "model": model = eval(prop[1]) - + # add block type _block_type = block_type.Block_type(self.texture_manager, name, texture, model) if number < len(self.block_types): self.block_types[number] = _block_type - + else: self.block_types.append(_block_type) + self.texture_manager.generate_mipmaps() + self.light_blocks = [10, 11, 50, 51, 62, 75] - self.texture_manager.generate_mipmaps() + # parse entity type data file + + with open("data/entities.mcpy") as f: + entities_data = f.readlines() + + for _entity in entities_data: + if _entity[0] in "\n#": # skip if empty line or comment + continue + + name, props = _entity.split(':', 1) + + # default entity + + model = models.pig + texture = "pig" + + width = 0.6 + height = 1.8 + + # read properties + + for prop in props.split(','): + prop = prop.strip() + *prop, = filter(None, prop.split(' ', 1)) + + if prop[0] == "width": + width = float(prop[1]) + + elif prop[0] == "height": + height = float(prop[1]) + elif prop[0] == "texture": + texture = prop[1] + + elif prop[0] == "model": + model = eval(prop[1]) + + # add entity type + + self.entity_types[name] = entity_type.Entity_type(self, name, texture, model, width, height) + + gl.glBindVertexArray(0) + indices = [] for nquad in range(chunk.CHUNK_WIDTH * chunk.CHUNK_HEIGHT * chunk.CHUNK_LENGTH * 8): @@ -119,6 +160,7 @@ def __init__(self, shader, player, texture_manager, options): indices.append(4 * nquad + 3) indices.append(4 * nquad + 0) + gl.glBindVertexArray(0) self.ibo = gl.GLuint(0) gl.glGenBuffers(1, self.ibo) @@ -132,6 +174,31 @@ def __init__(self, shader, player, texture_manager, options): logging.debug("Created Shared Index Buffer") + # matrices + + self.mv_matrix = glm.mat4() + self.p_matrix = glm.mat4() + self.mvp_matrix = glm.mat4() + + # shaders + + lighting_shader = "alpha_lighting" + + if options.COLORED_LIGHTING: + lighting_shader = "colored_lighting" + + self.block_shader = shader.Shader(f"shaders/{lighting_shader}/vert.glsl", f"shaders/{lighting_shader}/frag.glsl") + self.block_shader_sampler_location = self.block_shader.find_uniform(b"u_TextureArraySampler") + self.block_shader_matrix_location = self.block_shader.find_uniform(b"u_MVPMatrix") + self.block_shader_daylight_location = self.block_shader.find_uniform(b"u_Daylight") + self.block_shader_chunk_offset_location = self.block_shader.find_uniform(b"u_ChunkPosition") + + self.entity_shader = shader.Shader("shaders/entity/vert.glsl", "shaders/entity/frag.glsl") + self.entity_shader_sampler_location = self.entity_shader.find_uniform(b"texture_sampler") + self.entity_shader_inverse_transform_matrix_location = self.entity_shader.find_uniform(b"inverse_transform_matrix") + self.entity_shader_matrix_location = self.entity_shader.find_uniform(b"matrix") + self.entity_shader_lighting_location = self.entity_shader.find_uniform(b"lighting") + # load the world self.save = save.Save(self) @@ -139,6 +206,8 @@ def __init__(self, shader, player, texture_manager, options): self.chunks = {} self.sorted_chunks = [] + self.entities = [] + # light update queue self.light_increase_queue = deque() # Node: World Position, light @@ -148,7 +217,7 @@ def __init__(self, shader, player, texture_manager, options): self.chunk_building_queue = deque() self.save.load() - + logging.info("Lighting chunks") for world_chunk in self.chunks.values(): self.init_skylight(world_chunk) @@ -164,14 +233,13 @@ def __init__(self, shader, player, texture_manager, options): self.pending_chunk_update_count = 0 self.chunk_update_counter = 0 + self.visible_entities = 0 def __del__(self): gl.glDeleteBuffers(1, ctypes.byref(self.ibo)) ################ LIGHTING ENGINE ################ - - def increase_light(self, world_pos, newlight, light_update=True): chunk = self.chunks[get_chunk_position(world_pos)] local_pos = get_local_position(world_pos) @@ -182,16 +250,15 @@ def increase_light(self, world_pos, newlight, light_update=True): self.propagate_increase(light_update) - def propagate_increase(self, light_update): """Starts propagating all queued block light increases This algorithm is derived from the Seed of Andromeda's tutorial It uses a FIFO queue to queue the pending blocks to light - It then checks its 6 neighbours and propagate light to one of them if the latter's light level + It then checks its 6 neighbours and propagate light to one of them if the latter's light level is lower than the former one""" while self.light_increase_queue: - pos, light_level = self.light_increase_queue.popleft() + pos, light_level = self.light_increase_queue.popleft() for direction in DIRECTIONS: neighbour_pos = pos + direction @@ -209,7 +276,7 @@ def propagate_increase(self, light_update): chunk.update_at_position(neighbour_pos) def init_skylight(self, pending_chunk): - """ Initializes the skylight of each chunks + """Initializes the skylight of each chunks To avoid unsufferable lag from propagating from the top of the chunks when most of the heights would be air, it instead runs a simple algorithm to check where the highest point of the chunk is and propagates skylight from @@ -240,9 +307,9 @@ def init_skylight(self, pending_chunk): self.skylight_increase_queue.append((pos, 15)) self.propagate_skylight_increase(False) - + def propagate_skylight_increase(self, light_update): - """Similar to the block light algorithm, but + """Similar to the block light algorithm, but do not lower the light level in the downward direction""" while self.skylight_increase_queue: pos, light_level = self.skylight_increase_queue.popleft() @@ -270,24 +337,22 @@ def propagate_skylight_increase(self, light_update): elif _chunk.get_sky_light(local_pos) + 2 <= light_level: _chunk.set_sky_light(local_pos, newlight - 1) self.skylight_increase_queue.append((neighbour_pos, newlight - 1)) - - + def decrease_light(self, world_pos): chunk = self.chunks[get_chunk_position(world_pos)] local_pos = get_local_position(world_pos) old_light = chunk.get_block_light(local_pos) chunk.set_block_light(local_pos, 0) self.light_decrease_queue.append((world_pos, old_light)) - + self.propagate_decrease(True) self.propagate_increase(True) - def propagate_decrease(self, light_update): """Starts propagating all queued block light decreases This algorithm is derived from the Seed of Andromeda's tutorial It uses a FIFO queue to queue the pending blocks to unlight - It then checks its 6 neighbours and unlight to one of them if the latter's light level + It then checks its 6 neighbours and unlight to one of them if the latter's light level is lower than the former one""" while self.light_decrease_queue: @@ -316,21 +381,20 @@ def propagate_decrease(self, light_update): elif neighbour_level >= light_level: self.light_increase_queue.append((neighbour_pos, neighbour_level)) - def decrease_skylight(self, world_pos, light_update=True): chunk = self.chunks[get_chunk_position(world_pos)] local_pos = get_local_position(world_pos) old_light = chunk.get_sky_light(local_pos) chunk.set_sky_light(local_pos, 0) self.skylight_decrease_queue.append((world_pos, old_light)) - + self.propagate_skylight_decrease(light_update) self.propagate_skylight_increase(light_update) - def propagate_skylight_decrease(self, light_update=True): - """Similar to the block light algorithm, but + """Similar to the block light algorithm, but always unlight in the downward direction""" + while self.skylight_decrease_queue: pos, light_level = self.skylight_decrease_queue.popleft() @@ -353,8 +417,8 @@ def propagate_skylight_decrease(self, light_update=True): elif neighbour_level >= light_level: self.skylight_increase_queue.append((neighbour_pos, neighbour_level)) - # Getter and setters - + # Getters and setters + def get_raw_light(self, position): chunk = self.chunks.get(get_chunk_position(position), None) if not chunk: @@ -362,15 +426,13 @@ def get_raw_light(self, position): local_position = self.get_local_position(position) return chunk.get_raw_light(local_position) - def get_light(self, position): chunk = self.chunks.get(get_chunk_position(position), None) if not chunk: return 0 local_position = self.get_local_position(position) return chunk.get_block_light(local_position) - - + def get_skylight(self, position): chunk = self.chunks.get(get_chunk_position(position), None) if not chunk: @@ -378,13 +440,11 @@ def get_skylight(self, position): local_position = self.get_local_position(position) return chunk.get_sky_light(local_position) - def set_light(self, position, light): chunk = self.chunks.get(get_chunk_position(position), None) local_position = get_local_position(position) chunk.set_block_light(local_position, light) - def set_skylight(self, position, light): chunk = self.chunks.get(get_chunk_position(position), None) local_position = get_local_position(position) @@ -392,43 +452,40 @@ def set_skylight(self, position, light): ################################################# - def get_block_number(self, position): chunk_position = get_chunk_position(position) if not chunk_position in self.chunks: return 0 - + lx, ly, lz = get_local_position(position) block_number = self.chunks[chunk_position].blocks[lx][ly][lz] return block_number - def get_transparency(self, position): block_type = self.block_types[self.get_block_number(position)] if not block_type: return 2 - - return block_type.transparent - + return block_type.transparency + def is_opaque_block(self, position): # get block type and check if it's opaque or not # air counts as a transparent block, so test for that too - + block_type = self.block_types[self.get_block_number(position)] - + if not block_type: return False - + return not block_type.transparent - + def create_chunk(self, chunk_position): self.chunks[chunk_position] = chunk.Chunk(self, chunk_position) self.init_skylight(self.chunks[chunk_position]) - + def set_block(self, position, number): # set number to 0 (air) to remove block x, y, z = position chunk_position = get_chunk_position(position) @@ -439,10 +496,10 @@ def set_block(self, position, number): # set number to 0 (air) to remove block self.create_chunk(chunk_position) - + if self.get_block_number(position) == number: # no point updating mesh if the block is the same return - + lx, ly, lz = get_local_position(position) self.chunks[chunk_position].blocks[lx][ly][lz] = number @@ -457,7 +514,7 @@ def set_block(self, position, number): # set number to 0 (air) to remove block elif self.block_types[number].transparent != 2: self.decrease_light(position) self.decrease_skylight(position) - + elif not number: self.decrease_light(position) self.decrease_skylight(position) @@ -467,7 +524,7 @@ def set_block(self, position, number): # set number to 0 (air) to remove block def try_update_chunk_at_position(chunk_position, position): if chunk_position in self.chunks: self.chunks[chunk_position].update_at_position(position) - + if lx == chunk.CHUNK_WIDTH - 1: try_update_chunk_at_position(glm.ivec3(cx + 1, cy, cz), (x + 1, y, z)) if lx == 0: try_update_chunk_at_position(glm.ivec3(cx - 1, cy, cz), (x - 1, y, z)) @@ -477,7 +534,6 @@ def try_update_chunk_at_position(chunk_position, position): if lz == chunk.CHUNK_LENGTH - 1: try_update_chunk_at_position(glm.ivec3(cx, cy, cz + 1), (x, y, z + 1)) if lz == 0: try_update_chunk_at_position(glm.ivec3(cx, cy, cz - 1), (x, y, z - 1)) - def try_set_block(self, position, number, collider): # if we're trying to remove a block, whatever let it go through @@ -489,7 +545,7 @@ def try_set_block(self, position, number, collider): for block_collider in self.block_types[number].colliders: if collider & (block_collider + position): return - + self.set_block(position, number) def toggle_AO(self): @@ -502,21 +558,21 @@ def speed_daytime(self): self.incrementer = 1 if self.daylight >= 1800: self.incrementer = -1 - + def can_render_chunk(self, chunk_position): - return self.player.check_in_frustum(chunk_position) and math.dist(self.get_chunk_position(self.player.position), chunk_position) <= self.options.RENDER_DISTANCE + return self.player.check_chunk_in_frustum(chunk_position) and math.dist(self.get_chunk_position(self.player.position), chunk_position) <= self.options.RENDER_DISTANCE def prepare_rendering(self): self.visible_chunks = [self.chunks[chunk_position] for chunk_position in self.chunks if self.can_render_chunk(chunk_position)] self.sort_chunks() - + def sort_chunks(self): player_chunk_pos = self.get_chunk_position(self.player.position) - self.visible_chunks.sort(key = cmp_to_key(lambda a, b: math.dist(player_chunk_pos, a.chunk_position) + self.visible_chunks.sort(key = cmp_to_key(lambda a, b: math.dist(player_chunk_pos, a.chunk_position) - math.dist(player_chunk_pos, b.chunk_position))) self.sorted_chunks = tuple(reversed(self.visible_chunks)) - + def draw_translucent_fast(self): gl.glEnable(gl.GL_BLEND) gl.glDisable(gl.GL_CULL_FACE) @@ -536,9 +592,9 @@ def draw_translucent_fancy(self): for render_chunk in self.sorted_chunks: render_chunk.draw_translucent(gl.GL_TRIANGLES) - + gl.glFrontFace(gl.GL_CCW) - + for render_chunk in self.sorted_chunks: render_chunk.draw_translucent(gl.GL_TRIANGLES) @@ -546,18 +602,57 @@ def draw_translucent_fancy(self): gl.glDepthMask(gl.GL_TRUE) draw_translucent = draw_translucent_fancy if options.FANCY_TRANSLUCENCY else draw_translucent_fast - + def draw(self): - self.c = 0 + # Debug variables + + self.visible_entities = 0 + + # daylight stuff + daylight_multiplier = self.daylight / 1800 - gl.glClearColor(0.5 * (daylight_multiplier - 0.26), - 0.8 * (daylight_multiplier - 0.26), + gl.glClearColor(0.5 * (daylight_multiplier - 0.26), + 0.8 * (daylight_multiplier - 0.26), (daylight_multiplier - 0.26) * 1.36, 1.0) - gl.glUniform1f(self.shader_daylight_location, daylight_multiplier) + + # setup block shader + + self.block_shader.use() + self.block_shader.uniform_matrix(self.block_shader_matrix_location, self.mvp_matrix) + gl.glUniform1f(self.block_shader_daylight_location, daylight_multiplier) + + # bind textures + + gl.glActiveTexture(gl.GL_TEXTURE0) + gl.glBindTexture(gl.GL_TEXTURE_2D_ARRAY, self.texture_manager.texture_array) + gl.glUniform1i(self.block_shader_sampler_location, 0) + + # draw chunks + + gl.glEnable(gl.GL_CULL_FACE) for render_chunk in self.visible_chunks: render_chunk.draw(gl.GL_TRIANGLES) + # draw entities + + self.entity_shader.use() + gl.glDisable(gl.GL_CULL_FACE) + + for entity in self.entities: + dist = math.sqrt(sum(map(lambda x: (x[0] - x[1]) ** 2, zip(entity.position, self.player.position)))) + + if dist > 32 or not self.player.check_in_frustum(entity.collider): + continue + + entity.draw() + self.visible_entities += 1 + + # draw translucent chunks + + gl.glEnable(gl.GL_CULL_FACE) + self.block_shader.use() + self.draw_translucent() def update_daylight(self): @@ -574,7 +669,7 @@ def update_daylight(self): self.incrementer = -1 self.daylight += self.incrementer - + def build_pending_chunks(self): if self.chunk_building_queue: pending_chunk = self.chunk_building_queue.popleft() @@ -584,7 +679,6 @@ def process_chunk_updates(self): for chunk in self.visible_chunks: chunk.process_chunk_updates() - def tick(self, delta_time): self.chunk_update_counter = 0 self.time += 1 @@ -592,8 +686,8 @@ def tick(self, delta_time): self.update_daylight() self.build_pending_chunks() self.process_chunk_updates() - - - - - + + + + + diff --git a/episode-10/block_type.py b/episode-10/block_type.py index 5e1ccf7b..caea115c 100644 --- a/episode-10/block_type.py +++ b/episode-10/block_type.py @@ -1,7 +1,6 @@ import models.cube # default model class Block_type: - # new optional model argument (cube model by default) def __init__(self, texture_manager, name = "unknown", block_face_textures = {"all": "cobblestone"}, model = models.cube): self.name = name @@ -10,7 +9,7 @@ def __init__(self, texture_manager, name = "unknown", block_face_textures = {"al self.transparent = model.transparent self.is_cube = model.is_cube - # replace data contained in numbers.py with model specific data + # get model specific data self.vertex_positions = model.vertex_positions self.tex_coords = model.tex_coords.copy() diff --git a/episode-10/texture_manager.py b/episode-10/texture_manager.py index 6cfc9fdf..191a11bd 100644 --- a/episode-10/texture_manager.py +++ b/episode-10/texture_manager.py @@ -25,14 +25,16 @@ def __init__(self, texture_width, texture_height, max_textures): 0, gl.GL_RGBA, gl.GL_UNSIGNED_BYTE, None) def generate_mipmaps(self): + gl.glBindTexture(gl.GL_TEXTURE_2D_ARRAY, self.texture_array) gl.glGenerateMipmap(gl.GL_TEXTURE_2D_ARRAY) def add_texture(self, texture): + gl.glBindTexture(gl.GL_TEXTURE_2D_ARRAY, self.texture_array) + if not texture in self.textures: self.textures.append(texture) texture_image = pyglet.image.load(f"textures/{texture}.png").get_image_data() - gl.glBindTexture(gl.GL_TEXTURE_2D_ARRAY, self.texture_array) gl.glTexSubImage3D( gl.GL_TEXTURE_2D_ARRAY, 0, diff --git a/episode-11/texture_manager.py b/episode-11/texture_manager.py index 6cfc9fdf..191a11bd 100644 --- a/episode-11/texture_manager.py +++ b/episode-11/texture_manager.py @@ -25,14 +25,16 @@ def __init__(self, texture_width, texture_height, max_textures): 0, gl.GL_RGBA, gl.GL_UNSIGNED_BYTE, None) def generate_mipmaps(self): + gl.glBindTexture(gl.GL_TEXTURE_2D_ARRAY, self.texture_array) gl.glGenerateMipmap(gl.GL_TEXTURE_2D_ARRAY) def add_texture(self, texture): + gl.glBindTexture(gl.GL_TEXTURE_2D_ARRAY, self.texture_array) + if not texture in self.textures: self.textures.append(texture) texture_image = pyglet.image.load(f"textures/{texture}.png").get_image_data() - gl.glBindTexture(gl.GL_TEXTURE_2D_ARRAY, self.texture_array) gl.glTexSubImage3D( gl.GL_TEXTURE_2D_ARRAY, 0, diff --git a/episode-12/block_type.py b/episode-12/block_type.py index 8b0668bb..5b3c433e 100644 --- a/episode-12/block_type.py +++ b/episode-12/block_type.py @@ -3,7 +3,6 @@ import models.cube # default model class Block_type: - # new optional model argument (cube model by default) def __init__(self, texture_manager, name = "unknown", block_face_textures = {"all": "cobblestone"}, model = models.cube): self.name = name self.block_face_textures = block_face_textures @@ -22,7 +21,7 @@ def __init__(self, texture_manager, name = "unknown", block_face_textures = {"al for _collider in model.colliders: self.colliders.append(collider.Collider(*_collider)) - # replace data contained in numbers.py with model specific data + # get model specific data self.vertex_positions = model.vertex_positions self.tex_coords = model.tex_coords.copy() diff --git a/episode-12/main.py b/episode-12/main.py index 5ea86f1a..fb9c0c75 100644 --- a/episode-12/main.py +++ b/episode-12/main.py @@ -46,7 +46,7 @@ def __init__(self, **args): # misc stuff self.holding = 44 # 5 - + def update(self, delta_time): # print(f"FPS: {1.0 / delta_time}") @@ -54,7 +54,7 @@ def update(self, delta_time): self.player.input = [0, 0, 0] self.player.update(delta_time) - + def on_draw(self): self.player.update_matrices() @@ -74,7 +74,7 @@ def on_draw(self): self.world.draw() gl.glFinish() - + # input functions def on_resize(self, width, height): @@ -106,7 +106,7 @@ def hit_callback(current_block, next_block): while hit_ray.distance < hit.HIT_RANGE: if hit_ray.step(hit_callback): break - + def on_mouse_motion(self, x, y, delta_x, delta_y): if self.mouse_captured: sensitivity = 0.004 @@ -115,10 +115,10 @@ def on_mouse_motion(self, x, y, delta_x, delta_y): self.player.rotation[1] += delta_y * sensitivity self.player.rotation[1] = max(-math.tau / 4, min(math.tau / 4, self.player.rotation[1])) - + def on_mouse_drag(self, x, y, delta_x, delta_y, buttons, modifiers): self.on_mouse_motion(x, y, delta_x, delta_y) - + def on_key_press(self, key, modifiers): if not self.mouse_captured: return @@ -177,7 +177,7 @@ def on_key_press(self, key, modifiers): elif key == pyglet.window.key.ESCAPE: self.mouse_captured = False self.set_exclusive_mouse(False) - + def on_key_release(self, key, modifiers): if not self.mouse_captured: return @@ -195,7 +195,7 @@ class Game: def __init__(self): self.config = gl.Config(double_buffer = True, major_version = 3, minor_version = 3, depth_size = 16) self.window = Window(config = self.config, width = 800, height = 600, caption = "Minecraft clone", resizable = True, vsync = False) - + def run(self): pyglet.app.run() diff --git a/episode-12/save.py b/episode-12/save.py index 57f6c6a0..ac9a961c 100644 --- a/episode-12/save.py +++ b/episode-12/save.py @@ -75,17 +75,17 @@ def save_chunk(self, chunk_position): chunk_data.save(chunk_path, gzipped = True) def load(self): - # for x in range(-16, 15): - # for y in range(-15, 16): - # self.load_chunk((x, 0, y)) + #for x in range(-16, 15): + # for y in range(-15, 16): + # self.load_chunk((x, 0, y)) - # for x in range(-4, 4): - # for y in range(-4, 4): - # self.load_chunk((x, 0, y)) - - for x in range(-1, 1): - for y in range(-1, 1): + for x in range(-4, 4): + for y in range(-4, 4): self.load_chunk((x, 0, y)) + + #for x in range(-1, 1): + # for y in range(-1, 1): + # self.load_chunk((x, 0, y)) def save(self): for chunk_position in self.world.chunks: @@ -96,4 +96,4 @@ def save(self): if chunk.modified: self.save_chunk(chunk_position) - chunk.modified = False \ No newline at end of file + chunk.modified = False diff --git a/episode-12/texture_manager.py b/episode-12/texture_manager.py index 6cfc9fdf..191a11bd 100644 --- a/episode-12/texture_manager.py +++ b/episode-12/texture_manager.py @@ -25,14 +25,16 @@ def __init__(self, texture_width, texture_height, max_textures): 0, gl.GL_RGBA, gl.GL_UNSIGNED_BYTE, None) def generate_mipmaps(self): + gl.glBindTexture(gl.GL_TEXTURE_2D_ARRAY, self.texture_array) gl.glGenerateMipmap(gl.GL_TEXTURE_2D_ARRAY) def add_texture(self, texture): + gl.glBindTexture(gl.GL_TEXTURE_2D_ARRAY, self.texture_array) + if not texture in self.textures: self.textures.append(texture) texture_image = pyglet.image.load(f"textures/{texture}.png").get_image_data() - gl.glBindTexture(gl.GL_TEXTURE_2D_ARRAY, self.texture_array) gl.glTexSubImage3D( gl.GL_TEXTURE_2D_ARRAY, 0, diff --git a/episode-13/block_type.py b/episode-13/block_type.py new file mode 100644 index 00000000..5b3c433e --- /dev/null +++ b/episode-13/block_type.py @@ -0,0 +1,70 @@ +import collider + +import models.cube # default model + +class Block_type: + def __init__(self, texture_manager, name = "unknown", block_face_textures = {"all": "cobblestone"}, model = models.cube): + self.name = name + self.block_face_textures = block_face_textures + self.model = model + + # create members based on model attributes + + self.transparent = model.transparent + self.is_cube = model.is_cube + self.glass = model.glass + + # create colliders + + self.colliders = [] + + for _collider in model.colliders: + self.colliders.append(collider.Collider(*_collider)) + + # get model specific data + + self.vertex_positions = model.vertex_positions + self.tex_coords = model.tex_coords.copy() + self.shading_values = model.shading_values + + def set_block_face(face, texture): + # make sure we don't add inexistent faces + + if face > len(self.tex_coords) - 1: + return + + self.tex_coords[face] = self.tex_coords[face].copy() + + for vertex in range(4): + self.tex_coords[face][vertex * 3 + 2] = texture + + for face in block_face_textures: + texture = block_face_textures[face] + texture_manager.add_texture(texture) + + texture_index = texture_manager.textures.index(texture) + + if face == "all": + for i in range(len(self.tex_coords)): + set_block_face(i, texture_index) + + elif face == "sides": + set_block_face(0, texture_index) + set_block_face(1, texture_index) + set_block_face(4, texture_index) + set_block_face(5, texture_index) + + elif face == "x": + set_block_face(0, texture_index) + set_block_face(1, texture_index) + + elif face == "y": + set_block_face(2, texture_index) + set_block_face(3, texture_index) + + elif face == "z": + set_block_face(4, texture_index) + set_block_face(5, texture_index) + + else: + set_block_face(["right", "left", "top", "bottom", "front", "back"].index(face), texture_index) \ No newline at end of file diff --git a/episode-13/chunk.py b/episode-13/chunk.py new file mode 100644 index 00000000..7bb7fff3 --- /dev/null +++ b/episode-13/chunk.py @@ -0,0 +1,183 @@ +import ctypes +import math + +import pyglet.gl as gl + +import subchunk + +CHUNK_WIDTH = 16 +CHUNK_HEIGHT = 128 +CHUNK_LENGTH = 16 + +class Chunk: + def __init__(self, world, chunk_position): + self.world = world + + self.modified = False + self.chunk_position = chunk_position + + self.position = ( + self.chunk_position[0] * CHUNK_WIDTH, + self.chunk_position[1] * CHUNK_HEIGHT, + self.chunk_position[2] * CHUNK_LENGTH) + + self.blocks = [[[0 + for z in range(CHUNK_LENGTH)] + for y in range(CHUNK_HEIGHT)] + for x in range(CHUNK_WIDTH )] + + self.subchunks = {} + + for x in range(int(CHUNK_WIDTH / subchunk.SUBCHUNK_WIDTH)): + for y in range(int(CHUNK_HEIGHT / subchunk.SUBCHUNK_HEIGHT)): + for z in range(int(CHUNK_LENGTH / subchunk.SUBCHUNK_LENGTH)): + self.subchunks[(x, y, z)] = subchunk.Subchunk(self, (x, y, z)) + + # mesh variables + + self.mesh_vertex_positions = [] + self.mesh_tex_coords = [] + self.mesh_shading_values = [] + + self.mesh_index_counter = 0 + self.mesh_indices = [] + + # create VAO and VBO's + + self.vao = gl.GLuint(0) + gl.glGenVertexArrays(1, self.vao) + gl.glBindVertexArray(self.vao) + + self.vertex_position_vbo = gl.GLuint(0) + gl.glGenBuffers(1, self.vertex_position_vbo) + + self.tex_coord_vbo = gl.GLuint(0) + gl.glGenBuffers(1, self.tex_coord_vbo) + + self.shading_values_vbo = gl.GLuint(0) + gl.glGenBuffers(1, self.shading_values_vbo) + + self.ibo = gl.GLuint(0) + gl.glGenBuffers(1, self.ibo) + + def update_subchunk_meshes(self): + for subchunk_position in self.subchunks: + subchunk = self.subchunks[subchunk_position] + subchunk.update_mesh() + + def update_at_position(self, position): + x, y, z = position + + lx = int(x % subchunk.SUBCHUNK_WIDTH ) + ly = int(y % subchunk.SUBCHUNK_HEIGHT) + lz = int(z % subchunk.SUBCHUNK_LENGTH) + + clx, cly, clz = self.world.get_local_position(position) + + sx = math.floor(clx / subchunk.SUBCHUNK_WIDTH) + sy = math.floor(cly / subchunk.SUBCHUNK_HEIGHT) + sz = math.floor(clz / subchunk.SUBCHUNK_LENGTH) + + self.subchunks[(sx, sy, sz)].update_mesh() + + def try_update_subchunk_mesh(subchunk_position): + if subchunk_position in self.subchunks: + self.subchunks[subchunk_position].update_mesh() + + if lx == subchunk.SUBCHUNK_WIDTH - 1: try_update_subchunk_mesh((sx + 1, sy, sz)) + if lx == 0: try_update_subchunk_mesh((sx - 1, sy, sz)) + + if ly == subchunk.SUBCHUNK_HEIGHT - 1: try_update_subchunk_mesh((sx, sy + 1, sz)) + if ly == 0: try_update_subchunk_mesh((sx, sy - 1, sz)) + + if lz == subchunk.SUBCHUNK_LENGTH - 1: try_update_subchunk_mesh((sx, sy, sz + 1)) + if lz == 0: try_update_subchunk_mesh((sx, sy, sz - 1)) + + def update_mesh(self): + # combine all the small subchunk meshes into one big chunk mesh + + self.mesh_vertex_positions = [] + self.mesh_tex_coords = [] + self.mesh_shading_values = [] + + self.mesh_index_counter = 0 + self.mesh_indices = [] + + for subchunk_position in self.subchunks: + subchunk = self.subchunks[subchunk_position] + + self.mesh_vertex_positions.extend(subchunk.mesh_vertex_positions) + self.mesh_tex_coords.extend(subchunk.mesh_tex_coords) + self.mesh_shading_values.extend(subchunk.mesh_shading_values) + + mesh_indices = [index + self.mesh_index_counter for index in subchunk.mesh_indices] + + self.mesh_indices.extend(mesh_indices) + self.mesh_index_counter += subchunk.mesh_index_counter + + # send the full mesh data to the GPU and free the memory used client-side (we don't need it anymore) + # don't forget to save the length of 'self.mesh_indices' before freeing + + self.mesh_indices_length = len(self.mesh_indices) + self.send_mesh_data_to_gpu() + + del self.mesh_vertex_positions + del self.mesh_tex_coords + del self.mesh_shading_values + + del self.mesh_indices + + def send_mesh_data_to_gpu(self): # pass mesh data to gpu + if not self.mesh_index_counter: + return + + gl.glBindVertexArray(self.vao) + + gl.glBindBuffer(gl.GL_ARRAY_BUFFER, self.vertex_position_vbo) + gl.glBufferData( + gl.GL_ARRAY_BUFFER, + ctypes.sizeof(gl.GLfloat * len(self.mesh_vertex_positions)), + (gl.GLfloat * len(self.mesh_vertex_positions)) (*self.mesh_vertex_positions), + gl.GL_STATIC_DRAW) + + gl.glVertexAttribPointer(0, 3, gl.GL_FLOAT, gl.GL_FALSE, 0, 0) + gl.glEnableVertexAttribArray(0) + + gl.glBindBuffer(gl.GL_ARRAY_BUFFER, self.tex_coord_vbo) + gl.glBufferData( + gl.GL_ARRAY_BUFFER, + ctypes.sizeof(gl.GLfloat * len(self.mesh_tex_coords)), + (gl.GLfloat * len(self.mesh_tex_coords)) (*self.mesh_tex_coords), + gl.GL_STATIC_DRAW) + + gl.glVertexAttribPointer(1, 3, gl.GL_FLOAT, gl.GL_FALSE, 0, 0) + gl.glEnableVertexAttribArray(1) + + gl.glBindBuffer(gl.GL_ARRAY_BUFFER, self.shading_values_vbo) + gl.glBufferData( + gl.GL_ARRAY_BUFFER, + ctypes.sizeof(gl.GLfloat * len(self.mesh_shading_values)), + (gl.GLfloat * len(self.mesh_shading_values)) (*self.mesh_shading_values), + gl.GL_STATIC_DRAW) + + gl.glVertexAttribPointer(2, 1, gl.GL_FLOAT, gl.GL_FALSE, 0, 0) + gl.glEnableVertexAttribArray(2) + + gl.glBindBuffer(gl.GL_ELEMENT_ARRAY_BUFFER, self.ibo) + gl.glBufferData( + gl.GL_ELEMENT_ARRAY_BUFFER, + ctypes.sizeof(gl.GLuint * self.mesh_indices_length), + (gl.GLuint * self.mesh_indices_length) (*self.mesh_indices), + gl.GL_STATIC_DRAW) + + def draw(self): + if not self.mesh_index_counter: + return + + gl.glBindVertexArray(self.vao) + + gl.glDrawElements( + gl.GL_TRIANGLES, + self.mesh_indices_length, + gl.GL_UNSIGNED_INT, + None) \ No newline at end of file diff --git a/episode-13/collider.py b/episode-13/collider.py new file mode 100644 index 00000000..c15926c0 --- /dev/null +++ b/episode-13/collider.py @@ -0,0 +1,67 @@ +class Collider: + def __init__(self, pos1 = (None,) * 3, pos2 = (None,) * 3): + # pos1: position of the collider vertex in the -X, -Y, -Z direction + # pos2: position of the collider vertex in the +X, +Y, +Z direction + + self.x1, self.y1, self.z1 = pos1 + self.x2, self.y2, self.z2 = pos2 + + def __add__(self, pos): + x, y, z = pos + + return Collider( + (self.x1 + x, self.y1 + y, self.z1 + z), + (self.x2 + x, self.y2 + y, self.z2 + z) + ) + + def __and__(self, collider): + x = min(self.x2, collider.x2) - max(self.x1, collider.x1) + y = min(self.y2, collider.y2) - max(self.y1, collider.y1) + z = min(self.z2, collider.z2) - max(self.z1, collider.z1) + + return x > 0 and y > 0 and z > 0 + + def collide(self, collider, velocity): + # self: the dynamic collider, which moves + # collider: the static collider, which stays put + + no_collision = 1, None + + # find entry & exit times for each axis + + vx, vy, vz = velocity + + time = lambda x, y: x / y if y else float('-' * (x > 0) + "inf") + + x_entry = time(collider.x1 - self.x2 if vx > 0 else collider.x2 - self.x1, vx) + x_exit = time(collider.x2 - self.x1 if vx > 0 else collider.x1 - self.x2, vx) + + y_entry = time(collider.y1 - self.y2 if vy > 0 else collider.y2 - self.y1, vy) + y_exit = time(collider.y2 - self.y1 if vy > 0 else collider.y1 - self.y2, vy) + + z_entry = time(collider.z1 - self.z2 if vz > 0 else collider.z2 - self.z1, vz) + z_exit = time(collider.z2 - self.z1 if vz > 0 else collider.z1 - self.z2, vz) + + # make sure we actually got a collision + + if x_entry < 0 and y_entry < 0 and z_entry < 0: + return no_collision + + if x_entry > 1 or y_entry > 1 or z_entry > 1: + return no_collision + + # on which axis did we collide first? + + entry = max(x_entry, y_entry, z_entry) + exit_ = min(x_exit, y_exit, z_exit ) + + if entry > exit_: + return no_collision + + # find normal of surface we collided with + + nx = (0, -1 if vx > 0 else 1)[entry == x_entry] + ny = (0, -1 if vy > 0 else 1)[entry == y_entry] + nz = (0, -1 if vz > 0 else 1)[entry == z_entry] + + return entry, (nx, ny, nz) \ No newline at end of file diff --git a/episode-13/data/blocks.mcpy b/episode-13/data/blocks.mcpy new file mode 100644 index 00000000..e3479b12 --- /dev/null +++ b/episode-13/data/blocks.mcpy @@ -0,0 +1,91 @@ +# block ID's from: +# https://www.minecraftforum.net/forums/minecraft-java-edition/discussion/114963-all-item-block-ids-in-one-place +# (with some slight modifications) + +1: name "Stone", texture.all stone +2: name "Grass", texture.top grass, texture.bottom dirt, texture.sides grass_side +3: name "Dirt", texture.all dirt +4: name "Cobblestone", texture.all cobblestone +5: name "Planks", texture.all planks +6: name "Sapling", model models.plant, texture.all sapling +7: name "Bedrock", texture.all bedrock +8: name "Water", model models.liquid, texture.all water +9: sameas 8, name "Stationary Water" +10: name "Lava", model models.liquid, texture.all lava +11: sameas 10, name "Stationary Lava" +12: name "Sand", texture.all sand +13: name "Gravel", texture.all gravel +14: name "Gold Ore", texture.all gold_ore +15: name "Iron Ore", texture.all iron_ore +16: name "Coal Ore", texture.all coal_ore +17: name "Log", texture.y log_y, texture.sides log_side +18: name "Leaves", model models.leaves, texture.all leaves +19: name "Sponge", texture.all sponge +20: name "Glass", model models.glass, texture.all glass +21: name "Red Cloth", texture.all red_cloth +22: name "Orange Cloth", texture.all orange_cloth +23: name "Yellow Cloth", texture.all yellow_cloth +24: name "Lime Cloth", texture.all lime_cloth +25: name "Green Cloth", texture.all green_cloth +26: name "Aqua Cloth", texture.all aqua_cloth +27: name "Cyan Cloth", texture.all cyan_cloth +28: name "Blue Cloth", texture.all blue_cloth +29: name "Purple Cloth", texture.all purple_cloth +30: name "Indigo Cloth", texture.all indigo_cloth +31: name "Violet Cloth", texture.all violet_cloth +32: name "Magenta Cloth", texture.all magenta_cloth +33: name "Pink Cloth", texture.all pink_cloth +34: name "Black Cloth", texture.all black_cloth +35: name "Grey Cloth", texture.all grey_cloth +36: name "White Cloth", texture.all white_cloth +37: name "Yellow Flower", model models.plant, texture.all yellow_flower +38: name "Red Rose", model models.plant, texture.all red_rose +39: name "Brown Mushroom", model models.plant, texture.all brown_mushroom +40: name "Red Mushroom", model models.plant, texture.all red_mushroom +41: name "Gold Block", texture.all gold_block +42: name "Iron Block", texture.all iron_block +43: name "Double Slab", texture.sides slab_side, texture.y slab_y +44: name "Slab", model models.slab, texture.sides slab_side, texture.y slab_y +45: name "Bricks", texture.all bricks +46: name "TNT", texture.top tnt_top, texture.bottom tnt_bottom, texture.sides tnt_side +47: name "Bookshelf", texture.y planks, texture.sides bookshelf +48: name "Mossy Cobblestone", texture.all mossy_cobblestone +49: name "Obsidian", texture.all obsidian +50: name "Torch", model models.torch, texture.top torch_top, texture.bottom torch, texture.sides torch +51: name "Fire", model models.fire, texture.all fire +# I know, the model name isn't great, but it's got the same graphical properties +52: name "Mob Spawner", model models.leaves, texture.all mob_spawner +53: name "Wooden Stairs", model models.stairs, texture.all planks +54: name "Chest", texture.y chest_top, texture.sides chest_side, texture.front chest_front +55: name "Redstone Wire", model models.flat, texture.all redstone_wire +56: name "Diamond Ore", texture.all diamond_ore +57: name "Diamond Block", texture.all diamond_block +58: name "Crafting Table", texture.top crafting_table_top, texture.bottom planks, texture.x crafting_table_x, texture.z crafting_table_z +59: name "Crops", model models.crop, texture.all crops +60: name "Soil", model models.soil, texture.all dirt, texture.top soil +61: name "Furnace", texture.y furnace_y, texture.sides furnace_side, texture.front furnace_front +62: name "Lit Furnace", texture.y furnace_y, texture.sides furnace_side, texture.front lit_furnace_front +63: name "Sign Post", model models.sign_post, texture.all planks +64: name "Wooden Door", model models.door, texture.all wooden_door +65: name "Ladder", model models.ladder, texture.all ladder +66: name "Rails", model models.flat, texture.all rails +67: name "Cobblestone Stairs", model models.stairs, texture.all cobblestone +68: name "Sign", model models.sign, texture.all planks +69: name "Lever", model models.lever, texture.all lever +70: name "Stone Pressure Plate", model models.pressure_plate, texture.all stone +71: name "Iron Door", model models.door, texture.all iron_door_bottom_half +72: name "Wooden Pressure Plate", model models.pressure_plate, texture.all planks +73: name "Redstone Ore", texture.all redstone_ore +# when we implement a lighting system, this will have some kind of "emissive" property +74: name "Lit Redstone Ore", texture.all redstone_ore +75: name "Redstone Torch", model models.torch, texture.top redstone_torch_top, texture.bottom redstone_torch, texture.sides redstone_torch +76: name "Redstone Torch (Off)", model models.torch, texture.top off_redstone_torch_top, texture.bottom off_redstone_torch, texture.sides off_redstone_torch +77: name "Stone Button", model models.button, texture.all stone +78: name "Snow", model models.snow, texture.all snow +# ditto as for mob spawners (52) +79: name "Ice", model models.tinted_glass, texture.all ice +80: name "Snow Block", texture.all snow +81: name "Cactus", model models.cactus, texture.top cactus_top, texture.bottom cactus_bottom, texture.sides cactus_side +82: name "Clay", texture.all clay +83: name "Sugar Cane", model models.plant, texture.all sugar_cane +84: name "Jukebox", texture.all jukebox, texture.top jukebox_top \ No newline at end of file diff --git a/episode-13/data/entities.mcpy b/episode-13/data/entities.mcpy new file mode 100644 index 00000000..1f9176db --- /dev/null +++ b/episode-13/data/entities.mcpy @@ -0,0 +1,7 @@ +Player: name "Player", width 0.6, height 1.8, model models.pig, texture pig +Pig: name "Pig", width 0.9, height 0.9, model models.pig, texture pig +Zombie: name "Zombie", width 0.6, height 1.95, model models.zombie, texture zombie +Skeleton: name "Skeleton", width 0.6, height 1.99, model models.skeleton, texture skeleton +Creeper: name "Creeper", width 0.6, height 1.7, model models.creeper, texture creeper +Cow: name "Cow", width 0.9, height 1.3, model models.cow, texture cow +Curry: name "Curry", width 0.9, height 1.8, model models.curry, texture curry diff --git a/episode-13/entity.py b/episode-13/entity.py new file mode 100644 index 00000000..d8b0e186 --- /dev/null +++ b/episode-13/entity.py @@ -0,0 +1,244 @@ +import math +import random + +import matrix +import collider + +import chunk + +FLYING_ACCEL = (0, 0, 0) +GRAVITY_ACCEL = (0, -32, 0) + +# these values all come (loosely) from Minecraft, but are multiplied by 20 (since Minecraft runs at 20 TPS) + +FRICTION = ( 20, 20, 20) + +DRAG_FLY = ( 5, 5, 5) +DRAG_JUMP = (1.8, 0, 1.8) +DRAG_FALL = (1.8, 0.4, 1.8) + +class Entity: + def __init__(self, world, entity_type): + self.world = world + self.entity_type = entity_type + + self.age = 0 + + # physical variables + + self.jump_height = 1.25 + self.flying = False + self.ghost = False + + self.position = [0, 80, 0] + self.rotation = [-math.tau / 4, 0] + + self.velocity = [0, 0, 0] + self.accel = [0, 0, 0] + + # collision variables + + self.collider = collider.Collider() + + self.grounded = False + self.wall = False + + def update_collider(self): + x, y, z = self.position + + self.collider.x1 = x - self.entity_type.width / 2 + self.collider.x2 = x + self.entity_type.width / 2 + + self.collider.y1 = y + self.collider.y2 = y + self.entity_type.height + + self.collider.z1 = z - self.entity_type.width / 2 + self.collider.z2 = z + self.entity_type.width / 2 + + def teleport(self, pos): + self.position = list(pos) + self.velocity = [0, 0, 0] # to prevent collisions + + def jump(self, height = None): + # obviously, we can't initiate a jump while in mid-air + + if not self.grounded: + return + + if height is None: + height = self.jump_height + + self.velocity[1] = math.sqrt(-2 * GRAVITY_ACCEL[1] * height) + + def reset(self): + # how large is the world? + + max_y = 0 + + max_x, max_z = (0, 0) + min_x, min_z = (0, 0) + + for pos in self.world.chunks: + x, y, z = pos + + max_y = max(max_y, (y + 1) * chunk.CHUNK_HEIGHT) + + max_x = max(max_x, (x + 1) * chunk.CHUNK_WIDTH) + min_x = min(min_x, x * chunk.CHUNK_WIDTH) + + max_z = max(max_z, (z + 1) * chunk.CHUNK_LENGTH) + min_z = min(min_z, z * chunk.CHUNK_LENGTH) + + # get random X & Z coordinates to teleport the player to + + x = random.randint(min_x, max_x) + z = random.randint(min_z, max_z) + + # find height at which to teleport to, by finding the first non-air block from the top of the world + + for y in range(chunk.CHUNK_HEIGHT - 1, -1, -1): + if not self.world.get_block_number((x, y, z)): + continue + + self.teleport((x, y + 1, z)) + break + + @property + def friction(self): + if self.flying: + return DRAG_FLY + + elif self.grounded: + return FRICTION + + elif self.velocity[1] > 0: + return DRAG_JUMP + + return DRAG_FALL + + def resolve_collision(self, delta_time): + adjusted_velocity = [v * delta_time for v in self.velocity] + vx, vy, vz = adjusted_velocity + + # find all the blocks we could potentially be colliding with + # this step is known as "broad-phasing" + + step_x = 1 if vx > 0 else -1 + step_y = 1 if vy > 0 else -1 + step_z = 1 if vz > 0 else -1 + + steps_xz = int(self.entity_type.width / 2) + steps_y = int(self.entity_type.height) + + x, y, z = map(int, self.position) + cx, cy, cz = [int(p + v) for p, v in zip(self.position, adjusted_velocity)] + + potential_collisions = [] + + for i in range(x - step_x * (steps_xz + 1), cx + step_x * (steps_xz + 2), step_x): + for j in range(y - step_y * (steps_y + 2), cy + step_y * (steps_y + 3), step_y): + for k in range(z - step_z * (steps_xz + 1), cz + step_z * (steps_xz + 2), step_z): + pos = (i, j, k) + num = self.world.get_block_number(pos) + + if not num: + continue + + for _collider in self.world.block_types[num].colliders: + entry_time, normal = self.collider.collide(_collider + pos, adjusted_velocity) + + if normal is None: + continue + + potential_collisions.append((entry_time, normal)) + + # get first collision + + if not potential_collisions: + return + + entry_time, normal = min(potential_collisions, key = lambda x: x[0]) + entry_time -= 0.001 + + if normal[0]: + self.velocity[0] = 0 + self.position[0] += vx * entry_time + + if normal[1]: + self.velocity[1] = 0 + self.position[1] += vy * entry_time + + if normal[2]: + self.velocity[2] = 0 + self.position[2] += vz * entry_time + + if normal[0] or normal[2]: + self.wall = True + + if normal[1] == 1: + self.grounded = True + + def update(self, delta_time): + initial_pos = tuple(self.position) + + # apply input acceleration, and adjust for friction/drag + + self.velocity = [v + a * f * delta_time for v, a, f in zip(self.velocity, self.accel, self.friction)] + self.accel = [0, 0, 0] + + # compute collisions + + self.update_collider() + + self.grounded = False + self.wall = False + + if not self.ghost: + for _ in range(3): + self.resolve_collision(delta_time) + + self.position = [x + v * delta_time for x, v in zip(self.position, self.velocity)] + + # apply gravity acceleration + + gravity = FLYING_ACCEL if self.flying else GRAVITY_ACCEL + self.velocity = [v + a * delta_time for v, a in zip(self.velocity, gravity)] + + # apply friction/drag + + self.velocity = [v - min(v * f * delta_time, v, key = abs) for v, f in zip(self.velocity, self.friction)] + + # make sure we can rely on the entity's collider outside of this function + + self.update_collider() + + # animate the entity + + dx = self.position[0] - initial_pos[0] + dz = self.position[2] - initial_pos[2] + + speed = math.sqrt(dx ** 2 + dz ** 2) + self.age += delta_time + self.entity_type.animate(self.age, speed / delta_time, self.position, self.rotation) + + def draw(self): + # compute MVP matrix + + mvp = matrix.copy_matrix(self.world.mvp_matrix) + + mvp.translate(*self.position) + mvp.rotate_2d(self.rotation[0], 0) + + # compute inverse transformation matrix + + inverse = matrix.Matrix() + inverse.load_identity() + + inverse.rotate_2d(-self.rotation[0], 0) + + # actually draw entity + + self.world.entity_shader.uniform_matrix(self.world.entity_shader_inverse_transform_matrix_location, inverse) + self.world.entity_shader.uniform_matrix(self.world.entity_shader_matrix_location, mvp) + + self.entity_type.draw() diff --git a/episode-13/entity_type.py b/episode-13/entity_type.py new file mode 100644 index 00000000..a226b7ee --- /dev/null +++ b/episode-13/entity_type.py @@ -0,0 +1,234 @@ +import ctypes +import math + +import pyglet + +import pyglet.gl as gl + +import matrix + +import models.pig # default model + +class Entity_type: + def __init__(self, world, name = "unknown", texture = "pig", model = models.pig, width = 0.6, height = 1.8): + self.world = world + + self.name = name + self.model = model + + self.width = width + self.height = height + + # load texture image + + texture_image = pyglet.image.load(f"textures/{texture}.png").get_image_data() + + self.texture_width = texture_image.width + self.texture_height = texture_image.height + + # create texture + + self.texture = gl.GLuint(0) + gl.glGenTextures(1, self.texture) + gl.glBindTexture(gl.GL_TEXTURE_2D, self.texture) + + gl.glTexParameteri(gl.GL_TEXTURE_2D, gl.GL_TEXTURE_MIN_FILTER, gl.GL_NEAREST) + gl.glTexParameteri(gl.GL_TEXTURE_2D, gl.GL_TEXTURE_MAG_FILTER, gl.GL_NEAREST) + + gl.glTexImage2D( + gl.GL_TEXTURE_2D, 0, gl.GL_RGBA, + self.texture_width, self.texture_height, + 0, gl.GL_RGBA, gl.GL_UNSIGNED_BYTE, + texture_image.get_data("RGBA", self.texture_width * 4)) + + gl.glGenerateMipmap(gl.GL_TEXTURE_2D) + + # get total size of the models so we can create vertex buffers + + vertex_count = 0 + tex_coord_count = 0 + + for bone in model.bones: + vertex_count += len(sum(bone["vertices"], [])) // 3 + tex_coord_count += len(sum(bone["tex_coords"], [])) // 2 + + # create VAO/VBO/IBO + + self.vao = gl.GLuint(0) + gl.glGenVertexArrays(1, self.vao) + gl.glBindVertexArray(self.vao) + + # vertex positions & normals + # we'll combine these two (6 floats per vertex, first 3 for position, next 3 for normal) + + self.vertices_vbo = gl.GLuint(0) + gl.glGenBuffers(1, self.vertices_vbo) + + gl.glBindBuffer(gl.GL_ARRAY_BUFFER, self.vertices_vbo) + gl.glBufferData(gl.GL_ARRAY_BUFFER, + ctypes.sizeof(gl.GLfloat * vertex_count * 6), + 0, gl.GL_STREAM_DRAW) + + size = ctypes.sizeof(gl.GLfloat * 3) + + gl.glVertexAttribPointer(0, 3, gl.GL_FLOAT, gl.GL_FALSE, size * 2, size * 0) + gl.glEnableVertexAttribArray(0) + + gl.glVertexAttribPointer(1, 3, gl.GL_FLOAT, gl.GL_FALSE, size * 2, size * 1) + gl.glEnableVertexAttribArray(1) + + # texture coordinates + # these can be filled in straight away as they won't change + + self.tex_coords_vbo = gl.GLuint(0) + gl.glGenBuffers(1, self.tex_coords_vbo) + + gl.glBindBuffer(gl.GL_ARRAY_BUFFER, self.tex_coords_vbo) + gl.glBufferData(gl.GL_ARRAY_BUFFER, ctypes.sizeof(gl.GLfloat * tex_coord_count * 2), 0, gl.GL_STATIC_DRAW) + + offset = 0 + + for bone in self.model.bones: + tex_coords = sum(bone["tex_coords"], []) + + type_ = gl.GLfloat * len(tex_coords) + size = ctypes.sizeof(type_) + + gl.glBufferSubData( + gl.GL_ARRAY_BUFFER, offset, + size, (type_) (*tex_coords)) + + offset += size + + gl.glVertexAttribPointer(2, 2, gl.GL_FLOAT, gl.GL_FALSE, 0, 0) + gl.glEnableVertexAttribArray(2) + + # compute indices + + self.indices = [] + + for i in range(vertex_count): + self.indices.extend(x + i * 4 for x in (0, 1, 2, 0, 2, 3)) + + # indices + # these can be filled in straight away as they won't change + + self.ibo = gl.GLuint(0) + gl.glGenBuffers(1, self.ibo) + + gl.glBindBuffer(gl.GL_ELEMENT_ARRAY_BUFFER, self.ibo) + gl.glBufferData( + gl.GL_ELEMENT_ARRAY_BUFFER, + ctypes.sizeof(gl.GLuint * len(self.indices)), + (gl.GLuint * len(self.indices)) (*self.indices), + gl.GL_STATIC_DRAW) + + def animate(self, age, speed, position, rotation): + gl.glBindVertexArray(self.vao) + + # compute & upload vertex positions + + gl.glBindBuffer(gl.GL_ARRAY_BUFFER, self.vertices_vbo) + offset = 0 + + for bone in self.model.bones: + name = bone["name"] + pivot = bone["pivot"] + vertices = sum(bone["vertices"], []) + buffer = vertices * 2 # we want our buffer to hold both vertex positions & normals + + # compute animation transformation matrix + + anim = matrix.Matrix() + anim.load_identity() + + anim.translate(*pivot) + + kind = None + + if name == "head": + kind = "head" + + elif name[:3] == "leg": + kind = "odd_" * (int(name[3:]) in (1, 2)) + "leg" + + elif name == "rightLeg": + kind = "leg" + + elif name == "leftLeg": + kind = "odd_leg" + + elif name == "rightArm": + kind = "arm" + + elif name == "leftArm": + kind = "odd_arm" + + if kind is not None: + odd = "odd" in kind + + if kind == "head": + x, y, z = self.world.player.position + + dx = x - position[0] + dy = y - position[1] + dz = z - position[2] + + theta = -rotation[0] - math.atan2(dz, dx) - math.tau / 4 + iota = -math.atan2(dy, math.sqrt(dx ** 2 + dz ** 2)) + + anim.rotate_2d(theta, 0) + anim.rotate_2d(0, iota) + + if "leg" in kind: + phase = math.tau / 2 * odd + anim.rotate_2d(0, math.sin(age * 7 + phase) / 5 * speed) + + if "arm" in kind: + theta = (-age if odd else age) * 2 + phase = math.tau / 2 * odd + anim.rotate_2d(math.sin(theta + phase) / 8, math.cos(theta + phase) / 8 - math.tau / 4) + + anim.translate(*[-x for x in pivot]) + + for i in range(0, len(vertices), 3): + vector = vertices[i: i + 3] + [1] + buffer[i * 2: i * 2 + 3] = matrix.multiply_matrix_vector(anim, vector)[:3] + + # compute normals + + for i in range(0, len(buffer), 24): + # take the cross product between two vectors we know are on the plane the face belongs to + + n = matrix.cross_product( + [buffer[i + 0] - buffer[i + 6], buffer[i + 1] - buffer[i + 7], buffer[i + 2] - buffer[i + 8]], + [buffer[i + 0] - buffer[i + 12], buffer[i + 1] - buffer[i + 13], buffer[i + 2] - buffer[i + 14]] + ) + + # each vertex of a face will have the same normal, so we can simply copy it 4 times + + for j in range(4): + buffer[i + j * 6 + 3: i + j * 6 + 6] = n + + # upload vertex buffer section + + type_ = gl.GLfloat * len(buffer) + size = ctypes.sizeof(type_) + + gl.glBufferSubData( + gl.GL_ARRAY_BUFFER, offset, + size, (type_) (*buffer)) + + offset += size + + def draw(self): + # bind textures + + gl.glActiveTexture(gl.GL_TEXTURE0) + gl.glBindTexture(gl.GL_TEXTURE_2D, self.texture) + gl.glUniform1i(self.world.entity_shader_sampler_location, 0) + + # draw entity + + gl.glBindVertexArray(self.vao) + gl.glDrawElements(gl.GL_TRIANGLES, len(self.indices), gl.GL_UNSIGNED_INT, None) diff --git a/episode-13/hit.py b/episode-13/hit.py new file mode 100644 index 00000000..88389510 --- /dev/null +++ b/episode-13/hit.py @@ -0,0 +1,105 @@ +import math + +HIT_RANGE = 3 + +class Hit_ray: + def __init__(self, world, rotation, starting_position): + self.world = world + + # get the ray unit vector based on rotation angles + # sqrt(ux ^ 2 + uy ^ 2 + uz ^ 2) must always equal 1 + + self.vector = ( + math.cos(rotation[0]) * math.cos(rotation[1]), + math.sin(rotation[1]), + math.sin(rotation[0]) * math.cos(rotation[1])) + + # point position + self.position = list(starting_position) + + # block position in which point currently is + self.block = tuple(map(lambda x: int(round(x)), self.position)) + + # current distance the point has travelled + self.distance = 0 + + # 'check' and 'step' both return 'True' if something is hit, and 'False' if not + + def check(self, hit_callback, distance, current_block, next_block): + if self.world.get_block_number(next_block): + hit_callback(current_block, next_block) + return True + + else: + self.position = list(map(lambda x: self.position[x] + self.vector[x] * distance, range(3))) + + self.block = next_block + self.distance += distance + + return False + + def step(self, hit_callback): + bx, by, bz = self.block + + # point position relative to block centre + local_position = list(map(lambda x: self.position[x] - self.block[x], range(3))) + + # we don't want to deal with negatives, so remove the sign + # this is also cool because it means we don't need to take into account the sign of our ray vector + # we do need to remember which components were negative for later on, however + + sign = [1, 1, 1] # '1' for positive, '-1' for negative + absolute_vector = list(self.vector) + + for component in range(3): + if self.vector[component] < 0: + sign[component] = -1 + + absolute_vector[component] = -absolute_vector[component] + local_position[component] = -local_position[component] + + lx, ly, lz = local_position + vx, vy, vz = absolute_vector + + # calculate intersections + # I only detail the math for the first component (X) because the rest is pretty self-explanatory + + # ray line (passing through the point) r ≡ (x - lx) / vx = (y - ly) / lz = (z - lz) / vz (parametric equation) + + # +x face fx ≡ x = 0.5 (y & z can be any real number) + # r ∩ fx ≡ (0.5 - lx) / vx = (y - ly) / vy = (z - lz) / vz + + # x: x = 0.5 + # y: (y - ly) / vy = (0.5 - lx) / vx IFF y = (0.5 - lx) / vx * vy + ly + # z: (z - lz) / vz = (0.5 - lx) / vx IFF z = (0.5 - lx) / vx * vz + lz + + if vx: + x = 0.5 + y = (0.5 - lx) / vx * vy + ly + z = (0.5 - lx) / vx * vz + lz + + if y >= -0.5 and y <= 0.5 and z >= -0.5 and z <= 0.5: + distance = math.sqrt((x - lx) ** 2 + (y - ly) ** 2 + (z - lz) ** 2) + + # we can return straight away here + # if we intersect with one face, we know for a fact we're not intersecting with any of the others + + return self.check(hit_callback, distance, (bx, by, bz), (bx + sign[0], by, bz)) + + if vy: + x = (0.5 - ly) / vy * vx + lx + y = 0.5 + z = (0.5 - ly) / vy * vz + lz + + if x >= -0.5 and x <= 0.5 and z >= -0.5 and z <= 0.5: + distance = math.sqrt((x - lx) ** 2 + (y - ly) ** 2 + (z - lz) ** 2) + return self.check(hit_callback, distance, (bx, by, bz), (bx, by + sign[1], bz)) + + if vz: + x = (0.5 - lz) / vz * vx + lx + y = (0.5 - lz) / vz * vy + ly + z = 0.5 + + if x >= -0.5 and x <= 0.5 and y >= -0.5 and y <= 0.5: + distance = math.sqrt((x - lx) ** 2 + (y - ly) ** 2 + (z - lz) ** 2) + return self.check(hit_callback, distance, (bx, by, bz), (bx, by, bz + sign[2])) \ No newline at end of file diff --git a/episode-13/main.py b/episode-13/main.py new file mode 100644 index 00000000..67b11c0a --- /dev/null +++ b/episode-13/main.py @@ -0,0 +1,172 @@ +import math +import random +import pyglet + +pyglet.options["shadow_window"] = False +pyglet.options["debug_gl"] = False + +import pyglet.gl as gl + +import player +import mob + +import world + +import hit + +class Window(pyglet.window.Window): + def __init__(self, **args): + super().__init__(**args) + + # create world + + self.world = world.World(self.width, self.height) + + # pyglet stuff + + pyglet.clock.schedule_interval(self.update, 1.0 / 60) + self.mouse_captured = False + + # misc stuff + + self.frame = 0 + self.holding = 19 # 5 + + def update(self, delta_time): + self.frame += 1 + # print(f"FPS: {1.0 / delta_time}") + + if not self.mouse_captured: + self.world.player.input = [0, 0, 0] + + self.world.player.update(delta_time) + + # update other entities + + for entity in self.world.entities: + entity.update(delta_time) + + def on_draw(self): + self.world.player.update_matrices() + + # draw stuff + + gl.glEnable(gl.GL_DEPTH_TEST) + + gl.glClearColor(0.0, 0.0, 0.0, 0.0) + self.clear() + + self.world.draw() + + gl.glFinish() + + # input functions + + def on_resize(self, width, height): + print(f"Resize {width} * {height}") + gl.glViewport(0, 0, width, height) + + self.world.player.view_width = width + self.world.player.view_height = height + + def on_mouse_press(self, x, y, button, modifiers): + if not self.mouse_captured: + self.mouse_captured = True + self.set_exclusive_mouse(True) + + return + + # handle breaking/placing blocks + + def hit_callback(current_block, next_block): + if button == pyglet.window.mouse.RIGHT: self.world.try_set_block(current_block, self.holding, self.world.player.collider) + elif button == pyglet.window.mouse.LEFT: self.world.set_block(next_block, 0) + elif button == pyglet.window.mouse.MIDDLE: self.holding = self.world.get_block_number(next_block) + + x, y, z = self.world.player.position + y += self.world.player.eyelevel + + hit_ray = hit.Hit_ray(self.world, self.world.player.rotation, (x, y, z)) + + while hit_ray.distance < hit.HIT_RANGE: + if hit_ray.step(hit_callback): + break + + def on_mouse_motion(self, x, y, delta_x, delta_y): + if self.mouse_captured: + sensitivity = 0.004 + + self.world.player.rotation[0] += delta_x * sensitivity + self.world.player.rotation[1] += delta_y * sensitivity + + self.world.player.rotation[1] = max(-math.tau / 4, min(math.tau / 4, self.world.player.rotation[1])) + + def on_mouse_drag(self, x, y, delta_x, delta_y, buttons, modifiers): + self.on_mouse_motion(x, y, delta_x, delta_y) + + def on_key_press(self, key, modifiers): + if not self.mouse_captured: + return + + if key == pyglet.window.key.D: self.world.player.input[0] += 1 + elif key == pyglet.window.key.A: self.world.player.input[0] -= 1 + elif key == pyglet.window.key.W: self.world.player.input[2] += 1 + elif key == pyglet.window.key.S: self.world.player.input[2] -= 1 + + elif key == pyglet.window.key.SPACE : self.world.player.input[1] += 1 + elif key == pyglet.window.key.LSHIFT: self.world.player.input[1] -= 1 + elif key == pyglet.window.key.LCTRL : self.world.player.target_speed = player.SPRINTING_SPEED + + elif key == pyglet.window.key.F: + self.world.player.flying = not self.world.player.flying + + elif key == pyglet.window.key.G: + self.holding = random.randint(1, len(self.world.block_types) - 1) + + elif key == pyglet.window.key.N: + self.world.player.ghost = not self.world.player.ghost + + elif key == pyglet.window.key.O: + self.world.save.save() + + elif key == pyglet.window.key.R: + self.world.player.reset() + + elif key == pyglet.window.key.B: + for entity in self.world.entities: + entity.reset() + + elif key == pyglet.window.key.E: + _mob = mob.Mob(self.world, random.choice([*self.world.entity_types.values()])) + self.world.entities.append(_mob) + + _mob.teleport(self.world.player.position) + + elif key == pyglet.window.key.ESCAPE: + self.mouse_captured = False + self.set_exclusive_mouse(False) + + def on_key_release(self, key, modifiers): + if not self.mouse_captured: + return + + if key == pyglet.window.key.D: self.world.player.input[0] -= 1 + elif key == pyglet.window.key.A: self.world.player.input[0] += 1 + elif key == pyglet.window.key.W: self.world.player.input[2] -= 1 + elif key == pyglet.window.key.S: self.world.player.input[2] += 1 + + elif key == pyglet.window.key.SPACE : self.world.player.input[1] -= 1 + elif key == pyglet.window.key.LSHIFT: self.world.player.input[1] += 1 + elif key == pyglet.window.key.LCTRL : self.world.player.target_speed = player.WALKING_SPEED + +class Game: + def __init__(self): + self.config = gl.Config(double_buffer = True, major_version = 3, minor_version = 3, depth_size = 16) + self.window = Window(config = self.config, width = 800, height = 600, caption = "Minecraft clone", resizable = True, vsync = False) + + def run(self): + pyglet.app.run() + +if __name__ == "__main__": + game = Game() + game.run() diff --git a/episode-13/matrix.py b/episode-13/matrix.py new file mode 100644 index 00000000..9557478b --- /dev/null +++ b/episode-13/matrix.py @@ -0,0 +1,158 @@ + +import copy +import ctypes +import math + +def copy_matrix(matrix): + return copy.deepcopy(matrix) # we need to use deepcopy since we're dealing with 2D arrays + +clean_matrix = [[0.0 for x in range(4)] for x in range(4)] +identity_matrix = copy_matrix(clean_matrix) + +identity_matrix[0][0] = 1.0 +identity_matrix[1][1] = 1.0 +identity_matrix[2][2] = 1.0 +identity_matrix[3][3] = 1.0 + +def multiply_matrices(x_matrix, y_matrix): + result_matrix = copy_matrix(clean_matrix) + + for i in range(4): + for j in range(4): + result_matrix[i][j] = \ + (x_matrix[0][j] * y_matrix[i][0]) + \ + (x_matrix[1][j] * y_matrix[i][1]) + \ + (x_matrix[2][j] * y_matrix[i][2]) + \ + (x_matrix[3][j] * y_matrix[i][3]) + + return result_matrix + +def multiply_matrix_vector(matrix, vector): + result = [0] * 4 + + for i, row in enumerate(zip(*matrix.data)): # transpose into row-major + result[i] = \ + row[0] * vector[0] + \ + row[1] * vector[1] + \ + row[2] * vector[2] + \ + row[3] * vector[3] + + return result + +def cross_product(u, v): + return [ + u[1] * v[2] - u[2] * v[1], + -u[0] * v[2] + u[2] * v[0], + u[0] * v[1] - u[1] * v[0], + ] + +class Matrix: + def __init__(self, base = None): + if type(base) == Matrix: self.data = copy_matrix(base.data) + elif type(base) == list: self.data = copy_matrix(base) + else: self.data = copy_matrix(clean_matrix) + + def load_identity(self): + self.data = copy_matrix(identity_matrix) + + def __mul__(self, matrix): + return Matrix(multiply_matrices(self.data, matrix.data)) + + def __imul__(self, matrix): + self.data = multiply_matrices(self.data, matrix.data) + + def scale(self, x, y, z): + for i in range(4): self.data[0][i] *= x + for i in range(4): self.data[1][i] *= y + for i in range(4): self.data[2][i] *= z + + def translate(self, x, y, z): + for i in range(4): + self.data[3][i] = self.data[3][i] + (self.data[0][i] * x + self.data[1][i] * y + self.data[2][i] * z) + + def rotate(self, angle, x, y, z): + magnitude = math.sqrt(x * x + y * y + z * z) + + x /= -magnitude + y /= -magnitude + z /= -magnitude + + sin_angle = math.sin(angle) + cos_angle = math.cos(angle) + one_minus_cos = 1.0 - cos_angle + + xx = x * x + yy = y * y + zz = z * z + + xy = x * y + yz = y * z + zx = z * x + + xs = x * sin_angle + ys = y * sin_angle + zs = z * sin_angle + + rotation_matrix = copy_matrix(clean_matrix) + + rotation_matrix[0][0] = (one_minus_cos * xx) + cos_angle + rotation_matrix[0][1] = (one_minus_cos * xy) - zs + rotation_matrix[0][2] = (one_minus_cos * zx) + ys + + rotation_matrix[1][0] = (one_minus_cos * xy) + zs + rotation_matrix[1][1] = (one_minus_cos * yy) + cos_angle + rotation_matrix[1][2] = (one_minus_cos * yz) - xs + + rotation_matrix[2][0] = (one_minus_cos * zx) - ys + rotation_matrix[2][1] = (one_minus_cos * yz) + xs + rotation_matrix[2][2] = (one_minus_cos * zz) + cos_angle + + rotation_matrix[3][3] = 1.0 + self.data = multiply_matrices(self.data, rotation_matrix) + + def rotate_2d(self, x, y): + self.rotate(x, 0, 1.0, 0) + self.rotate(-y, math.cos(x), 0, math.sin(x)) + + def frustum(self, left, right, bottom, top, near, far): + deltax = right - left + deltay = top - bottom + deltaz = far - near + + frustum_matrix = copy_matrix(clean_matrix) + + frustum_matrix[0][0] = 2 * near / deltax + frustum_matrix[1][1] = 2 * near / deltay + + frustum_matrix[2][0] = (right + left) / deltax + frustum_matrix[2][1] = (top + bottom) / deltay + frustum_matrix[2][2] = -(near + far) / deltaz + + frustum_matrix[2][3] = -1.0 + frustum_matrix[3][2] = -2 * near * far / deltaz + + self.data = multiply_matrices(self.data, frustum_matrix) + + def perspective(self, fovy, aspect, near, far): + frustum_y = math.tan(math.radians(fovy) / 2) + frustum_x = frustum_y * aspect + + self.frustum(-frustum_x * near, frustum_x * near, -frustum_y * near, frustum_y * near, near, far) + + def orthographic(self, left, right, bottom, top, near, far): + deltax = right - left + deltay = top - bottom + deltaz = far - near + + orthographic_matrix = copy_matrix(identity_matrix) + + orthographic_matrix[0][0] = 2.0 / deltax + orthographic_matrix[3][0] = -(right + left) / deltax + + orthographic_matrix[1][1] = 2.0 / deltay + orthographic_matrix[3][1] = -(top + bottom) / deltay + + orthographic_matrix[2][2] = 2.0 / deltax + orthographic_matrix[3][2] = -(near + far) / deltaz + + self.data = multiply_matrices(self.data, orthographic_matrix) diff --git a/episode-13/mob.py b/episode-13/mob.py new file mode 100644 index 00000000..51a9c97b --- /dev/null +++ b/episode-13/mob.py @@ -0,0 +1,50 @@ +import random +import math + +import entity + +class Mob(entity.Entity): + def __init__(self, world, entity_type): + super().__init__(world, entity_type) + + self.heading = 0 + self.select_target() + + self.reset() + + def select_target(self): + self.target = [x + random.randint(-5, 5) for x in self.position] + + def update(self, delta_time): + if not random.randint(0, int(3 / delta_time)): # change target every 3 seconds on average + self.select_target() + + delta_x = self.position[0] - self.target[0] + delta_y = self.position[2] - self.target[2] + + self.heading = -math.atan2(delta_y, delta_x) + math.tau / 4 + self.heading += math.modf((self.rotation[0] - math.tau / 4) / math.tau)[1] * math.tau + + if delta_time * 5 > 1: + self.rotation[0] = self.heading + + else: + self.rotation[0] += (self.heading - self.rotation[0]) * delta_time * 5 + + target_dist = math.sqrt(delta_x ** 2 + delta_y ** 2) + + if target_dist > 1: + self.accel[0] = math.cos(self.rotation[0] + math.tau / 4) * 3 + self.accel[2] = -math.sin(self.rotation[0] + math.tau / 4) * 3 + + super().update(delta_time) + + if self.wall and self.grounded: + if random.randint(0, 3): + self.jump() + + else: + self.select_target() + + if self.position[1] < 0: + self.teleport((0, 80, 0)) diff --git a/episode-13/models/__init__.py b/episode-13/models/__init__.py new file mode 100644 index 00000000..472191d7 --- /dev/null +++ b/episode-13/models/__init__.py @@ -0,0 +1,34 @@ +# all possible models + +__all__ = [ + "cube", + "plant", + "liquid", + "leaves", + "glass", + "slab", + "torch", + "fire", + "stairs", + "flat", + "crop", + "soil", + "sign_post", + "door", + "ladder", + "sign", + "lever", + "pressure_plate", + "button", + "snow", + "cactus", + "tinted_glass", + "pig", + "zombie", + "skeleton", + "creeper", + "cow", + "curry", +] + +from . import * diff --git a/episode-13/models/button.py b/episode-13/models/button.py new file mode 100644 index 00000000..c8d8731e --- /dev/null +++ b/episode-13/models/button.py @@ -0,0 +1,32 @@ +transparent = True +is_cube = False +glass = False + +colliders = [] + +vertex_positions = [ + [ 0.5, 0.0, 0.5, 0.5, -0.5, 0.5, 0.5, -0.5, -0.5, 0.5, 0.0, -0.5], # right + [-0.5, 0.0, -0.5, -0.5, -0.5, -0.5, -0.5, -0.5, 0.5, -0.5, 0.0, 0.5], # left + [ 0.5, 0.0, 0.5, 0.5, 0.0, -0.5, -0.5, 0.0, -0.5, -0.5, 0.0, 0.5], # top + [-0.5, -0.5, 0.5, -0.5, -0.5, -0.5, 0.5, -0.5, -0.5, 0.5, -0.5, 0.5], # bottom + [-0.5, 0.0, 0.5, -0.5, -0.5, 0.5, 0.5, -0.5, 0.5, 0.5, 0.0, 0.5], # front + [ 0.5, 0.0, -0.5, 0.5, -0.5, -0.5, -0.5, -0.5, -0.5, -0.5, 0.0, -0.5], # back +] + +tex_coords = [ + [0.0, 0.5, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 0.5, 0.0], + [0.0, 0.5, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 0.5, 0.0], + [0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 1.0, 0.0], + [0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 1.0, 0.0], + [0.0, 0.5, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 0.5, 0.0], + [0.0, 0.5, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 0.5, 0.0], +] + +shading_values = [ + [0.6, 0.6, 0.6, 0.6], + [0.6, 0.6, 0.6, 0.6], + [1.0, 1.0, 1.0, 1.0], + [0.4, 0.4, 0.4, 0.4], + [0.8, 0.8, 0.8, 0.8], + [0.8, 0.8, 0.8, 0.8], +] \ No newline at end of file diff --git a/episode-13/models/cactus.py b/episode-13/models/cactus.py new file mode 100644 index 00000000..37baf785 --- /dev/null +++ b/episode-13/models/cactus.py @@ -0,0 +1,37 @@ +transparent = True +is_cube = False +glass = False + +colliders = [ + [ + (-0.4375, -0.5, -0.4375), + ( 0.4375, 0.5, 0.4375) + ] +] + +vertex_positions = [ + [ 0.4375, 0.5000, 0.5000, 0.4375, -0.5000, 0.5000, 0.4375, -0.5000, -0.5000, 0.4375, 0.5000, -0.5000], # right + [-0.4375, 0.5000, -0.5000, -0.4375, -0.5000, -0.5000, -0.4375, -0.5000, 0.5000, -0.4375, 0.5000, 0.5000], # left + [ 0.5000, 0.5000, 0.5000, 0.5000, 0.5000, -0.5000, -0.5000, 0.5000, -0.5000, -0.5000, 0.5000, 0.5000], # top + [-0.5000, -0.5000, 0.5000, -0.5000, -0.5000, -0.5000, 0.5000, -0.5000, -0.5000, 0.5000, -0.5000, 0.5000], # bottom + [-0.5000, 0.5000, 0.4375, -0.5000, -0.5000, 0.4375, 0.5000, -0.5000, 0.4375, 0.5000, 0.5000, 0.4375], # front + [ 0.5000, 0.5000, -0.4375, 0.5000, -0.5000, -0.4375, -0.5000, -0.5000, -0.4375, -0.5000, 0.5000, -0.4375], # back +] + +tex_coords = [ + [0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 1.0, 0.0], + [0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 1.0, 0.0], + [0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 1.0, 0.0], + [0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 1.0, 0.0], + [0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 1.0, 0.0], + [0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 1.0, 0.0], +] + +shading_values = [ + [0.6, 0.6, 0.6, 0.6], + [0.6, 0.6, 0.6, 0.6], + [1.0, 1.0, 1.0, 1.0], + [0.4, 0.4, 0.4, 0.4], + [0.8, 0.8, 0.8, 0.8], + [0.8, 0.8, 0.8, 0.8], +] \ No newline at end of file diff --git a/episode-13/models/cow.py b/episode-13/models/cow.py new file mode 100644 index 00000000..d88f904d --- /dev/null +++ b/episode-13/models/cow.py @@ -0,0 +1,8 @@ + +transparent = True +is_cube = False +glass = False + +colliders = [] + +bones = [{'name':'body','pivot':[0.0, 1.1875, 0.125],'vertices':[[-0.3749999701976776, 0.7499999403953552, 0.625, -0.3749999701976776, 0.7499999403953552, -0.5, 0.3749999701976776, 0.7499999403953552, -0.5, 0.3749999701976776, 0.7499999403953552, 0.625], [0.3749999701976776, 1.375, 0.625, 0.3749999701976776, 1.3749998807907104, -0.5, -0.3749999701976776, 1.3749998807907104, -0.5, -0.3749999701976776, 1.375, 0.625], [-0.3749999701976776, 0.7499999403953552, -0.5, -0.3749999701976776, 1.3749998807907104, -0.5, 0.3749999701976776, 1.3749998807907104, -0.5, 0.3749999701976776, 0.7499999403953552, -0.5], [0.3749999701976776, 0.7499999403953552, 0.625, 0.3749999701976776, 1.375, 0.625, -0.3749999701976776, 1.375, 0.625, -0.3749999701976776, 0.7499999403953552, 0.625], [0.3749999701976776, 0.7499999403953552, 0.625, 0.3749999701976776, 0.7499999403953552, -0.5, 0.3749999701976776, 1.3749998807907104, -0.5, 0.3749999701976776, 1.375, 0.625], [-0.3749999701976776, 1.375, 0.625, -0.3749999701976776, 1.3749998807907104, -0.5, -0.3749999701976776, 0.7499999403953552, -0.5, -0.3749999701976776, 0.7499999403953552, 0.625], [-0.1249999925494194, 0.6874999403953552, 0.625, -0.1249999925494194, 0.6874999403953552, 0.25, 0.1249999925494194, 0.6874999403953552, 0.25, 0.1249999925494194, 0.6874999403953552, 0.625], [0.1249999925494194, 0.7499999403953552, 0.625, 0.1249999925494194, 0.7499999403953552, 0.25, -0.1249999925494194, 0.7499999403953552, 0.25, -0.1249999925494194, 0.7499999403953552, 0.625], [-0.1249999925494194, 0.6874999403953552, 0.25, -0.1249999925494194, 0.7499999403953552, 0.25, 0.1249999925494194, 0.7499999403953552, 0.25, 0.1249999925494194, 0.6874999403953552, 0.25], [0.1249999925494194, 0.6874999403953552, 0.625, 0.1249999925494194, 0.7499999403953552, 0.625, -0.1249999925494194, 0.7499999403953552, 0.625, -0.1249999925494194, 0.6874999403953552, 0.625], [0.1249999925494194, 0.6874999403953552, 0.625, 0.1249999925494194, 0.6874999403953552, 0.25, 0.1249999925494194, 0.7499999403953552, 0.25, 0.1249999925494194, 0.7499999403953552, 0.625], [-0.1249999925494194, 0.7499999403953552, 0.625, -0.1249999925494194, 0.7499999403953552, 0.25, -0.1249999925494194, 0.6874999403953552, 0.25, -0.1249999925494194, 0.6874999403953552, 0.625]],'tex_coords':[[0.06493506493506493, 0.0, 0.06493506493506493, 0.6428571428571428, 0.14285714285714285, 0.6428571428571428, 0.14285714285714285, 0.0], [0.2077922077922078, 0.0, 0.2077922077922078, 0.6428571428571428, 0.2857142857142857, 0.6428571428571428, 0.2857142857142857, 0.0], [0.06493506493506493, 0.6428571428571428, 0.06493506493506493, 1.0, 0.14285714285714285, 1.0, 0.14285714285714285, 0.6428571428571428], [0.14285714285714285, 0.6428571428571428, 0.14285714285714285, 1.0, 0.22077922077922077, 1.0, 0.22077922077922077, 0.6428571428571428], [0.14285714285714285, 0.0, 0.14285714285714285, 0.6428571428571428, 0.2077922077922078, 0.6428571428571428, 0.2077922077922078, 0.0], [0.0, 0.0, 0.0, 0.6428571428571428, 0.06493506493506493, 0.6428571428571428, 0.06493506493506493, 0.0], [0.2922077922077922, 0.75, 0.2922077922077922, 0.9642857142857143, 0.3181818181818182, 0.9642857142857143, 0.3181818181818182, 0.75], [0.3246753246753247, 0.75, 0.3246753246753247, 0.9642857142857143, 0.35064935064935066, 0.9642857142857143, 0.35064935064935066, 0.75], [0.2922077922077922, 0.9642857142857143, 0.2922077922077922, 1.0, 0.3181818181818182, 1.0, 0.3181818181818182, 0.9642857142857143], [0.3181818181818182, 0.9642857142857143, 0.3181818181818182, 1.0, 0.34415584415584416, 1.0, 0.34415584415584416, 0.9642857142857143], [0.3181818181818182, 0.75, 0.3181818181818182, 0.9642857142857143, 0.3246753246753247, 0.9642857142857143, 0.3246753246753247, 0.75], [0.2857142857142857, 0.75, 0.2857142857142857, 0.9642857142857143, 0.2922077922077922, 0.9642857142857143, 0.2922077922077922, 0.75]],'shading_values':[[1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0]]}, {'name':'head','pivot':[0.0, 1.25, -0.5],'vertices':[[-0.25, 1.0, -0.875, -0.25, 1.5, -0.875, 0.25, 1.5, -0.875, 0.25, 1.0, -0.875], [0.25, 1.0, -0.5, 0.25, 1.5, -0.5, -0.25, 1.5, -0.5, -0.25, 1.0, -0.5], [-0.25, 1.5, -0.875, -0.25, 1.5, -0.5, 0.25, 1.5, -0.5, 0.25, 1.5, -0.875], [0.25, 1.0, -0.875, 0.25, 1.0, -0.5, -0.25, 1.0, -0.5, -0.25, 1.0, -0.875], [0.25, 1.0, -0.875, 0.25, 1.5, -0.875, 0.25, 1.5, -0.5, 0.25, 1.0, -0.5], [-0.25, 1.0, -0.5, -0.25, 1.5, -0.5, -0.25, 1.5, -0.875, -0.25, 1.0, -0.875], [-0.3125, 1.375, -0.75, -0.3125, 1.5625, -0.75, -0.25, 1.5625, -0.75, -0.25, 1.375, -0.75], [-0.25, 1.375, -0.6875, -0.25, 1.5625, -0.6875, -0.3125, 1.5625, -0.6875, -0.3125, 1.375, -0.6875], [-0.3125, 1.5625, -0.75, -0.3125, 1.5625, -0.6875, -0.25, 1.5625, -0.6875, -0.25, 1.5625, -0.75], [-0.25, 1.375, -0.75, -0.25, 1.375, -0.6875, -0.3125, 1.375, -0.6875, -0.3125, 1.375, -0.75], [-0.25, 1.375, -0.75, -0.25, 1.5625, -0.75, -0.25, 1.5625, -0.6875, -0.25, 1.375, -0.6875], [-0.3125, 1.375, -0.6875, -0.3125, 1.5625, -0.6875, -0.3125, 1.5625, -0.75, -0.3125, 1.375, -0.75], [0.25, 1.375, -0.75, 0.25, 1.5625, -0.75, 0.3125, 1.5625, -0.75, 0.3125, 1.375, -0.75], [0.3125, 1.375, -0.6875, 0.3125, 1.5625, -0.6875, 0.25, 1.5625, -0.6875, 0.25, 1.375, -0.6875], [0.25, 1.5625, -0.75, 0.25, 1.5625, -0.6875, 0.3125, 1.5625, -0.6875, 0.3125, 1.5625, -0.75], [0.3125, 1.375, -0.75, 0.3125, 1.375, -0.6875, 0.25, 1.375, -0.6875, 0.25, 1.375, -0.75], [0.3125, 1.375, -0.75, 0.3125, 1.5625, -0.75, 0.3125, 1.5625, -0.6875, 0.3125, 1.375, -0.6875], [0.25, 1.375, -0.6875, 0.25, 1.5625, -0.6875, 0.25, 1.5625, -0.75, 0.25, 1.375, -0.75]],'tex_coords':[[0.38961038961038963, 0.5, 0.38961038961038963, 0.7857142857142857, 0.44155844155844154, 0.7857142857142857, 0.44155844155844154, 0.5], [0.4805194805194805, 0.5, 0.4805194805194805, 0.7857142857142857, 0.5324675324675324, 0.7857142857142857, 0.5324675324675324, 0.5], [0.38961038961038963, 0.7857142857142857, 0.38961038961038963, 1.0, 0.44155844155844154, 1.0, 0.44155844155844154, 0.7857142857142857], [0.44155844155844154, 0.7857142857142857, 0.44155844155844154, 1.0, 0.4935064935064935, 1.0, 0.4935064935064935, 0.7857142857142857], [0.44155844155844154, 0.5, 0.44155844155844154, 0.7857142857142857, 0.4805194805194805, 0.7857142857142857, 0.4805194805194805, 0.5], [0.35064935064935066, 0.5, 0.35064935064935066, 0.7857142857142857, 0.38961038961038963, 0.7857142857142857, 0.38961038961038963, 0.5], [0.538961038961039, 0.8571428571428572, 0.538961038961039, 0.9642857142857143, 0.5454545454545454, 0.9642857142857143, 0.5454545454545454, 0.8571428571428572], [0.551948051948052, 0.8571428571428572, 0.551948051948052, 0.9642857142857143, 0.5584415584415584, 0.9642857142857143, 0.5584415584415584, 0.8571428571428572], [0.538961038961039, 0.9642857142857143, 0.538961038961039, 1.0, 0.5454545454545454, 1.0, 0.5454545454545454, 0.9642857142857143], [0.5454545454545454, 0.9642857142857143, 0.5454545454545454, 1.0, 0.551948051948052, 1.0, 0.551948051948052, 0.9642857142857143], [0.5454545454545454, 0.8571428571428572, 0.5454545454545454, 0.9642857142857143, 0.551948051948052, 0.9642857142857143, 0.551948051948052, 0.8571428571428572], [0.5324675324675324, 0.8571428571428572, 0.5324675324675324, 0.9642857142857143, 0.538961038961039, 0.9642857142857143, 0.538961038961039, 0.8571428571428572], [0.564935064935065, 0.8571428571428572, 0.564935064935065, 0.9642857142857143, 0.5714285714285714, 0.9642857142857143, 0.5714285714285714, 0.8571428571428572], [0.577922077922078, 0.8571428571428572, 0.577922077922078, 0.9642857142857143, 0.5844155844155844, 0.9642857142857143, 0.5844155844155844, 0.8571428571428572], [0.564935064935065, 0.9642857142857143, 0.564935064935065, 1.0, 0.5714285714285714, 1.0, 0.5714285714285714, 0.9642857142857143], [0.5714285714285714, 0.9642857142857143, 0.5714285714285714, 1.0, 0.577922077922078, 1.0, 0.577922077922078, 0.9642857142857143], [0.5714285714285714, 0.8571428571428572, 0.5714285714285714, 0.9642857142857143, 0.577922077922078, 0.9642857142857143, 0.577922077922078, 0.8571428571428572], [0.5584415584415584, 0.8571428571428572, 0.5584415584415584, 0.9642857142857143, 0.564935064935065, 0.9642857142857143, 0.564935064935065, 0.8571428571428572]],'shading_values':[[1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0]]}, {'name':'leg0','pivot':[-0.25, 0.75, 0.4375],'vertices':[[-0.3125, 0.0, 0.3125, -0.3125, 0.75, 0.3125, -0.0625, 0.75, 0.3125, -0.0625, 0.0, 0.3125], [-0.0625, 0.0, 0.5625, -0.0625, 0.75, 0.5625, -0.3125, 0.75, 0.5625, -0.3125, 0.0, 0.5625], [-0.3125, 0.75, 0.3125, -0.3125, 0.75, 0.5625, -0.0625, 0.75, 0.5625, -0.0625, 0.75, 0.3125], [-0.0625, 0.0, 0.3125, -0.0625, 0.0, 0.5625, -0.3125, 0.0, 0.5625, -0.3125, 0.0, 0.3125], [-0.0625, 0.0, 0.3125, -0.0625, 0.75, 0.3125, -0.0625, 0.75, 0.5625, -0.0625, 0.0, 0.5625], [-0.3125, 0.0, 0.5625, -0.3125, 0.75, 0.5625, -0.3125, 0.75, 0.3125, -0.3125, 0.0, 0.3125]],'tex_coords':[[0.6103896103896104, 0.4285714285714286, 0.6103896103896104, 0.8571428571428572, 0.6363636363636364, 0.8571428571428572, 0.6363636363636364, 0.4285714285714286], [0.6623376623376623, 0.4285714285714286, 0.6623376623376623, 0.8571428571428572, 0.6883116883116883, 0.8571428571428572, 0.6883116883116883, 0.4285714285714286], [0.6103896103896104, 0.8571428571428572, 0.6103896103896104, 1.0, 0.6363636363636364, 1.0, 0.6363636363636364, 0.8571428571428572], [0.6363636363636364, 0.8571428571428572, 0.6363636363636364, 1.0, 0.6623376623376623, 1.0, 0.6623376623376623, 0.8571428571428572], [0.6363636363636364, 0.4285714285714286, 0.6363636363636364, 0.8571428571428572, 0.6623376623376623, 0.8571428571428572, 0.6623376623376623, 0.4285714285714286], [0.5844155844155844, 0.4285714285714286, 0.5844155844155844, 0.8571428571428572, 0.6103896103896104, 0.8571428571428572, 0.6103896103896104, 0.4285714285714286]],'shading_values':[[1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0]]}, {'name':'leg1','pivot':[0.25, 0.75, 0.4375],'vertices':[[0.0625, 0.0, 0.3125, 0.0625, 0.75, 0.3125, 0.3125, 0.75, 0.3125, 0.3125, 0.0, 0.3125], [0.3125, 0.0, 0.5625, 0.3125, 0.75, 0.5625, 0.0625, 0.75, 0.5625, 0.0625, 0.0, 0.5625], [0.0625, 0.75, 0.3125, 0.0625, 0.75, 0.5625, 0.3125, 0.75, 0.5625, 0.3125, 0.75, 0.3125], [0.3125, 0.0, 0.3125, 0.3125, 0.0, 0.5625, 0.0625, 0.0, 0.5625, 0.0625, 0.0, 0.3125], [0.3125, 0.0, 0.3125, 0.3125, 0.75, 0.3125, 0.3125, 0.75, 0.5625, 0.3125, 0.0, 0.5625], [0.0625, 0.0, 0.5625, 0.0625, 0.75, 0.5625, 0.0625, 0.75, 0.3125, 0.0625, 0.0, 0.3125]],'tex_coords':[[0.7142857142857143, 0.4285714285714286, 0.7142857142857143, 0.8571428571428572, 0.7402597402597403, 0.8571428571428572, 0.7402597402597403, 0.4285714285714286], [0.7662337662337663, 0.4285714285714286, 0.7662337662337663, 0.8571428571428572, 0.7922077922077922, 0.8571428571428572, 0.7922077922077922, 0.4285714285714286], [0.7142857142857143, 0.8571428571428572, 0.7142857142857143, 1.0, 0.7402597402597403, 1.0, 0.7402597402597403, 0.8571428571428572], [0.7402597402597403, 0.8571428571428572, 0.7402597402597403, 1.0, 0.7662337662337663, 1.0, 0.7662337662337663, 0.8571428571428572], [0.7402597402597403, 0.4285714285714286, 0.7402597402597403, 0.8571428571428572, 0.7662337662337663, 0.8571428571428572, 0.7662337662337663, 0.4285714285714286], [0.6883116883116883, 0.4285714285714286, 0.6883116883116883, 0.8571428571428572, 0.7142857142857143, 0.8571428571428572, 0.7142857142857143, 0.4285714285714286]],'shading_values':[[1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0]]}, {'name':'leg2','pivot':[-0.25, 0.75, -0.375],'vertices':[[-0.3125, 0.0, -0.4375, -0.3125, 0.75, -0.4375, -0.0625, 0.75, -0.4375, -0.0625, 0.0, -0.4375], [-0.0625, 0.0, -0.1875, -0.0625, 0.75, -0.1875, -0.3125, 0.75, -0.1875, -0.3125, 0.0, -0.1875], [-0.3125, 0.75, -0.4375, -0.3125, 0.75, -0.1875, -0.0625, 0.75, -0.1875, -0.0625, 0.75, -0.4375], [-0.0625, 0.0, -0.4375, -0.0625, 0.0, -0.1875, -0.3125, 0.0, -0.1875, -0.3125, 0.0, -0.4375], [-0.0625, 0.0, -0.4375, -0.0625, 0.75, -0.4375, -0.0625, 0.75, -0.1875, -0.0625, 0.0, -0.1875], [-0.3125, 0.0, -0.1875, -0.3125, 0.75, -0.1875, -0.3125, 0.75, -0.4375, -0.3125, 0.0, -0.4375]],'tex_coords':[[0.8181818181818182, 0.4285714285714286, 0.8181818181818182, 0.8571428571428572, 0.8441558441558441, 0.8571428571428572, 0.8441558441558441, 0.4285714285714286], [0.8701298701298701, 0.4285714285714286, 0.8701298701298701, 0.8571428571428572, 0.8961038961038961, 0.8571428571428572, 0.8961038961038961, 0.4285714285714286], [0.8181818181818182, 0.8571428571428572, 0.8181818181818182, 1.0, 0.8441558441558441, 1.0, 0.8441558441558441, 0.8571428571428572], [0.8441558441558441, 0.8571428571428572, 0.8441558441558441, 1.0, 0.8701298701298701, 1.0, 0.8701298701298701, 0.8571428571428572], [0.8441558441558441, 0.4285714285714286, 0.8441558441558441, 0.8571428571428572, 0.8701298701298701, 0.8571428571428572, 0.8701298701298701, 0.4285714285714286], [0.7922077922077922, 0.4285714285714286, 0.7922077922077922, 0.8571428571428572, 0.8181818181818182, 0.8571428571428572, 0.8181818181818182, 0.4285714285714286]],'shading_values':[[1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0]]}, {'name':'leg3','pivot':[0.25, 0.75, -0.375],'vertices':[[0.0625, 0.0, -0.4375, 0.0625, 0.75, -0.4375, 0.3125, 0.75, -0.4375, 0.3125, 0.0, -0.4375], [0.3125, 0.0, -0.1875, 0.3125, 0.75, -0.1875, 0.0625, 0.75, -0.1875, 0.0625, 0.0, -0.1875], [0.0625, 0.75, -0.4375, 0.0625, 0.75, -0.1875, 0.3125, 0.75, -0.1875, 0.3125, 0.75, -0.4375], [0.3125, 0.0, -0.4375, 0.3125, 0.0, -0.1875, 0.0625, 0.0, -0.1875, 0.0625, 0.0, -0.4375], [0.3125, 0.0, -0.4375, 0.3125, 0.75, -0.4375, 0.3125, 0.75, -0.1875, 0.3125, 0.0, -0.1875], [0.0625, 0.0, -0.1875, 0.0625, 0.75, -0.1875, 0.0625, 0.75, -0.4375, 0.0625, 0.0, -0.4375]],'tex_coords':[[0.922077922077922, 0.4285714285714286, 0.922077922077922, 0.8571428571428572, 0.948051948051948, 0.8571428571428572, 0.948051948051948, 0.4285714285714286], [0.974025974025974, 0.4285714285714286, 0.974025974025974, 0.8571428571428572, 1.0, 0.8571428571428572, 1.0, 0.4285714285714286], [0.922077922077922, 0.8571428571428572, 0.922077922077922, 1.0, 0.948051948051948, 1.0, 0.948051948051948, 0.8571428571428572], [0.948051948051948, 0.8571428571428572, 0.948051948051948, 1.0, 0.974025974025974, 1.0, 0.974025974025974, 0.8571428571428572], [0.948051948051948, 0.4285714285714286, 0.948051948051948, 0.8571428571428572, 0.974025974025974, 0.8571428571428572, 0.974025974025974, 0.4285714285714286], [0.8961038961038961, 0.4285714285714286, 0.8961038961038961, 0.8571428571428572, 0.922077922077922, 0.8571428571428572, 0.922077922077922, 0.4285714285714286]],'shading_values':[[1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0]]}] diff --git a/episode-13/models/creeper.py b/episode-13/models/creeper.py new file mode 100644 index 00000000..f6860aa7 --- /dev/null +++ b/episode-13/models/creeper.py @@ -0,0 +1,8 @@ + +transparent = True +is_cube = False +glass = False + +colliders = [] + +bones = [{'name':'body','pivot':[0.0, 0.0, 0.0],'vertices':[[-0.25, 0.375, -0.125, -0.25, 1.125, -0.125, 0.25, 1.125, -0.125, 0.25, 0.375, -0.125], [0.25, 0.375, 0.125, 0.25, 1.125, 0.125, -0.25, 1.125, 0.125, -0.25, 0.375, 0.125], [-0.25, 1.125, -0.125, -0.25, 1.125, 0.125, 0.25, 1.125, 0.125, 0.25, 1.125, -0.125], [0.25, 0.375, -0.125, 0.25, 0.375, 0.125, -0.25, 0.375, 0.125, -0.25, 0.375, -0.125], [0.25, 0.375, -0.125, 0.25, 1.125, -0.125, 0.25, 1.125, 0.125, 0.25, 0.375, 0.125], [-0.25, 0.375, 0.125, -0.25, 1.125, 0.125, -0.25, 1.125, -0.125, -0.25, 0.375, -0.125]],'tex_coords':[[0.03333333333333333, 0.0, 0.03333333333333333, 0.75, 0.1, 0.75, 0.1, 0.0], [0.13333333333333333, 0.0, 0.13333333333333333, 0.75, 0.2, 0.75, 0.2, 0.0], [0.03333333333333333, 0.75, 0.03333333333333333, 1.0, 0.1, 1.0, 0.1, 0.75], [0.1, 0.75, 0.1, 1.0, 0.16666666666666666, 1.0, 0.16666666666666666, 0.75], [0.1, 0.0, 0.1, 0.75, 0.13333333333333333, 0.75, 0.13333333333333333, 0.0], [0.0, 0.0, 0.0, 0.75, 0.03333333333333333, 0.75, 0.03333333333333333, 0.0]],'shading_values':[[1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0]]}, {'name':'head','pivot':[0.0, 1.125, 0.0],'vertices':[[-0.25, 1.125, -0.25, -0.25, 1.625, -0.25, 0.25, 1.625, -0.25, 0.25, 1.125, -0.25], [0.25, 1.125, 0.25, 0.25, 1.625, 0.25, -0.25, 1.625, 0.25, -0.25, 1.125, 0.25], [-0.25, 1.625, -0.25, -0.25, 1.625, 0.25, 0.25, 1.625, 0.25, 0.25, 1.625, -0.25], [0.25, 1.125, -0.25, 0.25, 1.125, 0.25, -0.25, 1.125, 0.25, -0.25, 1.125, -0.25], [0.25, 1.125, -0.25, 0.25, 1.625, -0.25, 0.25, 1.625, 0.25, 0.25, 1.125, 0.25], [-0.25, 1.125, 0.25, -0.25, 1.625, 0.25, -0.25, 1.625, -0.25, -0.25, 1.125, -0.25]],'tex_coords':[[0.26666666666666666, 0.0, 0.26666666666666666, 0.5, 0.3333333333333333, 0.5, 0.3333333333333333, 0.0], [0.4, 0.0, 0.4, 0.5, 0.4666666666666667, 0.5, 0.4666666666666667, 0.0], [0.26666666666666666, 0.5, 0.26666666666666666, 1.0, 0.3333333333333333, 1.0, 0.3333333333333333, 0.5], [0.3333333333333333, 0.5, 0.3333333333333333, 1.0, 0.4, 1.0, 0.4, 0.5], [0.3333333333333333, 0.0, 0.3333333333333333, 0.5, 0.4, 0.5, 0.4, 0.0], [0.2, 0.0, 0.2, 0.5, 0.26666666666666666, 0.5, 0.26666666666666666, 0.0]],'shading_values':[[1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0]]}, {'name':'leg0','pivot':[-0.125, 0.375, 0.25],'vertices':[[-0.25, 0.0, 0.125, -0.25, 0.375, 0.125, 0.0, 0.375, 0.125, 0.0, 0.0, 0.125], [0.0, 0.0, 0.375, 0.0, 0.375, 0.375, -0.25, 0.375, 0.375, -0.25, 0.0, 0.375], [-0.25, 0.375, 0.125, -0.25, 0.375, 0.375, 0.0, 0.375, 0.375, 0.0, 0.375, 0.125], [0.0, 0.0, 0.125, 0.0, 0.0, 0.375, -0.25, 0.0, 0.375, -0.25, 0.0, 0.125], [0.0, 0.0, 0.125, 0.0, 0.375, 0.125, 0.0, 0.375, 0.375, 0.0, 0.0, 0.375], [-0.25, 0.0, 0.375, -0.25, 0.375, 0.375, -0.25, 0.375, 0.125, -0.25, 0.0, 0.125]],'tex_coords':[[0.5, 0.375, 0.5, 0.75, 0.5333333333333333, 0.75, 0.5333333333333333, 0.375], [0.5666666666666667, 0.375, 0.5666666666666667, 0.75, 0.6, 0.75, 0.6, 0.375], [0.5, 0.75, 0.5, 1.0, 0.5333333333333333, 1.0, 0.5333333333333333, 0.75], [0.5333333333333333, 0.75, 0.5333333333333333, 1.0, 0.5666666666666667, 1.0, 0.5666666666666667, 0.75], [0.5333333333333333, 0.375, 0.5333333333333333, 0.75, 0.5666666666666667, 0.75, 0.5666666666666667, 0.375], [0.4666666666666667, 0.375, 0.4666666666666667, 0.75, 0.5, 0.75, 0.5, 0.375]],'shading_values':[[1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0]]}, {'name':'leg1','pivot':[0.125, 0.375, 0.25],'vertices':[[0.0, 0.0, 0.125, 0.0, 0.375, 0.125, 0.25, 0.375, 0.125, 0.25, 0.0, 0.125], [0.25, 0.0, 0.375, 0.25, 0.375, 0.375, 0.0, 0.375, 0.375, 0.0, 0.0, 0.375], [0.0, 0.375, 0.125, 0.0, 0.375, 0.375, 0.25, 0.375, 0.375, 0.25, 0.375, 0.125], [0.25, 0.0, 0.125, 0.25, 0.0, 0.375, 0.0, 0.0, 0.375, 0.0, 0.0, 0.125], [0.25, 0.0, 0.125, 0.25, 0.375, 0.125, 0.25, 0.375, 0.375, 0.25, 0.0, 0.375], [0.0, 0.0, 0.375, 0.0, 0.375, 0.375, 0.0, 0.375, 0.125, 0.0, 0.0, 0.125]],'tex_coords':[[0.6333333333333333, 0.375, 0.6333333333333333, 0.75, 0.6666666666666666, 0.75, 0.6666666666666666, 0.375], [0.7, 0.375, 0.7, 0.75, 0.7333333333333333, 0.75, 0.7333333333333333, 0.375], [0.6333333333333333, 0.75, 0.6333333333333333, 1.0, 0.6666666666666666, 1.0, 0.6666666666666666, 0.75], [0.6666666666666666, 0.75, 0.6666666666666666, 1.0, 0.7, 1.0, 0.7, 0.75], [0.6666666666666666, 0.375, 0.6666666666666666, 0.75, 0.7, 0.75, 0.7, 0.375], [0.6, 0.375, 0.6, 0.75, 0.6333333333333333, 0.75, 0.6333333333333333, 0.375]],'shading_values':[[1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0]]}, {'name':'leg2','pivot':[-0.125, 0.375, -0.25],'vertices':[[-0.25, 0.0, -0.375, -0.25, 0.375, -0.375, 0.0, 0.375, -0.375, 0.0, 0.0, -0.375], [0.0, 0.0, -0.125, 0.0, 0.375, -0.125, -0.25, 0.375, -0.125, -0.25, 0.0, -0.125], [-0.25, 0.375, -0.375, -0.25, 0.375, -0.125, 0.0, 0.375, -0.125, 0.0, 0.375, -0.375], [0.0, 0.0, -0.375, 0.0, 0.0, -0.125, -0.25, 0.0, -0.125, -0.25, 0.0, -0.375], [0.0, 0.0, -0.375, 0.0, 0.375, -0.375, 0.0, 0.375, -0.125, 0.0, 0.0, -0.125], [-0.25, 0.0, -0.125, -0.25, 0.375, -0.125, -0.25, 0.375, -0.375, -0.25, 0.0, -0.375]],'tex_coords':[[0.7666666666666667, 0.375, 0.7666666666666667, 0.75, 0.8, 0.75, 0.8, 0.375], [0.8333333333333334, 0.375, 0.8333333333333334, 0.75, 0.8666666666666667, 0.75, 0.8666666666666667, 0.375], [0.7666666666666667, 0.75, 0.7666666666666667, 1.0, 0.8, 1.0, 0.8, 0.75], [0.8, 0.75, 0.8, 1.0, 0.8333333333333334, 1.0, 0.8333333333333334, 0.75], [0.8, 0.375, 0.8, 0.75, 0.8333333333333334, 0.75, 0.8333333333333334, 0.375], [0.7333333333333333, 0.375, 0.7333333333333333, 0.75, 0.7666666666666667, 0.75, 0.7666666666666667, 0.375]],'shading_values':[[1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0]]}, {'name':'leg3','pivot':[0.125, 0.375, -0.25],'vertices':[[0.0, 0.0, -0.375, 0.0, 0.375, -0.375, 0.25, 0.375, -0.375, 0.25, 0.0, -0.375], [0.25, 0.0, -0.125, 0.25, 0.375, -0.125, 0.0, 0.375, -0.125, 0.0, 0.0, -0.125], [0.0, 0.375, -0.375, 0.0, 0.375, -0.125, 0.25, 0.375, -0.125, 0.25, 0.375, -0.375], [0.25, 0.0, -0.375, 0.25, 0.0, -0.125, 0.0, 0.0, -0.125, 0.0, 0.0, -0.375], [0.25, 0.0, -0.375, 0.25, 0.375, -0.375, 0.25, 0.375, -0.125, 0.25, 0.0, -0.125], [0.0, 0.0, -0.125, 0.0, 0.375, -0.125, 0.0, 0.375, -0.375, 0.0, 0.0, -0.375]],'tex_coords':[[0.9, 0.375, 0.9, 0.75, 0.9333333333333333, 0.75, 0.9333333333333333, 0.375], [0.9666666666666667, 0.375, 0.9666666666666667, 0.75, 1.0, 0.75, 1.0, 0.375], [0.9, 0.75, 0.9, 1.0, 0.9333333333333333, 1.0, 0.9333333333333333, 0.75], [0.9333333333333333, 0.75, 0.9333333333333333, 1.0, 0.9666666666666667, 1.0, 0.9666666666666667, 0.75], [0.9333333333333333, 0.375, 0.9333333333333333, 0.75, 0.9666666666666667, 0.75, 0.9666666666666667, 0.375], [0.8666666666666667, 0.375, 0.8666666666666667, 0.75, 0.9, 0.75, 0.9, 0.375]],'shading_values':[[1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0]]}] diff --git a/episode-13/models/crop.py b/episode-13/models/crop.py new file mode 100644 index 00000000..e381cdb1 --- /dev/null +++ b/episode-13/models/crop.py @@ -0,0 +1,38 @@ +transparent = True +is_cube = False +glass = False + +colliders = [] + +vertex_positions = [ + [ 0.25, 0.4375, 0.50, 0.25, -0.5625, 0.50, 0.25, -0.5625, -0.50, 0.25, 0.4375, -0.50], # right + [ 0.25, 0.4375, -0.50, 0.25, -0.5625, -0.50, 0.25, -0.5625, 0.50, 0.25, 0.4375, 0.50], # right + [-0.25, 0.4375, -0.50, -0.25, -0.5625, -0.50, -0.25, -0.5625, 0.50, -0.25, 0.4375, 0.50], # left + [-0.25, 0.4375, 0.50, -0.25, -0.5625, 0.50, -0.25, -0.5625, -0.50, -0.25, 0.4375, -0.50], # left + [-0.50, 0.4375, 0.25, -0.50, -0.5625, 0.25, 0.50, -0.5625, 0.25, 0.50, 0.4375, 0.25], # front + [ 0.50, 0.4375, 0.25, 0.50, -0.5625, 0.25, -0.50, -0.5625, 0.25, -0.50, 0.4375, 0.25], # front + [ 0.50, 0.4375, -0.25, 0.50, -0.5625, -0.25, -0.50, -0.5625, -0.25, -0.50, 0.4375, -0.25], # back + [-0.50, 0.4375, -0.25, -0.50, -0.5625, -0.25, 0.50, -0.5625, -0.25, 0.50, 0.4375, -0.25], # back +] + +tex_coords = [ + [0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 1.0, 0.0], + [0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 1.0, 0.0], + [0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 1.0, 0.0], + [0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 1.0, 0.0], + [0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 1.0, 0.0], + [0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 1.0, 0.0], + [0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 1.0, 0.0], + [0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 1.0, 0.0], +] + +shading_values = [ + [0.6, 0.6, 0.6, 0.6], + [0.6, 0.6, 0.6, 0.6], + [0.6, 0.6, 0.6, 0.6], + [0.6, 0.6, 0.6, 0.6], + [0.8, 0.8, 0.8, 0.8], + [0.8, 0.8, 0.8, 0.8], + [0.8, 0.8, 0.8, 0.8], + [0.8, 0.8, 0.8, 0.8], +] \ No newline at end of file diff --git a/episode-13/models/cube.py b/episode-13/models/cube.py new file mode 100644 index 00000000..314edd50 --- /dev/null +++ b/episode-13/models/cube.py @@ -0,0 +1,37 @@ +transparent = False +is_cube = True +glass = False + +colliders = [ + [ + (-0.5, -0.5, -0.5), + ( 0.5, 0.5, 0.5) + ] +] + +vertex_positions = [ + [ 0.5, 0.5, 0.5, 0.5, -0.5, 0.5, 0.5, -0.5, -0.5, 0.5, 0.5, -0.5], # right + [-0.5, 0.5, -0.5, -0.5, -0.5, -0.5, -0.5, -0.5, 0.5, -0.5, 0.5, 0.5], # left + [ 0.5, 0.5, 0.5, 0.5, 0.5, -0.5, -0.5, 0.5, -0.5, -0.5, 0.5, 0.5], # top + [-0.5, -0.5, 0.5, -0.5, -0.5, -0.5, 0.5, -0.5, -0.5, 0.5, -0.5, 0.5], # bottom + [-0.5, 0.5, 0.5, -0.5, -0.5, 0.5, 0.5, -0.5, 0.5, 0.5, 0.5, 0.5], # front + [ 0.5, 0.5, -0.5, 0.5, -0.5, -0.5, -0.5, -0.5, -0.5, -0.5, 0.5, -0.5], # back +] + +tex_coords = [ + [0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 1.0, 0.0], + [0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 1.0, 0.0], + [0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 1.0, 0.0], + [0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 1.0, 0.0], + [0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 1.0, 0.0], + [0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 1.0, 0.0], +] + +shading_values = [ + [0.6, 0.6, 0.6, 0.6], + [0.6, 0.6, 0.6, 0.6], + [1.0, 1.0, 1.0, 1.0], + [0.4, 0.4, 0.4, 0.4], + [0.8, 0.8, 0.8, 0.8], + [0.8, 0.8, 0.8, 0.8], +] \ No newline at end of file diff --git a/episode-13/models/curry.py b/episode-13/models/curry.py new file mode 100644 index 00000000..dabce985 --- /dev/null +++ b/episode-13/models/curry.py @@ -0,0 +1,8 @@ + +transparent = True +is_cube = False +glass = False + +colliders = [] + +bones = [{'name':'body','pivot':[0.0, 1.5, 0.0],'vertices':[[-0.25, 0.75, -0.125, -0.25, 1.5, -0.125, 0.25, 1.5, -0.125, 0.25, 0.75, -0.125], [0.25, 0.75, 0.125, 0.25, 1.5, 0.125, -0.25, 1.5, 0.125, -0.25, 0.75, 0.125], [-0.25, 1.5, -0.125, -0.25, 1.5, 0.125, 0.25, 1.5, 0.125, 0.25, 1.5, -0.125], [0.25, 0.75, -0.125, 0.25, 0.75, 0.125, -0.25, 0.75, 0.125, -0.25, 0.75, -0.125], [0.25, 0.75, -0.125, 0.25, 1.5, -0.125, 0.25, 1.5, 0.125, 0.25, 0.75, 0.125], [-0.25, 0.75, 0.125, -0.25, 1.5, 0.125, -0.25, 1.5, -0.125, -0.25, 0.75, -0.125]],'tex_coords':[[0.018867924528301886, 0.0, 0.018867924528301886, 0.75, 0.05660377358490566, 0.75, 0.05660377358490566, 0.0], [0.07547169811320754, 0.0, 0.07547169811320754, 0.75, 0.11320754716981132, 0.75, 0.11320754716981132, 0.0], [0.018867924528301886, 0.75, 0.018867924528301886, 1.0, 0.05660377358490566, 1.0, 0.05660377358490566, 0.75], [0.05660377358490566, 0.75, 0.05660377358490566, 1.0, 0.09433962264150944, 1.0, 0.09433962264150944, 0.75], [0.05660377358490566, 0.0, 0.05660377358490566, 0.75, 0.07547169811320754, 0.75, 0.07547169811320754, 0.0], [0.0, 0.0, 0.0, 0.75, 0.018867924528301886, 0.75, 0.018867924528301886, 0.0]],'shading_values':[[1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0]]}, {'name':'head','pivot':[0.0, 1.5, 0.0],'vertices':[[-0.2536456286907196, 1.497308611869812, -0.23161627352237701, -0.2536456286907196, 1.997308611869812, -0.23161627352237701, 0.2463543713092804, 1.997308611869812, -0.23161627352237701, 0.2463543713092804, 1.497308611869812, -0.23161627352237701], [0.2463543713092804, 1.497308611869812, 0.2683837413787842, 0.2463543713092804, 1.997308611869812, 0.2683837413787842, -0.2536456286907196, 1.997308611869812, 0.2683837413787842, -0.2536456286907196, 1.497308611869812, 0.2683837413787842], [-0.2536456286907196, 1.997308611869812, -0.23161627352237701, -0.2536456286907196, 1.997308611869812, 0.2683837413787842, 0.2463543713092804, 1.997308611869812, 0.2683837413787842, 0.2463543713092804, 1.997308611869812, -0.23161627352237701], [0.2463543713092804, 1.497308611869812, -0.23161627352237701, 0.2463543713092804, 1.497308611869812, 0.2683837413787842, -0.2536456286907196, 1.497308611869812, 0.2683837413787842, -0.2536456286907196, 1.497308611869812, -0.23161627352237701], [0.2463543713092804, 1.497308611869812, -0.23161627352237701, 0.2463543713092804, 1.997308611869812, -0.23161627352237701, 0.2463543713092804, 1.997308611869812, 0.2683837413787842, 0.2463543713092804, 1.497308611869812, 0.2683837413787842], [-0.2536456286907196, 1.497308611869812, 0.2683837413787842, -0.2536456286907196, 1.997308611869812, 0.2683837413787842, -0.2536456286907196, 1.997308611869812, -0.23161627352237701, -0.2536456286907196, 1.497308611869812, -0.23161627352237701], [0.2316092699766159, 0.8962944149971008, -0.21831698715686798, 0.2316092699766159, 1.396294355392456, -0.21831698715686798, 0.7316092848777771, 1.396294355392456, -0.21831698715686798, 0.7316092848777771, 0.8962944149971008, -0.21831698715686798], [0.7316092848777771, 0.8962944149971008, 0.2816829979419708, 0.7316092848777771, 1.396294355392456, 0.2816829979419708, 0.2316092699766159, 1.396294355392456, 0.2816829979419708, 0.2316092699766159, 0.8962944149971008, 0.2816829979419708], [0.2316092699766159, 1.396294355392456, -0.21831698715686798, 0.2316092699766159, 1.396294355392456, 0.2816829979419708, 0.7316092848777771, 1.396294355392456, 0.2816829979419708, 0.7316092848777771, 1.396294355392456, -0.21831698715686798], [0.7316092848777771, 0.8962944149971008, -0.21831698715686798, 0.7316092848777771, 0.8962944149971008, 0.2816829979419708, 0.2316092699766159, 0.8962944149971008, 0.2816829979419708, 0.2316092699766159, 0.8962944149971008, -0.21831698715686798], [0.7316092848777771, 0.8962944149971008, -0.21831698715686798, 0.7316092848777771, 1.396294355392456, -0.21831698715686798, 0.7316092848777771, 1.396294355392456, 0.2816829979419708, 0.7316092848777771, 0.8962944149971008, 0.2816829979419708], [0.2316092699766159, 0.8962944149971008, 0.2816829979419708, 0.2316092699766159, 1.396294355392456, 0.2816829979419708, 0.2316092699766159, 1.396294355392456, -0.21831698715686798, 0.2316092699766159, 0.8962944149971008, -0.21831698715686798]],'tex_coords':[[0.1509433962264151, 0.0, 0.1509433962264151, 0.5, 0.18867924528301888, 0.5, 0.18867924528301888, 0.0], [0.22641509433962265, 0.0, 0.22641509433962265, 0.5, 0.2641509433962264, 0.5, 0.2641509433962264, 0.0], [0.1509433962264151, 0.5, 0.1509433962264151, 1.0, 0.18867924528301888, 1.0, 0.18867924528301888, 0.5], [0.18867924528301888, 0.5, 0.18867924528301888, 1.0, 0.22641509433962265, 1.0, 0.22641509433962265, 0.5], [0.18867924528301888, 0.0, 0.18867924528301888, 0.5, 0.22641509433962265, 0.5, 0.22641509433962265, 0.0], [0.11320754716981132, 0.0, 0.11320754716981132, 0.5, 0.1509433962264151, 0.5, 0.1509433962264151, 0.0], [0.3018867924528302, 0.0, 0.3018867924528302, 0.5, 0.33962264150943394, 0.5, 0.33962264150943394, 0.0], [0.37735849056603776, 0.0, 0.37735849056603776, 0.5, 0.41509433962264153, 0.5, 0.41509433962264153, 0.0], [0.3018867924528302, 0.5, 0.3018867924528302, 1.0, 0.33962264150943394, 1.0, 0.33962264150943394, 0.5], [0.33962264150943394, 0.5, 0.33962264150943394, 1.0, 0.37735849056603776, 1.0, 0.37735849056603776, 0.5], [0.33962264150943394, 0.0, 0.33962264150943394, 0.5, 0.37735849056603776, 0.5, 0.37735849056603776, 0.0], [0.2641509433962264, 0.0, 0.2641509433962264, 0.5, 0.3018867924528302, 0.5, 0.3018867924528302, 0.0]],'shading_values':[[1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0]]}, {'name':'hat','pivot':[0.0, 1.5, 0.0],'vertices':[[-0.25, 1.5, -0.25, -0.25, 2.0, -0.25, 0.25, 2.0, -0.25, 0.25, 1.5, -0.25], [0.25, 1.5, 0.25, 0.25, 2.0, 0.25, -0.25, 2.0, 0.25, -0.25, 1.5, 0.25], [-0.25, 2.0, -0.25, -0.25, 2.0, 0.25, 0.25, 2.0, 0.25, 0.25, 2.0, -0.25], [0.25, 1.5, -0.25, 0.25, 1.5, 0.25, -0.25, 1.5, 0.25, -0.25, 1.5, -0.25], [0.25, 1.5, -0.25, 0.25, 2.0, -0.25, 0.25, 2.0, 0.25, 0.25, 1.5, 0.25], [-0.25, 1.5, 0.25, -0.25, 2.0, 0.25, -0.25, 2.0, -0.25, -0.25, 1.5, -0.25]],'tex_coords':[[0.4528301886792453, 0.0, 0.4528301886792453, 0.5, 0.49056603773584906, 0.5, 0.49056603773584906, 0.0], [0.5283018867924528, 0.0, 0.5283018867924528, 0.5, 0.5660377358490566, 0.5, 0.5660377358490566, 0.0], [0.4528301886792453, 0.5, 0.4528301886792453, 1.0, 0.49056603773584906, 1.0, 0.49056603773584906, 0.5], [0.49056603773584906, 0.5, 0.49056603773584906, 1.0, 0.5283018867924528, 1.0, 0.5283018867924528, 0.5], [0.49056603773584906, 0.0, 0.49056603773584906, 0.5, 0.5283018867924528, 0.5, 0.5283018867924528, 0.0], [0.41509433962264153, 0.0, 0.41509433962264153, 0.5, 0.4528301886792453, 0.5, 0.4528301886792453, 0.0]],'shading_values':[[1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0]]}, {'name':'rightArm','pivot':[-0.3125, 1.375, 0.0],'vertices':[[-0.5, 0.75, -0.125, -0.5, 1.5, -0.125, -0.25, 1.5, -0.125, -0.25, 0.75, -0.125], [-0.25, 0.75, 0.125, -0.25, 1.5, 0.125, -0.5, 1.5, 0.125, -0.5, 0.75, 0.125], [-0.5, 1.5, -0.125, -0.5, 1.5, 0.125, -0.25, 1.5, 0.125, -0.25, 1.5, -0.125], [-0.25, 0.75, -0.125, -0.25, 0.75, 0.125, -0.5, 0.75, 0.125, -0.5, 0.75, -0.125], [-0.25, 0.75, -0.125, -0.25, 1.5, -0.125, -0.25, 1.5, 0.125, -0.25, 0.75, 0.125], [-0.5, 0.75, 0.125, -0.5, 1.5, 0.125, -0.5, 1.5, -0.125, -0.5, 0.75, -0.125]],'tex_coords':[[0.5849056603773585, 0.0, 0.5849056603773585, 0.75, 0.6037735849056604, 0.75, 0.6037735849056604, 0.0], [0.6226415094339622, 0.0, 0.6226415094339622, 0.75, 0.6415094339622641, 0.75, 0.6415094339622641, 0.0], [0.5849056603773585, 0.75, 0.5849056603773585, 1.0, 0.6037735849056604, 1.0, 0.6037735849056604, 0.75], [0.6037735849056604, 0.75, 0.6037735849056604, 1.0, 0.6226415094339622, 1.0, 0.6226415094339622, 0.75], [0.6037735849056604, 0.0, 0.6037735849056604, 0.75, 0.6226415094339622, 0.75, 0.6226415094339622, 0.0], [0.5660377358490566, 0.0, 0.5660377358490566, 0.75, 0.5849056603773585, 0.75, 0.5849056603773585, 0.0]],'shading_values':[[1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0]]}, {'name':'leftArm','pivot':[0.3125, 1.375, 0.0],'vertices':[[0.7019792795181274, 0.748781681060791, -0.02643335424363613, 0.7019792795181274, 1.498781681060791, -0.02643335424363613, 0.9519792795181274, 1.498781681060791, -0.02643335424363613, 0.9519792795181274, 0.748781681060791, -0.02643335424363613], [0.9519792795181274, 0.748781681060791, 0.22356665134429932, 0.9519792795181274, 1.498781681060791, 0.22356665134429932, 0.7019792795181274, 1.498781681060791, 0.22356665134429932, 0.7019792795181274, 0.748781681060791, 0.22356665134429932], [0.7019792795181274, 1.498781681060791, -0.02643335424363613, 0.7019792795181274, 1.498781681060791, 0.22356665134429932, 0.9519792795181274, 1.498781681060791, 0.22356665134429932, 0.9519792795181274, 1.498781681060791, -0.02643335424363613], [0.9519792795181274, 0.748781681060791, -0.02643335424363613, 0.9519792795181274, 0.748781681060791, 0.22356665134429932, 0.7019792795181274, 0.748781681060791, 0.22356665134429932, 0.7019792795181274, 0.748781681060791, -0.02643335424363613], [0.9519792795181274, 0.748781681060791, -0.02643335424363613, 0.9519792795181274, 1.498781681060791, -0.02643335424363613, 0.9519792795181274, 1.498781681060791, 0.22356665134429932, 0.9519792795181274, 0.748781681060791, 0.22356665134429932], [0.7019792795181274, 0.748781681060791, 0.22356665134429932, 0.7019792795181274, 1.498781681060791, 0.22356665134429932, 0.7019792795181274, 1.498781681060791, -0.02643335424363613, 0.7019792795181274, 0.748781681060791, -0.02643335424363613], [0.09342791140079498, 1.3167552947998047, -0.06984145194292068, 0.09342791140079498, 1.5042552947998047, -0.06984145194292068, 0.7184278964996338, 1.5042552947998047, -0.06984145194292068, 0.7184278964996338, 1.3167552947998047, -0.06984145194292068], [0.7184278964996338, 1.3167552947998047, 0.18015854060649872, 0.7184278964996338, 1.5042552947998047, 0.18015854060649872, 0.09342791140079498, 1.5042552947998047, 0.18015854060649872, 0.09342791140079498, 1.3167552947998047, 0.18015854060649872], [0.09342791140079498, 1.5042552947998047, -0.06984145194292068, 0.09342791140079498, 1.5042552947998047, 0.18015854060649872, 0.7184278964996338, 1.5042552947998047, 0.18015854060649872, 0.7184278964996338, 1.5042552947998047, -0.06984145194292068], [0.7184278964996338, 1.3167552947998047, -0.06984145194292068, 0.7184278964996338, 1.3167552947998047, 0.18015854060649872, 0.09342791140079498, 1.3167552947998047, 0.18015854060649872, 0.09342791140079498, 1.3167552947998047, -0.06984145194292068], [0.7184278964996338, 1.3167552947998047, -0.06984145194292068, 0.7184278964996338, 1.5042552947998047, -0.06984145194292068, 0.7184278964996338, 1.5042552947998047, 0.18015854060649872, 0.7184278964996338, 1.3167552947998047, 0.18015854060649872], [0.09342791140079498, 1.3167552947998047, 0.18015854060649872, 0.09342791140079498, 1.5042552947998047, 0.18015854060649872, 0.09342791140079498, 1.5042552947998047, -0.06984145194292068, 0.09342791140079498, 1.3167552947998047, -0.06984145194292068]],'tex_coords':[[0.660377358490566, 0.0, 0.660377358490566, 0.75, 0.6792452830188679, 0.75, 0.6792452830188679, 0.0], [0.6981132075471698, 0.0, 0.6981132075471698, 0.75, 0.7169811320754716, 0.75, 0.7169811320754716, 0.0], [0.660377358490566, 0.75, 0.660377358490566, 1.0, 0.6792452830188679, 1.0, 0.6792452830188679, 0.75], [0.6792452830188679, 0.75, 0.6792452830188679, 1.0, 0.6981132075471698, 1.0, 0.6981132075471698, 0.75], [0.6792452830188679, 0.0, 0.6792452830188679, 0.75, 0.6981132075471698, 0.75, 0.6981132075471698, 0.0], [0.6415094339622641, 0.0, 0.6415094339622641, 0.75, 0.660377358490566, 0.75, 0.660377358490566, 0.0], [0.7358490566037735, 0.5625, 0.7358490566037735, 0.75, 0.7830188679245284, 0.75, 0.7830188679245284, 0.5625], [0.8018867924528302, 0.5625, 0.8018867924528302, 0.75, 0.8490566037735849, 0.75, 0.8490566037735849, 0.5625], [0.7358490566037735, 0.75, 0.7358490566037735, 1.0, 0.7830188679245284, 1.0, 0.7830188679245284, 0.75], [0.7830188679245284, 0.75, 0.7830188679245284, 1.0, 0.8301886792452831, 1.0, 0.8301886792452831, 0.75], [0.7830188679245284, 0.5625, 0.7830188679245284, 0.75, 0.8018867924528302, 0.75, 0.8018867924528302, 0.5625], [0.7169811320754716, 0.5625, 0.7169811320754716, 0.75, 0.7358490566037735, 0.75, 0.7358490566037735, 0.5625]],'shading_values':[[1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0]]}, {'name':'rightLeg','pivot':[-0.11875, 0.75, 0.0],'vertices':[[-0.24375000596046448, 0.0, -0.125, -0.24375000596046448, 0.75, -0.125, 0.0062500000931322575, 0.75, -0.125, 0.0062500000931322575, 0.0, -0.125], [0.0062500000931322575, 0.0, 0.125, 0.0062500000931322575, 0.75, 0.125, -0.24375000596046448, 0.75, 0.125, -0.24375000596046448, 0.0, 0.125], [-0.24375000596046448, 0.75, -0.125, -0.24375000596046448, 0.75, 0.125, 0.0062500000931322575, 0.75, 0.125, 0.0062500000931322575, 0.75, -0.125], [0.0062500000931322575, 0.0, -0.125, 0.0062500000931322575, 0.0, 0.125, -0.24375000596046448, 0.0, 0.125, -0.24375000596046448, 0.0, -0.125], [0.0062500000931322575, 0.0, -0.125, 0.0062500000931322575, 0.75, -0.125, 0.0062500000931322575, 0.75, 0.125, 0.0062500000931322575, 0.0, 0.125], [-0.24375000596046448, 0.0, 0.125, -0.24375000596046448, 0.75, 0.125, -0.24375000596046448, 0.75, -0.125, -0.24375000596046448, 0.0, -0.125]],'tex_coords':[[0.8679245283018868, 0.0, 0.8679245283018868, 0.75, 0.8867924528301887, 0.75, 0.8867924528301887, 0.0], [0.9056603773584906, 0.0, 0.9056603773584906, 0.75, 0.9245283018867925, 0.75, 0.9245283018867925, 0.0], [0.8679245283018868, 0.75, 0.8679245283018868, 1.0, 0.8867924528301887, 1.0, 0.8867924528301887, 0.75], [0.8867924528301887, 0.75, 0.8867924528301887, 1.0, 0.9056603773584906, 1.0, 0.9056603773584906, 0.75], [0.8867924528301887, 0.0, 0.8867924528301887, 0.75, 0.9056603773584906, 0.75, 0.9056603773584906, 0.0], [0.8490566037735849, 0.0, 0.8490566037735849, 0.75, 0.8679245283018868, 0.75, 0.8679245283018868, 0.0]],'shading_values':[[1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0]]}, {'name':'leftLeg','pivot':[0.11875, 0.75, 0.0],'vertices':[[-0.0062500000931322575, 0.0, -0.125, -0.0062500000931322575, 0.75, -0.125, 0.24375000596046448, 0.75, -0.125, 0.24375000596046448, 0.0, -0.125], [0.24375000596046448, 0.0, 0.125, 0.24375000596046448, 0.75, 0.125, -0.0062500000931322575, 0.75, 0.125, -0.0062500000931322575, 0.0, 0.125], [-0.0062500000931322575, 0.75, -0.125, -0.0062500000931322575, 0.75, 0.125, 0.24375000596046448, 0.75, 0.125, 0.24375000596046448, 0.75, -0.125], [0.24375000596046448, 0.0, -0.125, 0.24375000596046448, 0.0, 0.125, -0.0062500000931322575, 0.0, 0.125, -0.0062500000931322575, 0.0, -0.125], [0.24375000596046448, 0.0, -0.125, 0.24375000596046448, 0.75, -0.125, 0.24375000596046448, 0.75, 0.125, 0.24375000596046448, 0.0, 0.125], [-0.0062500000931322575, 0.0, 0.125, -0.0062500000931322575, 0.75, 0.125, -0.0062500000931322575, 0.75, -0.125, -0.0062500000931322575, 0.0, -0.125]],'tex_coords':[[0.9433962264150944, 0.0, 0.9433962264150944, 0.75, 0.9622641509433962, 0.75, 0.9622641509433962, 0.0], [0.9811320754716981, 0.0, 0.9811320754716981, 0.75, 1.0, 0.75, 1.0, 0.0], [0.9433962264150944, 0.75, 0.9433962264150944, 1.0, 0.9622641509433962, 1.0, 0.9622641509433962, 0.75], [0.9622641509433962, 0.75, 0.9622641509433962, 1.0, 0.9811320754716981, 1.0, 0.9811320754716981, 0.75], [0.9622641509433962, 0.0, 0.9622641509433962, 0.75, 0.9811320754716981, 0.75, 0.9811320754716981, 0.0], [0.9245283018867925, 0.0, 0.9245283018867925, 0.75, 0.9433962264150944, 0.75, 0.9433962264150944, 0.0]],'shading_values':[[1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0]]}] diff --git a/episode-13/models/door.py b/episode-13/models/door.py new file mode 100644 index 00000000..24507a43 --- /dev/null +++ b/episode-13/models/door.py @@ -0,0 +1,32 @@ +transparent = False +is_cube = True +glass = False + +colliders = [] + +vertex_positions = [ + [ 0.5, 0.5, 0.5, 0.5, -0.5, 0.5, 0.5, -0.5, -0.5, 0.5, 0.5, -0.5], # right + [-0.5, 0.5, -0.5, -0.5, -0.5, -0.5, -0.5, -0.5, 0.5, -0.5, 0.5, 0.5], # left + [ 0.5, 0.5, 0.5, 0.5, 0.5, -0.5, -0.5, 0.5, -0.5, -0.5, 0.5, 0.5], # top + [-0.5, -0.5, 0.5, -0.5, -0.5, -0.5, 0.5, -0.5, -0.5, 0.5, -0.5, 0.5], # bottom + [-0.5, 0.5, 0.5, -0.5, -0.5, 0.5, 0.5, -0.5, 0.5, 0.5, 0.5, 0.5], # front + [ 0.5, 0.5, -0.5, 0.5, -0.5, -0.5, -0.5, -0.5, -0.5, -0.5, 0.5, -0.5], # back +] + +tex_coords = [ + [0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 1.0, 0.0], + [0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 1.0, 0.0], + [0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 1.0, 0.0], + [0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 1.0, 0.0], + [0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 1.0, 0.0], + [0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 1.0, 0.0], +] + +shading_values = [ + [0.6, 0.6, 0.6, 0.6], + [0.6, 0.6, 0.6, 0.6], + [1.0, 1.0, 1.0, 1.0], + [0.4, 0.4, 0.4, 0.4], + [0.8, 0.8, 0.8, 0.8], + [0.8, 0.8, 0.8, 0.8], +] \ No newline at end of file diff --git a/episode-13/models/fire.py b/episode-13/models/fire.py new file mode 100644 index 00000000..4acc8adc --- /dev/null +++ b/episode-13/models/fire.py @@ -0,0 +1,26 @@ +transparent = True +is_cube = False +glass = False + +colliders = [] + +vertex_positions = [ + [-0.3536, 0.5000, 0.3536, -0.3536, -0.5000, 0.3536, 0.3536, -0.5000, -0.3536, 0.3536, 0.5000, -0.3536], + [-0.3536, 0.5000, -0.3536, -0.3536, -0.5000, -0.3536, 0.3536, -0.5000, 0.3536, 0.3536, 0.5000, 0.3536], + [ 0.3536, 0.5000, -0.3536, 0.3536, -0.5000, -0.3536, -0.3536, -0.5000, 0.3536, -0.3536, 0.5000, 0.3536], + [ 0.3536, 0.5000, 0.3536, 0.3536, -0.5000, 0.3536, -0.3536, -0.5000, -0.3536, -0.3536, 0.5000, -0.3536], +] + +tex_coords = [ + [0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 1.0, 0.0], + [0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 1.0, 0.0], + [0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 1.0, 0.0], + [0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 1.0, 0.0], +] + +shading_values = [ + [1.0, 1.0, 1.0, 1.0], + [1.0, 1.0, 1.0, 1.0], + [1.0, 1.0, 1.0, 1.0], + [1.0, 1.0, 1.0, 1.0], +] \ No newline at end of file diff --git a/episode-13/models/flat.py b/episode-13/models/flat.py new file mode 100644 index 00000000..acfe6429 --- /dev/null +++ b/episode-13/models/flat.py @@ -0,0 +1,20 @@ +transparent = True +is_cube = False +glass = False + +colliders = [] + +vertex_positions = [ + [ 0.5, -0.4375, 0.5, 0.5, -0.4375, -0.5, -0.5, -0.4375, -0.5, -0.5, -0.4375, 0.5], # top + [-0.5, -0.4375, 0.5, -0.5, -0.4375, -0.5, 0.5, -0.4375, -0.5, 0.5, -0.4375, 0.5], # bottom +] + +tex_coords = [ + [0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 1.0, 0.0], + [0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 1.0, 0.0], +] + +shading_values = [ + [1.0, 1.0, 1.0, 1.0], + [0.4, 0.4, 0.4, 0.4], +] \ No newline at end of file diff --git a/episode-13/models/glass.py b/episode-13/models/glass.py new file mode 100644 index 00000000..893731a0 --- /dev/null +++ b/episode-13/models/glass.py @@ -0,0 +1,37 @@ +transparent = True +is_cube = True +glass = True + +colliders = [ + [ + (-0.5, -0.5, -0.5), + ( 0.5, 0.5, 0.5) + ] +] + +vertex_positions = [ + [ 0.5, 0.5, 0.5, 0.5, -0.5, 0.5, 0.5, -0.5, -0.5, 0.5, 0.5, -0.5], # right + [-0.5, 0.5, -0.5, -0.5, -0.5, -0.5, -0.5, -0.5, 0.5, -0.5, 0.5, 0.5], # left + [ 0.5, 0.5, 0.5, 0.5, 0.5, -0.5, -0.5, 0.5, -0.5, -0.5, 0.5, 0.5], # top + [-0.5, -0.5, 0.5, -0.5, -0.5, -0.5, 0.5, -0.5, -0.5, 0.5, -0.5, 0.5], # bottom + [-0.5, 0.5, 0.5, -0.5, -0.5, 0.5, 0.5, -0.5, 0.5, 0.5, 0.5, 0.5], # front + [ 0.5, 0.5, -0.5, 0.5, -0.5, -0.5, -0.5, -0.5, -0.5, -0.5, 0.5, -0.5], # back +] + +tex_coords = [ + [0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 1.0, 0.0], + [0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 1.0, 0.0], + [0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 1.0, 0.0], + [0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 1.0, 0.0], + [0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 1.0, 0.0], + [0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 1.0, 0.0], +] + +shading_values = [ + [0.6, 0.6, 0.6, 0.6], + [0.6, 0.6, 0.6, 0.6], + [1.0, 1.0, 1.0, 1.0], + [0.4, 0.4, 0.4, 0.4], + [0.8, 0.8, 0.8, 0.8], + [0.8, 0.8, 0.8, 0.8], +] \ No newline at end of file diff --git a/episode-13/models/ladder.py b/episode-13/models/ladder.py new file mode 100644 index 00000000..4acc8adc --- /dev/null +++ b/episode-13/models/ladder.py @@ -0,0 +1,26 @@ +transparent = True +is_cube = False +glass = False + +colliders = [] + +vertex_positions = [ + [-0.3536, 0.5000, 0.3536, -0.3536, -0.5000, 0.3536, 0.3536, -0.5000, -0.3536, 0.3536, 0.5000, -0.3536], + [-0.3536, 0.5000, -0.3536, -0.3536, -0.5000, -0.3536, 0.3536, -0.5000, 0.3536, 0.3536, 0.5000, 0.3536], + [ 0.3536, 0.5000, -0.3536, 0.3536, -0.5000, -0.3536, -0.3536, -0.5000, 0.3536, -0.3536, 0.5000, 0.3536], + [ 0.3536, 0.5000, 0.3536, 0.3536, -0.5000, 0.3536, -0.3536, -0.5000, -0.3536, -0.3536, 0.5000, -0.3536], +] + +tex_coords = [ + [0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 1.0, 0.0], + [0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 1.0, 0.0], + [0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 1.0, 0.0], + [0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 1.0, 0.0], +] + +shading_values = [ + [1.0, 1.0, 1.0, 1.0], + [1.0, 1.0, 1.0, 1.0], + [1.0, 1.0, 1.0, 1.0], + [1.0, 1.0, 1.0, 1.0], +] \ No newline at end of file diff --git a/episode-13/models/leaves.py b/episode-13/models/leaves.py new file mode 100644 index 00000000..52b3aa8e --- /dev/null +++ b/episode-13/models/leaves.py @@ -0,0 +1,37 @@ +transparent = True +is_cube = True +glass = False + +colliders = [ + [ + (-0.5, -0.5, -0.5), + ( 0.5, 0.5, 0.5) + ] +] + +vertex_positions = [ + [ 0.5, 0.5, 0.5, 0.5, -0.5, 0.5, 0.5, -0.5, -0.5, 0.5, 0.5, -0.5], # right + [-0.5, 0.5, -0.5, -0.5, -0.5, -0.5, -0.5, -0.5, 0.5, -0.5, 0.5, 0.5], # left + [ 0.5, 0.5, 0.5, 0.5, 0.5, -0.5, -0.5, 0.5, -0.5, -0.5, 0.5, 0.5], # top + [-0.5, -0.5, 0.5, -0.5, -0.5, -0.5, 0.5, -0.5, -0.5, 0.5, -0.5, 0.5], # bottom + [-0.5, 0.5, 0.5, -0.5, -0.5, 0.5, 0.5, -0.5, 0.5, 0.5, 0.5, 0.5], # front + [ 0.5, 0.5, -0.5, 0.5, -0.5, -0.5, -0.5, -0.5, -0.5, -0.5, 0.5, -0.5], # back +] + +tex_coords = [ + [0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 1.0, 0.0], + [0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 1.0, 0.0], + [0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 1.0, 0.0], + [0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 1.0, 0.0], + [0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 1.0, 0.0], + [0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 1.0, 0.0], +] + +shading_values = [ + [0.6, 0.6, 0.6, 0.6], + [0.6, 0.6, 0.6, 0.6], + [1.0, 1.0, 1.0, 1.0], + [0.4, 0.4, 0.4, 0.4], + [0.8, 0.8, 0.8, 0.8], + [0.8, 0.8, 0.8, 0.8], +] \ No newline at end of file diff --git a/episode-13/models/lever.py b/episode-13/models/lever.py new file mode 100644 index 00000000..c8d8731e --- /dev/null +++ b/episode-13/models/lever.py @@ -0,0 +1,32 @@ +transparent = True +is_cube = False +glass = False + +colliders = [] + +vertex_positions = [ + [ 0.5, 0.0, 0.5, 0.5, -0.5, 0.5, 0.5, -0.5, -0.5, 0.5, 0.0, -0.5], # right + [-0.5, 0.0, -0.5, -0.5, -0.5, -0.5, -0.5, -0.5, 0.5, -0.5, 0.0, 0.5], # left + [ 0.5, 0.0, 0.5, 0.5, 0.0, -0.5, -0.5, 0.0, -0.5, -0.5, 0.0, 0.5], # top + [-0.5, -0.5, 0.5, -0.5, -0.5, -0.5, 0.5, -0.5, -0.5, 0.5, -0.5, 0.5], # bottom + [-0.5, 0.0, 0.5, -0.5, -0.5, 0.5, 0.5, -0.5, 0.5, 0.5, 0.0, 0.5], # front + [ 0.5, 0.0, -0.5, 0.5, -0.5, -0.5, -0.5, -0.5, -0.5, -0.5, 0.0, -0.5], # back +] + +tex_coords = [ + [0.0, 0.5, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 0.5, 0.0], + [0.0, 0.5, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 0.5, 0.0], + [0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 1.0, 0.0], + [0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 1.0, 0.0], + [0.0, 0.5, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 0.5, 0.0], + [0.0, 0.5, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 0.5, 0.0], +] + +shading_values = [ + [0.6, 0.6, 0.6, 0.6], + [0.6, 0.6, 0.6, 0.6], + [1.0, 1.0, 1.0, 1.0], + [0.4, 0.4, 0.4, 0.4], + [0.8, 0.8, 0.8, 0.8], + [0.8, 0.8, 0.8, 0.8], +] \ No newline at end of file diff --git a/episode-13/models/liquid.py b/episode-13/models/liquid.py new file mode 100644 index 00000000..fc7cce26 --- /dev/null +++ b/episode-13/models/liquid.py @@ -0,0 +1,35 @@ +# in the end, it'd be nice to have it so that liquids fill up the whole block when they have a block above them +# this would avoid the problems this solution has + +transparent = True +is_cube = True +glass = True + +colliders = [] + +vertex_positions = [ + [ 0.500, 0.375, 0.500, 0.500, -0.625, 0.500, 0.500, -0.625, -0.500, 0.500, 0.375, -0.500], # right + [-0.500, 0.375, -0.500, -0.500, -0.625, -0.500, -0.500, -0.625, 0.500, -0.500, 0.375, 0.500], # left + [ 0.500, 0.375, 0.500, 0.500, 0.375, -0.500, -0.500, 0.375, -0.500, -0.500, 0.375, 0.500], # top + [-0.500, -0.625, 0.500, -0.500, -0.625, -0.500, 0.500, -0.625, -0.500, 0.500, -0.625, 0.500], # bottom + [-0.500, 0.375, 0.500, -0.500, -0.625, 0.500, 0.500, -0.625, 0.500, 0.500, 0.375, 0.500], # front + [ 0.500, 0.375, -0.500, 0.500, -0.625, -0.500, -0.500, -0.625, -0.500, -0.500, 0.375, -0.500], # back +] + +tex_coords = [ + [0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 1.0, 0.0], + [0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 1.0, 0.0], + [0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 1.0, 0.0], + [0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 1.0, 0.0], + [0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 1.0, 0.0], + [0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 1.0, 0.0], +] + +shading_values = [ + [0.6, 0.6, 0.6, 0.6], + [0.6, 0.6, 0.6, 0.6], + [1.0, 1.0, 1.0, 1.0], + [0.4, 0.4, 0.4, 0.4], + [0.8, 0.8, 0.8, 0.8], + [0.8, 0.8, 0.8, 0.8], +] diff --git a/episode-13/models/pig.py b/episode-13/models/pig.py new file mode 100644 index 00000000..eddfc53d --- /dev/null +++ b/episode-13/models/pig.py @@ -0,0 +1,8 @@ + +transparent = True +is_cube = False +glass = False + +colliders = [] + +bones = [{'name':'body','pivot':[0.0, 0.8125, 0.125],'vertices':[[-0.3124999701976776, 0.3750000298023224, 0.5, -0.3124999701976776, 0.375, -0.5, 0.3124999701976776, 0.375, -0.5, 0.3124999701976776, 0.3750000298023224, 0.5], [0.3124999701976776, 0.8750000596046448, 0.5, 0.3124999701976776, 0.875, -0.5, -0.3124999701976776, 0.875, -0.5, -0.3124999701976776, 0.8750000596046448, 0.5], [-0.3124999701976776, 0.375, -0.5, -0.3124999701976776, 0.875, -0.5, 0.3124999701976776, 0.875, -0.5, 0.3124999701976776, 0.375, -0.5], [0.3124999701976776, 0.3750000298023224, 0.5, 0.3124999701976776, 0.8750000596046448, 0.5, -0.3124999701976776, 0.8750000596046448, 0.5, -0.3124999701976776, 0.3750000298023224, 0.5], [0.3124999701976776, 0.3750000298023224, 0.5, 0.3124999701976776, 0.375, -0.5, 0.3124999701976776, 0.875, -0.5, 0.3124999701976776, 0.8750000596046448, 0.5], [-0.3124999701976776, 0.8750000596046448, 0.5, -0.3124999701976776, 0.875, -0.5, -0.3124999701976776, 0.375, -0.5, -0.3124999701976776, 0.3750000298023224, 0.5]],'tex_coords':[[0.056338028169014086, 0.0, 0.056338028169014086, 0.6666666666666667, 0.1267605633802817, 0.6666666666666667, 0.1267605633802817, 0.0], [0.18309859154929578, 0.0, 0.18309859154929578, 0.6666666666666667, 0.2535211267605634, 0.6666666666666667, 0.2535211267605634, 0.0], [0.056338028169014086, 0.6666666666666667, 0.056338028169014086, 1.0, 0.1267605633802817, 1.0, 0.1267605633802817, 0.6666666666666667], [0.1267605633802817, 0.6666666666666667, 0.1267605633802817, 1.0, 0.19718309859154928, 1.0, 0.19718309859154928, 0.6666666666666667], [0.1267605633802817, 0.0, 0.1267605633802817, 0.6666666666666667, 0.18309859154929578, 0.6666666666666667, 0.18309859154929578, 0.0], [0.0, 0.0, 0.0, 0.6666666666666667, 0.056338028169014086, 0.6666666666666667, 0.056338028169014086, 0.0]],'shading_values':[[1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0]]}, {'name':'head','pivot':[0.0, 0.75, -0.375],'vertices':[[-0.25, 0.5, -0.875, -0.25, 1.0, -0.875, 0.25, 1.0, -0.875, 0.25, 0.5, -0.875], [0.25, 0.5, -0.375, 0.25, 1.0, -0.375, -0.25, 1.0, -0.375, -0.25, 0.5, -0.375], [-0.25, 1.0, -0.875, -0.25, 1.0, -0.375, 0.25, 1.0, -0.375, 0.25, 1.0, -0.875], [0.25, 0.5, -0.875, 0.25, 0.5, -0.375, -0.25, 0.5, -0.375, -0.25, 0.5, -0.875], [0.25, 0.5, -0.875, 0.25, 1.0, -0.875, 0.25, 1.0, -0.375, 0.25, 0.5, -0.375], [-0.25, 0.5, -0.375, -0.25, 1.0, -0.375, -0.25, 1.0, -0.875, -0.25, 0.5, -0.875], [-0.125, 0.5625, -0.9375, -0.125, 0.75, -0.9375, 0.125, 0.75, -0.9375, 0.125, 0.5625, -0.9375], [0.125, 0.5625, -0.875, 0.125, 0.75, -0.875, -0.125, 0.75, -0.875, -0.125, 0.5625, -0.875], [-0.125, 0.75, -0.9375, -0.125, 0.75, -0.875, 0.125, 0.75, -0.875, 0.125, 0.75, -0.9375], [0.125, 0.5625, -0.9375, 0.125, 0.5625, -0.875, -0.125, 0.5625, -0.875, -0.125, 0.5625, -0.9375], [0.125, 0.5625, -0.9375, 0.125, 0.75, -0.9375, 0.125, 0.75, -0.875, 0.125, 0.5625, -0.875], [-0.125, 0.5625, -0.875, -0.125, 0.75, -0.875, -0.125, 0.75, -0.9375, -0.125, 0.5625, -0.9375]],'tex_coords':[[0.30985915492957744, 0.33333333333333337, 0.30985915492957744, 0.6666666666666667, 0.36619718309859156, 0.6666666666666667, 0.36619718309859156, 0.33333333333333337], [0.4225352112676056, 0.33333333333333337, 0.4225352112676056, 0.6666666666666667, 0.4788732394366197, 0.6666666666666667, 0.4788732394366197, 0.33333333333333337], [0.30985915492957744, 0.6666666666666667, 0.30985915492957744, 1.0, 0.36619718309859156, 1.0, 0.36619718309859156, 0.6666666666666667], [0.36619718309859156, 0.6666666666666667, 0.36619718309859156, 1.0, 0.4225352112676056, 1.0, 0.4225352112676056, 0.6666666666666667], [0.36619718309859156, 0.33333333333333337, 0.36619718309859156, 0.6666666666666667, 0.4225352112676056, 0.6666666666666667, 0.4225352112676056, 0.33333333333333337], [0.2535211267605634, 0.33333333333333337, 0.2535211267605634, 0.6666666666666667, 0.30985915492957744, 0.6666666666666667, 0.30985915492957744, 0.33333333333333337], [0.4859154929577465, 0.8333333333333334, 0.4859154929577465, 0.9583333333333334, 0.5140845070422535, 0.9583333333333334, 0.5140845070422535, 0.8333333333333334], [0.5211267605633803, 0.8333333333333334, 0.5211267605633803, 0.9583333333333334, 0.5492957746478874, 0.9583333333333334, 0.5492957746478874, 0.8333333333333334], [0.4859154929577465, 0.9583333333333334, 0.4859154929577465, 1.0, 0.5140845070422535, 1.0, 0.5140845070422535, 0.9583333333333334], [0.5140845070422535, 0.9583333333333334, 0.5140845070422535, 1.0, 0.5422535211267606, 1.0, 0.5422535211267606, 0.9583333333333334], [0.5140845070422535, 0.8333333333333334, 0.5140845070422535, 0.9583333333333334, 0.5211267605633803, 0.9583333333333334, 0.5211267605633803, 0.8333333333333334], [0.4788732394366197, 0.8333333333333334, 0.4788732394366197, 0.9583333333333334, 0.4859154929577465, 0.9583333333333334, 0.4859154929577465, 0.8333333333333334]],'shading_values':[[1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0]]}, {'name':'leg0','pivot':[-0.1875, 0.375, 0.4375],'vertices':[[-0.3125, 0.0, 0.3125, -0.3125, 0.375, 0.3125, -0.0625, 0.375, 0.3125, -0.0625, 0.0, 0.3125], [-0.0625, 0.0, 0.5625, -0.0625, 0.375, 0.5625, -0.3125, 0.375, 0.5625, -0.3125, 0.0, 0.5625], [-0.3125, 0.375, 0.3125, -0.3125, 0.375, 0.5625, -0.0625, 0.375, 0.5625, -0.0625, 0.375, 0.3125], [-0.0625, 0.0, 0.3125, -0.0625, 0.0, 0.5625, -0.3125, 0.0, 0.5625, -0.3125, 0.0, 0.3125], [-0.0625, 0.0, 0.3125, -0.0625, 0.375, 0.3125, -0.0625, 0.375, 0.5625, -0.0625, 0.0, 0.5625], [-0.3125, 0.0, 0.5625, -0.3125, 0.375, 0.5625, -0.3125, 0.375, 0.3125, -0.3125, 0.0, 0.3125]],'tex_coords':[[0.5774647887323944, 0.5833333333333333, 0.5774647887323944, 0.8333333333333334, 0.6056338028169014, 0.8333333333333334, 0.6056338028169014, 0.5833333333333333], [0.6338028169014085, 0.5833333333333333, 0.6338028169014085, 0.8333333333333334, 0.6619718309859155, 0.8333333333333334, 0.6619718309859155, 0.5833333333333333], [0.5774647887323944, 0.8333333333333334, 0.5774647887323944, 1.0, 0.6056338028169014, 1.0, 0.6056338028169014, 0.8333333333333334], [0.6056338028169014, 0.8333333333333334, 0.6056338028169014, 1.0, 0.6338028169014085, 1.0, 0.6338028169014085, 0.8333333333333334], [0.6056338028169014, 0.5833333333333333, 0.6056338028169014, 0.8333333333333334, 0.6338028169014085, 0.8333333333333334, 0.6338028169014085, 0.5833333333333333], [0.5492957746478874, 0.5833333333333333, 0.5492957746478874, 0.8333333333333334, 0.5774647887323944, 0.8333333333333334, 0.5774647887323944, 0.5833333333333333]],'shading_values':[[1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0]]}, {'name':'leg1','pivot':[0.1875, 0.375, 0.4375],'vertices':[[0.0625, 0.0, 0.3125, 0.0625, 0.375, 0.3125, 0.3125, 0.375, 0.3125, 0.3125, 0.0, 0.3125], [0.3125, 0.0, 0.5625, 0.3125, 0.375, 0.5625, 0.0625, 0.375, 0.5625, 0.0625, 0.0, 0.5625], [0.0625, 0.375, 0.3125, 0.0625, 0.375, 0.5625, 0.3125, 0.375, 0.5625, 0.3125, 0.375, 0.3125], [0.3125, 0.0, 0.3125, 0.3125, 0.0, 0.5625, 0.0625, 0.0, 0.5625, 0.0625, 0.0, 0.3125], [0.3125, 0.0, 0.3125, 0.3125, 0.375, 0.3125, 0.3125, 0.375, 0.5625, 0.3125, 0.0, 0.5625], [0.0625, 0.0, 0.5625, 0.0625, 0.375, 0.5625, 0.0625, 0.375, 0.3125, 0.0625, 0.0, 0.3125]],'tex_coords':[[0.6901408450704225, 0.5833333333333333, 0.6901408450704225, 0.8333333333333334, 0.7183098591549296, 0.8333333333333334, 0.7183098591549296, 0.5833333333333333], [0.7464788732394366, 0.5833333333333333, 0.7464788732394366, 0.8333333333333334, 0.7746478873239436, 0.8333333333333334, 0.7746478873239436, 0.5833333333333333], [0.6901408450704225, 0.8333333333333334, 0.6901408450704225, 1.0, 0.7183098591549296, 1.0, 0.7183098591549296, 0.8333333333333334], [0.7183098591549296, 0.8333333333333334, 0.7183098591549296, 1.0, 0.7464788732394366, 1.0, 0.7464788732394366, 0.8333333333333334], [0.7183098591549296, 0.5833333333333333, 0.7183098591549296, 0.8333333333333334, 0.7464788732394366, 0.8333333333333334, 0.7464788732394366, 0.5833333333333333], [0.6619718309859155, 0.5833333333333333, 0.6619718309859155, 0.8333333333333334, 0.6901408450704225, 0.8333333333333334, 0.6901408450704225, 0.5833333333333333]],'shading_values':[[1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0]]}, {'name':'leg2','pivot':[-0.1875, 0.375, -0.3125],'vertices':[[-0.3125, 0.0, -0.4375, -0.3125, 0.375, -0.4375, -0.0625, 0.375, -0.4375, -0.0625, 0.0, -0.4375], [-0.0625, 0.0, -0.1875, -0.0625, 0.375, -0.1875, -0.3125, 0.375, -0.1875, -0.3125, 0.0, -0.1875], [-0.3125, 0.375, -0.4375, -0.3125, 0.375, -0.1875, -0.0625, 0.375, -0.1875, -0.0625, 0.375, -0.4375], [-0.0625, 0.0, -0.4375, -0.0625, 0.0, -0.1875, -0.3125, 0.0, -0.1875, -0.3125, 0.0, -0.4375], [-0.0625, 0.0, -0.4375, -0.0625, 0.375, -0.4375, -0.0625, 0.375, -0.1875, -0.0625, 0.0, -0.1875], [-0.3125, 0.0, -0.1875, -0.3125, 0.375, -0.1875, -0.3125, 0.375, -0.4375, -0.3125, 0.0, -0.4375]],'tex_coords':[[0.8028169014084507, 0.5833333333333333, 0.8028169014084507, 0.8333333333333334, 0.8309859154929577, 0.8333333333333334, 0.8309859154929577, 0.5833333333333333], [0.8591549295774648, 0.5833333333333333, 0.8591549295774648, 0.8333333333333334, 0.8873239436619719, 0.8333333333333334, 0.8873239436619719, 0.5833333333333333], [0.8028169014084507, 0.8333333333333334, 0.8028169014084507, 1.0, 0.8309859154929577, 1.0, 0.8309859154929577, 0.8333333333333334], [0.8309859154929577, 0.8333333333333334, 0.8309859154929577, 1.0, 0.8591549295774648, 1.0, 0.8591549295774648, 0.8333333333333334], [0.8309859154929577, 0.5833333333333333, 0.8309859154929577, 0.8333333333333334, 0.8591549295774648, 0.8333333333333334, 0.8591549295774648, 0.5833333333333333], [0.7746478873239436, 0.5833333333333333, 0.7746478873239436, 0.8333333333333334, 0.8028169014084507, 0.8333333333333334, 0.8028169014084507, 0.5833333333333333]],'shading_values':[[1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0]]}, {'name':'leg3','pivot':[0.1875, 0.375, -0.3125],'vertices':[[0.0625, 0.0, -0.4375, 0.0625, 0.375, -0.4375, 0.3125, 0.375, -0.4375, 0.3125, 0.0, -0.4375], [0.3125, 0.0, -0.1875, 0.3125, 0.375, -0.1875, 0.0625, 0.375, -0.1875, 0.0625, 0.0, -0.1875], [0.0625, 0.375, -0.4375, 0.0625, 0.375, -0.1875, 0.3125, 0.375, -0.1875, 0.3125, 0.375, -0.4375], [0.3125, 0.0, -0.4375, 0.3125, 0.0, -0.1875, 0.0625, 0.0, -0.1875, 0.0625, 0.0, -0.4375], [0.3125, 0.0, -0.4375, 0.3125, 0.375, -0.4375, 0.3125, 0.375, -0.1875, 0.3125, 0.0, -0.1875], [0.0625, 0.0, -0.1875, 0.0625, 0.375, -0.1875, 0.0625, 0.375, -0.4375, 0.0625, 0.0, -0.4375]],'tex_coords':[[0.9154929577464789, 0.5833333333333333, 0.9154929577464789, 0.8333333333333334, 0.9436619718309859, 0.8333333333333334, 0.9436619718309859, 0.5833333333333333], [0.971830985915493, 0.5833333333333333, 0.971830985915493, 0.8333333333333334, 1.0, 0.8333333333333334, 1.0, 0.5833333333333333], [0.9154929577464789, 0.8333333333333334, 0.9154929577464789, 1.0, 0.9436619718309859, 1.0, 0.9436619718309859, 0.8333333333333334], [0.9436619718309859, 0.8333333333333334, 0.9436619718309859, 1.0, 0.971830985915493, 1.0, 0.971830985915493, 0.8333333333333334], [0.9436619718309859, 0.5833333333333333, 0.9436619718309859, 0.8333333333333334, 0.971830985915493, 0.8333333333333334, 0.971830985915493, 0.5833333333333333], [0.8873239436619719, 0.5833333333333333, 0.8873239436619719, 0.8333333333333334, 0.9154929577464789, 0.8333333333333334, 0.9154929577464789, 0.5833333333333333]],'shading_values':[[1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0]]}] diff --git a/episode-13/models/plant.py b/episode-13/models/plant.py new file mode 100644 index 00000000..4acc8adc --- /dev/null +++ b/episode-13/models/plant.py @@ -0,0 +1,26 @@ +transparent = True +is_cube = False +glass = False + +colliders = [] + +vertex_positions = [ + [-0.3536, 0.5000, 0.3536, -0.3536, -0.5000, 0.3536, 0.3536, -0.5000, -0.3536, 0.3536, 0.5000, -0.3536], + [-0.3536, 0.5000, -0.3536, -0.3536, -0.5000, -0.3536, 0.3536, -0.5000, 0.3536, 0.3536, 0.5000, 0.3536], + [ 0.3536, 0.5000, -0.3536, 0.3536, -0.5000, -0.3536, -0.3536, -0.5000, 0.3536, -0.3536, 0.5000, 0.3536], + [ 0.3536, 0.5000, 0.3536, 0.3536, -0.5000, 0.3536, -0.3536, -0.5000, -0.3536, -0.3536, 0.5000, -0.3536], +] + +tex_coords = [ + [0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 1.0, 0.0], + [0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 1.0, 0.0], + [0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 1.0, 0.0], + [0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 1.0, 0.0], +] + +shading_values = [ + [1.0, 1.0, 1.0, 1.0], + [1.0, 1.0, 1.0, 1.0], + [1.0, 1.0, 1.0, 1.0], + [1.0, 1.0, 1.0, 1.0], +] \ No newline at end of file diff --git a/episode-13/models/pressure_plate.py b/episode-13/models/pressure_plate.py new file mode 100644 index 00000000..acfe6429 --- /dev/null +++ b/episode-13/models/pressure_plate.py @@ -0,0 +1,20 @@ +transparent = True +is_cube = False +glass = False + +colliders = [] + +vertex_positions = [ + [ 0.5, -0.4375, 0.5, 0.5, -0.4375, -0.5, -0.5, -0.4375, -0.5, -0.5, -0.4375, 0.5], # top + [-0.5, -0.4375, 0.5, -0.5, -0.4375, -0.5, 0.5, -0.4375, -0.5, 0.5, -0.4375, 0.5], # bottom +] + +tex_coords = [ + [0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 1.0, 0.0], + [0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 1.0, 0.0], +] + +shading_values = [ + [1.0, 1.0, 1.0, 1.0], + [0.4, 0.4, 0.4, 0.4], +] \ No newline at end of file diff --git a/episode-13/models/sign.py b/episode-13/models/sign.py new file mode 100644 index 00000000..4acc8adc --- /dev/null +++ b/episode-13/models/sign.py @@ -0,0 +1,26 @@ +transparent = True +is_cube = False +glass = False + +colliders = [] + +vertex_positions = [ + [-0.3536, 0.5000, 0.3536, -0.3536, -0.5000, 0.3536, 0.3536, -0.5000, -0.3536, 0.3536, 0.5000, -0.3536], + [-0.3536, 0.5000, -0.3536, -0.3536, -0.5000, -0.3536, 0.3536, -0.5000, 0.3536, 0.3536, 0.5000, 0.3536], + [ 0.3536, 0.5000, -0.3536, 0.3536, -0.5000, -0.3536, -0.3536, -0.5000, 0.3536, -0.3536, 0.5000, 0.3536], + [ 0.3536, 0.5000, 0.3536, 0.3536, -0.5000, 0.3536, -0.3536, -0.5000, -0.3536, -0.3536, 0.5000, -0.3536], +] + +tex_coords = [ + [0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 1.0, 0.0], + [0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 1.0, 0.0], + [0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 1.0, 0.0], + [0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 1.0, 0.0], +] + +shading_values = [ + [1.0, 1.0, 1.0, 1.0], + [1.0, 1.0, 1.0, 1.0], + [1.0, 1.0, 1.0, 1.0], + [1.0, 1.0, 1.0, 1.0], +] \ No newline at end of file diff --git a/episode-13/models/sign_post.py b/episode-13/models/sign_post.py new file mode 100644 index 00000000..4acc8adc --- /dev/null +++ b/episode-13/models/sign_post.py @@ -0,0 +1,26 @@ +transparent = True +is_cube = False +glass = False + +colliders = [] + +vertex_positions = [ + [-0.3536, 0.5000, 0.3536, -0.3536, -0.5000, 0.3536, 0.3536, -0.5000, -0.3536, 0.3536, 0.5000, -0.3536], + [-0.3536, 0.5000, -0.3536, -0.3536, -0.5000, -0.3536, 0.3536, -0.5000, 0.3536, 0.3536, 0.5000, 0.3536], + [ 0.3536, 0.5000, -0.3536, 0.3536, -0.5000, -0.3536, -0.3536, -0.5000, 0.3536, -0.3536, 0.5000, 0.3536], + [ 0.3536, 0.5000, 0.3536, 0.3536, -0.5000, 0.3536, -0.3536, -0.5000, -0.3536, -0.3536, 0.5000, -0.3536], +] + +tex_coords = [ + [0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 1.0, 0.0], + [0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 1.0, 0.0], + [0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 1.0, 0.0], + [0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 1.0, 0.0], +] + +shading_values = [ + [1.0, 1.0, 1.0, 1.0], + [1.0, 1.0, 1.0, 1.0], + [1.0, 1.0, 1.0, 1.0], + [1.0, 1.0, 1.0, 1.0], +] \ No newline at end of file diff --git a/episode-13/models/skeleton.py b/episode-13/models/skeleton.py new file mode 100644 index 00000000..003cd6c2 --- /dev/null +++ b/episode-13/models/skeleton.py @@ -0,0 +1,8 @@ + +transparent = True +is_cube = False +glass = False + +colliders = [] + +bones = [{'name':'body','pivot':[0.0, 1.5, 0.0],'vertices':[[-0.25, 0.75, -0.125, -0.25, 1.5, -0.125, 0.25, 1.5, -0.125, 0.25, 0.75, -0.125], [0.25, 0.75, 0.125, 0.25, 1.5, 0.125, -0.25, 1.5, 0.125, -0.25, 0.75, 0.125], [-0.25, 1.5, -0.125, -0.25, 1.5, 0.125, 0.25, 1.5, 0.125, 0.25, 1.5, -0.125], [0.25, 0.75, -0.125, 0.25, 0.75, 0.125, -0.25, 0.75, 0.125, -0.25, 0.75, -0.125], [0.25, 0.75, -0.125, 0.25, 1.5, -0.125, 0.25, 1.5, 0.125, 0.25, 0.75, 0.125], [-0.25, 0.75, 0.125, -0.25, 1.5, 0.125, -0.25, 1.5, -0.125, -0.25, 0.75, -0.125]],'tex_coords':[[0.03333333333333333, 0.0, 0.03333333333333333, 0.75, 0.1, 0.75, 0.1, 0.0], [0.13333333333333333, 0.0, 0.13333333333333333, 0.75, 0.2, 0.75, 0.2, 0.0], [0.03333333333333333, 0.75, 0.03333333333333333, 1.0, 0.1, 1.0, 0.1, 0.75], [0.1, 0.75, 0.1, 1.0, 0.16666666666666666, 1.0, 0.16666666666666666, 0.75], [0.1, 0.0, 0.1, 0.75, 0.13333333333333333, 0.75, 0.13333333333333333, 0.0], [0.0, 0.0, 0.0, 0.75, 0.03333333333333333, 0.75, 0.03333333333333333, 0.0]],'shading_values':[[1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0]]}, {'name':'head','pivot':[0.0, 1.5, 0.0],'vertices':[[-0.25, 1.5, -0.25, -0.25, 2.0, -0.25, 0.25, 2.0, -0.25, 0.25, 1.5, -0.25], [0.25, 1.5, 0.25, 0.25, 2.0, 0.25, -0.25, 2.0, 0.25, -0.25, 1.5, 0.25], [-0.25, 2.0, -0.25, -0.25, 2.0, 0.25, 0.25, 2.0, 0.25, 0.25, 2.0, -0.25], [0.25, 1.5, -0.25, 0.25, 1.5, 0.25, -0.25, 1.5, 0.25, -0.25, 1.5, -0.25], [0.25, 1.5, -0.25, 0.25, 2.0, -0.25, 0.25, 2.0, 0.25, 0.25, 1.5, 0.25], [-0.25, 1.5, 0.25, -0.25, 2.0, 0.25, -0.25, 2.0, -0.25, -0.25, 1.5, -0.25]],'tex_coords':[[0.26666666666666666, 0.0, 0.26666666666666666, 0.5, 0.3333333333333333, 0.5, 0.3333333333333333, 0.0], [0.4, 0.0, 0.4, 0.5, 0.4666666666666667, 0.5, 0.4666666666666667, 0.0], [0.26666666666666666, 0.5, 0.26666666666666666, 1.0, 0.3333333333333333, 1.0, 0.3333333333333333, 0.5], [0.3333333333333333, 0.5, 0.3333333333333333, 1.0, 0.4, 1.0, 0.4, 0.5], [0.3333333333333333, 0.0, 0.3333333333333333, 0.5, 0.4, 0.5, 0.4, 0.0], [0.2, 0.0, 0.2, 0.5, 0.26666666666666666, 0.5, 0.26666666666666666, 0.0]],'shading_values':[[1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0]]}, {'name':'hat','pivot':[0.0, 1.5, 0.0],'vertices':[[-0.25, 1.5, -0.25, -0.25, 2.0, -0.25, 0.25, 2.0, -0.25, 0.25, 1.5, -0.25], [0.25, 1.5, 0.25, 0.25, 2.0, 0.25, -0.25, 2.0, 0.25, -0.25, 1.5, 0.25], [-0.25, 2.0, -0.25, -0.25, 2.0, 0.25, 0.25, 2.0, 0.25, 0.25, 2.0, -0.25], [0.25, 1.5, -0.25, 0.25, 1.5, 0.25, -0.25, 1.5, 0.25, -0.25, 1.5, -0.25], [0.25, 1.5, -0.25, 0.25, 2.0, -0.25, 0.25, 2.0, 0.25, 0.25, 1.5, 0.25], [-0.25, 1.5, 0.25, -0.25, 2.0, 0.25, -0.25, 2.0, -0.25, -0.25, 1.5, -0.25]],'tex_coords':[[0.5333333333333333, 0.0, 0.5333333333333333, 0.5, 0.6, 0.5, 0.6, 0.0], [0.6666666666666666, 0.0, 0.6666666666666666, 0.5, 0.7333333333333333, 0.5, 0.7333333333333333, 0.0], [0.5333333333333333, 0.5, 0.5333333333333333, 1.0, 0.6, 1.0, 0.6, 0.5], [0.6, 0.5, 0.6, 1.0, 0.6666666666666666, 1.0, 0.6666666666666666, 0.5], [0.6, 0.0, 0.6, 0.5, 0.6666666666666666, 0.5, 0.6666666666666666, 0.0], [0.4666666666666667, 0.0, 0.4666666666666667, 0.5, 0.5333333333333333, 0.5, 0.5333333333333333, 0.0]],'shading_values':[[1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0]]}, {'name':'rightArm','pivot':[-0.3125, 1.375, 0.0],'vertices':[[-0.375, 0.75, -0.0625, -0.375, 1.5, -0.0625, -0.25, 1.5, -0.0625, -0.25, 0.75, -0.0625], [-0.25, 0.75, 0.0625, -0.25, 1.5, 0.0625, -0.375, 1.5, 0.0625, -0.375, 0.75, 0.0625], [-0.375, 1.5, -0.0625, -0.375, 1.5, 0.0625, -0.25, 1.5, 0.0625, -0.25, 1.5, -0.0625], [-0.25, 0.75, -0.0625, -0.25, 0.75, 0.0625, -0.375, 0.75, 0.0625, -0.375, 0.75, -0.0625], [-0.25, 0.75, -0.0625, -0.25, 1.5, -0.0625, -0.25, 1.5, 0.0625, -0.25, 0.75, 0.0625], [-0.375, 0.75, 0.0625, -0.375, 1.5, 0.0625, -0.375, 1.5, -0.0625, -0.375, 0.75, -0.0625]],'tex_coords':[[0.75, 0.125, 0.75, 0.875, 0.7666666666666667, 0.875, 0.7666666666666667, 0.125], [0.7833333333333333, 0.125, 0.7833333333333333, 0.875, 0.8, 0.875, 0.8, 0.125], [0.75, 0.875, 0.75, 1.0, 0.7666666666666667, 1.0, 0.7666666666666667, 0.875], [0.7666666666666667, 0.875, 0.7666666666666667, 1.0, 0.7833333333333333, 1.0, 0.7833333333333333, 0.875], [0.7666666666666667, 0.125, 0.7666666666666667, 0.875, 0.7833333333333333, 0.875, 0.7833333333333333, 0.125], [0.7333333333333333, 0.125, 0.7333333333333333, 0.875, 0.75, 0.875, 0.75, 0.125]],'shading_values':[[1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0]]}, {'name':'leftArm','pivot':[0.3125, 1.375, 0.0],'vertices':[[0.25, 0.75, -0.0625, 0.25, 1.5, -0.0625, 0.375, 1.5, -0.0625, 0.375, 0.75, -0.0625], [0.375, 0.75, 0.0625, 0.375, 1.5, 0.0625, 0.25, 1.5, 0.0625, 0.25, 0.75, 0.0625], [0.25, 1.5, -0.0625, 0.25, 1.5, 0.0625, 0.375, 1.5, 0.0625, 0.375, 1.5, -0.0625], [0.375, 0.75, -0.0625, 0.375, 0.75, 0.0625, 0.25, 0.75, 0.0625, 0.25, 0.75, -0.0625], [0.375, 0.75, -0.0625, 0.375, 1.5, -0.0625, 0.375, 1.5, 0.0625, 0.375, 0.75, 0.0625], [0.25, 0.75, 0.0625, 0.25, 1.5, 0.0625, 0.25, 1.5, -0.0625, 0.25, 0.75, -0.0625]],'tex_coords':[[0.8166666666666667, 0.125, 0.8166666666666667, 0.875, 0.8333333333333334, 0.875, 0.8333333333333334, 0.125], [0.85, 0.125, 0.85, 0.875, 0.8666666666666667, 0.875, 0.8666666666666667, 0.125], [0.8166666666666667, 0.875, 0.8166666666666667, 1.0, 0.8333333333333334, 1.0, 0.8333333333333334, 0.875], [0.8333333333333334, 0.875, 0.8333333333333334, 1.0, 0.85, 1.0, 0.85, 0.875], [0.8333333333333334, 0.125, 0.8333333333333334, 0.875, 0.85, 0.875, 0.85, 0.125], [0.8, 0.125, 0.8, 0.875, 0.8166666666666667, 0.875, 0.8166666666666667, 0.125]],'shading_values':[[1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0]]}, {'name':'rightLeg','pivot':[-0.125, 0.75, 0.0],'vertices':[[-0.1875, 0.0, -0.0625, -0.1875, 0.75, -0.0625, -0.0625, 0.75, -0.0625, -0.0625, 0.0, -0.0625], [-0.0625, 0.0, 0.0625, -0.0625, 0.75, 0.0625, -0.1875, 0.75, 0.0625, -0.1875, 0.0, 0.0625], [-0.1875, 0.75, -0.0625, -0.1875, 0.75, 0.0625, -0.0625, 0.75, 0.0625, -0.0625, 0.75, -0.0625], [-0.0625, 0.0, -0.0625, -0.0625, 0.0, 0.0625, -0.1875, 0.0, 0.0625, -0.1875, 0.0, -0.0625], [-0.0625, 0.0, -0.0625, -0.0625, 0.75, -0.0625, -0.0625, 0.75, 0.0625, -0.0625, 0.0, 0.0625], [-0.1875, 0.0, 0.0625, -0.1875, 0.75, 0.0625, -0.1875, 0.75, -0.0625, -0.1875, 0.0, -0.0625]],'tex_coords':[[0.8833333333333333, 0.125, 0.8833333333333333, 0.875, 0.9, 0.875, 0.9, 0.125], [0.9166666666666666, 0.125, 0.9166666666666666, 0.875, 0.9333333333333333, 0.875, 0.9333333333333333, 0.125], [0.8833333333333333, 0.875, 0.8833333333333333, 1.0, 0.9, 1.0, 0.9, 0.875], [0.9, 0.875, 0.9, 1.0, 0.9166666666666666, 1.0, 0.9166666666666666, 0.875], [0.9, 0.125, 0.9, 0.875, 0.9166666666666666, 0.875, 0.9166666666666666, 0.125], [0.8666666666666667, 0.125, 0.8666666666666667, 0.875, 0.8833333333333333, 0.875, 0.8833333333333333, 0.125]],'shading_values':[[1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0]]}, {'name':'leftLeg','pivot':[0.125, 0.75, 0.0],'vertices':[[0.0625, 0.0, -0.0625, 0.0625, 0.75, -0.0625, 0.1875, 0.75, -0.0625, 0.1875, 0.0, -0.0625], [0.1875, 0.0, 0.0625, 0.1875, 0.75, 0.0625, 0.0625, 0.75, 0.0625, 0.0625, 0.0, 0.0625], [0.0625, 0.75, -0.0625, 0.0625, 0.75, 0.0625, 0.1875, 0.75, 0.0625, 0.1875, 0.75, -0.0625], [0.1875, 0.0, -0.0625, 0.1875, 0.0, 0.0625, 0.0625, 0.0, 0.0625, 0.0625, 0.0, -0.0625], [0.1875, 0.0, -0.0625, 0.1875, 0.75, -0.0625, 0.1875, 0.75, 0.0625, 0.1875, 0.0, 0.0625], [0.0625, 0.0, 0.0625, 0.0625, 0.75, 0.0625, 0.0625, 0.75, -0.0625, 0.0625, 0.0, -0.0625]],'tex_coords':[[0.95, 0.125, 0.95, 0.875, 0.9666666666666667, 0.875, 0.9666666666666667, 0.125], [0.9833333333333333, 0.125, 0.9833333333333333, 0.875, 1.0, 0.875, 1.0, 0.125], [0.95, 0.875, 0.95, 1.0, 0.9666666666666667, 1.0, 0.9666666666666667, 0.875], [0.9666666666666667, 0.875, 0.9666666666666667, 1.0, 0.9833333333333333, 1.0, 0.9833333333333333, 0.875], [0.9666666666666667, 0.125, 0.9666666666666667, 0.875, 0.9833333333333333, 0.875, 0.9833333333333333, 0.125], [0.9333333333333333, 0.125, 0.9333333333333333, 0.875, 0.95, 0.875, 0.95, 0.125]],'shading_values':[[1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0]]}] diff --git a/episode-13/models/slab.py b/episode-13/models/slab.py new file mode 100644 index 00000000..f3eed101 --- /dev/null +++ b/episode-13/models/slab.py @@ -0,0 +1,37 @@ +transparent = True +is_cube = False +glass = False + +colliders = [ + [ + (-0.5, -0.5, -0.5), + ( 0.5, 0.0, 0.5) + ] +] + +vertex_positions = [ + [ 0.5, 0.0, 0.5, 0.5, -0.5, 0.5, 0.5, -0.5, -0.5, 0.5, 0.0, -0.5], # right + [-0.5, 0.0, -0.5, -0.5, -0.5, -0.5, -0.5, -0.5, 0.5, -0.5, 0.0, 0.5], # left + [ 0.5, 0.0, 0.5, 0.5, 0.0, -0.5, -0.5, 0.0, -0.5, -0.5, 0.0, 0.5], # top + [-0.5, -0.5, 0.5, -0.5, -0.5, -0.5, 0.5, -0.5, -0.5, 0.5, -0.5, 0.5], # bottom + [-0.5, 0.0, 0.5, -0.5, -0.5, 0.5, 0.5, -0.5, 0.5, 0.5, 0.0, 0.5], # front + [ 0.5, 0.0, -0.5, 0.5, -0.5, -0.5, -0.5, -0.5, -0.5, -0.5, 0.0, -0.5], # back +] + +tex_coords = [ + [0.0, 0.5, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 0.5, 0.0], + [0.0, 0.5, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 0.5, 0.0], + [0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 1.0, 0.0], + [0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 1.0, 0.0], + [0.0, 0.5, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 0.5, 0.0], + [0.0, 0.5, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 0.5, 0.0], +] + +shading_values = [ + [0.6, 0.6, 0.6, 0.6], + [0.6, 0.6, 0.6, 0.6], + [1.0, 1.0, 1.0, 1.0], + [0.4, 0.4, 0.4, 0.4], + [0.8, 0.8, 0.8, 0.8], + [0.8, 0.8, 0.8, 0.8], +] \ No newline at end of file diff --git a/episode-13/models/snow.py b/episode-13/models/snow.py new file mode 100644 index 00000000..80e6239b --- /dev/null +++ b/episode-13/models/snow.py @@ -0,0 +1,25 @@ +transparent = True +is_cube = False +glass = False + +colliders = [ + [ + (-0.5, -0.5000, -0.5), + ( 0.5, -0.4375, 0.5) + ] +] + +vertex_positions = [ + [ 0.5, -0.4375, 0.5, 0.5, -0.4375, -0.5, -0.5, -0.4375, -0.5, -0.5, -0.4375, 0.5], # top + [-0.5, -0.4375, 0.5, -0.5, -0.4375, -0.5, 0.5, -0.4375, -0.5, 0.5, -0.4375, 0.5], # bottom +] + +tex_coords = [ + [0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 1.0, 0.0], + [0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 1.0, 0.0], +] + +shading_values = [ + [1.0, 1.0, 1.0, 1.0], + [0.4, 0.4, 0.4, 0.4], +] \ No newline at end of file diff --git a/episode-13/models/soil.py b/episode-13/models/soil.py new file mode 100644 index 00000000..447d963f --- /dev/null +++ b/episode-13/models/soil.py @@ -0,0 +1,37 @@ +transparent = True +is_cube = False +glass = False + +colliders = [ + [ + (-0.5, -0.5000, -0.5), + ( 0.5, 0.4375, 0.5) + ] +] + +vertex_positions = [ + [ 0.5, 0.4375, 0.5, 0.5, -0.5, 0.5, 0.5, -0.5, -0.5, 0.5, 0.4375, -0.5], # right + [-0.5, 0.4375, -0.5, -0.5, -0.5, -0.5, -0.5, -0.5, 0.5, -0.5, 0.4375, 0.5], # left + [ 0.5, 0.4375, 0.5, 0.5, 0.4375, -0.5, -0.5, 0.4375, -0.5, -0.5, 0.4375, 0.5], # top + [-0.5, -0.5, 0.5, -0.5, -0.5, -0.5, 0.5, -0.5, -0.5, 0.5, -0.5, 0.5], # bottom + [-0.5, 0.4375, 0.5, -0.5, -0.5, 0.5, 0.5, -0.5, 0.5, 0.5, 0.4375, 0.5], # front + [ 0.5, 0.4375, -0.5, 0.5, -0.5, -0.5, -0.5, -0.5, -0.5, -0.5, 0.4375, -0.5], # back +] + +tex_coords = [ + [0.0, 0.9375, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 0.9375, 0.0], + [0.0, 0.9375, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 0.9375, 0.0], + [0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 1.0, 0.0], + [0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 1.0, 0.0], + [0.0, 0.9375, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 0.9375, 0.0], + [0.0, 0.9375, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 0.9375, 0.0], +] + +shading_values = [ + [0.6, 0.6, 0.6, 0.6], + [0.6, 0.6, 0.6, 0.6], + [1.0, 1.0, 1.0, 1.0], + [0.4, 0.4, 0.4, 0.4], + [0.8, 0.8, 0.8, 0.8], + [0.8, 0.8, 0.8, 0.8], +] \ No newline at end of file diff --git a/episode-13/models/stairs.py b/episode-13/models/stairs.py new file mode 100644 index 00000000..f3eed101 --- /dev/null +++ b/episode-13/models/stairs.py @@ -0,0 +1,37 @@ +transparent = True +is_cube = False +glass = False + +colliders = [ + [ + (-0.5, -0.5, -0.5), + ( 0.5, 0.0, 0.5) + ] +] + +vertex_positions = [ + [ 0.5, 0.0, 0.5, 0.5, -0.5, 0.5, 0.5, -0.5, -0.5, 0.5, 0.0, -0.5], # right + [-0.5, 0.0, -0.5, -0.5, -0.5, -0.5, -0.5, -0.5, 0.5, -0.5, 0.0, 0.5], # left + [ 0.5, 0.0, 0.5, 0.5, 0.0, -0.5, -0.5, 0.0, -0.5, -0.5, 0.0, 0.5], # top + [-0.5, -0.5, 0.5, -0.5, -0.5, -0.5, 0.5, -0.5, -0.5, 0.5, -0.5, 0.5], # bottom + [-0.5, 0.0, 0.5, -0.5, -0.5, 0.5, 0.5, -0.5, 0.5, 0.5, 0.0, 0.5], # front + [ 0.5, 0.0, -0.5, 0.5, -0.5, -0.5, -0.5, -0.5, -0.5, -0.5, 0.0, -0.5], # back +] + +tex_coords = [ + [0.0, 0.5, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 0.5, 0.0], + [0.0, 0.5, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 0.5, 0.0], + [0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 1.0, 0.0], + [0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 1.0, 0.0], + [0.0, 0.5, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 0.5, 0.0], + [0.0, 0.5, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 0.5, 0.0], +] + +shading_values = [ + [0.6, 0.6, 0.6, 0.6], + [0.6, 0.6, 0.6, 0.6], + [1.0, 1.0, 1.0, 1.0], + [0.4, 0.4, 0.4, 0.4], + [0.8, 0.8, 0.8, 0.8], + [0.8, 0.8, 0.8, 0.8], +] \ No newline at end of file diff --git a/episode-13/models/tinted_glass.py b/episode-13/models/tinted_glass.py new file mode 100644 index 00000000..fbee5972 --- /dev/null +++ b/episode-13/models/tinted_glass.py @@ -0,0 +1,38 @@ +transparent = True +is_cube = True +glass = True +translucent = True + +colliders = [ + [ + (-0.5, -0.5, -0.5), + ( 0.5, 0.5, 0.5) + ] +] + +vertex_positions = [ + [ 0.5, 0.5, 0.5, 0.5, -0.5, 0.5, 0.5, -0.5, -0.5, 0.5, 0.5, -0.5], # right + [-0.5, 0.5, -0.5, -0.5, -0.5, -0.5, -0.5, -0.5, 0.5, -0.5, 0.5, 0.5], # left + [ 0.5, 0.5, 0.5, 0.5, 0.5, -0.5, -0.5, 0.5, -0.5, -0.5, 0.5, 0.5], # top + [-0.5, -0.5, 0.5, -0.5, -0.5, -0.5, 0.5, -0.5, -0.5, 0.5, -0.5, 0.5], # bottom + [-0.5, 0.5, 0.5, -0.5, -0.5, 0.5, 0.5, -0.5, 0.5, 0.5, 0.5, 0.5], # front + [ 0.5, 0.5, -0.5, 0.5, -0.5, -0.5, -0.5, -0.5, -0.5, -0.5, 0.5, -0.5], # back +] + +tex_coords = [ + [0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 1.0, 0.0], + [0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 1.0, 0.0], + [0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 1.0, 0.0], + [0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 1.0, 0.0], + [0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 1.0, 0.0], + [0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 1.0, 0.0], +] + +shading_values = [ + [0.6, 0.6, 0.6, 0.6], + [0.6, 0.6, 0.6, 0.6], + [1.0, 1.0, 1.0, 1.0], + [0.4, 0.4, 0.4, 0.4], + [0.8, 0.8, 0.8, 0.8], + [0.8, 0.8, 0.8, 0.8], +] diff --git a/episode-13/models/torch.py b/episode-13/models/torch.py new file mode 100644 index 00000000..1dbcc5fb --- /dev/null +++ b/episode-13/models/torch.py @@ -0,0 +1,32 @@ +transparent = True +is_cube = False +glass = False + +colliders = [] + +vertex_positions = [ + [ 0.0625, 0.5, 0.5, 0.0625, -0.5, 0.5, 0.0625, -0.5, -0.5, 0.0625, 0.5, -0.5], # right + [-0.0625, 0.5, -0.5, -0.0625, -0.5, -0.5, -0.0625, -0.5, 0.5, -0.0625, 0.5, 0.5], # left + [ 0.5, 0.125, 0.5, 0.5, 0.125, -0.5, -0.5, 0.125, -0.5, -0.5, 0.125, 0.5], # top + [-0.5, -0.5, 0.5, -0.5, -0.5, -0.5, 0.5, -0.5, -0.5, 0.5, -0.5, 0.5], # bottom + [-0.5, 0.5, 0.0625, -0.5, -0.5, 0.0625, 0.5, -0.5, 0.0625, 0.5, 0.5, 0.0625], # front + [ 0.5, 0.5, -0.0625, 0.5, -0.5, -0.0625, -0.5, -0.5, -0.0625, -0.5, 0.5, -0.0625], # back +] + +tex_coords = [ + [0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 1.0, 0.0], + [0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 1.0, 0.0], + [0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 1.0, 0.0], + [0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 1.0, 0.0], + [0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 1.0, 0.0], + [0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 1.0, 0.0], +] + +shading_values = [ + [0.6, 0.6, 0.6, 0.6], + [0.6, 0.6, 0.6, 0.6], + [1.0, 1.0, 1.0, 1.0], + [0.4, 0.4, 0.4, 0.4], + [0.8, 0.8, 0.8, 0.8], + [0.8, 0.8, 0.8, 0.8], +] diff --git a/episode-13/models/zombie.py b/episode-13/models/zombie.py new file mode 100644 index 00000000..d1650af9 --- /dev/null +++ b/episode-13/models/zombie.py @@ -0,0 +1,8 @@ + +transparent = True +is_cube = False +glass = False + +colliders = [] + +bones = [{'name':'body','pivot':[0.0, 1.5, 0.0],'vertices':[[-0.25, 0.75, -0.125, -0.25, 1.5, -0.125, 0.25, 1.5, -0.125, 0.25, 0.75, -0.125], [0.25, 0.75, 0.125, 0.25, 1.5, 0.125, -0.25, 1.5, 0.125, -0.25, 0.75, 0.125], [-0.25, 1.5, -0.125, -0.25, 1.5, 0.125, 0.25, 1.5, 0.125, 0.25, 1.5, -0.125], [0.25, 0.75, -0.125, 0.25, 0.75, 0.125, -0.25, 0.75, 0.125, -0.25, 0.75, -0.125], [0.25, 0.75, -0.125, 0.25, 1.5, -0.125, 0.25, 1.5, 0.125, 0.25, 0.75, 0.125], [-0.25, 0.75, 0.125, -0.25, 1.5, 0.125, -0.25, 1.5, -0.125, -0.25, 0.75, -0.125]],'tex_coords':[[0.02631578947368421, 0.0, 0.02631578947368421, 0.75, 0.07894736842105263, 0.75, 0.07894736842105263, 0.0], [0.10526315789473684, 0.0, 0.10526315789473684, 0.75, 0.15789473684210525, 0.75, 0.15789473684210525, 0.0], [0.02631578947368421, 0.75, 0.02631578947368421, 1.0, 0.07894736842105263, 1.0, 0.07894736842105263, 0.75], [0.07894736842105263, 0.75, 0.07894736842105263, 1.0, 0.13157894736842105, 1.0, 0.13157894736842105, 0.75], [0.07894736842105263, 0.0, 0.07894736842105263, 0.75, 0.10526315789473684, 0.75, 0.10526315789473684, 0.0], [0.0, 0.0, 0.0, 0.75, 0.02631578947368421, 0.75, 0.02631578947368421, 0.0]],'shading_values':[[1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0]]}, {'name':'head','pivot':[0.0, 1.5, 0.0],'vertices':[[-0.25, 1.5, -0.25, -0.25, 2.0, -0.25, 0.25, 2.0, -0.25, 0.25, 1.5, -0.25], [0.25, 1.5, 0.25, 0.25, 2.0, 0.25, -0.25, 2.0, 0.25, -0.25, 1.5, 0.25], [-0.25, 2.0, -0.25, -0.25, 2.0, 0.25, 0.25, 2.0, 0.25, 0.25, 2.0, -0.25], [0.25, 1.5, -0.25, 0.25, 1.5, 0.25, -0.25, 1.5, 0.25, -0.25, 1.5, -0.25], [0.25, 1.5, -0.25, 0.25, 2.0, -0.25, 0.25, 2.0, 0.25, 0.25, 1.5, 0.25], [-0.25, 1.5, 0.25, -0.25, 2.0, 0.25, -0.25, 2.0, -0.25, -0.25, 1.5, -0.25]],'tex_coords':[[0.21052631578947367, 0.0, 0.21052631578947367, 0.5, 0.2631578947368421, 0.5, 0.2631578947368421, 0.0], [0.3157894736842105, 0.0, 0.3157894736842105, 0.5, 0.3684210526315789, 0.5, 0.3684210526315789, 0.0], [0.21052631578947367, 0.5, 0.21052631578947367, 1.0, 0.2631578947368421, 1.0, 0.2631578947368421, 0.5], [0.2631578947368421, 0.5, 0.2631578947368421, 1.0, 0.3157894736842105, 1.0, 0.3157894736842105, 0.5], [0.2631578947368421, 0.0, 0.2631578947368421, 0.5, 0.3157894736842105, 0.5, 0.3157894736842105, 0.0], [0.15789473684210525, 0.0, 0.15789473684210525, 0.5, 0.21052631578947367, 0.5, 0.21052631578947367, 0.0]],'shading_values':[[1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0]]}, {'name':'hat','pivot':[0.0, 1.5, 0.0],'vertices':[[-0.25, 1.5, -0.25, -0.25, 2.0, -0.25, 0.25, 2.0, -0.25, 0.25, 1.5, -0.25], [0.25, 1.5, 0.25, 0.25, 2.0, 0.25, -0.25, 2.0, 0.25, -0.25, 1.5, 0.25], [-0.25, 2.0, -0.25, -0.25, 2.0, 0.25, 0.25, 2.0, 0.25, 0.25, 2.0, -0.25], [0.25, 1.5, -0.25, 0.25, 1.5, 0.25, -0.25, 1.5, 0.25, -0.25, 1.5, -0.25], [0.25, 1.5, -0.25, 0.25, 2.0, -0.25, 0.25, 2.0, 0.25, 0.25, 1.5, 0.25], [-0.25, 1.5, 0.25, -0.25, 2.0, 0.25, -0.25, 2.0, -0.25, -0.25, 1.5, -0.25]],'tex_coords':[[0.42105263157894735, 0.0, 0.42105263157894735, 0.5, 0.47368421052631576, 0.5, 0.47368421052631576, 0.0], [0.5263157894736842, 0.0, 0.5263157894736842, 0.5, 0.5789473684210527, 0.5, 0.5789473684210527, 0.0], [0.42105263157894735, 0.5, 0.42105263157894735, 1.0, 0.47368421052631576, 1.0, 0.47368421052631576, 0.5], [0.47368421052631576, 0.5, 0.47368421052631576, 1.0, 0.5263157894736842, 1.0, 0.5263157894736842, 0.5], [0.47368421052631576, 0.0, 0.47368421052631576, 0.5, 0.5263157894736842, 0.5, 0.5263157894736842, 0.0], [0.3684210526315789, 0.0, 0.3684210526315789, 0.5, 0.42105263157894735, 0.5, 0.42105263157894735, 0.0]],'shading_values':[[1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0]]}, {'name':'rightArm','pivot':[-0.3125, 1.375, 0.0],'vertices':[[-0.5, 0.75, -0.125, -0.5, 1.5, -0.125, -0.25, 1.5, -0.125, -0.25, 0.75, -0.125], [-0.25, 0.75, 0.125, -0.25, 1.5, 0.125, -0.5, 1.5, 0.125, -0.5, 0.75, 0.125], [-0.5, 1.5, -0.125, -0.5, 1.5, 0.125, -0.25, 1.5, 0.125, -0.25, 1.5, -0.125], [-0.25, 0.75, -0.125, -0.25, 0.75, 0.125, -0.5, 0.75, 0.125, -0.5, 0.75, -0.125], [-0.25, 0.75, -0.125, -0.25, 1.5, -0.125, -0.25, 1.5, 0.125, -0.25, 0.75, 0.125], [-0.5, 0.75, 0.125, -0.5, 1.5, 0.125, -0.5, 1.5, -0.125, -0.5, 0.75, -0.125]],'tex_coords':[[0.6052631578947368, 0.0, 0.6052631578947368, 0.75, 0.631578947368421, 0.75, 0.631578947368421, 0.0], [0.6578947368421053, 0.0, 0.6578947368421053, 0.75, 0.6842105263157895, 0.75, 0.6842105263157895, 0.0], [0.6052631578947368, 0.75, 0.6052631578947368, 1.0, 0.631578947368421, 1.0, 0.631578947368421, 0.75], [0.631578947368421, 0.75, 0.631578947368421, 1.0, 0.6578947368421053, 1.0, 0.6578947368421053, 0.75], [0.631578947368421, 0.0, 0.631578947368421, 0.75, 0.6578947368421053, 0.75, 0.6578947368421053, 0.0], [0.5789473684210527, 0.0, 0.5789473684210527, 0.75, 0.6052631578947368, 0.75, 0.6052631578947368, 0.0]],'shading_values':[[1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0]]}, {'name':'leftArm','pivot':[0.3125, 1.375, 0.0],'vertices':[[0.25, 0.75, -0.125, 0.25, 1.5, -0.125, 0.5, 1.5, -0.125, 0.5, 0.75, -0.125], [0.5, 0.75, 0.125, 0.5, 1.5, 0.125, 0.25, 1.5, 0.125, 0.25, 0.75, 0.125], [0.25, 1.5, -0.125, 0.25, 1.5, 0.125, 0.5, 1.5, 0.125, 0.5, 1.5, -0.125], [0.5, 0.75, -0.125, 0.5, 0.75, 0.125, 0.25, 0.75, 0.125, 0.25, 0.75, -0.125], [0.5, 0.75, -0.125, 0.5, 1.5, -0.125, 0.5, 1.5, 0.125, 0.5, 0.75, 0.125], [0.25, 0.75, 0.125, 0.25, 1.5, 0.125, 0.25, 1.5, -0.125, 0.25, 0.75, -0.125]],'tex_coords':[[0.7105263157894737, 0.0, 0.7105263157894737, 0.75, 0.7368421052631579, 0.75, 0.7368421052631579, 0.0], [0.7631578947368421, 0.0, 0.7631578947368421, 0.75, 0.7894736842105263, 0.75, 0.7894736842105263, 0.0], [0.7105263157894737, 0.75, 0.7105263157894737, 1.0, 0.7368421052631579, 1.0, 0.7368421052631579, 0.75], [0.7368421052631579, 0.75, 0.7368421052631579, 1.0, 0.7631578947368421, 1.0, 0.7631578947368421, 0.75], [0.7368421052631579, 0.0, 0.7368421052631579, 0.75, 0.7631578947368421, 0.75, 0.7631578947368421, 0.0], [0.6842105263157895, 0.0, 0.6842105263157895, 0.75, 0.7105263157894737, 0.75, 0.7105263157894737, 0.0]],'shading_values':[[1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0]]}, {'name':'rightLeg','pivot':[-0.11875, 0.75, 0.0],'vertices':[[-0.24375000596046448, 0.0, -0.125, -0.24375000596046448, 0.75, -0.125, 0.0062500000931322575, 0.75, -0.125, 0.0062500000931322575, 0.0, -0.125], [0.0062500000931322575, 0.0, 0.125, 0.0062500000931322575, 0.75, 0.125, -0.24375000596046448, 0.75, 0.125, -0.24375000596046448, 0.0, 0.125], [-0.24375000596046448, 0.75, -0.125, -0.24375000596046448, 0.75, 0.125, 0.0062500000931322575, 0.75, 0.125, 0.0062500000931322575, 0.75, -0.125], [0.0062500000931322575, 0.0, -0.125, 0.0062500000931322575, 0.0, 0.125, -0.24375000596046448, 0.0, 0.125, -0.24375000596046448, 0.0, -0.125], [0.0062500000931322575, 0.0, -0.125, 0.0062500000931322575, 0.75, -0.125, 0.0062500000931322575, 0.75, 0.125, 0.0062500000931322575, 0.0, 0.125], [-0.24375000596046448, 0.0, 0.125, -0.24375000596046448, 0.75, 0.125, -0.24375000596046448, 0.75, -0.125, -0.24375000596046448, 0.0, -0.125]],'tex_coords':[[0.8157894736842105, 0.0, 0.8157894736842105, 0.75, 0.8421052631578947, 0.75, 0.8421052631578947, 0.0], [0.868421052631579, 0.0, 0.868421052631579, 0.75, 0.8947368421052632, 0.75, 0.8947368421052632, 0.0], [0.8157894736842105, 0.75, 0.8157894736842105, 1.0, 0.8421052631578947, 1.0, 0.8421052631578947, 0.75], [0.8421052631578947, 0.75, 0.8421052631578947, 1.0, 0.868421052631579, 1.0, 0.868421052631579, 0.75], [0.8421052631578947, 0.0, 0.8421052631578947, 0.75, 0.868421052631579, 0.75, 0.868421052631579, 0.0], [0.7894736842105263, 0.0, 0.7894736842105263, 0.75, 0.8157894736842105, 0.75, 0.8157894736842105, 0.0]],'shading_values':[[1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0]]}, {'name':'leftLeg','pivot':[0.11875, 0.75, 0.0],'vertices':[[-0.0062500000931322575, 0.0, -0.125, -0.0062500000931322575, 0.75, -0.125, 0.24375000596046448, 0.75, -0.125, 0.24375000596046448, 0.0, -0.125], [0.24375000596046448, 0.0, 0.125, 0.24375000596046448, 0.75, 0.125, -0.0062500000931322575, 0.75, 0.125, -0.0062500000931322575, 0.0, 0.125], [-0.0062500000931322575, 0.75, -0.125, -0.0062500000931322575, 0.75, 0.125, 0.24375000596046448, 0.75, 0.125, 0.24375000596046448, 0.75, -0.125], [0.24375000596046448, 0.0, -0.125, 0.24375000596046448, 0.0, 0.125, -0.0062500000931322575, 0.0, 0.125, -0.0062500000931322575, 0.0, -0.125], [0.24375000596046448, 0.0, -0.125, 0.24375000596046448, 0.75, -0.125, 0.24375000596046448, 0.75, 0.125, 0.24375000596046448, 0.0, 0.125], [-0.0062500000931322575, 0.0, 0.125, -0.0062500000931322575, 0.75, 0.125, -0.0062500000931322575, 0.75, -0.125, -0.0062500000931322575, 0.0, -0.125]],'tex_coords':[[0.9210526315789473, 0.0, 0.9210526315789473, 0.75, 0.9473684210526315, 0.75, 0.9473684210526315, 0.0], [0.9736842105263158, 0.0, 0.9736842105263158, 0.75, 1.0, 0.75, 1.0, 0.0], [0.9210526315789473, 0.75, 0.9210526315789473, 1.0, 0.9473684210526315, 1.0, 0.9473684210526315, 0.75], [0.9473684210526315, 0.75, 0.9473684210526315, 1.0, 0.9736842105263158, 1.0, 0.9736842105263158, 0.75], [0.9473684210526315, 0.0, 0.9473684210526315, 0.75, 0.9736842105263158, 0.75, 0.9736842105263158, 0.0], [0.8947368421052632, 0.0, 0.8947368421052632, 0.75, 0.9210526315789473, 0.75, 0.9210526315789473, 0.0]],'shading_values':[[1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0]]}] diff --git a/episode-13/player.py b/episode-13/player.py new file mode 100644 index 00000000..1a77e0da --- /dev/null +++ b/episode-13/player.py @@ -0,0 +1,66 @@ +import math +import entity + +WALKING_SPEED = 4.317 +SPRINTING_SPEED = 7 # faster than in Minecraft, feels better + +class Player(entity.Entity): + def __init__(self, world, width, height): + super().__init__(world, world.entity_types["Player"]) + + self.view_width = width + self.view_height = height + + # camera variables + + self.eyelevel = self.entity_type.height - 0.2 + self.input = [0, 0, 0] + + self.target_speed = WALKING_SPEED + self.speed = self.target_speed + + def update(self, delta_time): + # process input + + if delta_time * 20 > 1: + self.speed = self.target_speed + + else: + self.speed += (self.target_speed - self.speed) * delta_time * 20 + + multiplier = self.speed * (1, 2)[self.flying] + + if self.flying and self.input[1]: + self.accel[1] = self.input[1] * multiplier + + if self.input[0] or self.input[2]: + angle = self.rotation[0] - math.atan2(self.input[2], self.input[0]) + math.tau / 4 + + self.accel[0] = math.cos(angle) * multiplier + self.accel[2] = math.sin(angle) * multiplier + + if not self.flying and self.input[1] > 0: + self.jump() + + # process physics & collisions &c + + super().update(delta_time) + + def update_matrices(self): + # create projection matrix + + self.world.p_matrix.load_identity() + + self.world.p_matrix.perspective( + 90 + 10 * (self.speed - WALKING_SPEED) / (SPRINTING_SPEED - WALKING_SPEED), + float(self.view_width) / self.view_height, 0.1, 500) + + # create modelview matrix + + self.world.mv_matrix.load_identity() + self.world.mv_matrix.rotate_2d(self.rotation[0] + math.tau / 4, self.rotation[1]) + self.world.mv_matrix.translate(-self.position[0], -self.position[1] - self.eyelevel, -self.position[2]) + + # modelviewprojection matrix + + self.world.mvp_matrix = self.world.p_matrix * self.world.mv_matrix diff --git a/episode-13/save.py b/episode-13/save.py new file mode 100644 index 00000000..5cc2793e --- /dev/null +++ b/episode-13/save.py @@ -0,0 +1,118 @@ +import nbtlib as nbt +import base36 + +import chunk +import mob + +class Save: + def __init__(self, world, path = "save"): + self.world = world + self.path = path + + def chunk_position_to_path(self, chunk_position): + x, _, z = chunk_position + + chunk_path = '/'.join((self.path, + base36.dumps(x % 64), base36.dumps(z % 64), + f"c.{base36.dumps(x)}.{base36.dumps(z)}.dat")) + + return chunk_path + + def load_chunk(self, chunk_position): + # load the chunk file + + chunk_path = self.chunk_position_to_path(chunk_position) + + try: + chunk_data = nbt.load(chunk_path) + + except FileNotFoundError: + return + + blocks = chunk_data["Level"]["Blocks"] + entities = [] # chunk_data["Level"]["Entities"] + + # create chunk and fill it with the blocks from our chunk file + + self.world.chunks[chunk_position] = chunk.Chunk(self.world, chunk_position) + + for x in range(chunk.CHUNK_WIDTH): + for y in range(chunk.CHUNK_HEIGHT): + for z in range(chunk.CHUNK_LENGTH): + self.world.chunks[chunk_position].blocks[x][y][z] = blocks[ + x * chunk.CHUNK_LENGTH * chunk.CHUNK_HEIGHT + + z * chunk.CHUNK_HEIGHT + + y] + + # load entities from chunk + + for entity in entities: + name = entity["id"] + + if name not in self.world.entity_types: + continue + + mob_ = mob.Mob(self.world, self.world.entity_types[name]) + *mob_.position, = entity["Pos"] + + print(name, mob_.position) + + self.world.entities.append(mob_) + + def save_chunk(self, chunk_position): + x, y, z = chunk_position + + # try to load the chunk file + # if it doesn't exist, create a new one + + chunk_path = self.chunk_position_to_path(chunk_position) + + try: + chunk_data = nbt.load(chunk_path) + + except FileNotFoundError: + chunk_data = nbt.File({"": nbt.Compound({"Level": nbt.Compound()})}) + + chunk_data["Level"]["xPos"] = x + chunk_data["Level"]["zPos"] = z + + # fill the chunk file with the blocks from our chunk + + chunk_blocks = nbt.ByteArray([0] * (chunk.CHUNK_WIDTH * chunk.CHUNK_HEIGHT * chunk.CHUNK_LENGTH)) + + for x in range(chunk.CHUNK_WIDTH): + for y in range(chunk.CHUNK_HEIGHT): + for z in range(chunk.CHUNK_LENGTH): + chunk_blocks[ + x * chunk.CHUNK_LENGTH * chunk.CHUNK_HEIGHT + + z * chunk.CHUNK_HEIGHT + + y] = self.world.chunks[chunk_position].blocks[x][y][z] + + # save the chunk file + + chunk_data["Level"]["Blocks"] = chunk_blocks + chunk_data.save(chunk_path, gzipped = True) + + def load(self): + # for x in range(-16, 15): + # for y in range(-15, 16): + # self.load_chunk((x, 0, y)) + + # for x in range(-4, 4): + # for y in range(-4, 4): + # self.load_chunk((x, 0, y)) + + for x in range(-1, 1): + for y in range(-1, 1): + self.load_chunk((x, 0, y)) + + def save(self): + for chunk_position in self.world.chunks: + if chunk_position[1] != 0: # reject all chunks above and below the world limit + continue + + chunk = self.world.chunks[chunk_position] + + if chunk.modified: + self.save_chunk(chunk_position) + chunk.modified = False diff --git a/episode-13/save/0/0/c.0.0.dat b/episode-13/save/0/0/c.0.0.dat new file mode 100644 index 00000000..13d6d4b0 Binary files /dev/null and b/episode-13/save/0/0/c.0.0.dat differ diff --git a/episode-13/save/0/1/c.0.1.dat b/episode-13/save/0/1/c.0.1.dat new file mode 100644 index 00000000..dd61294b Binary files /dev/null and b/episode-13/save/0/1/c.0.1.dat differ diff --git a/episode-13/save/0/1o/c.0.-4.dat b/episode-13/save/0/1o/c.0.-4.dat new file mode 100644 index 00000000..d840026b Binary files /dev/null and b/episode-13/save/0/1o/c.0.-4.dat differ diff --git a/episode-13/save/0/1p/c.0.-3.dat b/episode-13/save/0/1p/c.0.-3.dat new file mode 100644 index 00000000..d9392f71 Binary files /dev/null and b/episode-13/save/0/1p/c.0.-3.dat differ diff --git a/episode-13/save/0/1q/c.0.-2.dat b/episode-13/save/0/1q/c.0.-2.dat new file mode 100644 index 00000000..a298fd6a Binary files /dev/null and b/episode-13/save/0/1q/c.0.-2.dat differ diff --git a/episode-13/save/0/1r/c.0.-1.dat b/episode-13/save/0/1r/c.0.-1.dat new file mode 100644 index 00000000..a1e4b255 Binary files /dev/null and b/episode-13/save/0/1r/c.0.-1.dat differ diff --git a/episode-13/save/0/2/c.0.2.dat b/episode-13/save/0/2/c.0.2.dat new file mode 100644 index 00000000..29d57ca6 Binary files /dev/null and b/episode-13/save/0/2/c.0.2.dat differ diff --git a/episode-13/save/0/3/c.0.3.dat b/episode-13/save/0/3/c.0.3.dat new file mode 100644 index 00000000..69d837c0 Binary files /dev/null and b/episode-13/save/0/3/c.0.3.dat differ diff --git a/episode-13/save/1/0/c.1.0.dat b/episode-13/save/1/0/c.1.0.dat new file mode 100644 index 00000000..74fb0052 Binary files /dev/null and b/episode-13/save/1/0/c.1.0.dat differ diff --git a/episode-13/save/1/1/c.1.1.dat b/episode-13/save/1/1/c.1.1.dat new file mode 100644 index 00000000..20c7e221 Binary files /dev/null and b/episode-13/save/1/1/c.1.1.dat differ diff --git a/episode-13/save/1/1o/c.1.-4.dat b/episode-13/save/1/1o/c.1.-4.dat new file mode 100644 index 00000000..bf48008f Binary files /dev/null and b/episode-13/save/1/1o/c.1.-4.dat differ diff --git a/episode-13/save/1/1p/c.1.-3.dat b/episode-13/save/1/1p/c.1.-3.dat new file mode 100644 index 00000000..160702cf Binary files /dev/null and b/episode-13/save/1/1p/c.1.-3.dat differ diff --git a/episode-13/save/1/1q/c.1.-2.dat b/episode-13/save/1/1q/c.1.-2.dat new file mode 100644 index 00000000..31ad02ca Binary files /dev/null and b/episode-13/save/1/1q/c.1.-2.dat differ diff --git a/episode-13/save/1/1r/c.1.-1.dat b/episode-13/save/1/1r/c.1.-1.dat new file mode 100644 index 00000000..84fe36b0 Binary files /dev/null and b/episode-13/save/1/1r/c.1.-1.dat differ diff --git a/episode-13/save/1/2/c.1.2.dat b/episode-13/save/1/2/c.1.2.dat new file mode 100644 index 00000000..9132f761 Binary files /dev/null and b/episode-13/save/1/2/c.1.2.dat differ diff --git a/episode-13/save/1/3/c.1.3.dat b/episode-13/save/1/3/c.1.3.dat new file mode 100644 index 00000000..e15c80bc Binary files /dev/null and b/episode-13/save/1/3/c.1.3.dat differ diff --git a/episode-13/save/1o/0/c.-4.0.dat b/episode-13/save/1o/0/c.-4.0.dat new file mode 100644 index 00000000..af178e5b Binary files /dev/null and b/episode-13/save/1o/0/c.-4.0.dat differ diff --git a/episode-13/save/1o/1/c.-4.1.dat b/episode-13/save/1o/1/c.-4.1.dat new file mode 100644 index 00000000..cb228884 Binary files /dev/null and b/episode-13/save/1o/1/c.-4.1.dat differ diff --git a/episode-13/save/1o/1o/c.-4.-4.dat b/episode-13/save/1o/1o/c.-4.-4.dat new file mode 100644 index 00000000..63c9b6d1 Binary files /dev/null and b/episode-13/save/1o/1o/c.-4.-4.dat differ diff --git a/episode-13/save/1o/1p/c.-4.-3.dat b/episode-13/save/1o/1p/c.-4.-3.dat new file mode 100644 index 00000000..e83bd868 Binary files /dev/null and b/episode-13/save/1o/1p/c.-4.-3.dat differ diff --git a/episode-13/save/1o/1q/c.-4.-2.dat b/episode-13/save/1o/1q/c.-4.-2.dat new file mode 100644 index 00000000..2e6901dc Binary files /dev/null and b/episode-13/save/1o/1q/c.-4.-2.dat differ diff --git a/episode-13/save/1o/1r/c.-4.-1.dat b/episode-13/save/1o/1r/c.-4.-1.dat new file mode 100644 index 00000000..65ba04b9 Binary files /dev/null and b/episode-13/save/1o/1r/c.-4.-1.dat differ diff --git a/episode-13/save/1o/2/c.-4.2.dat b/episode-13/save/1o/2/c.-4.2.dat new file mode 100644 index 00000000..533d78f1 Binary files /dev/null and b/episode-13/save/1o/2/c.-4.2.dat differ diff --git a/episode-13/save/1o/3/c.-4.3.dat b/episode-13/save/1o/3/c.-4.3.dat new file mode 100644 index 00000000..bde272ba Binary files /dev/null and b/episode-13/save/1o/3/c.-4.3.dat differ diff --git a/episode-13/save/1p/0/c.-3.0.dat b/episode-13/save/1p/0/c.-3.0.dat new file mode 100644 index 00000000..549461da Binary files /dev/null and b/episode-13/save/1p/0/c.-3.0.dat differ diff --git a/episode-13/save/1p/1/c.-3.1.dat b/episode-13/save/1p/1/c.-3.1.dat new file mode 100644 index 00000000..074d25b7 Binary files /dev/null and b/episode-13/save/1p/1/c.-3.1.dat differ diff --git a/episode-13/save/1p/1o/c.-3.-4.dat b/episode-13/save/1p/1o/c.-3.-4.dat new file mode 100644 index 00000000..c9a6d415 Binary files /dev/null and b/episode-13/save/1p/1o/c.-3.-4.dat differ diff --git a/episode-13/save/1p/1p/c.-3.-3.dat b/episode-13/save/1p/1p/c.-3.-3.dat new file mode 100644 index 00000000..b57847d6 Binary files /dev/null and b/episode-13/save/1p/1p/c.-3.-3.dat differ diff --git a/episode-13/save/1p/1q/c.-3.-2.dat b/episode-13/save/1p/1q/c.-3.-2.dat new file mode 100644 index 00000000..c298dcb1 Binary files /dev/null and b/episode-13/save/1p/1q/c.-3.-2.dat differ diff --git a/episode-13/save/1p/1r/c.-3.-1.dat b/episode-13/save/1p/1r/c.-3.-1.dat new file mode 100644 index 00000000..6c49de48 Binary files /dev/null and b/episode-13/save/1p/1r/c.-3.-1.dat differ diff --git a/episode-13/save/1p/2/c.-3.2.dat b/episode-13/save/1p/2/c.-3.2.dat new file mode 100644 index 00000000..d27fe8c0 Binary files /dev/null and b/episode-13/save/1p/2/c.-3.2.dat differ diff --git a/episode-13/save/1p/3/c.-3.3.dat b/episode-13/save/1p/3/c.-3.3.dat new file mode 100644 index 00000000..bec68c2c Binary files /dev/null and b/episode-13/save/1p/3/c.-3.3.dat differ diff --git a/episode-13/save/1q/0/c.-2.0.dat b/episode-13/save/1q/0/c.-2.0.dat new file mode 100644 index 00000000..2a0f9d68 Binary files /dev/null and b/episode-13/save/1q/0/c.-2.0.dat differ diff --git a/episode-13/save/1q/1/c.-2.1.dat b/episode-13/save/1q/1/c.-2.1.dat new file mode 100644 index 00000000..1045f76a Binary files /dev/null and b/episode-13/save/1q/1/c.-2.1.dat differ diff --git a/episode-13/save/1q/1o/c.-2.-4.dat b/episode-13/save/1q/1o/c.-2.-4.dat new file mode 100644 index 00000000..ef51a50a Binary files /dev/null and b/episode-13/save/1q/1o/c.-2.-4.dat differ diff --git a/episode-13/save/1q/1p/c.-2.-3.dat b/episode-13/save/1q/1p/c.-2.-3.dat new file mode 100644 index 00000000..ec6aa86f Binary files /dev/null and b/episode-13/save/1q/1p/c.-2.-3.dat differ diff --git a/episode-13/save/1q/1q/c.-2.-2.dat b/episode-13/save/1q/1q/c.-2.-2.dat new file mode 100644 index 00000000..61d07f6d Binary files /dev/null and b/episode-13/save/1q/1q/c.-2.-2.dat differ diff --git a/episode-13/save/1q/1r/c.-2.-1.dat b/episode-13/save/1q/1r/c.-2.-1.dat new file mode 100644 index 00000000..f0587c54 Binary files /dev/null and b/episode-13/save/1q/1r/c.-2.-1.dat differ diff --git a/episode-13/save/1q/2/c.-2.2.dat b/episode-13/save/1q/2/c.-2.2.dat new file mode 100644 index 00000000..db26b75a Binary files /dev/null and b/episode-13/save/1q/2/c.-2.2.dat differ diff --git a/episode-13/save/1q/3/c.-2.3.dat b/episode-13/save/1q/3/c.-2.3.dat new file mode 100644 index 00000000..9a2d3fb1 Binary files /dev/null and b/episode-13/save/1q/3/c.-2.3.dat differ diff --git a/episode-13/save/1r/0/c.-1.0.dat b/episode-13/save/1r/0/c.-1.0.dat new file mode 100644 index 00000000..6e869d99 Binary files /dev/null and b/episode-13/save/1r/0/c.-1.0.dat differ diff --git a/episode-13/save/1r/1/c.-1.1.dat b/episode-13/save/1r/1/c.-1.1.dat new file mode 100644 index 00000000..9254e9ad Binary files /dev/null and b/episode-13/save/1r/1/c.-1.1.dat differ diff --git a/episode-13/save/1r/1o/c.-1.-4.dat b/episode-13/save/1r/1o/c.-1.-4.dat new file mode 100644 index 00000000..e113e918 Binary files /dev/null and b/episode-13/save/1r/1o/c.-1.-4.dat differ diff --git a/episode-13/save/1r/1p/c.-1.-3.dat b/episode-13/save/1r/1p/c.-1.-3.dat new file mode 100644 index 00000000..2ab9f0c0 Binary files /dev/null and b/episode-13/save/1r/1p/c.-1.-3.dat differ diff --git a/episode-13/save/1r/1q/c.-1.-2.dat b/episode-13/save/1r/1q/c.-1.-2.dat new file mode 100644 index 00000000..776431da Binary files /dev/null and b/episode-13/save/1r/1q/c.-1.-2.dat differ diff --git a/episode-13/save/1r/1r/c.-1.-1.dat b/episode-13/save/1r/1r/c.-1.-1.dat new file mode 100644 index 00000000..83d36a09 Binary files /dev/null and b/episode-13/save/1r/1r/c.-1.-1.dat differ diff --git a/episode-13/save/1r/2/c.-1.2.dat b/episode-13/save/1r/2/c.-1.2.dat new file mode 100644 index 00000000..7db9d2f1 Binary files /dev/null and b/episode-13/save/1r/2/c.-1.2.dat differ diff --git a/episode-13/save/1r/3/c.-1.3.dat b/episode-13/save/1r/3/c.-1.3.dat new file mode 100644 index 00000000..6ac5f8b2 Binary files /dev/null and b/episode-13/save/1r/3/c.-1.3.dat differ diff --git a/episode-13/save/2/0/c.2.0.dat b/episode-13/save/2/0/c.2.0.dat new file mode 100644 index 00000000..35ca0883 Binary files /dev/null and b/episode-13/save/2/0/c.2.0.dat differ diff --git a/episode-13/save/2/1/c.2.1.dat b/episode-13/save/2/1/c.2.1.dat new file mode 100644 index 00000000..38098181 Binary files /dev/null and b/episode-13/save/2/1/c.2.1.dat differ diff --git a/episode-13/save/2/1o/c.2.-4.dat b/episode-13/save/2/1o/c.2.-4.dat new file mode 100644 index 00000000..ec2b75f5 Binary files /dev/null and b/episode-13/save/2/1o/c.2.-4.dat differ diff --git a/episode-13/save/2/1p/c.2.-3.dat b/episode-13/save/2/1p/c.2.-3.dat new file mode 100644 index 00000000..be2bfc66 Binary files /dev/null and b/episode-13/save/2/1p/c.2.-3.dat differ diff --git a/episode-13/save/2/1q/c.2.-2.dat b/episode-13/save/2/1q/c.2.-2.dat new file mode 100644 index 00000000..3ac417f3 Binary files /dev/null and b/episode-13/save/2/1q/c.2.-2.dat differ diff --git a/episode-13/save/2/1r/c.2.-1.dat b/episode-13/save/2/1r/c.2.-1.dat new file mode 100644 index 00000000..77f7311c Binary files /dev/null and b/episode-13/save/2/1r/c.2.-1.dat differ diff --git a/episode-13/save/2/2/c.2.2.dat b/episode-13/save/2/2/c.2.2.dat new file mode 100644 index 00000000..8bc0fc85 Binary files /dev/null and b/episode-13/save/2/2/c.2.2.dat differ diff --git a/episode-13/save/2/3/c.2.3.dat b/episode-13/save/2/3/c.2.3.dat new file mode 100644 index 00000000..fd08a54f Binary files /dev/null and b/episode-13/save/2/3/c.2.3.dat differ diff --git a/episode-13/save/3/0/c.3.0.dat b/episode-13/save/3/0/c.3.0.dat new file mode 100644 index 00000000..5d50c087 Binary files /dev/null and b/episode-13/save/3/0/c.3.0.dat differ diff --git a/episode-13/save/3/1/c.3.1.dat b/episode-13/save/3/1/c.3.1.dat new file mode 100644 index 00000000..bc472fc3 Binary files /dev/null and b/episode-13/save/3/1/c.3.1.dat differ diff --git a/episode-13/save/3/1o/c.3.-4.dat b/episode-13/save/3/1o/c.3.-4.dat new file mode 100644 index 00000000..0b093de8 Binary files /dev/null and b/episode-13/save/3/1o/c.3.-4.dat differ diff --git a/episode-13/save/3/1p/c.3.-3.dat b/episode-13/save/3/1p/c.3.-3.dat new file mode 100644 index 00000000..75ccf0b1 Binary files /dev/null and b/episode-13/save/3/1p/c.3.-3.dat differ diff --git a/episode-13/save/3/1q/c.3.-2.dat b/episode-13/save/3/1q/c.3.-2.dat new file mode 100644 index 00000000..3d08b972 Binary files /dev/null and b/episode-13/save/3/1q/c.3.-2.dat differ diff --git a/episode-13/save/3/1r/c.3.-1.dat b/episode-13/save/3/1r/c.3.-1.dat new file mode 100644 index 00000000..6f69f1d8 Binary files /dev/null and b/episode-13/save/3/1r/c.3.-1.dat differ diff --git a/episode-13/save/3/2/c.3.2.dat b/episode-13/save/3/2/c.3.2.dat new file mode 100644 index 00000000..02f4acb6 Binary files /dev/null and b/episode-13/save/3/2/c.3.2.dat differ diff --git a/episode-13/save/3/3/c.3.3.dat b/episode-13/save/3/3/c.3.3.dat new file mode 100644 index 00000000..159e18cd Binary files /dev/null and b/episode-13/save/3/3/c.3.3.dat differ diff --git a/episode-13/shader.py b/episode-13/shader.py new file mode 100644 index 00000000..5414a0e2 --- /dev/null +++ b/episode-13/shader.py @@ -0,0 +1,71 @@ +import ctypes +import pyglet.gl as gl + +class Shader_error(Exception): + def __init__(self, message): + self.message = message + +def create_shader(target, source_path): + # read shader source + + source_file = open(source_path, "rb") + source = source_file.read() + source_file.close() + + source_length = ctypes.c_int(len(source) + 1) + source_buffer = ctypes.create_string_buffer(source) + + buffer_pointer = ctypes.cast( + ctypes.pointer(ctypes.pointer(source_buffer)), + ctypes.POINTER(ctypes.POINTER(ctypes.c_char))) + + # compile shader + + gl.glShaderSource(target, 1, buffer_pointer, ctypes.byref(source_length)) + gl.glCompileShader(target) + + # handle potential errors + + log_length = gl.GLint(0) + gl.glGetShaderiv(target, gl.GL_INFO_LOG_LENGTH, ctypes.byref(log_length)) + + log_buffer = ctypes.create_string_buffer(log_length.value) + gl.glGetShaderInfoLog(target, log_length, None, log_buffer) + + if log_length.value > 1: + raise Shader_error(str(log_buffer.value)) + +class Shader: + def __init__(self, vert_path, frag_path): + self.program = gl.glCreateProgram() + + # create vertex shader + + self.vert_shader = gl.glCreateShader(gl.GL_VERTEX_SHADER) + create_shader(self.vert_shader, vert_path) + gl.glAttachShader(self.program, self.vert_shader) + + # create fragment shader + + self.frag_shader = gl.glCreateShader(gl.GL_FRAGMENT_SHADER) + create_shader(self.frag_shader, frag_path) + gl.glAttachShader(self.program, self.frag_shader) + + # link program and clean up + + gl.glLinkProgram(self.program) + + gl.glDeleteShader(self.vert_shader) + gl.glDeleteShader(self.frag_shader) + + def __del__(self): + gl.glDeleteProgram(self.program) + + def find_uniform(self, name): + return gl.glGetUniformLocation(self.program, ctypes.create_string_buffer(name)) + + def uniform_matrix(self, location, matrix): + gl.glUniformMatrix4fv(location, 1, gl.GL_FALSE, (gl.GLfloat * 16) (*sum(matrix.data, []))) + + def use(self): + gl.glUseProgram(self.program) diff --git a/episode-13/shaders/block/frag.glsl b/episode-13/shaders/block/frag.glsl new file mode 100644 index 00000000..46c3d2a2 --- /dev/null +++ b/episode-13/shaders/block/frag.glsl @@ -0,0 +1,18 @@ +#version 330 + +out vec4 fragment_colour; + +uniform sampler2DArray texture_array_sampler; + +in vec3 local_position; +in vec3 interpolated_tex_coords; +in float interpolated_shading_value; + +void main(void) { + vec4 texture_colour = texture(texture_array_sampler, interpolated_tex_coords); + fragment_colour = texture_colour * interpolated_shading_value; + + if (texture_colour.a == 0.0) { // discard if texel's alpha component is 0 (texel is transparent) + discard; + } +} \ No newline at end of file diff --git a/episode-13/shaders/block/vert.glsl b/episode-13/shaders/block/vert.glsl new file mode 100644 index 00000000..5a945d25 --- /dev/null +++ b/episode-13/shaders/block/vert.glsl @@ -0,0 +1,18 @@ +#version 330 + +layout(location = 0) in vec3 vertex_position; +layout(location = 1) in vec3 tex_coords; +layout(location = 2) in float shading_value; + +out vec3 local_position; +out vec3 interpolated_tex_coords; +out float interpolated_shading_value; + +uniform mat4 matrix; + +void main(void) { + local_position = vertex_position; + interpolated_tex_coords = tex_coords; + interpolated_shading_value = shading_value; + gl_Position = matrix * vec4(vertex_position, 1.0); +} \ No newline at end of file diff --git a/episode-13/shaders/entity/frag.glsl b/episode-13/shaders/entity/frag.glsl new file mode 100644 index 00000000..f0160fb9 --- /dev/null +++ b/episode-13/shaders/entity/frag.glsl @@ -0,0 +1,18 @@ +#version 330 + +out vec4 fragment_colour; + +uniform sampler2D texture_sampler; + +in vec3 local_position; +in vec2 interpolated_tex_coords; +in float shading; + +void main(void) { + vec4 texture_colour = texture(texture_sampler, interpolated_tex_coords); + fragment_colour = texture_colour * shading; + + if (texture_colour.a == 0.0) { // discard if texel's alpha component is 0 (texel is transparent) + discard; + } +} diff --git a/episode-13/shaders/entity/vert.glsl b/episode-13/shaders/entity/vert.glsl new file mode 100644 index 00000000..424fa4ba --- /dev/null +++ b/episode-13/shaders/entity/vert.glsl @@ -0,0 +1,28 @@ +#version 330 + +layout(location = 0) in vec3 vertex_position; +layout(location = 1) in vec3 normal; +layout(location = 2) in vec2 tex_coords; + +out vec3 local_position; +out vec2 interpolated_tex_coords; +out float shading; + +uniform mat4 inverse_transform_matrix; +uniform mat4 matrix; + +void main(void) { + local_position = vertex_position; + + interpolated_tex_coords = tex_coords; + + vec3 transformed_normal = (vec4(normal, 1.0) * inverse_transform_matrix).xyz; + vec3 sunlight = vec3(0.0, 2.0, 1.0); + + vec3 xz_absolute_normal = vec3(abs(transformed_normal.x), transformed_normal.y, abs(transformed_normal.z)); + float facing = dot(normalize(xz_absolute_normal), normalize(sunlight)); + + shading = max(0.4, (1. + facing) / 2); + + gl_Position = matrix * vec4(vertex_position, 1.0); +} diff --git a/episode-13/subchunk.py b/episode-13/subchunk.py new file mode 100644 index 00000000..839a77dd --- /dev/null +++ b/episode-13/subchunk.py @@ -0,0 +1,99 @@ +SUBCHUNK_WIDTH = 4 +SUBCHUNK_HEIGHT = 4 +SUBCHUNK_LENGTH = 4 + +class Subchunk: + def __init__(self, parent, subchunk_position): + self.parent = parent + self.world = self.parent.world + + self.subchunk_position = subchunk_position + + self.local_position = ( + self.subchunk_position[0] * SUBCHUNK_WIDTH, + self.subchunk_position[1] * SUBCHUNK_HEIGHT, + self.subchunk_position[2] * SUBCHUNK_LENGTH) + + self.position = ( + self.parent.position[0] + self.local_position[0], + self.parent.position[1] + self.local_position[1], + self.parent.position[2] + self.local_position[2]) + + # mesh variables + + self.mesh_vertex_positions = [] + self.mesh_tex_coords = [] + self.mesh_shading_values = [] + + self.mesh_index_counter = 0 + self.mesh_indices = [] + + def update_mesh(self): + self.mesh_vertex_positions = [] + self.mesh_tex_coords = [] + self.mesh_shading_values = [] + + self.mesh_index_counter = 0 + self.mesh_indices = [] + + def add_face(face): + vertex_positions = block_type.vertex_positions[face].copy() + + for i in range(4): + vertex_positions[i * 3 + 0] += x + vertex_positions[i * 3 + 1] += y + vertex_positions[i * 3 + 2] += z + + self.mesh_vertex_positions.extend(vertex_positions) + + indices = [0, 1, 2, 0, 2, 3] + for i in range(6): + indices[i] += self.mesh_index_counter + + self.mesh_indices.extend(indices) + self.mesh_index_counter += 4 + + self.mesh_tex_coords.extend(block_type.tex_coords[face]) + self.mesh_shading_values.extend(block_type.shading_values[face]) + + for local_x in range(SUBCHUNK_WIDTH): + for local_y in range(SUBCHUNK_HEIGHT): + for local_z in range(SUBCHUNK_LENGTH): + parent_lx = self.local_position[0] + local_x + parent_ly = self.local_position[1] + local_y + parent_lz = self.local_position[2] + local_z + + block_number = self.parent.blocks[parent_lx][parent_ly][parent_lz] + + if block_number: + block_type = self.world.block_types[block_number] + + x, y, z = ( + self.position[0] + local_x, + self.position[1] + local_y, + self.position[2] + local_z) + + def can_render_face(position): + if not self.world.is_opaque_block(position): + if block_type.glass and self.world.get_block_number(position) == block_number: + return False + + return True + + return False + + # if block is cube, we want it to check neighbouring blocks so that we don't uselessly render faces + # if block isn't a cube, we just want to render all faces, regardless of neighbouring blocks + # since the vast majority of blocks are probably anyway going to be cubes, this won't impact performance all that much; the amount of useless faces drawn is going to be minimal + + if block_type.is_cube: + if can_render_face((x + 1, y, z)): add_face(0) + if can_render_face((x - 1, y, z)): add_face(1) + if can_render_face((x, y + 1, z)): add_face(2) + if can_render_face((x, y - 1, z)): add_face(3) + if can_render_face((x, y, z + 1)): add_face(4) + if can_render_face((x, y, z - 1)): add_face(5) + + else: + for i in range(len(block_type.vertex_positions)): + add_face(i) \ No newline at end of file diff --git a/episode-13/texture_manager.py b/episode-13/texture_manager.py new file mode 100644 index 00000000..191a11bd --- /dev/null +++ b/episode-13/texture_manager.py @@ -0,0 +1,44 @@ +import ctypes +import pyglet + +import pyglet.gl as gl + +class Texture_manager: + def __init__(self, texture_width, texture_height, max_textures): + self.texture_width = texture_width + self.texture_height = texture_height + + self.max_textures = max_textures + + self.textures = [] + + self.texture_array = gl.GLuint(0) + gl.glGenTextures(1, self.texture_array) + gl.glBindTexture(gl.GL_TEXTURE_2D_ARRAY, self.texture_array) + + gl.glTexParameteri(gl.GL_TEXTURE_2D_ARRAY, gl.GL_TEXTURE_MIN_FILTER, gl.GL_NEAREST) + gl.glTexParameteri(gl.GL_TEXTURE_2D_ARRAY, gl.GL_TEXTURE_MAG_FILTER, gl.GL_NEAREST) + + gl.glTexImage3D( + gl.GL_TEXTURE_2D_ARRAY, 0, gl.GL_RGBA, + self.texture_width, self.texture_height, self.max_textures, + 0, gl.GL_RGBA, gl.GL_UNSIGNED_BYTE, None) + + def generate_mipmaps(self): + gl.glBindTexture(gl.GL_TEXTURE_2D_ARRAY, self.texture_array) + gl.glGenerateMipmap(gl.GL_TEXTURE_2D_ARRAY) + + def add_texture(self, texture): + gl.glBindTexture(gl.GL_TEXTURE_2D_ARRAY, self.texture_array) + + if not texture in self.textures: + self.textures.append(texture) + + texture_image = pyglet.image.load(f"textures/{texture}.png").get_image_data() + + gl.glTexSubImage3D( + gl.GL_TEXTURE_2D_ARRAY, 0, + 0, 0, self.textures.index(texture), + self.texture_width, self.texture_height, 1, + gl.GL_RGBA, gl.GL_UNSIGNED_BYTE, + texture_image.get_data("RGBA", texture_image.width * 4)) \ No newline at end of file diff --git a/episode-13/textures/aqua_cloth.png b/episode-13/textures/aqua_cloth.png new file mode 100644 index 00000000..d24b7d5b Binary files /dev/null and b/episode-13/textures/aqua_cloth.png differ diff --git a/episode-13/textures/bedrock.png b/episode-13/textures/bedrock.png new file mode 100644 index 00000000..8922e20f Binary files /dev/null and b/episode-13/textures/bedrock.png differ diff --git a/episode-13/textures/black_cloth.png b/episode-13/textures/black_cloth.png new file mode 100644 index 00000000..b9a0c8fd Binary files /dev/null and b/episode-13/textures/black_cloth.png differ diff --git a/episode-13/textures/blue_cloth.png b/episode-13/textures/blue_cloth.png new file mode 100644 index 00000000..8a58871f Binary files /dev/null and b/episode-13/textures/blue_cloth.png differ diff --git a/episode-13/textures/bookshelf.png b/episode-13/textures/bookshelf.png new file mode 100644 index 00000000..1fd85b5e Binary files /dev/null and b/episode-13/textures/bookshelf.png differ diff --git a/episode-13/textures/bricks.png b/episode-13/textures/bricks.png new file mode 100644 index 00000000..30f8548a Binary files /dev/null and b/episode-13/textures/bricks.png differ diff --git a/episode-13/textures/brown_mushroom.png b/episode-13/textures/brown_mushroom.png new file mode 100644 index 00000000..fc2245cc Binary files /dev/null and b/episode-13/textures/brown_mushroom.png differ diff --git a/episode-13/textures/cactus_bottom.png b/episode-13/textures/cactus_bottom.png new file mode 100644 index 00000000..ca2984b4 Binary files /dev/null and b/episode-13/textures/cactus_bottom.png differ diff --git a/episode-13/textures/cactus_side.png b/episode-13/textures/cactus_side.png new file mode 100644 index 00000000..b59d492f Binary files /dev/null and b/episode-13/textures/cactus_side.png differ diff --git a/episode-13/textures/cactus_top.png b/episode-13/textures/cactus_top.png new file mode 100644 index 00000000..f03df7f0 Binary files /dev/null and b/episode-13/textures/cactus_top.png differ diff --git a/episode-13/textures/chest_front.png b/episode-13/textures/chest_front.png new file mode 100644 index 00000000..5bb4289d Binary files /dev/null and b/episode-13/textures/chest_front.png differ diff --git a/episode-13/textures/chest_side.png b/episode-13/textures/chest_side.png new file mode 100644 index 00000000..d4dd91c6 Binary files /dev/null and b/episode-13/textures/chest_side.png differ diff --git a/episode-13/textures/chest_top.png b/episode-13/textures/chest_top.png new file mode 100644 index 00000000..b05685cc Binary files /dev/null and b/episode-13/textures/chest_top.png differ diff --git a/episode-13/textures/clay.png b/episode-13/textures/clay.png new file mode 100644 index 00000000..3670a867 Binary files /dev/null and b/episode-13/textures/clay.png differ diff --git a/episode-13/textures/coal_ore.png b/episode-13/textures/coal_ore.png new file mode 100644 index 00000000..c60f980d Binary files /dev/null and b/episode-13/textures/coal_ore.png differ diff --git a/episode-13/textures/cobblestone.png b/episode-13/textures/cobblestone.png new file mode 100644 index 00000000..b43d14dd Binary files /dev/null and b/episode-13/textures/cobblestone.png differ diff --git a/episode-13/textures/cow.png b/episode-13/textures/cow.png new file mode 100644 index 00000000..f5ebec71 Binary files /dev/null and b/episode-13/textures/cow.png differ diff --git a/episode-13/textures/crafting_table_top.png b/episode-13/textures/crafting_table_top.png new file mode 100644 index 00000000..cc3000ad Binary files /dev/null and b/episode-13/textures/crafting_table_top.png differ diff --git a/episode-13/textures/crafting_table_x.png b/episode-13/textures/crafting_table_x.png new file mode 100644 index 00000000..49c8803c Binary files /dev/null and b/episode-13/textures/crafting_table_x.png differ diff --git a/episode-13/textures/crafting_table_z.png b/episode-13/textures/crafting_table_z.png new file mode 100644 index 00000000..31de683d Binary files /dev/null and b/episode-13/textures/crafting_table_z.png differ diff --git a/episode-13/textures/creeper.png b/episode-13/textures/creeper.png new file mode 100644 index 00000000..25015dff Binary files /dev/null and b/episode-13/textures/creeper.png differ diff --git a/episode-13/textures/crops.png b/episode-13/textures/crops.png new file mode 100644 index 00000000..9a530f08 Binary files /dev/null and b/episode-13/textures/crops.png differ diff --git a/episode-13/textures/curry.png b/episode-13/textures/curry.png new file mode 100644 index 00000000..3991d0fd Binary files /dev/null and b/episode-13/textures/curry.png differ diff --git a/episode-13/textures/cyan_cloth.png b/episode-13/textures/cyan_cloth.png new file mode 100644 index 00000000..79ecc348 Binary files /dev/null and b/episode-13/textures/cyan_cloth.png differ diff --git a/episode-13/textures/dead_bush.png b/episode-13/textures/dead_bush.png new file mode 100644 index 00000000..ca793d4b Binary files /dev/null and b/episode-13/textures/dead_bush.png differ diff --git a/episode-13/textures/diamond_block.png b/episode-13/textures/diamond_block.png new file mode 100644 index 00000000..c6d07a6f Binary files /dev/null and b/episode-13/textures/diamond_block.png differ diff --git a/episode-13/textures/diamond_ore.png b/episode-13/textures/diamond_ore.png new file mode 100644 index 00000000..18877726 Binary files /dev/null and b/episode-13/textures/diamond_ore.png differ diff --git a/episode-13/textures/dirt.png b/episode-13/textures/dirt.png new file mode 100644 index 00000000..58d3fac4 Binary files /dev/null and b/episode-13/textures/dirt.png differ diff --git a/episode-13/textures/fire.png b/episode-13/textures/fire.png new file mode 100644 index 00000000..ae4a5b91 Binary files /dev/null and b/episode-13/textures/fire.png differ diff --git a/episode-13/textures/furnace_front.png b/episode-13/textures/furnace_front.png new file mode 100644 index 00000000..8059c5af Binary files /dev/null and b/episode-13/textures/furnace_front.png differ diff --git a/episode-13/textures/furnace_side.png b/episode-13/textures/furnace_side.png new file mode 100644 index 00000000..18aaba26 Binary files /dev/null and b/episode-13/textures/furnace_side.png differ diff --git a/episode-13/textures/furnace_y.png b/episode-13/textures/furnace_y.png new file mode 100644 index 00000000..d4a429f1 Binary files /dev/null and b/episode-13/textures/furnace_y.png differ diff --git a/episode-13/textures/glass.png b/episode-13/textures/glass.png new file mode 100644 index 00000000..64cb447f Binary files /dev/null and b/episode-13/textures/glass.png differ diff --git a/episode-13/textures/gold_block.png b/episode-13/textures/gold_block.png new file mode 100644 index 00000000..c6c25774 Binary files /dev/null and b/episode-13/textures/gold_block.png differ diff --git a/episode-13/textures/gold_ore.png b/episode-13/textures/gold_ore.png new file mode 100644 index 00000000..d5221fe3 Binary files /dev/null and b/episode-13/textures/gold_ore.png differ diff --git a/episode-13/textures/grass.png b/episode-13/textures/grass.png new file mode 100644 index 00000000..89ffa14d Binary files /dev/null and b/episode-13/textures/grass.png differ diff --git a/episode-13/textures/grass_side.png b/episode-13/textures/grass_side.png new file mode 100644 index 00000000..a2e27891 Binary files /dev/null and b/episode-13/textures/grass_side.png differ diff --git a/episode-13/textures/gravel.png b/episode-13/textures/gravel.png new file mode 100644 index 00000000..5e56f715 Binary files /dev/null and b/episode-13/textures/gravel.png differ diff --git a/episode-13/textures/green_cloth.png b/episode-13/textures/green_cloth.png new file mode 100644 index 00000000..7455d725 Binary files /dev/null and b/episode-13/textures/green_cloth.png differ diff --git a/episode-13/textures/grey_cloth.png b/episode-13/textures/grey_cloth.png new file mode 100644 index 00000000..4dc15772 Binary files /dev/null and b/episode-13/textures/grey_cloth.png differ diff --git a/episode-13/textures/ice.png b/episode-13/textures/ice.png new file mode 100644 index 00000000..d17fe06e Binary files /dev/null and b/episode-13/textures/ice.png differ diff --git a/episode-13/textures/indigo_cloth.png b/episode-13/textures/indigo_cloth.png new file mode 100644 index 00000000..59c1ae01 Binary files /dev/null and b/episode-13/textures/indigo_cloth.png differ diff --git a/episode-13/textures/iron_block.png b/episode-13/textures/iron_block.png new file mode 100644 index 00000000..f782394f Binary files /dev/null and b/episode-13/textures/iron_block.png differ diff --git a/episode-13/textures/iron_door.png b/episode-13/textures/iron_door.png new file mode 100644 index 00000000..e00dc8df Binary files /dev/null and b/episode-13/textures/iron_door.png differ diff --git a/episode-13/textures/iron_door_bottom_half.png b/episode-13/textures/iron_door_bottom_half.png new file mode 100644 index 00000000..283d8965 Binary files /dev/null and b/episode-13/textures/iron_door_bottom_half.png differ diff --git a/episode-13/textures/iron_ore.png b/episode-13/textures/iron_ore.png new file mode 100644 index 00000000..001beee9 Binary files /dev/null and b/episode-13/textures/iron_ore.png differ diff --git a/episode-13/textures/jukebox.png b/episode-13/textures/jukebox.png new file mode 100644 index 00000000..4f9dfca9 Binary files /dev/null and b/episode-13/textures/jukebox.png differ diff --git a/episode-13/textures/jukebox_top.png b/episode-13/textures/jukebox_top.png new file mode 100644 index 00000000..ceb81f2c Binary files /dev/null and b/episode-13/textures/jukebox_top.png differ diff --git a/episode-13/textures/ladder.png b/episode-13/textures/ladder.png new file mode 100644 index 00000000..3f0a7877 Binary files /dev/null and b/episode-13/textures/ladder.png differ diff --git a/episode-13/textures/lava.png b/episode-13/textures/lava.png new file mode 100644 index 00000000..52f13999 Binary files /dev/null and b/episode-13/textures/lava.png differ diff --git a/episode-13/textures/leaves.png b/episode-13/textures/leaves.png new file mode 100644 index 00000000..858664e1 Binary files /dev/null and b/episode-13/textures/leaves.png differ diff --git a/episode-13/textures/lever.png b/episode-13/textures/lever.png new file mode 100644 index 00000000..b43d14dd Binary files /dev/null and b/episode-13/textures/lever.png differ diff --git a/episode-13/textures/lime_cloth.png b/episode-13/textures/lime_cloth.png new file mode 100644 index 00000000..99bf0b18 Binary files /dev/null and b/episode-13/textures/lime_cloth.png differ diff --git a/episode-13/textures/lit_furnace_front.png b/episode-13/textures/lit_furnace_front.png new file mode 100644 index 00000000..83abc9f7 Binary files /dev/null and b/episode-13/textures/lit_furnace_front.png differ diff --git a/episode-13/textures/log_side.png b/episode-13/textures/log_side.png new file mode 100644 index 00000000..e33b02fe Binary files /dev/null and b/episode-13/textures/log_side.png differ diff --git a/episode-13/textures/log_y.png b/episode-13/textures/log_y.png new file mode 100644 index 00000000..186b8582 Binary files /dev/null and b/episode-13/textures/log_y.png differ diff --git a/episode-13/textures/magenta_cloth.png b/episode-13/textures/magenta_cloth.png new file mode 100644 index 00000000..ac80e9e2 Binary files /dev/null and b/episode-13/textures/magenta_cloth.png differ diff --git a/episode-13/textures/mob_spawner.png b/episode-13/textures/mob_spawner.png new file mode 100644 index 00000000..3ba90802 Binary files /dev/null and b/episode-13/textures/mob_spawner.png differ diff --git a/episode-13/textures/mossy_cobblestone.png b/episode-13/textures/mossy_cobblestone.png new file mode 100644 index 00000000..d76bac86 Binary files /dev/null and b/episode-13/textures/mossy_cobblestone.png differ diff --git a/episode-13/textures/obsidian.png b/episode-13/textures/obsidian.png new file mode 100644 index 00000000..b4869a91 Binary files /dev/null and b/episode-13/textures/obsidian.png differ diff --git a/episode-13/textures/off_redstone_torch.png b/episode-13/textures/off_redstone_torch.png new file mode 100644 index 00000000..e0909434 Binary files /dev/null and b/episode-13/textures/off_redstone_torch.png differ diff --git a/episode-13/textures/off_redstone_torch_top.png b/episode-13/textures/off_redstone_torch_top.png new file mode 100644 index 00000000..c2d50249 Binary files /dev/null and b/episode-13/textures/off_redstone_torch_top.png differ diff --git a/episode-13/textures/orange_cloth.png b/episode-13/textures/orange_cloth.png new file mode 100644 index 00000000..c05421c6 Binary files /dev/null and b/episode-13/textures/orange_cloth.png differ diff --git a/episode-13/textures/pig.png b/episode-13/textures/pig.png new file mode 100644 index 00000000..e3e7fdcb Binary files /dev/null and b/episode-13/textures/pig.png differ diff --git a/episode-13/textures/pink_cloth.png b/episode-13/textures/pink_cloth.png new file mode 100644 index 00000000..d83b6162 Binary files /dev/null and b/episode-13/textures/pink_cloth.png differ diff --git a/episode-13/textures/planks.png b/episode-13/textures/planks.png new file mode 100644 index 00000000..346f77dc Binary files /dev/null and b/episode-13/textures/planks.png differ diff --git a/episode-13/textures/purple_cloth.png b/episode-13/textures/purple_cloth.png new file mode 100644 index 00000000..8b245d92 Binary files /dev/null and b/episode-13/textures/purple_cloth.png differ diff --git a/episode-13/textures/rails.png b/episode-13/textures/rails.png new file mode 100644 index 00000000..802d13ce Binary files /dev/null and b/episode-13/textures/rails.png differ diff --git a/episode-13/textures/red_cloth.png b/episode-13/textures/red_cloth.png new file mode 100644 index 00000000..7990f69f Binary files /dev/null and b/episode-13/textures/red_cloth.png differ diff --git a/episode-13/textures/red_mushroom.png b/episode-13/textures/red_mushroom.png new file mode 100644 index 00000000..1ea2f78d Binary files /dev/null and b/episode-13/textures/red_mushroom.png differ diff --git a/episode-13/textures/red_rose.png b/episode-13/textures/red_rose.png new file mode 100644 index 00000000..4a202b59 Binary files /dev/null and b/episode-13/textures/red_rose.png differ diff --git a/episode-13/textures/redstone_ore.png b/episode-13/textures/redstone_ore.png new file mode 100644 index 00000000..ef0bcfe4 Binary files /dev/null and b/episode-13/textures/redstone_ore.png differ diff --git a/episode-13/textures/redstone_torch.png b/episode-13/textures/redstone_torch.png new file mode 100644 index 00000000..b9aec5eb Binary files /dev/null and b/episode-13/textures/redstone_torch.png differ diff --git a/episode-13/textures/redstone_torch_top.png b/episode-13/textures/redstone_torch_top.png new file mode 100644 index 00000000..ecd10c45 Binary files /dev/null and b/episode-13/textures/redstone_torch_top.png differ diff --git a/episode-13/textures/redstone_wire.png b/episode-13/textures/redstone_wire.png new file mode 100644 index 00000000..c4427878 Binary files /dev/null and b/episode-13/textures/redstone_wire.png differ diff --git a/episode-13/textures/sand.png b/episode-13/textures/sand.png new file mode 100644 index 00000000..257020ed Binary files /dev/null and b/episode-13/textures/sand.png differ diff --git a/episode-13/textures/sapling.png b/episode-13/textures/sapling.png new file mode 100644 index 00000000..df8784b3 Binary files /dev/null and b/episode-13/textures/sapling.png differ diff --git a/episode-13/textures/skeleton.png b/episode-13/textures/skeleton.png new file mode 100644 index 00000000..7e3f0957 Binary files /dev/null and b/episode-13/textures/skeleton.png differ diff --git a/episode-13/textures/slab_side.png b/episode-13/textures/slab_side.png new file mode 100644 index 00000000..0c9bc23a Binary files /dev/null and b/episode-13/textures/slab_side.png differ diff --git a/episode-13/textures/slab_y.png b/episode-13/textures/slab_y.png new file mode 100644 index 00000000..4ccf6c61 Binary files /dev/null and b/episode-13/textures/slab_y.png differ diff --git a/episode-13/textures/snow.png b/episode-13/textures/snow.png new file mode 100644 index 00000000..be324c1d Binary files /dev/null and b/episode-13/textures/snow.png differ diff --git a/episode-13/textures/snowy_grass_side.png b/episode-13/textures/snowy_grass_side.png new file mode 100644 index 00000000..da174175 Binary files /dev/null and b/episode-13/textures/snowy_grass_side.png differ diff --git a/episode-13/textures/soil.png b/episode-13/textures/soil.png new file mode 100644 index 00000000..8cde713b Binary files /dev/null and b/episode-13/textures/soil.png differ diff --git a/episode-13/textures/sponge.png b/episode-13/textures/sponge.png new file mode 100644 index 00000000..dcb11e79 Binary files /dev/null and b/episode-13/textures/sponge.png differ diff --git a/episode-13/textures/stone.png b/episode-13/textures/stone.png new file mode 100644 index 00000000..49b7f024 Binary files /dev/null and b/episode-13/textures/stone.png differ diff --git a/episode-13/textures/sugar_cane.png b/episode-13/textures/sugar_cane.png new file mode 100644 index 00000000..10e918d0 Binary files /dev/null and b/episode-13/textures/sugar_cane.png differ diff --git a/episode-13/textures/tnt_bottom.png b/episode-13/textures/tnt_bottom.png new file mode 100644 index 00000000..55c2f8fd Binary files /dev/null and b/episode-13/textures/tnt_bottom.png differ diff --git a/episode-13/textures/tnt_side.png b/episode-13/textures/tnt_side.png new file mode 100644 index 00000000..7aaa0d75 Binary files /dev/null and b/episode-13/textures/tnt_side.png differ diff --git a/episode-13/textures/tnt_top.png b/episode-13/textures/tnt_top.png new file mode 100644 index 00000000..9985223d Binary files /dev/null and b/episode-13/textures/tnt_top.png differ diff --git a/episode-13/textures/torch.png b/episode-13/textures/torch.png new file mode 100644 index 00000000..e7d24f31 Binary files /dev/null and b/episode-13/textures/torch.png differ diff --git a/episode-13/textures/torch_top.png b/episode-13/textures/torch_top.png new file mode 100644 index 00000000..8d66d02f Binary files /dev/null and b/episode-13/textures/torch_top.png differ diff --git a/episode-13/textures/unknown.png b/episode-13/textures/unknown.png new file mode 100644 index 00000000..1ba274d9 Binary files /dev/null and b/episode-13/textures/unknown.png differ diff --git a/episode-13/textures/violet_cloth.png b/episode-13/textures/violet_cloth.png new file mode 100644 index 00000000..30374ae3 Binary files /dev/null and b/episode-13/textures/violet_cloth.png differ diff --git a/episode-13/textures/water.png b/episode-13/textures/water.png new file mode 100644 index 00000000..a081420c Binary files /dev/null and b/episode-13/textures/water.png differ diff --git a/episode-13/textures/white_cloth.png b/episode-13/textures/white_cloth.png new file mode 100644 index 00000000..6d24926e Binary files /dev/null and b/episode-13/textures/white_cloth.png differ diff --git a/episode-13/textures/wooden_door.png b/episode-13/textures/wooden_door.png new file mode 100644 index 00000000..9d21e890 Binary files /dev/null and b/episode-13/textures/wooden_door.png differ diff --git a/episode-13/textures/yellow_cloth.png b/episode-13/textures/yellow_cloth.png new file mode 100644 index 00000000..f939f410 Binary files /dev/null and b/episode-13/textures/yellow_cloth.png differ diff --git a/episode-13/textures/yellow_flower.png b/episode-13/textures/yellow_flower.png new file mode 100644 index 00000000..6f35174d Binary files /dev/null and b/episode-13/textures/yellow_flower.png differ diff --git a/episode-13/textures/zombie.png b/episode-13/textures/zombie.png new file mode 100644 index 00000000..81ec3d12 Binary files /dev/null and b/episode-13/textures/zombie.png differ diff --git a/episode-13/vscode_mcpy_extension/language-configuration.json b/episode-13/vscode_mcpy_extension/language-configuration.json new file mode 100644 index 00000000..6bd45cbc --- /dev/null +++ b/episode-13/vscode_mcpy_extension/language-configuration.json @@ -0,0 +1,33 @@ +{ + "comments": { + "lineComment": "#" + }, + "brackets": [ + [ + "[", + "]" + ], + ], + "autoClosingPairs": [ + { + "open": "\"", + "close": "\"", + "notIn": ["string"] + }, + { + "open": "[", + "close": "]", + "notIn": ["comment"] + }, + ], + "surroundingPairs": [ + [ + "\"", + "\"" + ], + [ + "[", + "]" + ], + ] +} \ No newline at end of file diff --git a/episode-13/vscode_mcpy_extension/package.json b/episode-13/vscode_mcpy_extension/package.json new file mode 100644 index 00000000..6d90c2ab --- /dev/null +++ b/episode-13/vscode_mcpy_extension/package.json @@ -0,0 +1,53 @@ +{ + "name": "mcpy", + "displayName": "MCPY", + "description": "Syntax highlighting for MCPY data files", + "categories": [ + "Programming Languages" + ], + "publisher": "obiwac", + "author": { + "name": "obiwac" + }, + "homepage": "https://github.com/obiwac/python-minecraft-clone", + "version": "0.0.2", + "engines": { + "vscode": "^1.22.0" + }, + "contributes": { + "languages": [ + { + "id": "mcpy_blocks", + "aliases": [ + "MCPY Blocks" + ], + "filenames": [ + "blocks.mcpy" + ], + "configuration": "./language-configuration.json" + }, + { + "id": "mcpy_entities", + "aliases": [ + "MCPY Entities" + ], + "filenames": [ + "entities.mcpy" + ], + "configuration": "./language-configuration.json" + } + ], + "grammars": [ + { + "language": "mcpy_blocks", + "scopeName": "source.mcpy_blocks", + "path": "./syntaxes/mcpy_blocks.tmLanguage.json" + }, + { + "language": "mcpy_entities", + "scopeName": "source.mcpy_entities", + "path": "./syntaxes/mcpy_entities.tmLanguage.json" + } + ] + } +} \ No newline at end of file diff --git a/episode-13/vscode_mcpy_extension/syntaxes/mcpy_blocks.tmLanguage.json b/episode-13/vscode_mcpy_extension/syntaxes/mcpy_blocks.tmLanguage.json new file mode 100644 index 00000000..64518887 --- /dev/null +++ b/episode-13/vscode_mcpy_extension/syntaxes/mcpy_blocks.tmLanguage.json @@ -0,0 +1,44 @@ +{ + "name": "mcpy_blocks", + "scopeName": "source.mcpy_blocks", + "patterns": [ + { + "name": "keyword.control.mcpy_blocks", + "match": "\\b(name|texture|model)\\b" + }, + { + "name": "keyword.operator.mcpy_blocks", + "match": "\\b(sameas)\\b" + }, + { + "name": "entity.name.tag.mcpy_blocks", + "match": "\\b^[0-9]+(:)|(:)\\b" + }, + { + "name": "variable.class.mcpy_blocks", + "match": "\\bmodels\\b" + }, + { + "name": "entity.name.function.mcpy_blocks", + "match": "\\b(all|sides|x|y|z|top|bottom|front|back|left|right)\\b" + }, + { + "name": "constant.numeric.mcpy_blocks", + "match": "\\b[0-9]+\\b" + }, + { + "name": "comment.line.mcpy_blocks", + "begin": "#", + "end": "$" + }, + { + "name": "string.quoted.double.mcpy_blocks", + "begin": "\"", + "end": "\"", + "patterns": [{ + "name": "constant.character.escape.mcpy_blocks", + "match": "\\\\." + }] + } + ] +} \ No newline at end of file diff --git a/episode-13/vscode_mcpy_extension/syntaxes/mcpy_entities.tmLanguage.json b/episode-13/vscode_mcpy_extension/syntaxes/mcpy_entities.tmLanguage.json new file mode 100644 index 00000000..fa07dbc4 --- /dev/null +++ b/episode-13/vscode_mcpy_extension/syntaxes/mcpy_entities.tmLanguage.json @@ -0,0 +1,36 @@ +{ + "name": "mcpy_entities", + "scopeName": "source.mcpy_entities", + "patterns": [ + { + "name": "keyword.operator.mcpy_entities", + "match": "\\b(name|width|height|model|texture)\\b" + }, + { + "name": "entity.name.tag.mcpy_entities", + "match": "\\b^.+(:)|(:)\\b" + }, + { + "name": "variable.class.mcpy_entities", + "match": "\\bmodels\\b" + }, + { + "name": "constant.numeric.mcpy_entities", + "match": "\\b[0-9]+\\.*[0-9]*\\b" + }, + { + "name": "comment.line.mcpy_entities", + "begin": "#", + "end": "$" + }, + { + "name": "string.quoted.double.mcpy_entities", + "begin": "\"", + "end": "\"", + "patterns": [{ + "name": "constant.character.escape.mcpy_entities", + "match": "\\\\." + }] + } + ] +} \ No newline at end of file diff --git a/episode-13/work/convert.py b/episode-13/work/convert.py new file mode 100644 index 00000000..648297ac --- /dev/null +++ b/episode-13/work/convert.py @@ -0,0 +1,185 @@ +import sys +import json +import math +import glm # from pyglm + +name = sys.argv[1] + +with open(f"work/models/{name}.json") as f: + data, = json.load(f).values() + +x_res = data["texturewidth"] +y_res = data["textureheight"] + +raw_bones = data["bones"] + +PIXEL_SIZE = 1 / 16 + +def map_vertices(*vertices): + return [*map(lambda x: x * PIXEL_SIZE, vertices)] + +def map_tex_coords(*tex_coords): + *u, = map(lambda u: u / x_res, tex_coords[0::2]) + *v, = map(lambda v: 1 - v / y_res, tex_coords[1::2]) + + return sum(map(list, zip(u, v)), []) + +bones = [] + +class Bone: + def __init__(self, name, bone = None): + self.name = name + self.pivot = [0, 0, 0] + + self.vertices = [] + self.tex_coords = [] + self.shading_values = [] + + # automatically process raw bone data + + if bone is None: + return + + self.pivot = [x * PIXEL_SIZE for x in bone["pivot"]] + cubes = bone["cubes"] + + for cube in cubes: + self.add_cube(cube) + + def __repr__(self): + return f"{{'name':'{self.name}','pivot':{self.pivot},'vertices':{self.vertices},'tex_coords':{self.tex_coords},'shading_values':{self.shading_values}}}" + + def add_cube(self, cube): + x, y, z = cube["origin"] + pivot = cube.get("pivot", (0, 0, 0)) + rotation = cube.get("rotation", (0, 0, 0)) + sx, sy, sz = cube["size"] + u, v = cube["uv"] # note that UV's start from the top-left (because... well... just because... idk) + + # snap rotation, because our dataset is a bit weird + + *rotation, = map(lambda x: round(x / 90) * 90, rotation) + + # construct transformation matrix based on pivot & rotation + + matrix = glm.translate(glm.mat4(), glm.vec3(pivot)) + matrix = glm.rotate(matrix, -math.radians(rotation[0]), glm.vec3(1, 0, 0)) + matrix = glm.rotate(matrix, -math.radians(rotation[1]), glm.vec3(0, 1, 0)) + matrix = glm.rotate(matrix, -math.radians(rotation[2]), glm.vec3(0, 0, 1)) + matrix = glm.translate(matrix, glm.vec3([-x for x in pivot])) + + def transform(*vector): + return (*(matrix * glm.vec3(vector)),) + + # front/back faces + + self.vertices.append(map_vertices( + *transform(x, y, z), + *transform(x, y + sy, z), + *transform(x + sx, y + sy, z), + *transform(x + sx, y, z), + )) + + self.tex_coords.append(map_tex_coords( + u + sz, v + sz + sy, + u + sz, v + sz, + u + sz + sx, v + sz, + u + sz + sx, v + sz + sy, + )) + + self.vertices.append(map_vertices( + *transform(x + sx, y, z + sz), + *transform(x + sx, y + sy, z + sz), + *transform(x, y + sy, z + sz), + *transform(x, y, z + sz), + )) + + self.tex_coords.append(map_tex_coords( + u + sz + sx + sz, v + sz + sy, + u + sz + sx + sz, v + sz, + u + sz + sx + sz + sx, v + sz, + u + sz + sx + sz + sx, v + sz + sy, + )) + + # top/bottom faces + + self.vertices.append(map_vertices( + *transform(x, y + sy, z ), + *transform(x, y + sy, z + sz), + *transform(x + sx, y + sy, z + sz), + *transform(x + sx, y + sy, z ), + )) + + self.tex_coords.append(map_tex_coords( + u + sz, v + sz, + u + sz, v, + u + sz + sx, v, + u + sz + sx, v + sz, + )) + + self.vertices.append(map_vertices( + *transform(x + sx, y, z ), + *transform(x + sx, y, z + sz), + *transform(x, y, z + sz), + *transform(x, y, z ), + )) + + self.tex_coords.append(map_tex_coords( + u + sz + sx, v + sz, + u + sz + sx, v, + u + sz + sx + sx, v, + u + sz + sx + sx, v + sz, + )) + + # left/right faces + + self.vertices.append(map_vertices( + *transform(x + sx, y, z ), + *transform(x + sx, y + sy, z ), + *transform(x + sx, y + sy, z + sz), + *transform(x + sx, y, z + sz), + )) + + self.tex_coords.append(map_tex_coords( + u + sz + sx, v + sz + sy, + u + sz + sx, v + sz, + u + sz + sx + sz, v + sz, + u + sz + sx + sz, v + sz + sy, + )) + + self.vertices.append(map_vertices( + *transform(x, y, z + sz), + *transform(x, y + sy, z + sz), + *transform(x, y + sy, z ), + *transform(x, y, z ), + )) + + self.tex_coords.append(map_tex_coords( + u, v + sz + sy, + u, v + sz, + u + sz, v + sz, + u + sz, v + sz + sy, + )) + + for _ in range(6): + self.shading_values.append([1.0, 1.0, 1.0, 1.0]) + +# process the model + +for bone in raw_bones: + bones.append(Bone(bone["name"], bone)) + +# output model + +out = f""" +transparent = True +is_cube = False +glass = False + +colliders = [] + +bones = {bones} +""" + +with open(f"models/{name}.py", "w") as f: + f.write(out) diff --git a/episode-13/work/models/cow.json b/episode-13/work/models/cow.json new file mode 100644 index 00000000..6430f9b3 --- /dev/null +++ b/episode-13/work/models/cow.json @@ -0,0 +1,334 @@ +{ + "geometry.cow": { + "textureheight": 28, + "texturewidth": 154, + "bones": [ + { + "name": "body", + "pivot": [ + 0, + 19, + 2 + ], + "rotation": [ + 90, + 0, + 0 + ], + "reset": true, + "cubes": [ + { + "origin": [ + -6, + 11, + -5 + ], + "pivot": [ + 0, + 19, + 2 + ], + "rotation": [ + 90, + 0, + -5 + ], + "size": [ + 12, + 18, + 10 + ], + "uv": [ + 0, + 0 + ] + }, + { + "origin": [ + -2, + 11, + -6 + ], + "pivot": [ + 0, + 19, + 2 + ], + "rotation": [ + 90, + 0, + -6 + ], + "size": [ + 4, + 6, + 1 + ], + "uv": [ + 44, + 0 + ] + } + ] + }, + { + "name": "head", + "pivot": [ + 0, + 20, + -8 + ], + "rotation": [ + 0, + 0, + 0 + ], + "reset": true, + "cubes": [ + { + "origin": [ + -4, + 16, + -14 + ], + "pivot": [ + 0, + 20, + -8 + ], + "rotation": [ + 0, + 0, + -14 + ], + "size": [ + 8, + 8, + 6 + ], + "uv": [ + 54, + 0 + ] + }, + { + "origin": [ + -5, + 22, + -12 + ], + "pivot": [ + 0, + 20, + -8 + ], + "rotation": [ + 0, + 0, + -12 + ], + "size": [ + 1, + 3, + 1 + ], + "uv": [ + 82, + 0 + ] + }, + { + "origin": [ + 4, + 22, + -12 + ], + "pivot": [ + 0, + 20, + -8 + ], + "rotation": [ + 0, + 0, + -12 + ], + "size": [ + 1, + 3, + 1 + ], + "uv": [ + 86, + 0 + ] + } + ] + }, + { + "name": "leg0", + "pivot": [ + -4, + 12, + 7 + ], + "rotation": [ + 0, + 0, + 0 + ], + "cubes": [ + { + "origin": [ + -5, + 0, + 5 + ], + "pivot": [ + -4, + 12, + 7 + ], + "rotation": [ + 0, + 0, + 5 + ], + "size": [ + 4, + 12, + 4 + ], + "uv": [ + 90, + 0 + ] + } + ] + }, + { + "name": "leg1", + "pivot": [ + 4, + 12, + 7 + ], + "rotation": [ + 0, + 0, + 0 + ], + "cubes": [ + { + "origin": [ + 1, + 0, + 5 + ], + "pivot": [ + 4, + 12, + 7 + ], + "rotation": [ + 0, + 0, + 5 + ], + "size": [ + 4, + 12, + 4 + ], + "uv": [ + 106, + 0 + ] + } + ] + }, + { + "name": "leg2", + "pivot": [ + -4, + 12, + -6 + ], + "rotation": [ + 0, + 0, + 0 + ], + "cubes": [ + { + "origin": [ + -5, + 0, + -7 + ], + "pivot": [ + -4, + 12, + -6 + ], + "rotation": [ + 0, + 0, + -7 + ], + "size": [ + 4, + 12, + 4 + ], + "uv": [ + 122, + 0 + ] + } + ] + }, + { + "name": "leg3", + "pivot": [ + 4, + 12, + -6 + ], + "rotation": [ + 0, + 0, + 0 + ], + "cubes": [ + { + "origin": [ + 1, + 0, + -7 + ], + "pivot": [ + 4, + 12, + -6 + ], + "rotation": [ + 0, + 0, + -7 + ], + "size": [ + 4, + 12, + 4 + ], + "uv": [ + 138, + 0 + ] + } + ] + } + ] + } +} \ No newline at end of file diff --git a/episode-13/work/models/creeper.json b/episode-13/work/models/creeper.json new file mode 100644 index 00000000..72ecdc94 --- /dev/null +++ b/episode-13/work/models/creeper.json @@ -0,0 +1,254 @@ +{ + "geometry.creeper": { + "textureheight": 16, + "texturewidth": 120, + "bones": [ + { + "name": "body", + "pivot": [ + 0, + 0, + 0 + ], + "rotation": [ + 0, + 0, + 0 + ], + "cubes": [ + { + "origin": [ + -4, + 6, + -2 + ], + "pivot": [ + 0, + 0, + 0 + ], + "rotation": [ + 0, + 0, + -2 + ], + "size": [ + 8, + 12, + 4 + ], + "uv": [ + 0, + 0 + ] + } + ] + }, + { + "name": "head", + "pivot": [ + 0, + 18, + 0 + ], + "rotation": [ + 0, + 0, + 0 + ], + "cubes": [ + { + "origin": [ + -4, + 18, + -4 + ], + "pivot": [ + 0, + 18, + 0 + ], + "rotation": [ + 0, + 0, + -4 + ], + "size": [ + 8, + 8, + 8 + ], + "uv": [ + 24, + 0 + ] + } + ] + }, + { + "name": "leg0", + "pivot": [ + -2, + 6, + 4 + ], + "rotation": [ + 0, + 0, + 0 + ], + "cubes": [ + { + "origin": [ + -4, + 0, + 2 + ], + "pivot": [ + -2, + 6, + 4 + ], + "rotation": [ + 0, + 0, + 2 + ], + "size": [ + 4, + 6, + 4 + ], + "uv": [ + 56, + 0 + ] + } + ] + }, + { + "name": "leg1", + "pivot": [ + 2, + 6, + 4 + ], + "rotation": [ + 0, + 0, + 0 + ], + "cubes": [ + { + "origin": [ + 0, + 0, + 2 + ], + "pivot": [ + 2, + 6, + 4 + ], + "rotation": [ + 0, + 0, + 2 + ], + "size": [ + 4, + 6, + 4 + ], + "uv": [ + 72, + 0 + ] + } + ] + }, + { + "name": "leg2", + "pivot": [ + -2, + 6, + -4 + ], + "rotation": [ + 0, + 0, + 0 + ], + "cubes": [ + { + "origin": [ + -4, + 0, + -6 + ], + "pivot": [ + -2, + 6, + -4 + ], + "rotation": [ + 0, + 0, + -6 + ], + "size": [ + 4, + 6, + 4 + ], + "uv": [ + 88, + 0 + ] + } + ] + }, + { + "name": "leg3", + "pivot": [ + 2, + 6, + -4 + ], + "rotation": [ + 0, + 0, + 0 + ], + "cubes": [ + { + "origin": [ + 0, + 0, + -6 + ], + "pivot": [ + 2, + 6, + -4 + ], + "rotation": [ + 0, + 0, + -6 + ], + "size": [ + 4, + 6, + 4 + ], + "uv": [ + 104, + 0 + ] + } + ] + } + ] + } +} \ No newline at end of file diff --git a/episode-13/work/models/curry.json b/episode-13/work/models/curry.json new file mode 100644 index 00000000..5a38c1f6 --- /dev/null +++ b/episode-13/work/models/curry.json @@ -0,0 +1,262 @@ +{ + "geometry.zombie": { + "textureheight": 16, + "texturewidth": 212, + "bones": [ + { + "name": "body", + "pivot": [ + 0, + 24, + 0 + ], + "rotation": [ + 0, + 0, + 0 + ], + "cubes": [ + { + "origin": [ + -4, + 12, + -2 + ], + "size": [ + 8, + 12, + 4 + ], + "uv": [ + 0, + 0 + ] + } + ] + }, + { + "name": "head", + "pivot": [ + 0, + 24, + 0 + ], + "rotation": [ + 0, + 0, + 0 + ], + "cubes": [ + { + "origin": [ + -4.0583300306269, + 23.95693829559, + -3.705860295036 + ], + "size": [ + 8, + 8, + 8 + ], + "uv": [ + 24, + 0 + ] + }, + { + "origin": [ + 3.7057484089696, + 14.34071060707, + -3.4930718291813 + ], + "size": [ + 8, + 8, + 8 + ], + "uv": [ + 56, + 0 + ] + } + ] + }, + { + "name": "hat", + "pivot": [ + 0, + 24, + 0 + ], + "rotation": [ + 0, + 0, + 0 + ], + "neverRender": true, + "cubes": [ + { + "origin": [ + -4, + 24, + -4 + ], + "size": [ + 8, + 8, + 8 + ], + "uv": [ + 88, + 0 + ], + "inflate": 0.5 + } + ] + }, + { + "name": "rightArm", + "pivot": [ + -5, + 22, + 0 + ], + "rotation": [ + 0, + 0, + 0 + ], + "cubes": [ + { + "origin": [ + -8, + 12, + -2 + ], + "size": [ + 4, + 12, + 4 + ], + "uv": [ + 120, + 0 + ] + } + ] + }, + { + "name": "leftArm", + "pivot": [ + 5, + 22, + 0 + ], + "rotation": [ + 0, + 0, + 0 + ], + "mirror": true, + "cubes": [ + { + "origin": [ + 11.231668626323, + 11.980507371494, + -0.4229336717497 + ], + "size": [ + 4, + 12, + 4 + ], + "uv": [ + 136, + 0 + ] + }, + { + "origin": [ + 1.4948465561419, + 21.068085665897, + -1.1174632729199 + ], + "size": [ + 10, + 3, + 4 + ], + "uv": [ + 152, + 0 + ], + "inflate": 0.01 + } + ] + }, + { + "name": "rightLeg", + "pivot": [ + -1.9, + 12, + 0 + ], + "rotation": [ + 0, + 0, + 0 + ], + "cubes": [ + { + "origin": [ + -3.9, + 0, + -2 + ], + "size": [ + 4, + 12, + 4 + ], + "uv": [ + 180, + 0 + ] + } + ] + }, + { + "name": "leftLeg", + "pivot": [ + 1.9, + 12, + 0 + ], + "rotation": [ + 0, + 0, + 0 + ], + "mirror": true, + "cubes": [ + { + "origin": [ + -0.1, + 0, + -2 + ], + "size": [ + 4, + 12, + 4 + ], + "uv": [ + 196, + 0 + ] + } + ] + } + ] + } +} \ No newline at end of file diff --git a/episode-13/work/models/pig.json b/episode-13/work/models/pig.json new file mode 100644 index 00000000..d6c60706 --- /dev/null +++ b/episode-13/work/models/pig.json @@ -0,0 +1,286 @@ +{ + "geometry.pig": { + "textureheight": 24, + "texturewidth": 142, + "bones": [ + { + "name": "body", + "pivot": [ + 0, + 13, + 2 + ], + "rotation": [ + 0, + 0, + 0 + ], + "reset": true, + "cubes": [ + { + "origin": [ + -5, + 7, + -5 + ], + "pivot": [ + 0, + 13, + 2 + ], + "rotation": [ + 90, + 0, + -5 + ], + "size": [ + 10, + 16, + 8 + ], + "uv": [ + 0, + 0 + ] + } + ] + }, + { + "name": "head", + "pivot": [ + 0, + 12, + -6 + ], + "rotation": [ + 0, + 0, + 0 + ], + "reset": true, + "cubes": [ + { + "origin": [ + -4, + 8, + -14 + ], + "pivot": [ + 0, + 12, + -6 + ], + "rotation": [ + 0, + 0, + -14 + ], + "size": [ + 8, + 8, + 8 + ], + "uv": [ + 36, + 0 + ] + }, + { + "origin": [ + -2, + 9, + -15 + ], + "pivot": [ + 0, + 12, + -6 + ], + "rotation": [ + 0, + 0, + -15 + ], + "size": [ + 4, + 3, + 1 + ], + "uv": [ + 68, + 0 + ] + } + ] + }, + { + "name": "leg0", + "pivot": [ + -3, + 6, + 7 + ], + "rotation": [ + 0, + 0, + 0 + ], + "reset": true, + "cubes": [ + { + "origin": [ + -5, + 0, + 5 + ], + "pivot": [ + -3, + 6, + 7 + ], + "rotation": [ + 0, + 0, + 5 + ], + "size": [ + 4, + 6, + 4 + ], + "uv": [ + 78, + 0 + ] + } + ] + }, + { + "name": "leg1", + "pivot": [ + 3, + 6, + 7 + ], + "rotation": [ + 0, + 0, + 0 + ], + "reset": true, + "cubes": [ + { + "origin": [ + 1, + 0, + 5 + ], + "pivot": [ + 3, + 6, + 7 + ], + "rotation": [ + 0, + 0, + 5 + ], + "size": [ + 4, + 6, + 4 + ], + "uv": [ + 94, + 0 + ] + } + ] + }, + { + "name": "leg2", + "pivot": [ + -3, + 6, + -5 + ], + "rotation": [ + 0, + 0, + 0 + ], + "reset": true, + "cubes": [ + { + "origin": [ + -5, + 0, + -7 + ], + "pivot": [ + -3, + 6, + -5 + ], + "rotation": [ + 0, + 0, + -7 + ], + "size": [ + 4, + 6, + 4 + ], + "uv": [ + 110, + 0 + ] + } + ] + }, + { + "name": "leg3", + "pivot": [ + 3, + 6, + -5 + ], + "rotation": [ + 0, + 0, + 0 + ], + "reset": true, + "cubes": [ + { + "origin": [ + 1, + 0, + -7 + ], + "pivot": [ + 3, + 6, + -5 + ], + "rotation": [ + 0, + 0, + -7 + ], + "size": [ + 4, + 6, + 4 + ], + "uv": [ + 126, + 0 + ] + } + ] + } + ] + } +} \ No newline at end of file diff --git a/episode-13/work/models/skeleton.json b/episode-13/work/models/skeleton.json new file mode 100644 index 00000000..9bb543b1 --- /dev/null +++ b/episode-13/work/models/skeleton.json @@ -0,0 +1,304 @@ +{ + "geometry.skeleton": { + "textureheight": 16, + "texturewidth": 120, + "bones": [ + { + "name": "body", + "pivot": [ + 0, + 24, + 0 + ], + "rotation": [ + 0, + 0, + 0 + ], + "material": "alpha", + "cubes": [ + { + "origin": [ + -4, + 12, + -2 + ], + "pivot": [ + 0, + 24, + 0 + ], + "rotation": [ + 0, + 0, + -2 + ], + "size": [ + 8, + 12, + 4 + ], + "uv": [ + 0, + 0 + ] + } + ] + }, + { + "name": "head", + "pivot": [ + 0, + 24, + 0 + ], + "rotation": [ + 0, + 0, + 0 + ], + "cubes": [ + { + "origin": [ + -4, + 24, + -4 + ], + "pivot": [ + 0, + 24, + 0 + ], + "rotation": [ + 0, + 0, + -4 + ], + "size": [ + 8, + 8, + 8 + ], + "uv": [ + 24, + 0 + ] + } + ] + }, + { + "name": "hat", + "pivot": [ + 0, + 24, + 0 + ], + "rotation": [ + 0, + 0, + 0 + ], + "neverRender": true, + "cubes": [ + { + "origin": [ + -4, + 24, + -4 + ], + "pivot": [ + 0, + 24, + 0 + ], + "rotation": [ + 0, + 0, + -4 + ], + "size": [ + 8, + 8, + 8 + ], + "uv": [ + 56, + 0 + ], + "inflate": 0.5 + } + ] + }, + { + "name": "rightArm", + "pivot": [ + -5, + 22, + 0 + ], + "rotation": [ + 0, + 0, + 0 + ], + "reset": "true", + "cubes": [ + { + "origin": [ + -6, + 12, + -1 + ], + "pivot": [ + -5, + 22, + 0 + ], + "rotation": [ + 0, + 0, + -1 + ], + "size": [ + 2, + 12, + 2 + ], + "uv": [ + 88, + 0 + ] + } + ] + }, + { + "name": "leftArm", + "pivot": [ + 5, + 22, + 0 + ], + "rotation": [ + 0, + 0, + 0 + ], + "reset": "true", + "mirror": true, + "cubes": [ + { + "origin": [ + 4, + 12, + -1 + ], + "pivot": [ + 5, + 22, + 0 + ], + "rotation": [ + 0, + 0, + -1 + ], + "size": [ + 2, + 12, + 2 + ], + "uv": [ + 96, + 0 + ] + } + ] + }, + { + "name": "rightLeg", + "pivot": [ + -2, + 12, + 0 + ], + "rotation": [ + 0, + 0, + 0 + ], + "reset": "true", + "cubes": [ + { + "origin": [ + -3, + 0, + -1 + ], + "pivot": [ + -2, + 12, + 0 + ], + "rotation": [ + 0, + 0, + -1 + ], + "size": [ + 2, + 12, + 2 + ], + "uv": [ + 104, + 0 + ] + } + ] + }, + { + "name": "leftLeg", + "pivot": [ + 2, + 12, + 0 + ], + "rotation": [ + 0, + 0, + 0 + ], + "reset": "true", + "mirror": true, + "cubes": [ + { + "origin": [ + 1, + 0, + -1 + ], + "pivot": [ + 2, + 12, + 0 + ], + "rotation": [ + 0, + 0, + -1 + ], + "size": [ + 2, + 12, + 2 + ], + "uv": [ + 112, + 0 + ] + } + ] + } + ] + } +} \ No newline at end of file diff --git a/episode-13/work/models/spider.json b/episode-13/work/models/spider.json new file mode 100644 index 00000000..328ce7fe --- /dev/null +++ b/episode-13/work/models/spider.json @@ -0,0 +1,460 @@ +{ + "geometry.spider": { + "textureheight": 20, + "texturewidth": 388, + "bones": [ + { + "name": "head", + "pivot": [ + 0, + 9, + -3 + ], + "rotation": [ + 0, + 0, + 0 + ], + "material": "emissive", + "cubes": [ + { + "origin": [ + -4, + 5, + -11 + ], + "pivot": [ + 0, + 9, + -3 + ], + "rotation": [ + 0, + 0, + -11 + ], + "size": [ + 8, + 8, + 8 + ], + "uv": [ + 0, + 0 + ] + } + ] + }, + { + "name": "body0", + "pivot": [ + 0, + 9, + 0 + ], + "rotation": [ + 0, + 0, + 0 + ], + "cubes": [ + { + "origin": [ + -3, + 6, + -3 + ], + "pivot": [ + 0, + 9, + 0 + ], + "rotation": [ + 0, + 0, + -3 + ], + "size": [ + 6, + 6, + 6 + ], + "uv": [ + 32, + 0 + ] + } + ] + }, + { + "name": "body1", + "pivot": [ + 0, + 9, + 9 + ], + "rotation": [ + 0, + 0, + 0 + ], + "cubes": [ + { + "origin": [ + -5, + 5, + 3 + ], + "pivot": [ + 0, + 9, + 9 + ], + "rotation": [ + 0, + 0, + 3 + ], + "size": [ + 10, + 8, + 12 + ], + "uv": [ + 56, + 0 + ] + } + ] + }, + { + "name": "leg0", + "pivot": [ + -4, + 9, + 2 + ], + "rotation": [ + 0, + -10, + 170 + ], + "cubes": [ + { + "origin": [ + -19, + 8, + 1 + ], + "pivot": [ + -4, + 9, + 2 + ], + "rotation": [ + 0, + -10, + 1 + ], + "size": [ + 16, + 2, + 2 + ], + "uv": [ + 100, + 0 + ] + } + ] + }, + { + "name": "leg1", + "pivot": [ + 4, + 9, + 2 + ], + "rotation": [ + 0, + -5, + 170 + ], + "cubes": [ + { + "origin": [ + 3, + 8, + 1 + ], + "pivot": [ + 4, + 9, + 2 + ], + "rotation": [ + 0, + -5, + 1 + ], + "size": [ + 16, + 2, + 2 + ], + "uv": [ + 136, + 0 + ] + } + ] + }, + { + "name": "leg2", + "pivot": [ + -4, + 9, + 1 + ], + "rotation": [ + 0, + 5, + 170 + ], + "cubes": [ + { + "origin": [ + -19, + 8, + 0 + ], + "pivot": [ + -4, + 9, + 1 + ], + "rotation": [ + 0, + 5, + 0 + ], + "size": [ + 16, + 2, + 2 + ], + "uv": [ + 172, + 0 + ] + } + ] + }, + { + "name": "leg3", + "pivot": [ + 4, + 9, + 1 + ], + "rotation": [ + 0, + 15, + 170 + ], + "cubes": [ + { + "origin": [ + 3, + 8, + 0 + ], + "pivot": [ + 4, + 9, + 1 + ], + "rotation": [ + 0, + 15, + 0 + ], + "size": [ + 16, + 2, + 2 + ], + "uv": [ + 208, + 0 + ] + } + ] + }, + { + "name": "leg4", + "pivot": [ + -4, + 9, + 0 + ], + "rotation": [ + 0, + 10, + -170 + ], + "cubes": [ + { + "origin": [ + -19, + 8, + -1.0000000000000004 + ], + "pivot": [ + -4, + 9, + 0 + ], + "rotation": [ + 0, + 10, + -1.0000000000000004 + ], + "size": [ + 16, + 2, + 2 + ], + "uv": [ + 244, + 0 + ] + } + ] + }, + { + "name": "leg5", + "pivot": [ + 4, + 9, + 0 + ], + "rotation": [ + 0, + 5, + -170 + ], + "cubes": [ + { + "origin": [ + 3, + 8, + -1 + ], + "pivot": [ + 4, + 9, + 0 + ], + "rotation": [ + 0, + 5, + -1 + ], + "size": [ + 16, + 2, + 2 + ], + "uv": [ + 280, + 0 + ] + } + ] + }, + { + "name": "leg6", + "pivot": [ + -4, + 9, + -1 + ], + "rotation": [ + 0, + -5, + -170 + ], + "cubes": [ + { + "origin": [ + -19, + 8, + -2 + ], + "pivot": [ + -4, + 9, + -1 + ], + "rotation": [ + 0, + -5, + -2 + ], + "size": [ + 16, + 2, + 2 + ], + "uv": [ + 316, + 0 + ] + } + ] + }, + { + "name": "leg7", + "pivot": [ + 4, + 9, + -1 + ], + "rotation": [ + 0, + -10, + -170 + ], + "cubes": [ + { + "origin": [ + 3, + 8, + -2 + ], + "pivot": [ + 4, + 9, + -1 + ], + "rotation": [ + 0, + -10, + -2 + ], + "size": [ + 16, + 2, + 2 + ], + "uv": [ + 352, + 0 + ] + } + ] + } + ] + } +} \ No newline at end of file diff --git a/episode-13/work/models/zombie.json b/episode-13/work/models/zombie.json new file mode 100644 index 00000000..c772ea2d --- /dev/null +++ b/episode-13/work/models/zombie.json @@ -0,0 +1,299 @@ +{ + "geometry.zombie": { + "textureheight": 16, + "texturewidth": 152, + "bones": [ + { + "name": "body", + "pivot": [ + 0, + 24, + 0 + ], + "rotation": [ + 0, + 0, + 0 + ], + "cubes": [ + { + "origin": [ + -4, + 12, + -2 + ], + "pivot": [ + 0, + 24, + 0 + ], + "rotation": [ + 0, + 0, + -2 + ], + "size": [ + 8, + 12, + 4 + ], + "uv": [ + 0, + 0 + ] + } + ] + }, + { + "name": "head", + "pivot": [ + 0, + 24, + 0 + ], + "rotation": [ + 0, + 0, + 0 + ], + "cubes": [ + { + "origin": [ + -4, + 24, + -4 + ], + "pivot": [ + 0, + 24, + 0 + ], + "rotation": [ + 0, + 0, + -4 + ], + "size": [ + 8, + 8, + 8 + ], + "uv": [ + 24, + 0 + ] + } + ] + }, + { + "name": "hat", + "pivot": [ + 0, + 24, + 0 + ], + "rotation": [ + 0, + 0, + 0 + ], + "neverRender": true, + "cubes": [ + { + "origin": [ + -4, + 24, + -4 + ], + "pivot": [ + 0, + 24, + 0 + ], + "rotation": [ + 0, + 0, + -4 + ], + "size": [ + 8, + 8, + 8 + ], + "uv": [ + 56, + 0 + ], + "inflate": 0.5 + } + ] + }, + { + "name": "rightArm", + "pivot": [ + -5, + 22, + 0 + ], + "rotation": [ + 0, + 0, + 0 + ], + "cubes": [ + { + "origin": [ + -8, + 12, + -2 + ], + "pivot": [ + -5, + 22, + 0 + ], + "rotation": [ + 0, + 0, + -2 + ], + "size": [ + 4, + 12, + 4 + ], + "uv": [ + 88, + 0 + ] + } + ] + }, + { + "name": "leftArm", + "pivot": [ + 5, + 22, + 0 + ], + "rotation": [ + 0, + 0, + 0 + ], + "mirror": true, + "cubes": [ + { + "origin": [ + 4, + 12, + -2 + ], + "pivot": [ + 5, + 22, + 0 + ], + "rotation": [ + 0, + 0, + -2 + ], + "size": [ + 4, + 12, + 4 + ], + "uv": [ + 104, + 0 + ] + } + ] + }, + { + "name": "rightLeg", + "pivot": [ + -1.9, + 12, + 0 + ], + "rotation": [ + 0, + 0, + 0 + ], + "cubes": [ + { + "origin": [ + -3.9, + 0, + -2 + ], + "pivot": [ + -1.9, + 12, + 0 + ], + "rotation": [ + 0, + 0, + -2 + ], + "size": [ + 4, + 12, + 4 + ], + "uv": [ + 120, + 0 + ] + } + ] + }, + { + "name": "leftLeg", + "pivot": [ + 1.9, + 12, + 0 + ], + "rotation": [ + 0, + 0, + 0 + ], + "mirror": true, + "cubes": [ + { + "origin": [ + -0.1, + 0, + -2 + ], + "pivot": [ + 1.9, + 12, + 0 + ], + "rotation": [ + 0, + 0, + -2 + ], + "size": [ + 4, + 12, + 4 + ], + "uv": [ + 136, + 0 + ] + } + ] + } + ] + } +} diff --git a/episode-13/world.py b/episode-13/world.py new file mode 100644 index 00000000..7f8a0b3b --- /dev/null +++ b/episode-13/world.py @@ -0,0 +1,274 @@ +import math +import matrix + +import save +import chunk +import shader + +import block_type +import texture_manager + +import player +import entity_type + +import pyglet.gl as gl + +# import custom block models + +import models + +class World: + def __init__(self, width, height): + self.texture_manager = texture_manager.Texture_manager(16, 16, 256) + self.block_types = [None] + + self.entity_types = {} + + # parse block type data file + + with open("data/blocks.mcpy") as f: + blocks_data = f.readlines() + + for block in blocks_data: + if block[0] in ['\n', '#']: # skip if empty line or comment + continue + + number, props = block.split(':', 1) + number = int(number) + + # default block + + name = "Unknown" + model = models.cube + texture = {"all": "unknown"} + + # read properties + + for prop in props.split(','): + prop = prop.strip() + prop = list(filter(None, prop.split(' ', 1))) + + if prop[0] == "sameas": + sameas_number = int(prop[1]) + + name = self.block_types[sameas_number].name + texture = self.block_types[sameas_number].block_face_textures + model = self.block_types[sameas_number].model + + elif prop[0] == "name": + name = eval(prop[1]) + + elif prop[0][:7] == "texture": + _, side = prop[0].split('.') + texture[side] = prop[1].strip() + + elif prop[0] == "model": + model = eval(prop[1]) + + # add block type + + _block_type = block_type.Block_type(self.texture_manager, name, texture, model) + + if number < len(self.block_types): + self.block_types[number] = _block_type + + else: + self.block_types.append(_block_type) + + self.texture_manager.generate_mipmaps() + + # parse entity type data file + + with open("data/entities.mcpy") as f: + entities_data = f.readlines() + + for _entity in entities_data: + if _entity[0] in "\n#": # skip if empty line or comment + continue + + name, props = _entity.split(':', 1) + + # default entity + + model = models.pig + texture = "pig" + + width = 0.6 + height = 1.8 + + # read properties + + for prop in props.split(','): + prop = prop.strip() + *prop, = filter(None, prop.split(' ', 1)) + + if prop[0] == "width": + width = float(prop[1]) + + elif prop[0] == "height": + height = float(prop[1]) + + elif prop[0] == "texture": + texture = prop[1] + + elif prop[0] == "model": + model = eval(prop[1]) + + # add entity type + + self.entity_types[name] = entity_type.Entity_type(self, name, texture, model, width, height) + + # matrices + + self.mv_matrix = matrix.Matrix() + self.p_matrix = matrix.Matrix() + self.mvp_matrix = matrix.Matrix() + + # shaders + + self.block_shader = shader.Shader("shaders/block/vert.glsl", "shaders/block/frag.glsl") + self.block_shader_sampler_location = self.block_shader.find_uniform(b"texture_array_sampler") + self.block_shader_matrix_location = self.block_shader.find_uniform(b"matrix") + + self.entity_shader = shader.Shader("shaders/entity/vert.glsl", "shaders/entity/frag.glsl") + self.entity_shader_sampler_location = self.entity_shader.find_uniform(b"texture_sampler") + self.entity_shader_inverse_transform_matrix_location = self.entity_shader.find_uniform(b"inverse_transform_matrix") + self.entity_shader_matrix_location = self.entity_shader.find_uniform(b"matrix") + + # load the world + + self.save = save.Save(self) + + self.chunks = {} + self.entities = [] + + self.save.load() + + for chunk_position in self.chunks: + self.chunks[chunk_position].update_subchunk_meshes() + self.chunks[chunk_position].update_mesh() + + # create player + + self.player = player.Player(self, width, height) + + def get_chunk_position(self, position): + x, y, z = position + + return ( + math.floor(x / chunk.CHUNK_WIDTH), + math.floor(y / chunk.CHUNK_HEIGHT), + math.floor(z / chunk.CHUNK_LENGTH)) + + def get_local_position(self, position): + x, y, z = position + + return ( + int(x % chunk.CHUNK_WIDTH), + int(y % chunk.CHUNK_HEIGHT), + int(z % chunk.CHUNK_LENGTH)) + + def get_block_number(self, position): + chunk_position = self.get_chunk_position(position) + + if not chunk_position in self.chunks: + return 0 + + lx, ly, lz = self.get_local_position(position) + + block_number = self.chunks[chunk_position].blocks[lx][ly][lz] + return block_number + + def is_opaque_block(self, position): + # get block type and check if it's opaque or not + # air counts as a transparent block, so test for that too + + block_type = self.block_types[self.get_block_number(position)] + + if not block_type: + return False + + return not block_type.transparent + + def set_block(self, position, number): # set number to 0 (air) to remove block + x, y, z = position + chunk_position = self.get_chunk_position(position) + + if not chunk_position in self.chunks: # if no chunks exist at this position, create a new one + if number == 0: + return # no point in creating a whole new chunk if we're not gonna be adding anything + + self.chunks[chunk_position] = chunk.Chunk(self, chunk_position) + + if self.get_block_number(position) == number: # no point updating mesh if the block is the same + return + + lx, ly, lz = self.get_local_position(position) + + self.chunks[chunk_position].blocks[lx][ly][lz] = number + self.chunks[chunk_position].modified = True + + self.chunks[chunk_position].update_at_position((x, y, z)) + self.chunks[chunk_position].update_mesh() + + cx, cy, cz = chunk_position + + def try_update_chunk_at_position(chunk_position, position): + if chunk_position in self.chunks: + self.chunks[chunk_position].update_at_position(position) + self.chunks[chunk_position].update_mesh() + + if lx == chunk.CHUNK_WIDTH - 1: try_update_chunk_at_position((cx + 1, cy, cz), (x + 1, y, z)) + if lx == 0: try_update_chunk_at_position((cx - 1, cy, cz), (x - 1, y, z)) + + if ly == chunk.CHUNK_HEIGHT - 1: try_update_chunk_at_position((cx, cy + 1, cz), (x, y + 1, z)) + if ly == 0: try_update_chunk_at_position((cx, cy - 1, cz), (x, y - 1, z)) + + if lz == chunk.CHUNK_LENGTH - 1: try_update_chunk_at_position((cx, cy, cz + 1), (x, y, z + 1)) + if lz == 0: try_update_chunk_at_position((cx, cy, cz - 1), (x, y, z - 1)) + + def try_set_block(self, pos, num, collider): + # if we're trying to remove a block, whatever let it go through + + if not num: + return self.set_block(pos, 0) + + # make sure the block doesn't intersect with the passed collider + + for block_collider in self.block_types[num].colliders: + if collider & (block_collider + pos): + return + + self.set_block(pos, num) + + def draw(self): + # setup block shader + + self.block_shader.use() + self.block_shader.uniform_matrix(self.block_shader_matrix_location, self.mvp_matrix) + + # bind textures + + gl.glActiveTexture(gl.GL_TEXTURE0) + gl.glBindTexture(gl.GL_TEXTURE_2D_ARRAY, self.texture_manager.texture_array) + gl.glUniform1i(self.block_shader_sampler_location, 0) + + # draw chunks + + gl.glEnable(gl.GL_CULL_FACE) + + for chunk_position in self.chunks: + self.chunks[chunk_position].draw() + + # draw entities + + self.entity_shader.use() + gl.glDisable(gl.GL_CULL_FACE) + + for entity in self.entities: + dist = math.sqrt(sum(map(lambda x: (x[0] - x[1]) ** 2, zip(entity.position, self.player.position)))) + + if dist > 32: + continue + + entity.draw() diff --git a/episode-5/texture_manager.py b/episode-5/texture_manager.py index a26180f0..191a11bd 100644 --- a/episode-5/texture_manager.py +++ b/episode-5/texture_manager.py @@ -10,31 +10,33 @@ def __init__(self, texture_width, texture_height, max_textures): self.max_textures = max_textures - self.textures = [] # an array to keep track of the textures we've already added + self.textures = [] - self.texture_array = gl.GLuint(0) # create our texture array + self.texture_array = gl.GLuint(0) gl.glGenTextures(1, self.texture_array) gl.glBindTexture(gl.GL_TEXTURE_2D_ARRAY, self.texture_array) - gl.glTexParameteri(gl.GL_TEXTURE_2D_ARRAY, gl.GL_TEXTURE_MAG_FILTER, gl.GL_NEAREST) # disable texture filtering for magnification (return the texel that's nearest to the fragment's texture coordinate) + gl.glTexParameteri(gl.GL_TEXTURE_2D_ARRAY, gl.GL_TEXTURE_MIN_FILTER, gl.GL_NEAREST) + gl.glTexParameteri(gl.GL_TEXTURE_2D_ARRAY, gl.GL_TEXTURE_MAG_FILTER, gl.GL_NEAREST) - gl.glTexImage3D( # set the dimensions of our texture array + gl.glTexImage3D( gl.GL_TEXTURE_2D_ARRAY, 0, gl.GL_RGBA, self.texture_width, self.texture_height, self.max_textures, 0, gl.GL_RGBA, gl.GL_UNSIGNED_BYTE, None) def generate_mipmaps(self): - gl.glBindTexture(gl.GL_TEXTURE_2D_ARRAY, self.texture_array) # make sure our texture is bound - gl.glGenerateMipmap(gl.GL_TEXTURE_2D_ARRAY) # generate mipmaps for our texture + gl.glBindTexture(gl.GL_TEXTURE_2D_ARRAY, self.texture_array) + gl.glGenerateMipmap(gl.GL_TEXTURE_2D_ARRAY) def add_texture(self, texture): - if not texture in self.textures: # check to see if our texture has not yet been added - self.textures.append(texture) # add it to our textures list if not + gl.glBindTexture(gl.GL_TEXTURE_2D_ARRAY, self.texture_array) + + if not texture in self.textures: + self.textures.append(texture) - texture_image = pyglet.image.load(f"textures/{texture}.png").get_image_data() # load and get the image data of the texture we want - gl.glBindTexture(gl.GL_TEXTURE_2D_ARRAY, self.texture_array) # make sure our texture array is bound + texture_image = pyglet.image.load(f"textures/{texture}.png").get_image_data() - gl.glTexSubImage3D( # paste our texture's image data in the appropriate spot in our texture array + gl.glTexSubImage3D( gl.GL_TEXTURE_2D_ARRAY, 0, 0, 0, self.textures.index(texture), self.texture_width, self.texture_height, 1, diff --git a/episode-6/texture_manager.py b/episode-6/texture_manager.py index 13993f9e..191a11bd 100644 --- a/episode-6/texture_manager.py +++ b/episode-6/texture_manager.py @@ -16,6 +16,7 @@ def __init__(self, texture_width, texture_height, max_textures): gl.glGenTextures(1, self.texture_array) gl.glBindTexture(gl.GL_TEXTURE_2D_ARRAY, self.texture_array) + gl.glTexParameteri(gl.GL_TEXTURE_2D_ARRAY, gl.GL_TEXTURE_MIN_FILTER, gl.GL_NEAREST) gl.glTexParameteri(gl.GL_TEXTURE_2D_ARRAY, gl.GL_TEXTURE_MAG_FILTER, gl.GL_NEAREST) gl.glTexImage3D( @@ -24,14 +25,16 @@ def __init__(self, texture_width, texture_height, max_textures): 0, gl.GL_RGBA, gl.GL_UNSIGNED_BYTE, None) def generate_mipmaps(self): + gl.glBindTexture(gl.GL_TEXTURE_2D_ARRAY, self.texture_array) gl.glGenerateMipmap(gl.GL_TEXTURE_2D_ARRAY) def add_texture(self, texture): + gl.glBindTexture(gl.GL_TEXTURE_2D_ARRAY, self.texture_array) + if not texture in self.textures: self.textures.append(texture) texture_image = pyglet.image.load(f"textures/{texture}.png").get_image_data() - gl.glBindTexture(gl.GL_TEXTURE_2D_ARRAY, self.texture_array) gl.glTexSubImage3D( gl.GL_TEXTURE_2D_ARRAY, 0, diff --git a/episode-7/texture_manager.py b/episode-7/texture_manager.py index 13993f9e..191a11bd 100644 --- a/episode-7/texture_manager.py +++ b/episode-7/texture_manager.py @@ -16,6 +16,7 @@ def __init__(self, texture_width, texture_height, max_textures): gl.glGenTextures(1, self.texture_array) gl.glBindTexture(gl.GL_TEXTURE_2D_ARRAY, self.texture_array) + gl.glTexParameteri(gl.GL_TEXTURE_2D_ARRAY, gl.GL_TEXTURE_MIN_FILTER, gl.GL_NEAREST) gl.glTexParameteri(gl.GL_TEXTURE_2D_ARRAY, gl.GL_TEXTURE_MAG_FILTER, gl.GL_NEAREST) gl.glTexImage3D( @@ -24,14 +25,16 @@ def __init__(self, texture_width, texture_height, max_textures): 0, gl.GL_RGBA, gl.GL_UNSIGNED_BYTE, None) def generate_mipmaps(self): + gl.glBindTexture(gl.GL_TEXTURE_2D_ARRAY, self.texture_array) gl.glGenerateMipmap(gl.GL_TEXTURE_2D_ARRAY) def add_texture(self, texture): + gl.glBindTexture(gl.GL_TEXTURE_2D_ARRAY, self.texture_array) + if not texture in self.textures: self.textures.append(texture) texture_image = pyglet.image.load(f"textures/{texture}.png").get_image_data() - gl.glBindTexture(gl.GL_TEXTURE_2D_ARRAY, self.texture_array) gl.glTexSubImage3D( gl.GL_TEXTURE_2D_ARRAY, 0, diff --git a/episode-8/texture_manager.py b/episode-8/texture_manager.py index 13993f9e..191a11bd 100644 --- a/episode-8/texture_manager.py +++ b/episode-8/texture_manager.py @@ -16,6 +16,7 @@ def __init__(self, texture_width, texture_height, max_textures): gl.glGenTextures(1, self.texture_array) gl.glBindTexture(gl.GL_TEXTURE_2D_ARRAY, self.texture_array) + gl.glTexParameteri(gl.GL_TEXTURE_2D_ARRAY, gl.GL_TEXTURE_MIN_FILTER, gl.GL_NEAREST) gl.glTexParameteri(gl.GL_TEXTURE_2D_ARRAY, gl.GL_TEXTURE_MAG_FILTER, gl.GL_NEAREST) gl.glTexImage3D( @@ -24,14 +25,16 @@ def __init__(self, texture_width, texture_height, max_textures): 0, gl.GL_RGBA, gl.GL_UNSIGNED_BYTE, None) def generate_mipmaps(self): + gl.glBindTexture(gl.GL_TEXTURE_2D_ARRAY, self.texture_array) gl.glGenerateMipmap(gl.GL_TEXTURE_2D_ARRAY) def add_texture(self, texture): + gl.glBindTexture(gl.GL_TEXTURE_2D_ARRAY, self.texture_array) + if not texture in self.textures: self.textures.append(texture) texture_image = pyglet.image.load(f"textures/{texture}.png").get_image_data() - gl.glBindTexture(gl.GL_TEXTURE_2D_ARRAY, self.texture_array) gl.glTexSubImage3D( gl.GL_TEXTURE_2D_ARRAY, 0, diff --git a/episode-9/block_type.py b/episode-9/block_type.py index 5e1ccf7b..7d386851 100644 --- a/episode-9/block_type.py +++ b/episode-9/block_type.py @@ -1,7 +1,6 @@ import models.cube # default model class Block_type: - # new optional model argument (cube model by default) def __init__(self, texture_manager, name = "unknown", block_face_textures = {"all": "cobblestone"}, model = models.cube): self.name = name @@ -10,7 +9,7 @@ def __init__(self, texture_manager, name = "unknown", block_face_textures = {"al self.transparent = model.transparent self.is_cube = model.is_cube - # replace data contained in numbers.py with model specific data + # get model specific data self.vertex_positions = model.vertex_positions self.tex_coords = model.tex_coords.copy() @@ -18,6 +17,7 @@ def __init__(self, texture_manager, name = "unknown", block_face_textures = {"al def set_block_face(face, texture): # make sure we don't add inexistent faces + if face > len(self.tex_coords) - 1: return diff --git a/episode-9/texture_manager.py b/episode-9/texture_manager.py index 6cfc9fdf..191a11bd 100644 --- a/episode-9/texture_manager.py +++ b/episode-9/texture_manager.py @@ -25,14 +25,16 @@ def __init__(self, texture_width, texture_height, max_textures): 0, gl.GL_RGBA, gl.GL_UNSIGNED_BYTE, None) def generate_mipmaps(self): + gl.glBindTexture(gl.GL_TEXTURE_2D_ARRAY, self.texture_array) gl.glGenerateMipmap(gl.GL_TEXTURE_2D_ARRAY) def add_texture(self, texture): + gl.glBindTexture(gl.GL_TEXTURE_2D_ARRAY, self.texture_array) + if not texture in self.textures: self.textures.append(texture) texture_image = pyglet.image.load(f"textures/{texture}.png").get_image_data() - gl.glBindTexture(gl.GL_TEXTURE_2D_ARRAY, self.texture_array) gl.glTexSubImage3D( gl.GL_TEXTURE_2D_ARRAY, 0,