SkillAgentSearch skills...

Pyn3D

A Python 3D Game Engine and Renderer - With Mesh Tools

Install / Use

/learn @underpig1/Pyn3D
About this skill

Quality Score

0/100

Supported Platforms

Universal

README

Pyn3D

A Python 3D Game Engine and Renderer - Now With Mesh Tools

What Is Pyn?

Pyn is a Python 3D game engine and renderer. It is great for creating your own 3D games from scratch with Python, and includes great mesh tools and environmental features. Pyn allows simple physics and easy manipulation to create 3D visualizers, games, and more. Pyn has lighting, materials, and textures, and is completely free and open-source. It is very easy to use and create your own meshes and renders, as well as built-in mesh tools to manipulate your meshes.

For more information, see the documentation wiki
Install Pyn
Try a Project

Documentation

Contents


<a name = "intro"></a>

Introduction to Pyn

Pyn is a Python 3D game engine and renderer. It is great for creating your own 3D games from scratch with Python, and includes great mesh tools and environmental features. Pyn allows simple physics and easy manipulation to create 3D visualizers, games, and more. Pyn has lighting, materials, and textures, and is completely free and open-source. It is very easy to use and create your own meshes and renders, as well as built-in mesh tools to manipulate your meshes.

<a name = "start"></a>

Getting Started

Starting with Pyn is very simple:

from Pyn3D import *

All Pyn programs must begin with the init() script.

The Camera class creates a camera in your scene.

The Mouse class creates a mouse, and allows editing of the cursor and other properties.

The window() function creates and updates the window with your specifications.

Simple example program:

from Pyn3D import *

init()
# initialize window
cam = Camera(pos = (0, 0, -5))
mouse = Mouse()
# creates a camera and mouse object

Light(pos = (0, 3, 0), strength = 10)
Cube(pos = (0, 0, 0))
# creates a light and cube object

while True:
    window(cam)
    # updates the window

<a name = "init"></a>

Init

Starting with Pyn needs the init script to create a window.

init(width, height)

The width and height properties determine the window's width and height. The default width and height is 400 by 400.

<a name = "mouse"></a>

Mouse

The Mouse object is needed to determine the properties and position of the mouse or cursor.

Mouse(pos, visible, lock, cursor)
Position:
  • Vector2 tuple
  • The starting position of the cursor
Mouse(pos = (0, 0))
Visible:
  • 0 or 1 integer
  • Visibility of the cursor
Mouse(visible = 0)
Lock:
  • 0 or 1 integer
  • Locks cursor to window
Mouse(lock = 1)
Cursor:
  • Pygame cursor
  • Cursor display
Mouse(cursor = pygame.cursors.arrow)

<a name = "window"></a>

Window

The window() function updates the window to your specifications.

window(camera, background, light)
Camera:
  • Camera object
  • Camera perspective displayed in the window
window(camera = cam)
Background:
  • RGB tuple
  • Background color of the window
window(background = (255, 255, 255))
Light:
  • Bool
  • Determines whether the background color is affected by Light objects
window(light = True)

<a name = "camera"></a>

Camera

Cameras are needed in Pyn programs for visualization.

Camera(pos, rot, fly, fixed, spd)
Position:
  • Vector3 tuple
  • The position of the camera
Camera(pos = (0, 0, -5))
Rotation:
  • Vector2 tuple
  • The rotation of the camera
Camera(rot = (0, 0))
Flight:
  • Bool
  • If the camera can fly using Q and E keys
Camera(fly = False)
Fixed:
  • Bool
  • If the camera cannot move using W, A, S, and D keys
Camera(fixed = False)
Speed:
  • Float
  • Speed of the camera when moving
Camera(spd = 0.5)
Bounding Box:
  • List of Vector3 tuples
  • Bounding box vertices for collision detection
cam.bbox = [(-0.5, -0.5, -0.5), (0.5, -0.5, -0.5), (0.5, 0.5, -0.5), (-0.5, 0.5, -0.5), (-0.5, -0.5, 0.5), (0.5, -0.5, 0.5), (0.5, 0.5, 0.5), (-0.5, 0.5, 0.5)]
Check Collisions:
  • Object
  • Checks collisions with other object
cam.checkCollisions(cube)

<a name = "objects"></a>

Objects

Objects are empty 3D objects which can be used for displaying visuals.

Object(pos, size, material, parent, physic)
Position:
  • Vector3 tuple
  • The position of the object
Object(pos = (0, 0, -5))
Size:
  • Float
  • The size of the object
Object(size = 5)
Material:
  • Material object index
  • The size of the object
Object(material = 0)
Parent:
  • Parent object
  • The parent of the object
Object(parent = cam)
Physic:
  • Physic list
  • The physics properties of the object
Object(physics = ["softbody", "gravity", "collider"])
Check Collisions:
  • Object
  • Checks collisions with other object
object.checkCollisions(cube)
Rotate:
  • X, Y, Z floats
  • Rotates object
object.rotate((10, 10, 10))
Move:
  • X, Y, Z floats
  • Moves object
object.move(0, 10, 0)
Place:
  • X, Y, Z floats
  • Places object
object.place(0, 0, 10)
Scale:
  • X, Y, Z floats
  • Scales object
object.scale(10, 0, 0)

<a name = "meshes"></a>

Meshes

Meshes are pre-built meshes which come with Pyn and already-made coordinates.

Some pre-made meshes:

Cube()
Plane()
Point()
Line()
Circle()

<a name = "polygons"></a>

Polygons

Polygons are 3D buildable objects based on Vector3D tuple X, Y, Z coordinates.

Example:

Polygon(args = [(0, 0, 0), (10, 10, 10), (0, 10, 0), (0, 0, 0)])
# creates a polygon mesh face based on X, Y, Z coordinates

<a name = "customs"></a>

Custom Meshes

Custom Meshes are buildable 3D meshes based on vertices, faces, and default face colors.

Example

class MyMesh(Object):
     vertices = [(-4, -1, -1), (1, -1, -1), (1, 1, -1), (-3, 1, -1), (-4, -1, 1), (1, -1, 1), (1, 1, 1), (-3, 1, 1)]
     faces = [(0, 1, 2, 3), (4, 5, 6, 7), (0, 1, 5, 4), (2, 3, 7, 6), (0, 3, 7, 4), (1, 2, 6, 5)]
     colors = [(100, 0, 0), (50, 50, 10), (100, 50, 50), (50, 100, 50), (50, 100, 100), (50, 50, 100), (50, 10, 100), (50, 100, 100), (50, 100, 10), (10, 50, 100)]

Custom Meshes must be an instance of the Object class.

<a name = "lights"></a>

Lights

Lights are needed for lighting effects.

Light(pos, strength)

Lights can cause changes in color and brightness for objects, as well as the window background color.

Position:
  • Vector3 tuple
  • The position of the object
Light(pos = (0, 0, 0))
Strength:
  • Integer
  • The strength of the light
Light(strength = 10)

<a name = "materials"></a>

Materials

Materials are objects for materializing meshes.

Material(color, emmission)

Materials can then be assigned to meshes.

Color:
  • RBG float
  • The color of the material
Light(color = (0, 0, 0))
Emmision:
  • Integer
  • The emission factor of the material
Light(emmission = 1)

<a name = "texturing"></a>

Texturing

Texturing is a method of assigning an image or pixel map texture to the mesh using materials. Textures are texture objects for texturing meshes.

Texture()

Textures can be created using pixel maps or images, and must be assigned to the object by colors, each pixel being assigned a certain color. Mesh Tools are required for pixelating the mesh to add the pixel map to the mesh.

<a name = "imagetextures"></a>

Image Textures

Image Textures are texture objects for texturing meshes using images.

Texture(path)
Path:
  • String
  • The path of the image
Texture(path = "myImage.png")

<a name = "maptextures"></a>

Map Textures

Map Textures are texture objects based on a pixel map.

Texture()

Map textures can also be based on image textures.

Pixmap:
  • List of RGB tuples
  • The pixel map of the texture
texture.pixmap = [(0, 0, 0), (10, 10, 10), (0, 0, 0), (10, 10, 10)]

<a name = "usingmaterials"></a>

Using Materials

Materials can be assigned though meshes' material variable.

myMaterial = Material(color = (0, 10, 0), emmision = 10)
Object(material = myMaterial)

<a name = "changecolor"></a>

Change Color

The changeColor() function brightens or darkens a color.

changeColor(rgb, scale)
RGB:
  • RBG float
  • The color of the UI object
changeColor(rgb = (100, 100, 100))
Scale:
  • Integer
  • Amount to darken or lighten
changeColor(scale = 10)

<a name = "ui"></a>

UI

UI objects are displayed on top of t

View on GitHub
GitHub Stars6
CategoryDevelopment
Updated3mo ago
Forks2

Languages

Python

Security Score

87/100

Audited on Dec 19, 2025

No findings