skip to navigation
skip to content

Not Logged In

pi3d 1.8a

pi3d OpenGLES2 3D graphics library

Latest Version: 1.13

Introduction to Pi3D

Pi3D written by Tim Skillman, Paddy Gaunt, Tom Ritchford Copyright (c) 2014

High speed, hardware accelerated 3D graphics with easy to use python code. Runs on Raspberry Pi and linux computers (with reasonably recent graphics cards).

documentation: http://pi3d.github.io/html/index.html

demos: https://github.com/pi3d/pi3d_demos

source code: https://github.com/tipam/pi3d

A Very Brief Explanation

The whole idea of Pi3d is that you don’t have to get involved in too many of the nuts and bolts of how the OpenGL graphics processor works however it might help to get an overview of the layout of Pi3d. More detailed explanations can be found in the documentation of each of the modules. Read http://pi3d.github.io/html/FAQ.html before you try anything ambitious or if anything goes wrong, obviously. There is a http://pi3d.github.io/html/GPUexplain.html where I try to explain in some more detail what is going on.

Display The Display class is the core and is used to hold screen dimension information, to initiate the graphics functionality and for ‘central’ information, such as timing, for the animation. There needs to be an instance of Display in existence before some of the other objects are created so it’s a good idea to create one first job.

Shape All objects to be drawn by Pi3d inherit from the Shape class which holds details of position, rotation, scale as well as specific data needed for drawing the shape. Each Shape contains an array of Buffer objects; normally only containing one but there could be more in complicated models created with external 3D applications.

Buffer The Buffer objects contain the arrays of values representing vertices, normals, faces and texture coordinates in a form that can be quickly read by the graphics processor. Each Buffer object within a Shape can be textured using a different image or shade (RGB) value and, if needed, a different Shader

Shader The Shader class is used to compile very fast programs that are run on the graphics processor. They have two parts: Vertex Shaders that do calculation for each of the vertices of the Buffer and Fragment Shaders applied to each pixel. In Pi3d we have kept the shaders out of the main python files and divided them using the two extensions .vs and .fs The shader language is C like, very clever indeed, but rather hard to fathom out.

Camera In order to draw a Shape on the Display the Shader needs to be passed the vertex information in the Buffers and needs know how the Shape has been moved. But it also needs to know how the Camera has moved. The Camera class generally has just one instance and if you do not create one explicitly then Display will generate a default one when you first try to draw something. The Camera has position and rotation information similar to Shapes but also information to create the view, such as how wide-angle or telephoto the lens is.

Texture The Texture objects are used to load images from file into a form that can be passed to the Shader to draw onto a surface. They can also be applied as normal maps to give much finer local detail or as reflection maps - a much faster way to make surfaces look shiny than ray tracing.

Light To produce a 3D appearance most of the Shaders use directional lighting and if you draw a Shape without creating a Light a default instance will be created by the Display. The Light has properties defining the direction, the colour (and strength i.e. RGB values) and ambient colour (and strength).

Acknowledgements

Pi3D started with code based on Peter de Rivaz ‘pyopengles’ (https://github.com/peterderivaz/pyopengles) with some tweaking from Jon Macey’s code jonmacey.blogspot.co.uk/2012/06/)

Many Thanks, especially to Peter de Rivaz, Jon Macey, Richar Urwin, Peter Hess, David Wallin and others who have contributed to Pi3D - keep up the good work!

 
File Type Py Version Uploaded on Size
pi3d-1.9.tar.gz (md5) Source 2014-08-02 153KB
  • Downloads (All Versions):
  • 41 downloads in the last day
  • 411 downloads in the last week
  • 649 downloads in the last month