Skip to content

Pi3D createEnvironmentCube

tipam edited this page Jul 11, 2012 · 5 revisions

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.

createEnvironmentCube(size,type)

There are currently three types of environment map supported; Faces, Cross and Halfcross ...

1) Faces Environment Cube

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

2) Cross Environment Cube

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

3) Half-Cross Environment Cube

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

Clone this wiki locally