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) using the set_normal_shine() function. If you look closely at the surface of the model, the bumptex texture provides additional surface detail and the shinetex texture can be seen as the reflection on the surface.

To display our model within something more interesting than a default blue space, we will create an EnvironmentCube object. This defines a large space that has a special texture applied to the inside space (in this instance, it will load the sbox_front/back/bottom/left and sbox_right images from the texturesecubes directory), so it effectively encloses the objects within. The result is that you get a pleasant backdrop for your object.

Again, we define a default CAMERA object with rot and tilt variables to control the view. Within the DISPLAY.loop_running() section, we can control the view of the
CAMERA object using the mouse and rotate the model on its axis at different rates to let it
spin and show all its sides (using the RotateIncX/Y/Z() function to specify the rate of rotation). Finally, we ensure that the DISPLAY is updated by drawing the model and the environment cube.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.137.164.24