Lumina Renderer is an open-source, feature-rich 3D rendering engine built using PyQt5 and OpenGL. It supports rendering OBJ models, cube generation, material and texture customization, and interactive user controls. Designed with flexibility and scalability in mind, Lumina Renderer is suitable for educational purposes, game development, and various other applications.
- OBJ Model Support: Load and render 3D models from OBJ files with support for materials and textures.
- Cube Generation: Quickly generate 3D cubes for testing and prototyping.
- Interactive Controls: Mouse controls for rotating, zooming, and panning the camera view.
- Material Customization: Use a color picker to customize materials on the fly.
- Performance Optimizations: Leveraging OpenGL Vertex Buffer Objects (VBOs) for efficient rendering.
- Extensible Design: Easily extend the renderer with more features or customize it for specific use cases.
- Animation Support: Basic animation capabilities to animate models within the scene.
lumina-renderer/
│
├── README.md # Project documentation
├── requirements.txt # Python dependencies
├── main.py # Entry point of the application
├── assets/
│ └── models/ # Sample OBJ models for testing
└── src/
├── __init__.py # Package initialization
├── gl_widget.py # OpenGL widget for rendering
├── main_window.py # Main application window
└── obj_model.py # OBJ model loading and processing
- Python 3.6 or higher
- Pip package manager
- Clone the repository:
git clone https://github.com/vanthunder/lumina-renderer.git
cd lumina-renderer
- Create a virtual environment (optional but recommended):
python -m venv venv
source venv/bin/activate # On Windows use `venv\Scripts\activate`
- Install the required dependencies:
pip install -r requirements.txt
- Run the application:
python main.py
- Create Cube: Click the "Create Cube" button to generate and display a simple 3D cube.
- Load OBJ: Click the "Load OBJ" button to open a file dialog and select an OBJ file to load and render.
- Change Material Color: Click the "Change Material Color" button to open a color picker and change the material color of the model.
- Rotate Model: Click and drag with the right mouse button to rotate the model around the X and Y axes.
- Pan View: Click and drag with the middle mouse button (or scroll wheel) to pan the view horizontally and vertically.
- Zoom In/Out: Use the mouse wheel to zoom in and out of the scene.
- Esc: Close the application.
- Click on the "Load OBJ" button.
- Navigate to the
assets/models/
directory or any directory containing your OBJ files. - Select the desired OBJ file and click "Open".
- The model will be loaded and displayed in the OpenGL widget.
- Click on the "Change Material Color" button.
- Use the color picker dialog to select a new color.
- Click "OK" to apply the color to the model.
Ensure that the project structure is maintained as shown above. The src
directory contains the main application modules:
gl_widget.py
: Contains the GLWidget class, responsible for rendering the 3D scene using OpenGL.main_window.py
: Contains the MainWindow class, which sets up the main application window and user interface.obj_model.py
: Contains the OBJModel class, which handles loading and parsing of OBJ files.
The project relies on the following Python packages:
- PyQt5: For the GUI components and window management.
- PyOpenGL: To access OpenGL functions for rendering.
- NumPy: For efficient numerical computations, particularly when handling vertex data.
These are specified in the requirements.txt
file:
PyQt5>=5.15.0
PyOpenGL>=3.1.5
NumPy>=1.19.0
You can run the application using the main.py
script:
python main.py
The entry point of the application. It initializes the PyQt application and displays the main window.
Defines the MainWindow class, which sets up the user interface, including buttons and the OpenGL widget. It handles user interactions and events.
Defines the GLWidget class, which is a subclass of QOpenGLWidget. It handles all OpenGL rendering, including initializing the OpenGL context, rendering the scene, and responding to user input for interaction.
Defines the OBJModel class, responsible for loading and parsing OBJ files. It handles vertices, normals, and faces, and provides functionality to generate a cube model.
- ImportError: If you encounter import errors related to PyQt5 or PyOpenGL, ensure that the packages are installed correctly and match the versions specified in
requirements.txt
. - OpenGL Errors: If the application reports OpenGL errors, ensure that your system's graphics drivers are up to date and support the required OpenGL version.
- Model Rendering Issues: If models are not rendering correctly (e.g., missing faces), check the OBJ files for correctness. The renderer expects faces to be defined in a counter-clockwise order.
- Enable Face Culling: Uncomment
glEnable(GL_CULL_FACE)
ininitializeGL()
to enable face culling, which can help identify issues with face winding. - OpenGL Error Checking: Add
glGetError()
calls after OpenGL functions to check for errors. - Logging: Use Python's logging module to add debug statements and track the application's state.
Contributions are welcome! Please follow these steps to contribute:
- Fork the repository on GitHub.
- Clone your forked repository:
git clone https://github.com/vanthunder/lumina-renderer.git
cd lumina-renderer
- Create a new branch for your feature or bug fix:
git checkout -b feature/your-feature-name
- Make your changes to the codebase.
- Commit your changes with descriptive messages:
git commit -am 'Add new feature: description of feature'
- Push your branch to GitHub:
git push origin feature/your-feature-name
- Open a pull request on the main repository.
- Describe your changes in detail and submit the pull request.
This project is licensed under the MIT License. See the LICENSE file for details.
- PyQt5: For providing a powerful set of tools for creating GUIs in Python.
- PyOpenGL: For making OpenGL accessible in Python applications.
- NumPy: For efficient numerical computations.
For questions, suggestions, or issues, please open an issue on the GitHub repository or contact the maintainers directly.