How to do it...

Create and run the following 3dModel.py script:

#!/usr/bin/python3 """ Wavefront obj model loading. Material properties set in mtl file. Uses the import pi3d method to load *everything* """ import demo import pi3d from math import sin, cos, radians KEY = {'ESC':27,'NONE':-1} # Setup display and initialise pi3d DISPLAY = pi3d.Display.create() #capture mouse and key presses mykeys = pi3d.Keyboard() mymouse = pi3d.Mouse(restrict = False) mymouse.start() def main(): #Model textures and shaders shader = pi3d.Shader("uv_reflect") bumptex = pi3d.Texture("textures/floor_nm.jpg") shinetex = pi3d.Texture("textures/stars.jpg") # load model #mymodel = pi3d.Model(file_string='models/teapot.obj', z=10) mymodel = pi3d.Model(file_string='models/monkey.obj', ...

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.