Skip to main content

"3D Graphics Programming Toolkit"

Project description

Payton 3D SDK

example workflow Downloads Downloads

Payton is a 3D Software Development Kit that serves as a general-purpose playground for programming. With Payton, users can quickly and easily kickstart their ideas and create tools for the next step, such as map editors, small animations, small algorithms, or artificial intelligence for games. Unlike game engines and other libraries that can be too complex and time-consuming to start, Payton comes with pre-set defaults, making it unique and simple to use.

Payton is not intended to be a game engine or a full-featured 3D environment as there are already plenty of tools available for those purposes. However, it excels at tools programming and allows users to easily visualize their goals and achieve them. Users can also move forward from Payton to any other place if they desire.

While 2D graphs and charts are useful in reports, some cases require visualizing data in 3 or 4 dimensions. Payton enables users to extend their graphics into 4 dimensions and read real-time data from sensors, cameras, or any other data source. These sources can be anything that generates time-based 3D data, including thermometers, random number generators, toy cars connected to speed sensors, maps, or vehicle ports. Payton can even handle time-based formulas. Although it can get complex, Payton is designed to be easy to use, even for beginners who can follow the tutorials to kick-start their programming skills.

Contents of this Document:

Features:

  • 3D Math Library
  • Various base geometries:
    • Cube
    • Cylinder
    • Triangular Mesh
    • Plane
    • Lines
    • Particle System
    • Sphere
    • Dynamic Grid
  • Clean default scene
  • Pre-defined keyboard-mouse and camera controls
  • Pre-defined environment
  • Clock system for parallel tasks and time-based operations
  • Simple collision detection
  • Optional Physics Engine
    • Basic support for Bullet Physics (to be extended)
  • Extendable controllers
  • Pre-defined lighting with shadows
  • Material support
  • Clickable objects and virtual planes
  • Shader support
  • Basic GUI Support
    • Window
    • Panel
    • Button
    • EditBox (with multi-line support)
  • 3D File formats:
    • AWP3D Animated High-Poly 3D Object
    • Wavefront OBJ
    • Quake 2 MD2 with Animations
  • Mesh Generation Tools
    • Extrude Line in 3D
    • Rotate Line around an axis in 3D
    • Fill between lines
  • Mesh modifiers:
    • Merge Mesh
    • Subdivide Mesh
  • Extensive examples for every feature

Install

Requirements:

  • LibSDL2 sudo apt install libsdl2-dev for debian/ubuntu based linux distros. For other platforms, you can see your favourite package manager.
  • imagemagick sudo apt install imagemagick for debian/ubuntu based linux distros. For other platforms, you can see your favourite package manager.
  • Python 3.10+
  • A Graphics card that supports OpenGL 3.3+

Install using Pip:

From a bash terminal:

pip install payton

This should install all dependencies. If you get any permission errors, you are probably installing the library to system-global so missing some permissions. If you do not want to use pipenv or virtualenv, then you might want to run above command as sudo pip3 install payton

Optional Bullet Physics Integration

Payton supports Bullet Physics at a basic level for solid geometries.

pip install pybullet

Once Bullet Physics is successfully installed in the same environment as Payton, it will be automatically activated and you will be able to use its basic properties. Check out the relevant examples.

Optional GTK3 Integration

Instead of SDL2, you can use GTK3 (along with all nice GTK3 widgets) with Payton. https://raw.githubusercontent.com/sinanislekdemir/payton/assets/assets/gtk3.jpg

You need to install Python GTK3 Bindings.

AWP3D Format and Exporter

AWP3D is simply a ZIP file containing every frame as a Wavefront object. To export your animated Blender objects as AWP3D files, you can use the exporter add-on available here:

https://github.com/sinanislekdemir/payton/tree/master/plugins

Using Payton with Anaconda

As of version 0.0.10, Payton is installable on Anaconda. From Anaconda Prompt:

pip install payton

Is sufficient to install Payton and it's dependencies on Anaconda.

Payton will be available to use with Spyder or JupyterLab on local.

Upgrade to the latest version:

Payton is under active maintenance. This means I am spending some time to fix the bugs or make it better. So you might want to upgrade it occasionally.

pip3 install payton --upgrade

should do the trick!

Getting Started

Your first code

from payton.scene import Scene

scene = Scene()
scene.run()

This will create your first empty scene and show it inside an SDL window.

Controls

Key / Action Description
Mouse Wheel Zoom In - Zoom Out
Right Mouse Button Drag Rotate Scene
Middle Mouse Button Drag Pan Scene
Escape Quit Simulation
C Change Camera Mode (Perspective / Orthographic)
Space UnPause / Pause Scene Clocks
G Show / Hide Grid
W Change Display Mode (Solid / Wireframe / Points)
F2 Previous Camera
F3 Next Camera
H Open / Close Help Window

Environment variables

Some options can be configured from the environment variables.

  • SDL_WINDOW_WIDTH: Set window width.
  • SDL_WINDOW_HEIGHT: Set window height.
  • GL_MULTISAMPLEBUFFERES: Set OpenGL multisample buffer count for antialiasing. (usually 1 or 2)
  • GL_MULTISAMPLESAMPLES: Set OpenGL multisample sampling count for antialiasing. (usually 1-16)

Without GL_MULTISAMPLEBUFFERS AND GL_MULTISAMPLESAMPLES, you may notice pixelated graphics. There is no default set for those values because they can vary between graphic cards.

Troubleshooting

In some older systems or where a decent graphics driver is not installed, you can try running Payton code with MESA. It runs fine. There will be some performance decrease. But it will not be noticeable for basic applications.

To enforce MESA 3.3, you can run payton with:

MESA_GL_VERSION_OVERRIDE=3.3 python <path-to-your-payton-code>

Examples

Personally, I don’t really read the long descriptive documentation unless necessary. I like things simple and self-explaining. Therefore, instead of writing long documentations, I write simple examples to use each feature of Payton without digging much into the internals.

Examples can be downloaded from Payton Github Page.

You can either download the whole repository as a zip file or you can just git clone it.

Tested in Windows 10 Paperspace, seems to be working as expected https://user-images.githubusercontent.com/1842484/84317888-38767780-ab76-11ea-8337-a102d7c59275.png

Supports pyBullet solid geometry physics https://www.youtube.com/watch?v=Zt2vnUMLYVs

Example Index

Contribution

  • Please keep using type hints in the main library.
  • Type hinting can be ignored for examples.
  • Example codes should be plain and simple.
  • Every new features should include sensible defaults.
    • Nothing should be too verbose to use.
  • Make sure that make check is clear before pushing your code.
  • Running isort . is not mandatory but highly encouraged.
  • Ever new feature should have an example code.
  • There is a reason why some methods are longer than they should and complex.
    • To reduce code jumps and stack switches.
    • To run faster.

Screenshots and Videos

Examples Showcase:

https://github.com/sinanislekdemir/payton/blob/assets/assets/02.jpg?raw=true https://github.com/sinanislekdemir/payton/blob/assets/assets/04.jpg?raw=true https://github.com/sinanislekdemir/payton/blob/assets/assets/05.jpg?raw=true https://github.com/sinanislekdemir/payton/blob/assets/assets/11.jpg?raw=true https://github.com/sinanislekdemir/payton/blob/assets/assets/awp3d.jpg?raw=true https://github.com/sinanislekdemir/payton/blob/assets/assets/bullet.jpg?raw=true https://github.com/sinanislekdemir/payton/blob/assets/assets/day.jpg?raw=true https://github.com/sinanislekdemir/payton/blob/assets/assets/engrave.jpg?raw=true https://github.com/sinanislekdemir/payton/blob/assets/assets/explosion.jpg?raw=true https://github.com/sinanislekdemir/payton/blob/assets/assets/gui.jpg?raw=true https://github.com/sinanislekdemir/payton/blob/assets/assets/quake.jpg?raw=true https://github.com/sinanislekdemir/payton/blob/assets/assets/ripple.jpg?raw=true https://github.com/sinanislekdemir/payton/blob/assets/assets/spot.jpg?raw=true

Some free-thoughts and decisions:

I've choosen to use List[float] type for Vectors because:

  • I needed something mutable. Otherwise, the number of memory copy and swaps would be too much. So, I've crossed out Tuple and NamedTuple.
  • dataclass has an overhead to convert to C-type floats and arrays in memory.

So, to gain some performance, I have created the main library with a risk of non-strict vector lengths.

Project details


Release history Release notifications | RSS feed

This version

1.3.1

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

payton-1.3.1.tar.gz (207.5 kB view details)

Uploaded Source

Built Distribution

Payton-1.3.1-py3-none-any.whl (215.9 kB view details)

Uploaded Python 3

File details

Details for the file payton-1.3.1.tar.gz.

File metadata

  • Download URL: payton-1.3.1.tar.gz
  • Upload date:
  • Size: 207.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.12.0

File hashes

Hashes for payton-1.3.1.tar.gz
Algorithm Hash digest
SHA256 13edefd72073878dc8ab9ad1be41464a4d43e143020cfcaaa1f2e208d08ba2b4
MD5 b83762bf0f71b4d531bb74a4bb8f8961
BLAKE2b-256 6eef74f686fbe7e8c6ff8ef1848af0cb6d0ae48d65af69ff023a1dd412eadab9

See more details on using hashes here.

File details

Details for the file Payton-1.3.1-py3-none-any.whl.

File metadata

  • Download URL: Payton-1.3.1-py3-none-any.whl
  • Upload date:
  • Size: 215.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.12.0

File hashes

Hashes for Payton-1.3.1-py3-none-any.whl
Algorithm Hash digest
SHA256 3cd4ac3c9a9defc6d28b62dd02aca678e8323d47c54e89b6cdc9395375fe0ab7
MD5 8faf1ea80e8cda9bf0ae35197753924f
BLAKE2b-256 c490061083b714b848782b3e3ab41c65c3c9196d5c0717dfa05af9aaec9f28dc

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page