diff options
| author | alonrubintec <alonrubintech@gmail.com> | 2023-02-01 18:06:38 +0200 |
|---|---|---|
| committer | alonrubintec <alonrubintech@gmail.com> | 2023-02-01 18:06:38 +0200 |
| commit | f61c4d284d979c81cfaf1d22c22e09cdb0c7c569 (patch) | |
| tree | 591a87f55712da50f4e17a50e1c4688b8a5bf2a3 | |
| parent | 633ea19d966b2e8e25b3f39bbb8ea95b90a4ab38 (diff) | |
Initial commit
| -rw-r--r-- | README.md | 8 | ||||
| -rw-r--r-- | arcball.py | 3 | ||||
| -rw-r--r-- | engine.py | 5 | ||||
| -rw-r--r-- | functions.py | 6 | ||||
| -rw-r--r-- | main.py | 8 | ||||
| -rw-r--r-- | requirements.txt | bin | 0 -> 184 bytes |
6 files changed, 16 insertions, 14 deletions
@@ -1,12 +1,12 @@ ## Qt 3DViewer -### Qt 3DViewer is a compact tool for viewing 3D models in a user friendly way. +### Qt 3DViewer is a compact tool for viewing 3D models in a user-friendly way. <br>This project is a compact and user-friendly application designed to showcase <br>3D models in a visually appealing manner. With support for a wide range of <br>file formats including .obj, .stl, .ply, .off, and .om. Powered by Python the PyQt framework, the app use OpenGL, in combination -<br>with ModernGL to render the 3D models and scenes in a interactive experience. +<br>with ModernGL to render the 3D models and scenes in an interactive experience. <br>Designed and developed by Alon Rubin. @@ -27,8 +27,8 @@ Powered by Python the PyQt framework, the app use OpenGL, in combination ### How to install: 1. Install Python 3.9 -2. Install PyQt 5 -3. Import all the Libraries +2. Install requirements +3. run "main.py" file ## Like this project? @@ -92,7 +92,8 @@ class ArcBallUtil(ArcBall): self.click(mouse_pt) return - def Matrix4fSetRotationFromMatrix3f(self, NewObj, m3x3): + @staticmethod + def Matrix4fSetRotationFromMatrix3f(NewObj, m3x3): scale = np.linalg.norm(NewObj[:3, :3], ord='fro') / np.sqrt(3) NewObj[0:3, 0:3] = m3x3 * scale scaled_NewObj = NewObj @@ -148,14 +148,15 @@ class QGLControllerWidget(QtOpenGL.QGLWidget): self.grid_alpha_value = (alpha*0.01) def background_color(self, color): - self.bg_color = color = color + self.bg_color = color def update_fov(self, num): self.fov = num self.camera_zoom = self.camera_distance(num) self.update() - def camera_distance(self, num): + @staticmethod + def camera_distance(num): return 1 / (math.tan(math.radians(num / 2))) def update_grid_cell(self, cells): diff --git a/functions.py b/functions.py index 043bc16..8d65204 100644 --- a/functions.py +++ b/functions.py @@ -5,7 +5,7 @@ import openmesh import re -def open_file( opengl_obj, obj_path, obj_name, uv_label, material_label, drawcalls_label, vertices_label, triangles_label, edges_label): +def open_file(opengl_obj, obj_path, obj_name, uv_label, material_label, drawcalls_label, vertices_label, triangles_label, edges_label): file_name = QtWidgets.QFileDialog.getOpenFileName( None, 'Open file', '', "Mesh files (*.obj *.stl *.ply *.off *.om)") if not file_name[0]: @@ -59,7 +59,7 @@ def draw_calls(file_path, drawcalls_label): with open(file_path, "r") as file: contents = file.read() draw = tuple(re.findall(r'usemtl (\S+)', contents)) - if len(draw)>1: + if len(draw) > 1: drawcalls_label.setText(str(len(draw))) else: drawcalls_label.setText(str(1)) @@ -100,7 +100,7 @@ def change_slider(slider, line, openGL, btn_name=""): openGL.update_grid_alpha(value) -def updateSlider(slider, line): +def update_slider(slider, line): value = int(line.text()) slider.setValue(value) @@ -41,13 +41,13 @@ class MainWindow(QtWidgets.QMainWindow): # Settings Sliders self.fov_slider.valueChanged.connect(lambda: f.change_slider(self.fov_slider, self.fov_slider_value, self.openGL, "fov")) - self.fov_slider_value.textChanged.connect(lambda: f.updateSlider(self.fov_slider, self.fov_slider_value)) + self.fov_slider_value.textChanged.connect(lambda: f.update_slider(self.fov_slider, self.fov_slider_value)) self.grid_slider.valueChanged.connect(lambda: f.change_slider(self.grid_slider, self.grid_slider_value, self.openGL, "na")) - self.grid_slider_value.textChanged.connect(lambda: f.updateSlider(self.grid_slider, self.grid_slider_value)) + self.grid_slider_value.textChanged.connect(lambda: f.update_slider(self.grid_slider, self.grid_slider_value)) # Settings Sliders self.wireframe_slider.valueChanged.connect(lambda: f.change_slider(self.wireframe_slider, self.wireframe_slider_value, self.openGL, "wireframe")) - self.wireframe_slider_value.textChanged.connect(lambda: f.updateSlider(self.wireframe_slider, self.wireframe_slider_value)) + self.wireframe_slider_value.textChanged.connect(lambda: f.update_slider(self.wireframe_slider, self.wireframe_slider_value)) # Settings radio buttons self.wireframe_radio.toggled.connect(lambda: self.openGL.make_wireframe()) @@ -57,7 +57,7 @@ class MainWindow(QtWidgets.QMainWindow): self.grid_cell.textChanged.connect(lambda: f.update_grid_size(self.grid_cell, self.openGL, "cell")) self.grid_size.textChanged.connect(lambda: f.update_grid_size(self.grid_size, self.openGL, "size")) self.grid_slider.valueChanged.connect(lambda: f.change_slider(self.grid_slider, self.grid_slider_value, self.openGL, "grid")) - self.grid_slider_value.textChanged.connect(lambda: f.updateSlider(self.grid_slider, self.grid_slider_value)) + self.grid_slider_value.textChanged.connect(lambda: f.update_slider(self.grid_slider, self.grid_slider_value)) if __name__ == '__main__': diff --git a/requirements.txt b/requirements.txt Binary files differnew file mode 100644 index 0000000..d3c5d6b --- /dev/null +++ b/requirements.txt |
