Sitelet https://github.com/pi3d/pi3d.github.com/tree/master/html
Skip to content

Latest commit

 

History

History
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="X-UA-Compatible" content="IE=Edge" />
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Introduction to pi3d &#8212; pi3d 2.47 documentation</title>
    <link rel="stylesheet" href="/sitelet?url=https%3A%2F%2Fgithub.com%2Fpi3d%2Fpi3d.github.com%2Ftree%2Fmaster%2F_static%2Fclassic.css" type="text/css" />
    <link rel="stylesheet" href="/sitelet?url=https%3A%2F%2Fgithub.com%2Fpi3d%2Fpi3d.github.com%2Ftree%2Fmaster%2F_static%2Fpygments.css" type="text/css" />
    
    <script type="text/javascript" id="documentation_options" data-url_root="./" src="/sitelet?url=https%3A%2F%2Fgithub.com%2Fpi3d%2Fpi3d.github.com%2Ftree%2Fmaster%2F_static%2Fdocumentation_options.js"></script>
    <script type="text/javascript" src="/sitelet?url=https%3A%2F%2Fgithub.com%2Fpi3d%2Fpi3d.github.com%2Ftree%2Fmaster%2F_static%2Fjquery.js"></script>
    <script type="text/javascript" src="/sitelet?url=https%3A%2F%2Fgithub.com%2Fpi3d%2Fpi3d.github.com%2Ftree%2Fmaster%2F_static%2Funderscore.js"></script>
    <script type="text/javascript" src="/sitelet?url=https%3A%2F%2Fgithub.com%2Fpi3d%2Fpi3d.github.com%2Ftree%2Fmaster%2F_static%2Fdoctools.js"></script>
    <script type="text/javascript" src="/sitelet?url=https%3A%2F%2Fgithub.com%2Fpi3d%2Fpi3d.github.com%2Ftree%2Fmaster%2F_static%2Flanguage_data.js"></script>
    
    <link rel="index" title="Index" href="/sitelet?url=https%3A%2F%2Fgithub.com%2Fpi3d%2Fpi3d.github.com%2Ftree%2Fmaster%2Fgenindex.html" />
    <link rel="search" title="Search" href="/sitelet?url=https%3A%2F%2Fgithub.com%2Fpi3d%2Fpi3d.github.com%2Ftree%2Fmaster%2Fsearch.html" />
    <link rel="next" title="Frequently Asked Questions" href="/sitelet?url=https%3A%2F%2Fgithub.com%2Fpi3d%2Fpi3d.github.com%2Ftree%2Fmaster%2FFAQ.html" />
    <link rel="prev" title="Welcome to pi3d’s documentation!" href="/sitelet?url=https%3A%2F%2Fgithub.com%2Fpi3d%2Fpi3d.github.com%2Ftree%2Fmaster%2Findex.html" /> 
  </head><body>
    <div class="related" role="navigation" aria-label="related navigation">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="/sitelet?url=https%3A%2F%2Fgithub.com%2Fpi3d%2Fpi3d.github.com%2Ftree%2Fmaster%2Fgenindex.html" title="General Index"
             accesskey="I">index</a></li>
        <li class="right" >
          <a href="/sitelet?url=https%3A%2F%2Fgithub.com%2Fpi3d%2Fpi3d.github.com%2Ftree%2Fmaster%2Fpy-modindex.html" title="Python Module Index"
             >modules</a> |</li>
        <li class="right" >
          <a href="/sitelet?url=https%3A%2F%2Fgithub.com%2Fpi3d%2Fpi3d.github.com%2Ftree%2Fmaster%2FFAQ.html" title="Frequently Asked Questions"
             accesskey="N">next</a> |</li>
        <li class="right" >
          <a href="/sitelet?url=https%3A%2F%2Fgithub.com%2Fpi3d%2Fpi3d.github.com%2Ftree%2Fmaster%2Findex.html" title="Welcome to pi3d’s documentation!"
             accesskey="P">previous</a> |</li>
        <li class="nav-item nav-item-0"><a href="/sitelet?url=https%3A%2F%2Fgithub.com%2Fpi3d%2Fpi3d.github.com%2Ftree%2Fmaster%2Findex.html">pi3d 2.47 documentation</a> &#187;</li> 
      </ul>
    </div>  

    <div class="document">
      <div class="documentwrapper">
        <div class="bodywrapper">
          <div class="body" role="main">
            
  <div class="section" id="introduction-to-pi3d">
<h1>Introduction to pi3d<a class="headerlink" href="#introduction-to-pi3d" title="Permalink to this headline">¶</a></h1>
<p><strong>pi3d written by Tim Skillman, Paddy Gaunt, Tom Ritchford</strong> Copyright © 2012 - 2021</p>
<img alt="_images/pi3dlogo128.png" class="align-left" src="/sitelet?url=https%3A%2F%2Fgithub.com%2Fpi3d%2Fpi3d.github.com%2Ftree%2Fmaster%2F_images%2Fpi3dlogo128.png" />
<p><a class="reference external" href="/sitelet?url=https%3A%2F%2Fgithub.com%2Fpi3d%2Fpi3d.github.com%2Ftree%2Fmaster%2F%253Ca%2520href%3D"https://youtu.be/TGGmnG_hrz4">RunTests</a" rel="nofollow">https://youtu.be/TGGmnG_hrz4">RunTests</a> is a video of the standard tests, giving an idea of what
pi3d does, also here’s an excellent, self explanatory <a class="reference external" href="/sitelet?url=https%3A%2F%2Fgithub.com%2Fpi3d%2Fpi3d.github.com%2Ftree%2Fmaster%2F%253Ca%2520href%3D"https://youtu.be/gXTU6x8dQJw">YouTube</a" rel="nofollow">https://youtu.be/gXTU6x8dQJw">YouTube</a> video made by
Peter Farrell that covers much of the content of this ReadMe.</p>
<p>There’s plenty of 3D code flying around for the Raspberry Pi,
but much of it is rather complicated to understand and most of it can sit
under the bonnet!</p>
<p>pi3d is a Python module that aims to greatly simplify writing 3D in Python
whilst giving access to the power of the Raspberry Pi GPU. It enables both
3D and 2D rendering and aims to provide a host of exciting commands to load
in textured/animated models, create fractal landscapes, shaders and much more.</p>
<p>The pi3d module runs on platforms other than the Raspberry Pi (On Windows
using pygame, on linux using the X server directly and on Android using
python-for-android) and runs with python 3 as well as 2.
The OpenGLES2.0 functionality of the Raspberry Pi or Android is used directly
or via mesa or ANGLE on ‘big’ machines. This makes it generally <em>faster</em>
and opens up the world of <em>shaders</em> that allow effects such as normal and
reflection maps, blurring and many others. It has various demos of built-in
shapes, landscapes, model loading, walk-about camera and much more! See the demos
on github.com/pi3d/pi3d_demos and experiment with them ..</p>
<p>If you are reading this document as the ReadMe in the repository then you
can find the full version of the documentation here
<a class="reference external" href="/sitelet?url=https%3A%2F%2Fgithub.com%2Fpi3d%2Fpi3d.github.com%2Ftree%2Fmaster%2F%253Ca%2520href%3D"http://pi3d.github.io/html/index.html">http://pi3d.github.io/html/index.html</a></p" rel="nofollow">http://pi3d.github.io/html/index.html">http://pi3d.github.io/html/index.html</a></p>
</div>
<div class="section" id="demos-on-github-com-pi3d-pi3d-demos-include">
<h1>Demos on github.com/pi3d/pi3d_demos include<a class="headerlink" href="#demos-on-github-com-pi3d-pi3d-demos-include" title="Permalink to this headline">¶</a></h1>
<ol class="arabic">
<li><p class="first"><strong>ForestWalk.py</strong> Walk about a forest on a landscape generated from a
bitmap</p>
<blockquote>
<div><img alt="_images/forestwalk_sml.jpg" class="align-right" src="/sitelet?url=https%3A%2F%2Fgithub.com%2Fpi3d%2Fpi3d.github.com%2Ftree%2Fmaster%2F_images%2Fforestwalk_sml.jpg" />
</div></blockquote>
</li>
<li><p class="first"><strong>Triceratops.py</strong> Large model loading with several
bitmaps</p>
<blockquote>
<div><img alt="_images/triceratops_sml.jpg" src="/sitelet?url=https%3A%2F%2Fgithub.com%2Fpi3d%2Fpi3d.github.com%2Ftree%2Fmaster%2F_images%2Ftriceratops_sml.jpg" />
</div></blockquote>
</li>
<li><p class="first"><strong>BuckfastAbbey.py</strong> Explore a model of the beautiful Buckfast Abbey in
Buckfastleigh, Devon, England</p>
<blockquote>
<div><img alt="_images/buckfast_sml.jpg" class="align-right" src="/sitelet?url=https%3A%2F%2Fgithub.com%2Fpi3d%2Fpi3d.github.com%2Ftree%2Fmaster%2F_images%2Fbuckfast_sml.jpg" />
</div></blockquote>
</li>
<li><p class="first"><strong>Earth.py</strong> Demonstrates semi-transparent clouds and hierarchical
rotations</p>
<blockquote>
<div><img alt="_images/earth_sml.jpg" src="/sitelet?url=https%3A%2F%2Fgithub.com%2Fpi3d%2Fpi3d.github.com%2Ftree%2Fmaster%2F_images%2Fearth_sml.jpg" />
</div></blockquote>
</li>
<li><p class="first"><strong>Clouds3D.py</strong> Blended sprites in
perspective view</p>
<blockquote>
<div><img alt="_images/clouds3d_sml.jpg" class="align-right" src="/sitelet?url=https%3A%2F%2Fgithub.com%2Fpi3d%2Fpi3d.github.com%2Ftree%2Fmaster%2F_images%2Fclouds3d_sml.jpg" />
</div></blockquote>
</li>
<li><p class="first"><strong>Raspberry_Rain.py</strong> Raining Raspberries,  full-screen, over the
desktop</p>
<blockquote>
<div><img alt="_images/raspberryrain_sml.jpg" src="/sitelet?url=https%3A%2F%2Fgithub.com%2Fpi3d%2Fpi3d.github.com%2Ftree%2Fmaster%2F_images%2Fraspberryrain_sml.jpg" />
</div></blockquote>
</li>
<li><p class="first"><strong>RobotWalkabout.py</strong> Another off-planet example of a basic avatar robot
drifting about</p>
<blockquote>
<div><img alt="_images/walkabout_sml.jpg" class="align-right" src="/sitelet?url=https%3A%2F%2Fgithub.com%2Fpi3d%2Fpi3d.github.com%2Ftree%2Fmaster%2F_images%2Fwalkabout_sml.jpg" />
</div></blockquote>
</li>
<li><p class="first"><strong>EnvironmentCube.py</strong> New environment cubes to try out in texture/ecubes -
some high quality ones!</p>
<blockquote>
<div><img alt="_images/envcube_sml.jpg" src="/sitelet?url=https%3A%2F%2Fgithub.com%2Fpi3d%2Fpi3d.github.com%2Ftree%2Fmaster%2F_images%2Fenvcube_sml.jpg" />
</div></blockquote>
</li>
<li><p class="first"><strong>Shapes.py</strong> Demos available shapes and text
in a 3D context</p>
<blockquote>
<div><img alt="_images/shapes_sml.jpg" class="align-right" src="/sitelet?url=https%3A%2F%2Fgithub.com%2Fpi3d%2Fpi3d.github.com%2Ftree%2Fmaster%2F_images%2Fshapes_sml.jpg" />
</div></blockquote>
</li>
<li><p class="first"><strong>MarsStation.py</strong> Navigate around an abandoned Mars base-station with
open/shut doors. Implements a new Level-Of-Detail (LOD) feature and TKwindow
interface</p>
<blockquote>
<div><img alt="_images/marsstation_sml.jpg" src="/sitelet?url=https%3A%2F%2Fgithub.com%2Fpi3d%2Fpi3d.github.com%2Ftree%2Fmaster%2F_images%2Fmarsstation_sml.jpg" />
</div></blockquote>
</li>
<li><p class="first"><strong>Amazing.py</strong> Can you find yourself around the
amazing maze?</p>
<blockquote>
<div><img alt="_images/amazing_sml.jpg" class="align-right" src="/sitelet?url=https%3A%2F%2Fgithub.com%2Fpi3d%2Fpi3d.github.com%2Ftree%2Fmaster%2F_images%2Famazing_sml.jpg" />
</div></blockquote>
</li>
<li><p class="first"><strong>TigerTank.py</strong> Ever played World Of Tanks (WOT)? This tank emulates
how a WOT tank works. Uses realistic modelling in a TKwindow</p>
<blockquote>
<div><img alt="_images/tigertank_sml.jpg" src="/sitelet?url=https%3A%2F%2Fgithub.com%2Fpi3d%2Fpi3d.github.com%2Ftree%2Fmaster%2F_images%2Ftigertank_sml.jpg" />
</div></blockquote>
</li>
<li><p class="first"><strong>Pong.py</strong>  A snazzy 3D version of landscape pinball and pong
against a Raspberry!</p>
<blockquote>
<div><img alt="_images/pong_sml.jpg" class="align-right" src="/sitelet?url=https%3A%2F%2Fgithub.com%2Fpi3d%2Fpi3d.github.com%2Ftree%2Fmaster%2F_images%2Fpong_sml.jpg" />
</div></blockquote>
</li>
<li><p class="first"><strong>Blur.py</strong> Simulates giving the camera a focal distance and blurs
nearer and further objects</p>
<blockquote>
<div><img alt="_images/blur_sml.jpg" src="/sitelet?url=https%3A%2F%2Fgithub.com%2Fpi3d%2Fpi3d.github.com%2Ftree%2Fmaster%2F_images%2Fblur_sml.jpg" />
</div></blockquote>
</li>
<li><p class="first"><strong>LoadModelObj.py</strong> Loads a model from obj file (quicker) and applies
a normal map and relfection map</p>
<blockquote>
<div><img alt="_images/teapot_sml.jpg" class="align-right" src="/sitelet?url=https%3A%2F%2Fgithub.com%2Fpi3d%2Fpi3d.github.com%2Ftree%2Fmaster%2F_images%2Fteapot_sml.jpg" />
</div></blockquote>
</li>
<li><p class="first"><strong>Silo.py</strong> Uses the Building class to create a claustrophobic maze
set in the desert.</p>
<blockquote>
<div><img alt="_images/silo_sml.jpg" src="/sitelet?url=https%3A%2F%2Fgithub.com%2Fpi3d%2Fpi3d.github.com%2Ftree%2Fmaster%2F_images%2Fsilo_sml.jpg" />
</div></blockquote>
</li>
<li><p class="first"><strong>Water.py</strong> A series of wave normal maps are used to animate a surface
and produce a realistic moving reflection.</p>
<blockquote>
<div><img alt="_images/water_sml.jpg" class="align-right" src="/sitelet?url=https%3A%2F%2Fgithub.com%2Fpi3d%2Fpi3d.github.com%2Ftree%2Fmaster%2F_images%2Fwater_sml.jpg" />
</div></blockquote>
</li>
<li><p class="first"><strong>ClashWalk.py</strong> The graphics processor calculates where the camera can
or cannot go depending on what is drawn in front of it. Potentially useful
for first person navigation</p>
</li>
<li><p class="first"><strong>CollisionBalls.py</strong> More bouncing balls across the screen -
this time  bouncing off each other on the desktop</p>
</li>
</ol>
<p>There are actually at least 50 demos showing a variety of ways of using
pi3d with different levels of complexity.</p>
</div>
<div class="section" id="files-and-folders-in-this-repository">
<h1>Files and folders in this repository<a class="headerlink" href="#files-and-folders-in-this-repository" title="Permalink to this headline">¶</a></h1>
<p>Installation tar.gz on python.pypi.org is c.190kB extracts to 770kB. Total
zipped download from github is c.600 kB extracts to c.1100kB</p>
<ol class="arabic simple">
<li><strong>pi3d</strong> The main pi3d module files 517kB</li>
<li><strong>pyxlib</strong> Library to enable use on general linux machines 209kB</li>
<li><strong>images</strong> To show in ReadMe on github 325kB</li>
<li><strong>ReadMe</strong> This file in markup and plain text 27kB</li>
<li><strong>ChangeLog.txt</strong> Latest changes of pi3d 16kB</li>
<li><strong>six_mod.py</strong> utilities to help run under python2 and python3 13kB</li>
<li><strong>misc. others</strong> 10kB</li>
</ol>
</div>
<div class="section" id="setup-on-the-raspberry-pi">
<h1>Setup on the Raspberry Pi<a class="headerlink" href="#setup-on-the-raspberry-pi" title="Permalink to this headline">¶</a></h1>
<ol class="arabic">
<li><p class="first"><strong>Qick Start Guide, NB take the time to read the paragraphs below too</strong></p>
<p>From 2015 raspbian has the relevant dependencies installed so you just
need to:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ sudo pip3 install pi3d
$ sudo raspi-config # set gpu_mem=128 - see comments below about graphics driver choice
</pre></div>
</div>
<p><em>Raspberry Pi v4 and later</em> <strong>require</strong> the new FAKE KMS (mesa-v3d-VC6..) driver and
pi3d will rely on having the X11 server running. (X11 is what supports the desktop
GUI so if you want to run pi3d applications from the command line, without the
overhead of the desktop you will need to start the X11 server first; see the FAQs
for more details but along the lines of <code class="docutils literal notranslate"><span class="pre">sudo</span> <span class="pre">xinit</span> <span class="pre">/usr/bin/python3</span> <span class="pre">/home/pi/pi3d_demos/Earth.py</span> <span class="pre">-display</span> <span class="pre">:0</span></code>
run from /home/pi/pi3d_demos)</p>
<p><em>Older Raspberry Pi versions</em> will run python applications using pi3d from the
command line using the ‘legacy’ drivers but can also run using the new drivers so
long as X11 server is running (as with RPi4).</p>
<p>Although you can <code class="docutils literal notranslate"><span class="pre">git</span> <span class="pre">clone</span></code> pi3d_demos  as in the recipe below this
will include quite a bit of extra history so it is quicker to download
the zip from github.com/pi3d/pi3d_demos and extract it on your system,
either using browser and desktop or wget and unzip.</p>
<p>Here’s a list of commands that have definitely worked on a couple of
fresh stretch or buster installs. Please take time to check out the paragraphs below
even if you use either of these quick start recipes… <em>certainly</em> if
have any non-standard aspirations or set-up. The long
list of dependencies (3rd apt-get line) may take a while to run as well
as the install Pillow. Both will create hundreds of lines of messages:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ cd ~
$ sudo pip3 install pi3d
$ sudo raspi-config # set gpu_mem=128 - see graphics driver comment above

####### download demos in their latest form, quicker #######
$ wget https://github.com/pi3d/pi3d_demos/archive/master.zip
$ unzip master.zip
$ rm master.zip
$ mv pi3d_demos-master pi3d_demos
####### or download the full revision history, slower ######
$ git clone https://github.com/pi3d/pi3d_demos.git

$ cd ~/pi3d_demos
$ python3 RunTests.py
</pre></div>
</div>
</li>
<li><p class="first"><strong>Download source, Extract and install</strong></p>
<p>There are various possibilities depending on the machine, what’s already
installed and whether you want to work with some of the latest additions.</p>
<p>If you have pip installed you should be able to open a terminal and
use <code class="docutils literal notranslate"><span class="pre">pip3</span> <span class="pre">install</span></code> as above</p>
<p>(or pip-3.2, pip3.4, pip or whatever see below*) If you don’t have pip installed
you probably should install it as described below under <code class="docutils literal notranslate"><span class="pre">Python</span> <span class="pre">Imaging</span></code>
as it’s the easiest way to install Pillow prior to debian jessie based
installations.  You can do the equivalent of <code class="docutils literal notranslate"><span class="pre">pip</span> <span class="pre">install</span></code> manually
by downloading from <a class="reference external" href="/sitelet?url=https%3A%2F%2Fgithub.com%2Fpi3d%2Fpi3d.github.com%2Ftree%2Fmaster%2F%253Ca%2520href%3D"https://pypi.python.org/pypi/pi3d">https://pypi.python.org/pypi/pi3d</a" rel="nofollow">https://pypi.python.org/pypi/pi3d">https://pypi.python.org/pypi/pi3d</a> and extracting
the package, then in a terminal:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ sudo python3 setup.py install
</pre></div>
</div>
<p>This will put the package into the
relevant location on your device (for instance
/usr/local/lib/python3.4/dist-packages/) allowing it to be imported
by your applications.</p>
<p>If you might want to use features being added in the develop branch (i.e. between
issues) you will need to download or git clone the latest code from
<a class="reference external" href="/sitelet?url=https%3A%2F%2Fgithub.com%2Fpi3d%2Fpi3d.github.com%2Ftree%2Fmaster%2F%253Ca%2520href%3D"https://github.com/tipam/pi3d/">https://github.com/tipam/pi3d/</a">https://github.com/tipam/pi3d/">https://github.com/tipam/pi3d/</a> where there is a <code class="docutils literal notranslate"><span class="pre">Download</span> <span class="pre">ZIP</span></code> link,
or you can install git (bundled in raspbian) then clone using <code class="docutils literal notranslate"><span class="pre">git</span>
<span class="pre">clone</span> <span class="pre">https://github.com/tipam/pi3d.git</span></code> this git method will give
you the option to use the develop branch <code class="docutils literal notranslate"><span class="pre">git</span> <span class="pre">checkout</span> <span class="pre">develop</span></code> and
update the code by running, from the pi3d directory:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ git checkout develop
$ git pull origin develop
# the master branch should always be the same as you get with pip3 install
</pre></div>
</div>
<p>But to pick up this version of pi3d you will need tell python where to look.
In the pi3d_demos directory there is a file called demo.py which is imported just
before pi3d. Basically it just does <code class="docutils literal notranslate"><span class="pre">sys.path.insert(1,</span> <span class="pre">'/home/pi/pi3d')</span></code> so
while that line is there your program will use the cloned repository version of pi3d.</p>
</li>
<li><p class="first"><strong>Memory Split setup</strong></p>
<p>Although most demos work on 64MB of memory, you are strongly advised to have
a 128MB of graphics memory split, especially for full-screen 3D graphics.
In the latest Raspbian build you need to either choose the GUI setup,
run <code class="docutils literal notranslate"><span class="pre">sudo</span> <span class="pre">raspi-config</span></code> or edit the config.txt file (in the boot
directory) and set the variable <code class="docutils literal notranslate"><span class="pre">gpu_mem=128</span></code> for 128MB of graphics
memory.</p>
</li>
<li><p class="first"><strong>Install Python Imaging</strong></p>
<p>Before trying any of the demos or pi3d, you need the Python
Imaging Library as this is needed for importing any graphics used by
pi3d (though see the minimal example below, which doesn’t!). The
original Imaging library is no longer really maintained and
doesn’t run on python_3. The better equivalent replacement is Pillow.</p>
<p>As of raspbian jessie Pillow is the default imaging library. It’s already
installed on the <code class="docutils literal notranslate"><span class="pre">fully</span> <span class="pre">featured</span></code> SD image, but it’s left off the
lite image it can be installed using the debian package manager
(for lite image you also need <code class="docutils literal notranslate"><span class="pre">sudo</span> <span class="pre">apt-get</span> <span class="pre">install</span> <span class="pre">python3-numpy</span></code>):</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ sudo apt-get install python3-pil
</pre></div>
</div>
<p>(NB <code class="docutils literal notranslate"><span class="pre">python-pil</span></code> will install for python2), but prior
to jessie you needed to:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ sudo apt-get install python3-dev python3-setuptools libjpeg-dev zlib1g-dev libpng12-dev libfreetype6-dev
$ sudo apt-get install python3-pip
$ sudo pip3 install Pillow
...
</pre></div>
</div>
<p>If you miss any of the dependent libraries and need to add them later
you will have to <code class="docutils literal notranslate"><span class="pre">pip3</span> <span class="pre">uninstall</span></code> then re <code class="docutils literal notranslate"><span class="pre">pip3</span> <span class="pre">install</span></code></p>
<p>(on ubuntu and jessie <code class="docutils literal notranslate"><span class="pre">pip3</span></code> should work, could be other names,
google for help or search:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ sudo find /usr/bin/ -name pip*
</pre></div>
</div>
<p>!) If had previously installed the old PIL:
using <code class="docutils literal notranslate"><span class="pre">$</span> <span class="pre">sudo</span> <span class="pre">apt-get</span> <span class="pre">install</span> <span class="pre">python-imaging</span></code> When you later switch
to Pillow you will need to <code class="docutils literal notranslate"><span class="pre">sudo</span> <span class="pre">apt-get</span> <span class="pre">remove</span> <span class="pre">python-imaging</span></code> first.</p>
<p>To run on Arch linux you will need to install:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ pacman -S python
$ pacman -S python-pillow
$ pacman -S python-numpy
</pre></div>
</div>
<p>python2 has to be explicitly asked for. See <a class="reference external" href="/sitelet?url=https%3A%2F%2Fgithub.com%2Fpi3d%2Fpi3d.github.com%2Ftree%2Fmaster%2FFAQ.html">FAQ</a> for a description
of all the steps to get a quick loading stand-alone pi3d SD card.</p>
</li>
</ol>
</div>
<div class="section" id="setup-on-desktop-and-laptop-machines">
<h1>Setup on desktop and laptop machines<a class="headerlink" href="#setup-on-desktop-and-laptop-machines" title="Permalink to this headline">¶</a></h1>
<blockquote>
<div><p>The machine will need to have a gpu that runs OpenGL2+ and obviously
it will need to have python installed. Setting up in a Linux environment
is most similar to the procedure for the Raspberry Pi. In fact by far the
most staightforward route is to make a Raspbian Pixel USB stick following
the instructions here <a class="reference external" href="/sitelet?url=https%3A%2F%2Fgithub.com%2Fpi3d%2Fpi3d.github.com%2Ftree%2Fmaster%2F%253Ca%2520href%3D"https://www.raspberrypi.org/blog/pixel-pc-mac/">https://www.raspberrypi.org/blog/pixel-pc-mac/</a" rel="nofollow">https://www.raspberrypi.org/blog/pixel-pc-mac/">https://www.raspberrypi.org/blog/pixel-pc-mac/</a>
After that your PC will behave pretty much like the Raspberry Pi and pi3d
will work after a simple <code class="docutils literal notranslate"><span class="pre">sudo</span> <span class="pre">pip3</span> <span class="pre">install</span> <span class="pre">pi3d</span></code> The USB isn’t as fast
as a hard drive but everything else will run at PC speed. Linux can be set
up in its own boot partition or in vmware (eg Player which is free, you
will also need to <code class="docutils literal notranslate"><span class="pre">enable</span> <span class="pre">3d</span> <span class="pre">acceleration</span></code>.)</p>
<p>For non Pixel linux you will need to install libraries
that emulate OpenGLES behaviour for the gpu:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ sudo apt-get install mesa-utils-extra
</pre></div>
</div>
<p>Which should install mesa versions of libEGL.so and libGLESv2.so However
mesa-utils-extra isn’t available on all linux distros but libgles2-mesa
and libgles2-mesa-dev may provide the required libraries.</p>
<p>In vmware player on Windows_8.1 I have successfully run pi3d installing lubuntu
(quickest to set up (1h inc downloads) and run) and ubuntu but debian 7 took a lot
more setting up and didn’t render graphics! Apparently LinuxMint does
work. One issue running under vmware is that the Mouse class doesn’t get
the correct movements back from /dev/input/mice so you have to use the
argument <code class="docutils literal notranslate"><span class="pre">use_x=True</span></code>. This provides coordinates of the pointer position
relative to the window so limits movement for steering as used in the demos.</p>
<p>The installation of PIL or Pillow should be the same as for the Raspberry
Pi above but you are more likely to need to manually install python3-numpy.</p>
<p>It is likely that pi3d will run on OSX but you might have to compile
your own mesa libraries (though some seem to be available) Pi3d has
been run successfully in vmware on mac.</p>
</div></blockquote>
</div>
<div class="section" id="windows">
<h1>Windows<a class="headerlink" href="#windows" title="Permalink to this headline">¶</a></h1>
<blockquote>
<div><p>In order for pi3d to run on windows you need to install python, Pillow
and numpy (as above) but pi3d also requires pygame to provide the graphics
surface and UI, also ANGLE has been used to provide the EGL and GLESv2 emulator
libraries. These dll files are used by some common applications such as the
Chrome and Firefox browsers so you may have copies already on your machine but in
my experience you will need to copy the files to your project location and
existing copies will be 32 bit versions so won’t work with 64 bit python
- see notes below.</p>
<p>There are the usual issues of 32v.64bit and python2v3. Initially, while
testing and developing I used python2.7 and 32 bits, msi installing
python and pygame and pip installing numpy and Pillow as this seemed to
be the most straightforward. Subsequently I have installed various different
version of python both 32 and 64 bit and I have found the best and
quickest method by far is to install python using the standard windows
install (If you want the 64 bit version you have to avoid the obvious and look
at the list of all versions as the default download button will be 32 bit) <strong>then
install everything else from Christoph Gohlke’s site</strong>
<a class="reference external" href="/sitelet?url=https%3A%2F%2Fgithub.com%2Fpi3d%2Fpi3d.github.com%2Ftree%2Fmaster%2F%253Ca%2520href%3D"http://www.lfd.uci.edu/~gohlke/pythonlibs/">http://www.lfd.uci.edu/~gohlke/pythonlibs/</a>:</p" rel="nofollow">http://www.lfd.uci.edu/~gohlke/pythonlibs/">http://www.lfd.uci.edu/~gohlke/pythonlibs/</a>:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>1. Install python from python.org. When running the installer I had
to select the last option in the list of components to install
``..add python.exe to Path`` by selecting the option to install on
hard drive. Also choose the option to install for all users
2. http://www.lfd.uci.edu/~gohlke/pythonlibs/#pygame
3. http://www.lfd.uci.edu/~gohlke/pythonlibs/#numpy
4. http://www.lfd.uci.edu/~gohlke/pythonlibs/#pillow
5. each then installed from the command line with
``pip install numpy-1.11.1+mkl-cp35-cp35m-win32.whl`` and so on.
</pre></div>
</div>
<p>As well as installing the python modules you also need to either find
several ANGLE dll files on your system or download them from
<a class="reference external" href="/sitelet?url=https%3A%2F%2Fgithub.com%2Fpi3d%2Fpi3d.github.com%2Ftree%2Fmaster%2F%253Ca%2520href%3D"http://github.com/paddywwoof/pi3d_windll">http://github.com/paddywwoof/pi3d_windll</a">http://github.com/paddywwoof/pi3d_windll">http://github.com/paddywwoof/pi3d_windll</a> and copy them into the starting
directory of the main python file of your project. (If you are running
64 bit python you will have to use the downloaded versions.) In theory
you could alter the Windows <code class="docutils literal notranslate"><span class="pre">Path</span></code> to point to the location of these
files but I couldn’t get that to work. If you manage to do this then you
need to edit the path to these files in the pi3d file <code class="docutils literal notranslate"><span class="pre">pi3d/constants/__init__.py</span></code>
around lines 87,88. You should be able to find the Chrome and Firefox
copies of the dlls by starting a search from <code class="docutils literal notranslate"><span class="pre">C:\Program</span> <span class="pre">Files</span> <span class="pre">(x86)\</span></code>
You need to copy the files:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">libglesv2</span><span class="o">.</span><span class="n">dll</span>
<span class="n">libegl</span><span class="o">.</span><span class="n">dll</span>
<span class="n">d3dcompiler_47</span><span class="o">.</span><span class="n">dll</span> <span class="c1">## NB the number at the end will increment with later releases</span>
<span class="n">mozglue</span><span class="o">.</span><span class="n">dll</span> <span class="c1">## only for Firefox</span>
</pre></div>
</div>
<p>You might only need the first two files if your system has recent drivers
or GPU. When trying to get 64 bit python working I tried two different
options when compiling the dll files but they seem to be equivalent and
I will rationalize them when I get chance.</p>
<p>You can install pi3d using the pip or easy_install methods but you can also
either clone it with git or download the zip from github and extract
somewhere sensible on your system. If you do this you will then have to
add the path to pi3d at the beginning of any files trying to import pi3d:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="kn">import</span> <span class="nn">sys</span>
<span class="n">sys</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">insert</span><span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="s2">&quot;C:/Users/whoever/Documents/GitHub/pi3d&quot;</span><span class="p">)</span>
</pre></div>
</div>
<p>For convenience, in pi3d_demos this is included in a file <code class="docutils literal notranslate"><span class="pre">demo.py</span></code>
which is imported at the start of each file. I have found it safer to use
generic forward <code class="docutils literal notranslate"><span class="pre">/</span></code> than windows <code class="docutils literal notranslate"><span class="pre">\</span></code> or <code class="docutils literal notranslate"><span class="pre">\\</span></code> in these paths.</p>
<p>On windows the pi3d events system (as used by Silo and a couple of other
demos) does not work as it uses fairly low level linux specific code.</p>
<p>If you <code class="docutils literal notranslate"><span class="pre">mymouse</span> <span class="pre">=</span> <span class="pre">pi3d.Mouse(restrict=False)</span></code> as in most of the demos
then the cursor becomes hidden and stuck at the centre of the pygame window.
This means you can’t move or resize the window or close it with the X.
i.e. you must make sure that you have a keyboard methods of escaping from
the program (presumably Ctrl+Alt+Del would be a route!).</p>
</div></blockquote>
</div>
<div class="section" id="android">
<h1>Android<a class="headerlink" href="#android" title="Permalink to this headline">¶</a></h1>
<blockquote>
<div>Running pi3d on Android is more complicated, but possible.
see <a class="reference external" href="/sitelet?url=https%3A%2F%2Fgithub.com%2Fpi3d%2Fpi3d.github.com%2Ftree%2Fmaster%2FAndroidUse.html">Android</a></div></blockquote>
</div>
<div class="section" id="editing-scripts-and-running">
<h1>Editing scripts and running<a class="headerlink" href="#editing-scripts-and-running" title="Permalink to this headline">¶</a></h1>
<ol class="arabic">
<li><p class="first"><strong>Install Geany to run pi3d</strong></p>
<p>Although you can use any editor and run the scripts in a terminal using python,
on the RaspberryPi Geany seems to be the easiest and most compatible
application to use for creating and running Python scripts. Download
and install it with:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ sudo apt-get install geany xterm
</pre></div>
</div>
<p>NB IDLE can’t cope with some aspects of the way that most of the pi3d
demos get key presses using the curses module. There will be an error
to the effect <code class="docutils literal notranslate"><span class="pre">curses.cbreak()</span> <span class="pre">returned</span> <span class="pre">ERR</span></code></p>
</li>
<li><p class="first"><strong>Optionally, install tk.</strong></p>
<p>Some of the demos require the tk graphics toolkit.  To download and install it:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ sudo apt-get install tk
</pre></div>
</div>
</li>
<li><p class="first"><strong>Load and run</strong></p>
<p>NB to get all the demos from github and run, in
a terminal:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ git clone https://github.com/pi3d/pi3d_demos.git
$ cd ~/pi3d_demos
$ python3 Minimal.py
</pre></div>
</div>
<p>or load any of the demos into Geany and run (using the cogs icon). As a minimum,
scripts need these elements in order to use the pi3d library:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="kn">import</span> <span class="nn">pi3d</span>
<span class="n">DISPLAY</span> <span class="o">=</span> <span class="n">pi3d</span><span class="o">.</span><span class="n">Display</span><span class="o">.</span><span class="n">create</span><span class="p">()</span>
<span class="n">ball</span> <span class="o">=</span> <span class="n">pi3d</span><span class="o">.</span><span class="n">Sphere</span><span class="p">(</span><span class="n">z</span><span class="o">=</span><span class="mf">5.0</span><span class="p">)</span>
<span class="k">while</span> <span class="n">DISPLAY</span><span class="o">.</span><span class="n">loop_running</span><span class="p">():</span>
  <span class="n">ball</span><span class="o">.</span><span class="n">draw</span><span class="p">()</span>
</pre></div>
</div>
<p>(Which should work even without python imaging) But.. a real application
will need other code to actually do something, for instance to get user
input in order to stop the program!</p>
</li>
</ol>
</div>
<div class="section" id="a-very-brief-explanation">
<h1>A Very Brief Explanation<a class="headerlink" href="#a-very-brief-explanation" title="Permalink to this headline">¶</a></h1>
<p>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 <a class="reference external" href="/sitelet?url=https%3A%2F%2Fgithub.com%2Fpi3d%2Fpi3d.github.com%2Ftree%2Fmaster%2FFAQ.html">FAQ</a> before
you try anything ambitious or if anything goes wrong, obviously. There is a
<a class="reference external" href="/sitelet?url=https%3A%2F%2Fgithub.com%2Fpi3d%2Fpi3d.github.com%2Ftree%2Fmaster%2FGPUexplain.html">3D Graphics Explanation</a> where I try to explain in some more detail what
is going on.</p>
<blockquote>
<div><p><strong>Display</strong> The <a class="reference external" href="/sitelet?url=https%3A%2F%2Fgithub.com%2Fpi3d%2Fpi3d.github.com%2Ftree%2Fmaster%2Fpi3d.html%23pi3d.Display.Display">Display</a> 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 <a class="reference external" href="/sitelet?url=https%3A%2F%2Fgithub.com%2Fpi3d%2Fpi3d.github.com%2Ftree%2Fmaster%2Fpi3d.html%23pi3d.Display.Display">Display</a> in existence
before some of the other objects are created so it’s a good idea to create one
first job.</p>
<p><strong>Shape</strong> <a class="reference external" href="/sitelet?url=https%3A%2F%2Fgithub.com%2Fpi3d%2Fpi3d.github.com%2Ftree%2Fmaster%2Fpi3d.shape.html%23module-pi3d.shape.Cone">All objects to be drawn by pi3d</a> inherit from the <a class="reference external" href="/sitelet?url=https%3A%2F%2Fgithub.com%2Fpi3d%2Fpi3d.github.com%2Ftree%2Fmaster%2Fpi3d.html%23pi3d.Shape.Shape">Shape</a> class which holds
details of position, rotation, scale as well as specific data needed for
drawing the shape. Each <a class="reference external" href="/sitelet?url=https%3A%2F%2Fgithub.com%2Fpi3d%2Fpi3d.github.com%2Ftree%2Fmaster%2Fpi3d.html%23pi3d.Shape.Shape">Shape</a> contains an array of <a class="reference external" href="/sitelet?url=https%3A%2F%2Fgithub.com%2Fpi3d%2Fpi3d.github.com%2Ftree%2Fmaster%2Fpi3d.html%23pi3d.Buffer.Buffer">Buffer</a> objects; normally
only containing one but there could be more in complicated models created
with external 3D applications.</p>
<p><strong>Buffer</strong> The <a class="reference external" href="/sitelet?url=https%3A%2F%2Fgithub.com%2Fpi3d%2Fpi3d.github.com%2Ftree%2Fmaster%2Fpi3d.html%23pi3d.Buffer.Buffer">Buffer</a> 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 <a class="reference external" href="/sitelet?url=https%3A%2F%2Fgithub.com%2Fpi3d%2Fpi3d.github.com%2Ftree%2Fmaster%2Fpi3d.html%23pi3d.Buffer.Buffer">Buffer</a> object within a <a class="reference external" href="/sitelet?url=https%3A%2F%2Fgithub.com%2Fpi3d%2Fpi3d.github.com%2Ftree%2Fmaster%2Fpi3d.html%23pi3d.Shape.Shape">Shape</a> can be textured
using a different image or shade (RGB) value and, if needed, a different <a class="reference external" href="/sitelet?url=https%3A%2F%2Fgithub.com%2Fpi3d%2Fpi3d.github.com%2Ftree%2Fmaster%2Fpi3d.html%23pi3d.Shader.Shader">Shader</a></p>
<p><strong>Shader</strong> The <a class="reference external" href="/sitelet?url=https%3A%2F%2Fgithub.com%2Fpi3d%2Fpi3d.github.com%2Ftree%2Fmaster%2Fpi3d.html%23pi3d.Shader.Shader">Shader</a> class is used to compile <em>very fast</em> programs that are run on
the graphics processor. They have two parts: <em>Vertex Shaders</em> that do calculation
for each of the vertices of the <a class="reference external" href="/sitelet?url=https%3A%2F%2Fgithub.com%2Fpi3d%2Fpi3d.github.com%2Ftree%2Fmaster%2Fpi3d.html%23pi3d.Buffer.Buffer">Buffer</a> and <em>Fragment Shaders</em> 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.</p>
<p><strong>Camera</strong> In order to draw a <a class="reference external" href="/sitelet?url=https%3A%2F%2Fgithub.com%2Fpi3d%2Fpi3d.github.com%2Ftree%2Fmaster%2Fpi3d.html%23pi3d.Shape.Shape">Shape</a> on the <a class="reference external" href="/sitelet?url=https%3A%2F%2Fgithub.com%2Fpi3d%2Fpi3d.github.com%2Ftree%2Fmaster%2Fpi3d.html%23pi3d.Display.Display">Display</a> the <a class="reference external" href="/sitelet?url=https%3A%2F%2Fgithub.com%2Fpi3d%2Fpi3d.github.com%2Ftree%2Fmaster%2Fpi3d.html%23pi3d.Shader.Shader">Shader</a> needs to be passed the
vertex information in the Buffers and needs know how the <a class="reference external" href="/sitelet?url=https%3A%2F%2Fgithub.com%2Fpi3d%2Fpi3d.github.com%2Ftree%2Fmaster%2Fpi3d.html%23pi3d.Shape.Shape">Shape</a> has been moved.
But it also needs to know how the <a class="reference external" href="/sitelet?url=https%3A%2F%2Fgithub.com%2Fpi3d%2Fpi3d.github.com%2Ftree%2Fmaster%2Fpi3d.html%23pi3d.Camera.Camera">Camera</a> has moved. The <a class="reference external" href="/sitelet?url=https%3A%2F%2Fgithub.com%2Fpi3d%2Fpi3d.github.com%2Ftree%2Fmaster%2Fpi3d.html%23pi3d.Camera.Camera">Camera</a> class generally
has just one instance and if you do not create one explicitly then <a class="reference external" href="/sitelet?url=https%3A%2F%2Fgithub.com%2Fpi3d%2Fpi3d.github.com%2Ftree%2Fmaster%2Fpi3d.html%23pi3d.Display.Display">Display</a> will
generate a default one when you first try to draw something. The <a class="reference external" href="/sitelet?url=https%3A%2F%2Fgithub.com%2Fpi3d%2Fpi3d.github.com%2Ftree%2Fmaster%2Fpi3d.html%23pi3d.Camera.Camera">Camera</a>
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.</p>
<p><strong>Texture</strong> The <a class="reference external" href="/sitelet?url=https%3A%2F%2Fgithub.com%2Fpi3d%2Fpi3d.github.com%2Ftree%2Fmaster%2Fpi3d.html%23pi3d.Texture.Texture">Texture</a> objects are used to load images from file into a form that
can be passed to the <a class="reference external" href="/sitelet?url=https%3A%2F%2Fgithub.com%2Fpi3d%2Fpi3d.github.com%2Ftree%2Fmaster%2Fpi3d.html%23pi3d.Shader.Shader">Shader</a> 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.</p>
<p><strong>Light</strong> To produce a 3D appearance most of the Shaders use directional lighting and
if you draw a <a class="reference external" href="/sitelet?url=https%3A%2F%2Fgithub.com%2Fpi3d%2Fpi3d.github.com%2Ftree%2Fmaster%2Fpi3d.html%23pi3d.Shape.Shape">Shape</a> without creating a <a class="reference external" href="/sitelet?url=https%3A%2F%2Fgithub.com%2Fpi3d%2Fpi3d.github.com%2Ftree%2Fmaster%2Fpi3d.html%23pi3d.Light.Light">Light</a> a default instance will be
created by the <a class="reference external" href="/sitelet?url=https%3A%2F%2Fgithub.com%2Fpi3d%2Fpi3d.github.com%2Ftree%2Fmaster%2Fpi3d.html%23pi3d.Display.Display">Display</a>. The <a class="reference external" href="/sitelet?url=https%3A%2F%2Fgithub.com%2Fpi3d%2Fpi3d.github.com%2Ftree%2Fmaster%2Fpi3d.html%23pi3d.Light.Light">Light</a> has properties defining the direction,
the colour (and strength i.e. RGB values) and ambient colour (and strength).</p>
<p>Although drawing a Shape requires references to <code class="docutils literal notranslate"><span class="pre">Shader</span></code>, <code class="docutils literal notranslate"><span class="pre">Light</span></code> and <code class="docutils literal notranslate"><span class="pre">Camera</span></code>
objects, default instances will be created automatically if they are not
specified (as in the example minimal code above)</p>
<p>When you look through the demos you will see one or two things that may
not be immediately obvious. All the demos start with:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="ch">#!/usr/bin/python</span>
<span class="kn">from</span> <span class="nn">__future__</span> <span class="k">import</span> <span class="n">absolute_import</span><span class="p">,</span> <span class="n">division</span><span class="p">,</span> <span class="n">print_function</span><span class="p">,</span> <span class="n">unicode_literals</span>
</pre></div>
</div>
<p>Although these lines can often be left out, the first tells any process running the file
as a script that it’s python and the second is basically to help the transition
of this code to run using python 3:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="kn">import</span> <span class="nn">demo</span>
</pre></div>
</div>
<p>Allows the demo files to be put in a different location from pi3d but still run. If you install
pi3d using pip or <code class="docutils literal notranslate"><span class="pre">python</span> <span class="pre">setup.py</span> <span class="pre">install</span></code> then you can take this out:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="kn">import</span> <span class="nn">pi3d</span>
</pre></div>
</div>
<p>Is an alternative to importing just what you need i.e.:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="kn">from</span> <span class="nn">pi3d.constants</span> <span class="k">import</span> <span class="o">*</span>
<span class="kn">from</span> <span class="nn">pi3d</span> <span class="k">import</span> <span class="n">Display</span>
<span class="kn">from</span> <span class="nn">pi3d.Texture</span> <span class="k">import</span> <span class="n">Texture</span>
<span class="kn">from</span> <span class="nn">pi3d.Keyboard</span> <span class="k">import</span> <span class="n">Keyboard</span>
<span class="kn">from</span> <span class="nn">pi3d.Light</span> <span class="k">import</span> <span class="n">Light</span>
<span class="kn">from</span> <span class="nn">pi3d.Shader</span> <span class="k">import</span> <span class="n">Shader</span>
<span class="kn">from</span> <span class="nn">pi3d.util.String</span> <span class="k">import</span> <span class="n">String</span>
<span class="o">...</span>
<span class="kn">from</span> <span class="nn">pi3d.shape.Sphere</span> <span class="k">import</span> <span class="n">Sphere</span>
<span class="kn">from</span> <span class="nn">pi3d.shape.Sprite</span> <span class="k">import</span> <span class="n">Sprite</span>
</pre></div>
</div>
<p>If you import the whole lot using <code class="docutils literal notranslate"><span class="pre">import</span> <span class="pre">pi3d</span></code> then you need to prefix classes
and functions with <code class="docutils literal notranslate"><span class="pre">pi3d.</span></code> A third way to import the modules would be to use
<code class="docutils literal notranslate"><span class="pre">from</span> <span class="pre">pi3d</span> <span class="pre">import</span> <span class="pre">*</span></code> this saves having to use the <code class="docutils literal notranslate"><span class="pre">pi3d.</span></code> prefix but
is <strong>much harder to debug</strong> if there is a name conflict.</p>
</div></blockquote>
</div>
<div class="section" id="documentation">
<h1>Documentation<a class="headerlink" href="#documentation" title="Permalink to this headline">¶</a></h1>
<p>Please note that pi3d functions may change significantly during its development.</p>
<p>Bug reports, comments, feature requests and fixes are most welcome!</p>
<p>Please email on <a class="reference external" href="mailto:pi3d&amp;#37;&amp;#52;&amp;#48;googlegroups&amp;#46;com">pi3d<span>&#64;</span>googlegroups<span>&#46;</span>com</a> or contact us through the Raspberry Pi forums
or on <a class="reference external" href="/sitelet?url=https%3A%2F%2Fgithub.com%2Fpi3d%2Fpi3d.github.com%2Ftree%2Fmaster%2F%253Ca%2520href%3D"http://pi3d.github.io/html/index.html">http://pi3d.github.io/html/index.html</a></p" rel="nofollow">http://pi3d.github.io/html/index.html">http://pi3d.github.io/html/index.html</a></p>
</div>
<div class="section" id="acknowledgements">
<h1>Acknowledgements<a class="headerlink" href="#acknowledgements" title="Permalink to this headline">¶</a></h1>
<p>pi3d started with code based on Peter de Rivaz ‘pyopengles’
(<a class="reference external" href="/sitelet?url=https%3A%2F%2Fgithub.com%2Fpi3d%2Fpi3d.github.com%2Ftree%2Fmaster%2F%253Ca%2520href%3D"https://github.com/peterderivaz/pyopengles">https://github.com/peterderivaz/pyopengles</a">https://github.com/peterderivaz/pyopengles">https://github.com/peterderivaz/pyopengles</a>) with some tweaking from Jon Macey’s
code (jonmacey.blogspot.co.uk/2012/06/).</p>
<p>Many Thanks, especially to Peter de Rivaz, Jon Macey, Richar Urwin, Peter Hess,
David Wallin, Avishay Orpaz (avishorp), Guenter Kreidl, Benjamin Denozière,
Matthew Coleman, Piotr Bednarski, &#64;swehner and others who have contributed
to pi3d - keep up the good work!</p>
<p><strong>PLEASE READ LICENSING AND COPYRIGHT NOTICES ESPECIALLY IF USING FOR COMMERCIAL PURPOSES</strong></p>
</div>


          </div>
        </div>
      </div>
      <div class="sphinxsidebar" role="navigation" aria-label="main navigation">
        <div class="sphinxsidebarwrapper">
  <h3><a href="/sitelet?url=https%3A%2F%2Fgithub.com%2Fpi3d%2Fpi3d.github.com%2Ftree%2Fmaster%2Findex.html">Table of Contents</a></h3>
  <ul>
<li><a class="reference internal" href="#">Introduction to pi3d</a></li>
<li><a class="reference internal" href="#demos-on-github-com-pi3d-pi3d-demos-include">Demos on github.com/pi3d/pi3d_demos include</a></li>
<li><a class="reference internal" href="#files-and-folders-in-this-repository">Files and folders in this repository</a></li>
<li><a class="reference internal" href="#setup-on-the-raspberry-pi">Setup on the Raspberry Pi</a></li>
<li><a class="reference internal" href="#setup-on-desktop-and-laptop-machines">Setup on desktop and laptop machines</a></li>
<li><a class="reference internal" href="#windows">Windows</a></li>
<li><a class="reference internal" href="#android">Android</a></li>
<li><a class="reference internal" href="#editing-scripts-and-running">Editing scripts and running</a></li>
<li><a class="reference internal" href="#a-very-brief-explanation">A Very Brief Explanation</a></li>
<li><a class="reference internal" href="#documentation">Documentation</a></li>
<li><a class="reference internal" href="#acknowledgements">Acknowledgements</a></li>
</ul>

  <h4>Previous topic</h4>
  <p class="topless"><a href="/sitelet?url=https%3A%2F%2Fgithub.com%2Fpi3d%2Fpi3d.github.com%2Ftree%2Fmaster%2Findex.html"
                        title="previous chapter">Welcome to pi3d’s documentation!</a></p>
  <h4>Next topic</h4>
  <p class="topless"><a href="/sitelet?url=https%3A%2F%2Fgithub.com%2Fpi3d%2Fpi3d.github.com%2Ftree%2Fmaster%2FFAQ.html"
                        title="next chapter">Frequently Asked Questions</a></p>
  <div role="note" aria-label="source link">
    <h3>This Page</h3>
    <ul class="this-page-menu">
      <li><a href="/sitelet?url=https%3A%2F%2Fgithub.com%2Fpi3d%2Fpi3d.github.com%2Ftree%2Fmaster%2F_sources%2FReadMe.rst.txt"
            rel="nofollow">Show Source</a></li>
    </ul>
   </div>
<div id="searchbox" style="display: none" role="search">
  <h3>Quick search</h3>
    <div class="searchformwrapper">
    <form class="search" action="/sitelet?url=https%3A%2F%2Fgithub.com%2Fpi3d%2Fpi3d.github.com%2Ftree%2Fmaster%2Fsearch.html" method="get">
      <input type="text" name="q" />
      <input type="submit" value="Go" />
      <input type="hidden" name="check_keywords" value="yes" />
      <input type="hidden" name="area" value="default" />
    </form>
    </div>
</div>
<script type="text/javascript">$('#searchbox').show(0);</script>
        </div>
      </div>
      <div class="clearer"></div>
    </div>
    <div class="related" role="navigation" aria-label="related navigation">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="/sitelet?url=https%3A%2F%2Fgithub.com%2Fpi3d%2Fpi3d.github.com%2Ftree%2Fmaster%2Fgenindex.html" title="General Index"
             >index</a></li>
        <li class="right" >
          <a href="/sitelet?url=https%3A%2F%2Fgithub.com%2Fpi3d%2Fpi3d.github.com%2Ftree%2Fmaster%2Fpy-modindex.html" title="Python Module Index"
             >modules</a> |</li>
        <li class="right" >
          <a href="/sitelet?url=https%3A%2F%2Fgithub.com%2Fpi3d%2Fpi3d.github.com%2Ftree%2Fmaster%2FFAQ.html" title="Frequently Asked Questions"
             >next</a> |</li>
        <li class="right" >
          <a href="/sitelet?url=https%3A%2F%2Fgithub.com%2Fpi3d%2Fpi3d.github.com%2Ftree%2Fmaster%2Findex.html" title="Welcome to pi3d’s documentation!"
             >previous</a> |</li>
        <li class="nav-item nav-item-0"><a href="/sitelet?url=https%3A%2F%2Fgithub.com%2Fpi3d%2Fpi3d.github.com%2Ftree%2Fmaster%2Findex.html">pi3d 2.47 documentation</a> &#187;</li> 
      </ul>
    </div>
    <div class="footer" role="contentinfo">
        &#169; Copyright 2012-2021, The pi3d team.
      Created using <a href="/sitelet?url=https%3A%2F%2Fgithub.com%2Fpi3d%2Fpi3d.github.com%2Ftree%2Fmaster%2F%253Ca%2520href%3D"http://sphinx-doc.org/">Sphinx</a" rel="nofollow">http://sphinx-doc.org/">Sphinx</a> 1.8.5.
    </div>
  </body>
</html>