How to do it...

Create the following 3dObject.py script:

#!/usr/bin/python3 """ Create a 3D space with a Tetrahedron inside and rotate the view around using the mouse. """ from math import sin, cos, radians import demo import pi3d KEY = {'ESC':27,'NONE':-1} DISPLAY = pi3d.Display.create(x=50, y=50) #capture mouse and key presses mykeys = pi3d.Keyboard() mymouse = pi3d.Mouse(restrict = False) mymouse.start() def main(): CAMERA = pi3d.Camera.instance() tex = pi3d.Texture("textures/stripwood.jpg") flatsh = pi3d.Shader("uv_flat") #Define the coordinates for our shape (x,y,z) A = (-1.0,-1.0,-1.0) B = (1.0,-1.0,1.0) C = (-1.0,-1.0,1.0) D = (-1.0,1.0,1.0) ids = ["A","B","C","D"] coords = [A,B,C,D] myTetra = pi3d.Tetrahedron(x=0.0, y=0.0, z=0.0, ...

Get Raspberry Pi 3 Cookbook for Python Programmers - Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.