-
Notifications
You must be signed in to change notification settings - Fork 74
Pi3D createEnvironmentCube
An environment cube is an 360 degree image that surrounds the scene. It's probably the easiest way to create a full 3D environment without 3D! A simple adventure game could enable the user to point and click to an area of interest in the environment cube (such as a path for example) and another environment cube could be loaded in and so on.
There are currently three types of environment map supported; Faces, Cross and Halfcross ...
You can provide six images (512x512 pixels max) to create an environment cube. The following code achieves this. Please note that you must load the textures in this order ...
envmaps = []
envmaps.append(pi3d.loadTexture("textures/sbox_top.jpg")
envmaps.append(pi3d.loadTexture("textures/sbox_left.jpg")
envmaps.append(pi3d.loadTexture("textures/sbox_front.jpg")
envmaps.append(pi3d.loadTexture("textures/sbox_right.jpg")
envmaps.append(pi3d.loadTexture("textures/sbox_back.jpg")
envmaps.append(pi3d.loadTexture("textures/sbox_bottom.jpg") #This one can be ignored but you must use envmaps.append(None) instead
myecube = pi3d.createEnvironmentCube(900.0, "FACES")
... next line goes in rendering loop
myecube.draw(envmaps, x,y,z) #x,y,z represents the centre of the scene
A Single image of an 'unfolded box' (1024x1024 pixels max) is used to render this type of environment cube ...
envmap = pi3d.loadTexture("textures/skybox_miramar.jpg")
myecube = pi3d.createEnvironmentCube(900.0, "CROSS")
... next line goes in rendering loop
myecube.draw(envmap, x,y,z) #x,y,z represents the centre of the scene
The same as the cross environment cube except that texture is like a small cross;
envmap = pi3d.loadTexture("textures/skybox.jpg")
myecube = pi3d.createEnvironmentCube(900.0, "HALFCROSS")
... next line goes in rendering loop
myecube.draw(envmap, x,y,z) #x,y,z represents the centre of the scene