triview 0.0.1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- triview/__init__.py +2 -0
- triview/__main__.py +89 -0
- triview/models/teapot.obj +4663 -0
- triview/triview.py +174 -0
- triview-0.0.1.dist-info/METADATA +3 -0
- triview-0.0.1.dist-info/RECORD +9 -0
- triview-0.0.1.dist-info/WHEEL +5 -0
- triview-0.0.1.dist-info/entry_points.txt +2 -0
- triview-0.0.1.dist-info/top_level.txt +1 -0
triview/__init__.py
ADDED
triview/__main__.py
ADDED
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
# __main__.py
|
|
2
|
+
import tkinter as tk
|
|
3
|
+
from tkinter import messagebox
|
|
4
|
+
from triview import TRIVIEW
|
|
5
|
+
import os
|
|
6
|
+
|
|
7
|
+
ask = messagebox.askyesno("Triview", f"Are You Sure You Want to Load teapot.obj ?\n This can be very Laggy\n")
|
|
8
|
+
if not ask:
|
|
9
|
+
quit()
|
|
10
|
+
|
|
11
|
+
window = tk.Tk()
|
|
12
|
+
window.geometry("600x500")
|
|
13
|
+
window.resizable(False, False)
|
|
14
|
+
window.title("Triview")
|
|
15
|
+
render_frame = tk.Frame(window)
|
|
16
|
+
render_frame.pack(side="top", expand = True, fill = "both")
|
|
17
|
+
controls_frame = tk.Frame(window, height=20)
|
|
18
|
+
controls_frame.pack(side="bottom", expand = True, fill = "x")
|
|
19
|
+
controls_frame_left = tk.Frame(controls_frame)
|
|
20
|
+
controls_frame_left.pack(side="left", expand = True, fill = "x")
|
|
21
|
+
controls_frame_right = tk.Frame(controls_frame)
|
|
22
|
+
controls_frame_right.pack(side="right", expand = True, fill = "x")
|
|
23
|
+
tv = TRIVIEW()
|
|
24
|
+
tv.initialize(render_frame, "gray20", "white", "gray20", [0,1.5,-15], 1000,0,0)
|
|
25
|
+
BASE_DIR = os.path.dirname(__file__)
|
|
26
|
+
path = os.path.join(BASE_DIR, "models", "teapot.obj")
|
|
27
|
+
model = tv.load_obj(path)
|
|
28
|
+
if model is None:
|
|
29
|
+
print("Error : Cannot Load Model")
|
|
30
|
+
quit()
|
|
31
|
+
vertices, faces = model
|
|
32
|
+
|
|
33
|
+
def change_x(amount):
|
|
34
|
+
tv.camera[0] += amount
|
|
35
|
+
projected = tv.project_vertices(vertices)
|
|
36
|
+
tv.render_mesh(projected, faces)
|
|
37
|
+
|
|
38
|
+
def change_y(amount):
|
|
39
|
+
tv.camera[1] += amount
|
|
40
|
+
projected = tv.project_vertices(vertices)
|
|
41
|
+
tv.render_mesh(projected, faces)
|
|
42
|
+
|
|
43
|
+
def change_z(amount):
|
|
44
|
+
tv.camera[2] += amount
|
|
45
|
+
projected = tv.project_vertices(vertices)
|
|
46
|
+
tv.render_mesh(projected, faces)
|
|
47
|
+
|
|
48
|
+
def change_yaw(amount):
|
|
49
|
+
tv.yaw += amount
|
|
50
|
+
projected = tv.project_vertices(vertices)
|
|
51
|
+
tv.render_mesh(projected, faces)
|
|
52
|
+
|
|
53
|
+
def change_pitch(amount):
|
|
54
|
+
tv.pitch += amount
|
|
55
|
+
projected = tv.project_vertices(vertices)
|
|
56
|
+
tv.render_mesh(projected, faces)
|
|
57
|
+
|
|
58
|
+
window.update()
|
|
59
|
+
projected = tv.project_vertices(vertices)
|
|
60
|
+
tv.render_mesh(projected, faces)
|
|
61
|
+
|
|
62
|
+
tk.Label(controls_frame_left, text="W - Move Forward", font=('Arial', 15, "bold")).pack(anchor="w", padx=(40,0))
|
|
63
|
+
tk.Label(controls_frame_left, text="A - Move Left", font=('Arial', 15, "bold")).pack(anchor="w", padx=(40,0))
|
|
64
|
+
tk.Label(controls_frame_left, text="S - Move Backward", font=('Arial', 15, "bold")).pack(anchor="w", padx=(40,0))
|
|
65
|
+
tk.Label(controls_frame_left, text="D - Move Right", font=('Arial', 15, "bold")).pack(anchor="w", padx=(40,0))
|
|
66
|
+
|
|
67
|
+
tk.Label(controls_frame_right, text="Up - Move Neck up", font=('Arial', 15, "bold")).pack(anchor="w")
|
|
68
|
+
tk.Label(controls_frame_right, text="Down - Move Neck down", font=('Arial', 15, "bold")).pack(anchor="w")
|
|
69
|
+
tk.Label(controls_frame_right, text="Left - Move Neck Left", font=('Arial', 15, "bold")).pack(anchor="w")
|
|
70
|
+
tk.Label(controls_frame_right, text="Right - Move Neck Right", font=('Arial', 15, "bold")).pack(anchor="w")
|
|
71
|
+
|
|
72
|
+
window.bind("<space>", lambda e: change_y(0.1))
|
|
73
|
+
window.bind("f", lambda e: change_y(-0.1))
|
|
74
|
+
|
|
75
|
+
window.bind("a", lambda e: change_x(-0.1))
|
|
76
|
+
window.bind("d", lambda e: change_x(0.1))
|
|
77
|
+
|
|
78
|
+
window.bind("w", lambda e: change_z(0.1))
|
|
79
|
+
window.bind("s", lambda e: change_z(-0.1))
|
|
80
|
+
|
|
81
|
+
window.bind("<Up>", lambda e: change_pitch(0.01))
|
|
82
|
+
window.bind("<Down>", lambda e: change_pitch(-0.01))
|
|
83
|
+
|
|
84
|
+
window.bind("<Left>", lambda e: change_yaw(-0.01))
|
|
85
|
+
window.bind("<Right>", lambda e: change_yaw(0.01))
|
|
86
|
+
|
|
87
|
+
window.bind("<Configure>", lambda e: tv.render_mesh(tv.project_vertices(vertices),faces))
|
|
88
|
+
|
|
89
|
+
window.mainloop()
|