How it works...

Like the 3dObject.py example, we define the DISPLAY shader (this time using uv_reflect) and some additional textures—bumptex (floor_nm.jpg) and shinetex (stars.jpg)—to use later. We define a model that we want to import, placing it at z=10 (if no coordinates are given, it will be placed at (0,0,0)). Since we do not specify a camera position, the default will place it within the view (see the section regarding the camera for more details).

We apply the shader using the set_shader() function. Next, we add some textures and effects using bumptex as a surface texture (scaled by 4). We apply an extra shiny effect using shinetex and apply a reflection strength of 0.5 (the strength ranges from 0.0, the weakest, to 1.0, the strongest) ...

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.