This project demonstrates a simple 3D perspective projection of an object using Python and the Pygame library. The user can control the position of the object along different axes, change the Object itself and control different values.
- Use W and S keys to move the object up and down along the y-axis.
- Use A and D keys to move the object left and right along the x-axis.
- Use Y and X keys to move the object forward and backward along the z-axis.
- Python standard library
- Pygame library
- Numpy library
- Install Python: https://www.python.org/downloads/
- Install Pygame:
pip install pygame
- Install Numpy:
pip install numpy
- Clone the repository:
git clone https://github.com/codeChaosConductor/Simple-3D-Object-Projection/
- Navigate to the project directory:
cd <project-directory>
- Run the script:
python simple_object_projection.py
You can customize the following parameters in the script:
fov
: Field of view for the perspective projection.far
: Far clipping plane distance.near
: Near clipping plane distance.speed
: Movement speed of the object.draw_vertices
: Set toTrue
to draw vertices.draw_edges
: Set toTrue
to draw edges.
You can create new objects by using the following lists in create_object_mesh.py
points
: List of 3D coordinates representing object vertices.edge_connections
: List of connections between vertices to create edges.face_connections
: List of connections between vertices to create faces. Enter the filename of the object and run the script to create the object. Now changefilename
insimple_object_projection
to the desired object and run the script.
- Developed by Fynn Mannack
- If you use this code in your project, please provide attribution by linking to this repository in your project documentation or source code.
This code was written as a part of my research paper (Facharbeit) about 3D-animations.
Feel free to modify the code, experiment with different objects, and integrate it into your own projects! If you find any issues or have suggestions, please create an issue or pull request.