Пример #1
0
    def _selection_changed(self, start: ivec3, end: ivec3, mode: Button):
        self.low = glm.min(start, end)
        self.high = glm.max(start, end)
        self.selection.set(self.low, self.high)
        size = vec3(self.high - self.low)

        self.center = map.vox2draw(vec3(self.low) + (size / 2) + 0.5)
        self.size = map.vox2draw(size + 1)
Пример #2
0
    def __init__(self, parent: 'scene.EditorScript'):
        super().__init__(parent)
        self.center = vec3(0)
        self.size = vec3(0)
        self.high = None
        self.low = None

        self.selection = BoxSelection(self.parent.editor.map)
Пример #3
0
    def draw(self):
        self.s.bind()
        self.s.uniform("alpha", 0.8)
        self.s.uniform("replacement_color", vec3(0, 0, 0))
        self.s.uniform("filter_color", vec3(0, 0, 0))

        gl.Blend(True)
        self.outline.draw(self.s)
        gl.Blend(False)
Пример #4
0
    def __init__(self, parent: 'scene.EditorScript', model: str="cp.kv6"):
        super().__init__(parent)

        if not model.endswith(".kv6"): model += ".kv6"
        self.name = f"Model ({model})"

        self.blocks = self.parent.editor.kv6_to_blocks(f"kv6/{model}")
        self.max_height = max(self.blocks.keys(), key=lambda b: b.z).z
        self.outline = draw.VXLBlocks(self.blocks, vec3(0, 0, self.max_height))
        self.outline_offset = vec3(0, 0, 0) # for rotation
        self.s: ShaderProgram = self.parent.editor.client.shader("map")
Пример #5
0
    def on_key(self, scancode: Key, modifiers: Keymod, pressed: bool):
        if not pressed: return

        if scancode == Key.UP:
            self.outline.rotation.y = 0
            self.outline_offset = vec3(0, 0, 0)
        elif scancode == Key.LEFT:
            self.outline.rotation.y = 90
            self.outline_offset = vec3(0, 0, 1)
        elif scancode == Key.DOWN:
            self.outline.rotation.y = 180
            self.outline_offset = vec3(1, 0, 1)
        elif scancode == Key.RIGHT:
            self.outline.rotation.y = 270
            self.outline_offset = vec3(1, 0, 0)
Пример #6
0
    def draw(self):
        if not self.is_selecting(): return

        self.s.bind()
        self.s.uniform("alpha", 0.6)
        self.s.uniform("replacement_color", vec3(0, 0, 0))

        gl.Blend(True)
        gl.DepthTest(False)
        self.outline.draw(self.s)
        gl.Blend(False)
        gl.DepthTest(True)
Пример #7
0
    def update(self, dt: float):
        f, hit = self.editor.hitcast()
        cur_color = self.editor.map.get_color(hit.x, hit.y, hit.z)

        # Draw tool information
        p = self.font.draw(f"Cursor: {hit}\n", vec2(30, 10), vec3(1, 0, 0),
                           vec2(1, 1), Align.TOP_LEFT)
        p = self.font.draw(f"Color@Cursor: {cur_color}\n", p,
                           vec3(cur_color) / 255.0)
        p = self.font.draw(f"Tool: {self.tool.name}\n", p, vec3(1, 0, 0))
        p = self.font.draw(f"Tool Mode: {self.mode.value}\n", p, vec3(1, 0, 0))
        p = self.font.draw(f"Tool Color: {self.color}\n", p,
                           vec3(self.color) / 255.0)

        self.tool.update(dt)

        self.msg_time = max(0, self.msg_time - dt)

        if self.msg_time > 0:
            self.font.draw(f"Selected Mode: {self.msg}", vec2(960, 617),
                           vec3(1, 0, 0), vec2(1.25), Align.BOTTOM_CENTER)
Пример #8
0
 def fog_color(self, r: int, g: int, b: int):
     self.parent.editor.uniforms.fog_color = glm.vec3(r, g, b) / 255
Пример #9
0
    def draw(self):
        if not self.is_selecting(): return

        self.parent.editor.debug.draw_cube(self.center, self.size, vec3(1, 0, 0))