PG3D is a simple 3D graphics library written using Pygame.
- Install Python 3.7 or newer. https://www.python.org/downloads/
- Open cmd/terminal and type:
pip install pg3d
- python 3.7+
- pygame
- Import the library
from pg3d import *
- Create an App instance and call the run function
app = App()
#---Code goes here---#
#--------------------#
app.run()
App(kwargs):
kwargs:
dimensions=(1000, 700)
cam_pos=[0, 0, 0]
BG_COLOR=None
LINE_COLOR=None
VERTEX_SIZE=2
fullscreen=False
mouse_look=False # Use mouse for camera orientation
functions:
run() # Draws all vertices and checks for movement
Model(args)
args:
app # Specify the App() object
path # Specify path of .obj file
Pyramid(args, kwargs)
args:
app # Specify the App() object
kwargs:
size=1
center=[0, 0, 0]
Cube(args, kwargs)
args:
app # Specify the App() object
kwargs:
size=1
center=[0, 0, 0]
Tetrahedron(args, kwargs)
args:
app # Specify the App() object
kwargs:
size=1
center=[0, 0, 0]
Triangle(args)
args:
app # Specify the App() object
vertices # List or tuple with 3 cartesian coordinates
functions:
__getitem__(index) # Returnes indext point of Triangle object
Point(args, kwargs)
args:
app # Specify the App() object
coordinate # A list with a single cartesian coordinate
kwargs:
vertex=True # If true the point is drawn and vice versa
functions:
__repr__() # Prints Point object
__setitem__(index, value) # Sets indexed coordinate of Point object to value
__getitem__(index) # Returns indexed coordinate of Point object