コード例 #1
0
ファイル: cube.py プロジェクト: marselan/pyzeichnen
def draw(ax, cubes, color='b', camera_az=0.0):
    ext = 2.0
    ax.plot([-ext, ext], [0, 0], [0, 0], '--', color='gray')
    ax.plot([0, 0], [-ext, ext], [0, 0], '--', color='gray')
    ax.plot([0, 0], [0, 0], [-ext, ext], '--', color='gray')
    dir1 = render.Vector3D(math.cos(camera_az), math.sin(camera_az), 0)
    dir2 = render.Vector3D(-math.sin(camera_az), math.cos(camera_az), 0)
    dir3 = render.Vector3D(0, 0, 1)
    dir1.draw(ax, color='r')
    dir2.draw(ax, color='g')
    dir3.draw(ax, color='b')
    for cube in cubes:
        cube.draw(ax, color=color, camera_az=camera_az)
コード例 #2
0
ファイル: main.py プロジェクト: marselan/pyzeichnen
def createScene(file_name):
    light = render.Vector3D(1.0, 0.0, 0.0)
    frustum = render.Frustum(6, 6, camera_dist, -100.0, 80, 80, plt2, light)
    scene = render.Scene3D(file_name, plt2, frustum, light)
    scene.parse_file()
    scene.camera_distance = initial_camera_dist
    return scene
コード例 #3
0
top1 = tki.Toplevel()
top1.title("Control Panel")
top1.wm_geometry("400x800+20+50")
fig1 = Figure(figsize=(10, 5), dpi=100)
canvas1 = FigureCanvasTkAgg(fig1, master=top1)

top2 = tki.Toplevel()
top2.title('Render')
top2.wm_geometry("800x800+1200+50")
fig2 = Figure(figsize=(10, 5), dpi=100)
c2 = FigureCanvasTkAgg(fig2, master=top2)
plt2 = fig2.add_subplot(111, aspect=1.0)
c2.get_tk_widget().pack(side=tki.TOP, fill=tki.BOTH, expand=1)

light = render.Vector3D(0.3, 0.5, 0.8)
frustum = render.Frustum(6, 6, camera_dist, -100.0, 80, 80, plt2, light)
scene = render.Scene3D('two_chests.obj', plt2, frustum, light)
scene.parse_file()
scene.camera_distance = camera_dist


def on_distance_changed(value):
    global camera_dist
    camera_dist = float(value)
    plt2.clear()
    plt2.plot([-box_size, box_size, box_size, -box_size, -box_size],
              [-box_size, -box_size, box_size, box_size, -box_size],
              color='w')
    scene.set_camera_distance(camera_dist)
    c2.draw()
コード例 #4
0
ファイル: cube.py プロジェクト: marselan/pyzeichnen
            cubes,
            color='b',
            camera_az=0.0,
            camera_elev=0.0,
            camera_ang=0.0,
            camera_dist=1.0):
    for cube in cubes:
        cube.project(ax,
                     color=color,
                     camera_az=camera_az,
                     camera_elev=camera_elev,
                     camera_ang=camera_ang,
                     camera_dist=camera_dist)


p1 = render.Vector3D(1, 1, 1)
p2 = render.Vector3D(1, 1, -1)
p3 = render.Vector3D(-1, 1, -1)
p4 = render.Vector3D(-1, 1, 1)
s1 = render.Polygon3D([p1, p2, p3, p4])

p1 = render.Vector3D(-1, 1, 1)
p2 = render.Vector3D(-1, 1, -1)
p3 = render.Vector3D(-1, -1, -1)
p4 = render.Vector3D(-1, -1, 1)
s2 = render.Polygon3D([p1, p2, p3, p4])

p1 = render.Vector3D(1, -1, 1)
p2 = render.Vector3D(1, -1, -1)
p3 = render.Vector3D(-1, -1, -1)
p4 = render.Vector3D(-1, -1, 1)
コード例 #5
0
ファイル: poc.py プロジェクト: marselan/pyzeichnen
    ax.plot([-ext, ext], [0, 0], [0, 0], '--', color='gray')
    ax.plot([0, 0], [-ext, ext], [0, 0], '--', color='gray')
    ax.plot([0, 0], [0, 0], [-ext, ext], '--', color='gray')
    dir1.draw(ax, color='r')
    dir2.draw(ax, color='g')
    dir3.draw(ax, color='b')
    for triangle in triangles:
        triangle.draw(ax, dir1, dir2, dir3, color=color)


def project(ax, dir1, dir2, dir3, triangles, color='b'):
    for triangle in triangles:
        triangle.project(ax, dir1, dir2, dir3, color=color)


p1 = render.Vector3D(1, 1, 0)
p2 = render.Vector3D(1, -1, 0)
p3 = render.Vector3D(0, 0, 1)
t1 = render.Triangle3D(p1, p2, p3)

p1 = render.Vector3D(1, 1, 0)
p2 = render.Vector3D(1, -1, 0)
p3 = render.Vector3D(0, 0, -1)
t2 = render.Triangle3D(p1, p2, p3)

p1 = render.Vector3D(-1, 1, 0)
p2 = render.Vector3D(-1, -1, 0)
p3 = render.Vector3D(0, 0, 1)
t3 = render.Triangle3D(p1, p2, p3)

p1 = render.Vector3D(-1, 1, 0)