Exemplo n.º 1
0
Arquivo: Blur.py Projeto: Arexxk/pi3d
#Create textures
shapeimg = Texture("textures/straw1.jpg")
shapebump = Texture("textures/floor_nm.jpg", True)
shapeshine = Texture("textures/pong3.png")

#Create shape
myshape = MergeShape(camera=persp_cam) #specify perspective view
asphere = Sphere(sides=16, slices=16)
myshape.radialCopy(asphere, step=72)
myshape.position(0.0, 0.0, 5.0)
myshape.set_draw_details(shader, [shapeimg, shapebump, shapeshine], 8.0, 0.1)

mysprite = Sprite(w=10.0, h=10.0, camera=persp_cam)
mysprite.position(0.0, 0.0, 15.0)
mysprite.set_draw_details(flatsh, [shapebump])

tick=0
next_time = time.time()+2.0

#load ttf font and set the font colour to 'raspberry'
arialFont = Ttffont("fonts/FreeMonoBoldOblique.ttf", "#dd00aa")
mystring = String(font=arialFont, string="blurring with distance!",
                  camera=ortho_cam, z=1.0, is_3d=False) # orthographic view
mystring.set_shader(flatsh)

# Fetch key presses.
mykeys = Keyboard()

# Display scene and rotate shape
while DISPLAY.loop_running():
Exemplo n.º 2
0
cloudTex.append(Texture("textures/cloud3.png", True))
cloudTex.append(Texture("textures/cloud4.png", True))
cloudTex.append(Texture("textures/cloud5.png", True))
cloudTex.append(Texture("textures/cloud6.png", True))

# Setup cloud positions and cloud image refs
cz = 0.0
clouds = []  # an array for the clouds
for b in range(0, cloudno):
    size = 0.5 + random.random() / 2.0
    cloud = Sprite(w=size * widex,
                   h=size * widey,
                   x=150.0 * (random.random() - 0.5),
                   y=0.0,
                   z=cloud_depth - cz)
    cloud.set_draw_details(shader, [cloudTex[int(random.random() * 4.99999)]],
                           0.0, 0.0)
    clouds.append(cloud)
    cz = cz + zd

CAMERA = Camera.instance()
CAMERA.position((0.0, 0.0, 50.0))
CAMERA.was_moved = False
# Fetch key presses
mykeys = Keyboard()

while DISPLAY.loop_running():
    # the z position of each cloud is held in clouds[i].unif[2] returned by cloud.z()
    # it stops the clouds being drawn behind nearer clouds and pixels being
    # discarded by the shader! that should be blended.
    # first go through the clouds to find index of furthest away
    maxDepthIndex = 0
Exemplo n.º 3
0
#Create textures
shapeimg = Texture("textures/straw1.jpg")
shapebump = Texture("textures/floor_nm.jpg", True)
shapeshine = Texture("textures/pong3.png")

#Create shape
myshape = MergeShape(camera=persp_cam)  #specify perspective view
asphere = Sphere(sides=16, slices=16)
myshape.radialCopy(asphere, step=72)
myshape.position(0.0, 0.0, 5.0)
myshape.set_draw_details(shader, [shapeimg, shapebump, shapeshine], 8.0, 0.1)

mysprite = Sprite(w=10.0, h=10.0, camera=persp_cam)
mysprite.position(0.0, 0.0, 15.0)
mysprite.set_draw_details(flatsh, [shapebump])

tick = 0
next_time = time.time() + 2.0

#load ttf font and set the font colour to 'raspberry'
arialFont = Ttffont("fonts/FreeMonoBoldOblique.ttf", "#dd00aa")
mystring = String(font=arialFont,
                  string="blurring with distance!",
                  camera=ortho_cam,
                  z=1.0,
                  is_3d=False)  # orthographic view
mystring.set_shader(flatsh)

# Fetch key presses.
mykeys = Keyboard()
Exemplo n.º 4
0
cloudTex = []
cloudTex.append(Texture("textures/cloud2.png",True))
cloudTex.append(Texture("textures/cloud3.png",True))
cloudTex.append(Texture("textures/cloud4.png",True))
cloudTex.append(Texture("textures/cloud5.png",True))
cloudTex.append(Texture("textures/cloud6.png",True))

# Setup cloud positions and cloud image refs
cz = 0.0
clouds = [] # an array for the clouds
for b in range (0, cloudno):
  size = 0.5 + random.random()/2.0
  cloud = Sprite(w=size * widex, h=size * widey, 
          x=150.0 * (random.random() - 0.5), y=0.0, z=cloud_depth - cz)
  cloud.set_draw_details(shader, [cloudTex[int(random.random() * 4.99999)]], 0.0, 0.0)
  clouds.append(cloud)
  cz = cz + zd

CAMERA = Camera.instance()
CAMERA.position((0.0, 0.0, 50.0))
CAMERA.was_moved = False
# Fetch key presses
mykeys = Keyboard()

while DISPLAY.loop_running():
  # the z position of each cloud is held in clouds[i].unif[2] returned by cloud.z()
  # it stops the clouds being drawn behind nearer clouds and pixels being 
  # discarded by the shader! that should be blended.
  # first go through the clouds to find index of furthest away
  maxDepthIndex = 0