forked from poliastro/poliastro
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e7d82c7
commit ffe5b19
Showing
10 changed files
with
138 additions
and
107 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import os | ||
import sys | ||
|
||
sys.path.insert(0, os.path.abspath('../../')) | ||
|
||
project = '3D Render' | ||
author = 'Rahul R. Sah' | ||
release = '0.1' | ||
|
||
extensions = [ | ||
'sphinx.ext.autodoc', | ||
'sphinx.ext.napoleon', | ||
'sphinx_rtd_theme', | ||
'myst_parser', | ||
] | ||
|
||
templates_path = ['_templates'] | ||
exclude_patterns = [] | ||
|
||
html_theme = 'sphinx_rtd_theme' | ||
html_static_path = ['_static'] | ||
|
||
myst_enable_extensions = [ | ||
"colon_fence", | ||
"deflist", | ||
"html_admonition", | ||
"html_image", | ||
"linkify", | ||
"replacements", | ||
"smartquotes", | ||
"substitution", | ||
"tasklist", | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
Data Loader Module | ||
================== | ||
|
||
.. automodule:: render.data_loader | ||
:members: | ||
:undoc-members: | ||
:show-inheritance: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
Example Render Module | ||
================== | ||
|
||
.. automodule:: example_render | ||
:members: | ||
:undoc-members: | ||
:show-inheritance: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
.. Project documentation master file, created by | ||
sphinx-quickstart on Thu Jan 16 07:16:25 2025. | ||
You can adapt this file completely to your liking, but it should at least | ||
contain the root `toctree` directive. | ||
3D Asteroid Rendering documentation! | ||
======================================== | ||
|
||
.. toctree:: | ||
:maxdepth: 2 | ||
:caption: Contents: | ||
|
||
scene | ||
data_loader | ||
example | ||
|
||
.. include:: ../../README.md | ||
|
||
|
||
Indices and tables | ||
================== | ||
|
||
* :ref:`genindex` | ||
* :ref:`modindex` | ||
* :ref:`search` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
Scene Module | ||
============ | ||
|
||
.. automodule:: render.scene | ||
:members: | ||
:undoc-members: | ||
:show-inheritance: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,37 @@ | ||
"""@author: Rahul R. Sah, Physics and Computer Science Department, Furman University | ||
[email protected]. | ||
""" | ||
This module demonstrates how to render a 3D model using Vispy. | ||
The module includes the following steps: | ||
1. Load the 3D model data from a file. | ||
2. Create a MainWindow instance. | ||
3. Set the 3D model in the MainWindow. | ||
4. Run the Vispy application. | ||
Usage: | ||
python example_render.py | ||
""" | ||
|
||
# How to render using this module | ||
from vispy import app | ||
from render.scene import MainWindow | ||
from render.data_loader import load_data | ||
|
||
vertices, faces = load_data("test_data/ROS_ST_K020_OSPCLAM_U_V1.OBJ") | ||
main_w = MainWindow() | ||
main_w.set_model(vertices, faces) | ||
def main(): | ||
""" | ||
Main function to render the 3D model. | ||
This function performs the following steps: | ||
1. Load the 3D model data from a file. | ||
2. Create a MainWindow instance. | ||
3. Set the 3D model in the MainWindow. | ||
4. Run the Vispy application. | ||
""" | ||
|
||
vertices, faces = load_data("test_data/ROS_ST_K020_OSPCLAM_U_V1.OBJ") | ||
main_w = MainWindow() | ||
main_w.set_model(vertices, faces) | ||
app.run() | ||
|
||
app.run() | ||
if __name__ == "__main__": | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,12 @@ | ||
"""@author: Rahul R. Sah, Physics and Computer Science Department, Furman University | ||
[email protected]. | ||
"""This module provides functionality to load 3D model data from a file. | ||
The `load_data` function reads a file containing 3D model data, extracts the vertex and face | ||
information, and returns them as numpy arrays. The file is expected to be in a specific format | ||
where each line represents either a vertex or a face. Vertices are denoted by lines starting | ||
with 'v' and faces by lines starting with 'f'. | ||
The function uses pandas to read the file and process the data. The vertices and faces are | ||
extracted based on their respective identifiers and returned as numpy arrays. | ||
""" | ||
|
||
import pandas as pd | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,3 @@ | ||
"""@author: Rahul R. Sah, Physics and Computer Science Department, Furman University | ||
[email protected]. | ||
""" | ||
import numpy as np | ||
from vispy import scene | ||
from vispy import app | ||
|
@@ -11,6 +8,11 @@ class MainWindow(scene.SceneCanvas): | |
""" | ||
Main window for rendering 3D models using Vispy. | ||
This class provides a graphical interface for rendering 3D models using the Vispy library. | ||
It sets up a scene canvas with interactive capabilities, allowing users to visualize and | ||
interact with 3D models. The canvas includes a grid layout and a view with a turntable | ||
camera for easy manipulation of the 3D scene. | ||
Parameters | ||
---------- | ||
*args : tuple | ||
|
@@ -28,6 +30,9 @@ def set_model(self, vertices, faces): | |
""" | ||
Set the 3D model to be rendered. | ||
This method takes arrays of vertices and faces, creates a mesh from them, and adds | ||
the mesh to the view for rendering. The mesh is shaded smoothly and colored grey. | ||
Parameters | ||
---------- | ||
vertices : numpy.ndarray | ||
|
@@ -39,11 +44,3 @@ def set_model(self, vertices, faces): | |
mesh = visuals.Mesh(meshdata=mesh_data, shading='smooth', color="grey") | ||
self.view.add(mesh) | ||
|
||
vertices = np.array([[1.0, 2.0, 3.0], | ||
[4.0, 5.0, 6.0]]) | ||
|
||
faces = np.array([[2, 2, 4]]) | ||
main_w = MainWindow() | ||
|
||
main_w.set_model(vertices, faces) | ||
app.run() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
[tox] | ||
envlist = docs | ||
|
||
[testenv:docs] | ||
deps = | ||
sphinx | ||
sphinx_rtd_theme | ||
myst-parser | ||
pandas | ||
numpy | ||
vispy | ||
commands = | ||
sphinx-build -b html docs/source docs/build/html |