How to use the payton.scene.geometry.Line function in Payton

To help you get started, we’ve selected a few Payton examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github sinanislekdemir / payton / examples / basics / 21_click_plane.py View on Github external
from payton.scene import Scene
from payton.scene.geometry import Line, Plane
from payton.scene.gui import info_box


def draw(hit):
    global scene
    scene.objects["line"].append([hit])


scene = Scene()
scene.add_click_plane([0, 0, 0.5], [0, 0, 1], draw)
scene.add_object("line", Line())
scene.objects["line"].material.color = [1.0, 0.0, 0.0]

ground = Plane(30, 30)
ground.position = [0, 0, 0.48]
scene.add_object("ground", ground)
scene.add_object(
    "info", info_box(left=10, top=10, width=220, height=100, label="Start Clicking \nto draw lines",),
)

scene.run()
github sinanislekdemir / payton / examples / basics / 17_line.py View on Github external
from payton.scene import Scene
from payton.scene.geometry import Line

scene = Scene()

line = Line(
    vertices=[[0, 0, 0], [0, 0, 1], [0.5, 0, 1.5], [1, 0, 1], [0, 0, 1], [1, 0, 0], [0, 0, 0], [1, 0, 1], [1, 0, 0]]
)

scene.add_object("line", line)
scene.run()
github sinanislekdemir / payton / examples / basics / 33_better_lines.py View on Github external
def __init__(self, **kwargs):
        super().__init__(**kwargs)
        self.line = Line()
        self.vertex_velocities = []
        self.line.material.color = RED
        self.grid.visible = False

        for i in range(20):
            x = random.randint(-1000, 1000) / 100
            y = random.randint(-1000, 1000) / 100
            z = random.randint(-1000, 1000) / 100
            self.line.append(vertices=[[x, y, z]])
            v = normalize_vector([x, y, z])
            if random.randint(0, 1) == 1:
                v = scale_vector(v, -1)
            self.vertex_velocities.append(v)

        self.add_object("line", self.line)
        self.create_clock("clock", 0.01, self.animate)
github sinanislekdemir / payton / examples / tools / 03_lines_to_mesh.py View on Github external
from payton.tools.mesh import lines_to_mesh

wall_line1 = Line(vertices=[[0, 2, 0], [5, 2, 0], [5, 2, 4], [0, 2, 4], [0, 2, 0]])
wall_line2 = Line(vertices=[[2, 2, 2], [3, 2, 2], [3, 2, 3], [2, 2, 3], [2, 2, 2]])

wall = lines_to_mesh([wall_line2, wall_line1])

texture_file = os.path.join(os.path.dirname(__file__), "wall.jpg")
wall.material.texture = texture_file

scene = Scene()
scene.add_object("wall_line1", wall_line1)
scene.add_object("wall_line2", wall_line2)
scene.add_object("wall", wall)

roof_base = Line(vertices=[[-1, -1, 4], [6, -1, 4], [6, 3, 4], [-1, 3, 4], [-1, -1, 4]])

roof_top = Line(vertices=[[2, 0.999, 7], [3, 0.999, 7], [3, 1.001, 7], [2, 1.001, 7], [2, 0.999, 7]])

roof = lines_to_mesh([roof_base, roof_top])
roof.material.texture = texture_file
roof.fix_texcoords(2, 2)  # Repeat the texture twice, make bricks at half size.

scene.add_object("roof_base_line", roof_base)
scene.add_object("roof_top_line", roof_top)
scene.add_object("roof", roof)

scene.run()
github sinanislekdemir / payton / examples / tools / 01_extrude_line.py View on Github external
from payton.scene import Scene
from payton.scene.geometry import Line
from payton.tools.mesh import extrude_line

line = Line(vertices=[[0, 0, 0], [2, 0, 1], [2, 2, 2], [0, 2, 3], [0, 0, 0]])

mesh = extrude_line(line, [0.0, 0.0, 1.0], 3)

scene = Scene()
scene.add_object("line", line)
scene.add_object("mesh", mesh)
scene.run()
github sinanislekdemir / payton / examples / tools / 02_rotate_line.py View on Github external
import math
import os

from payton.scene import Scene
from payton.scene.geometry import Line
from payton.tools.mesh import rotate_line

line = Line(
    vertices=[
        [0, 0, 0],
        [0.5, 0, 0],
        [0.6, 0, 0.25],
        [0.8, 0, 0.9],
        [0.9, 0, 1.5],
        [0.75, 0, 1.8],
        [0.3, 0, 2.1],
        [0.6, 0, 2.3],
    ]
)

mesh = rotate_line(line, [0, 0, 1], math.radians(360), steps=20)

texture_file = os.path.join(os.path.dirname(__file__), "green.jpg")
mesh.material.texture = texture_file
github sinanislekdemir / payton / examples / tools / 03_lines_to_mesh.py View on Github external
import os

from payton.scene import Scene
from payton.scene.geometry import Line
from payton.tools.mesh import lines_to_mesh

wall_line1 = Line(vertices=[[0, 2, 0], [5, 2, 0], [5, 2, 4], [0, 2, 4], [0, 2, 0]])
wall_line2 = Line(vertices=[[2, 2, 2], [3, 2, 2], [3, 2, 3], [2, 2, 3], [2, 2, 2]])

wall = lines_to_mesh([wall_line2, wall_line1])

texture_file = os.path.join(os.path.dirname(__file__), "wall.jpg")
wall.material.texture = texture_file

scene = Scene()
scene.add_object("wall_line1", wall_line1)
scene.add_object("wall_line2", wall_line2)
scene.add_object("wall", wall)

roof_base = Line(vertices=[[-1, -1, 4], [6, -1, 4], [6, 3, 4], [-1, 3, 4], [-1, -1, 4]])

roof_top = Line(vertices=[[2, 0.999, 7], [3, 0.999, 7], [3, 1.001, 7], [2, 1.001, 7], [2, 0.999, 7]])
github sinanislekdemir / payton / examples / tools / 03_lines_to_mesh.py View on Github external
wall_line1 = Line(vertices=[[0, 2, 0], [5, 2, 0], [5, 2, 4], [0, 2, 4], [0, 2, 0]])
wall_line2 = Line(vertices=[[2, 2, 2], [3, 2, 2], [3, 2, 3], [2, 2, 3], [2, 2, 2]])

wall = lines_to_mesh([wall_line2, wall_line1])

texture_file = os.path.join(os.path.dirname(__file__), "wall.jpg")
wall.material.texture = texture_file

scene = Scene()
scene.add_object("wall_line1", wall_line1)
scene.add_object("wall_line2", wall_line2)
scene.add_object("wall", wall)

roof_base = Line(vertices=[[-1, -1, 4], [6, -1, 4], [6, 3, 4], [-1, 3, 4], [-1, -1, 4]])

roof_top = Line(vertices=[[2, 0.999, 7], [3, 0.999, 7], [3, 1.001, 7], [2, 1.001, 7], [2, 0.999, 7]])

roof = lines_to_mesh([roof_base, roof_top])
roof.material.texture = texture_file
roof.fix_texcoords(2, 2)  # Repeat the texture twice, make bricks at half size.

scene.add_object("roof_base_line", roof_base)
scene.add_object("roof_top_line", roof_top)
scene.add_object("roof", roof)

scene.run()
github sinanislekdemir / payton / examples / tools / 03_lines_to_mesh.py View on Github external
import os

from payton.scene import Scene
from payton.scene.geometry import Line
from payton.tools.mesh import lines_to_mesh

wall_line1 = Line(vertices=[[0, 2, 0], [5, 2, 0], [5, 2, 4], [0, 2, 4], [0, 2, 0]])
wall_line2 = Line(vertices=[[2, 2, 2], [3, 2, 2], [3, 2, 3], [2, 2, 3], [2, 2, 2]])

wall = lines_to_mesh([wall_line2, wall_line1])

texture_file = os.path.join(os.path.dirname(__file__), "wall.jpg")
wall.material.texture = texture_file

scene = Scene()
scene.add_object("wall_line1", wall_line1)
scene.add_object("wall_line2", wall_line2)
scene.add_object("wall", wall)

roof_base = Line(vertices=[[-1, -1, 4], [6, -1, 4], [6, 3, 4], [-1, 3, 4], [-1, -1, 4]])

roof_top = Line(vertices=[[2, 0.999, 7], [3, 0.999, 7], [3, 1.001, 7], [2, 1.001, 7], [2, 0.999, 7]])

roof = lines_to_mesh([roof_base, roof_top])