예제 #1
0
파일: pablo.py 프로젝트: pabloav/pi3d
# before running this example
#

import pi3d
import math

# Setup display and initialise pi3d
display = pi3d.display()
display.create3D(1,1,1280,1024)   	# x,y,width,height
display.setBackColour(0,0,0,1)    	# r,g,b,alpha

# Load textures

# Setting 2nd param to True renders 'True' Blending
# (this can be changed later to 'False' with 'cloudimg.blend = False')
myplane = pi3d.createPlane(300, 300, 'box', 100, 100, 0)

starsimg = pi3d.loadTexture("textures/stars2.jpg")

arialFont = pi3d.font("MicrosoftSansSerif","#dd00aa")   #load AR_CENA font and set the font colour to 'raspberry'
destineFont = pi3d.font("Tahoma", "#0055ff")

# Fetch key presses
mykeys = pi3d.key()

rot=0.0

# Display scene
while 1:
    display.clear()
예제 #2
0
# Create elevation map
mapwidth=1000.0
mapdepth=1000.0
mapheight=60.0
landimg = pi3d.loadTexture("textures/stonygrass.jpg")
#surface1 = pi3d.loadTextureAlpha("textures/gravel3.png")
mymap = pi3d.createElevationMapFromTexture("textures/mountainsHgt.jpg",mapwidth,mapdepth,mapheight,64,64,10.0) #testislands.jpg
#mymap2 = pi3d.createElevationMapFromTexture("textures/mountainsHgt.jpg",mapwidth,mapdepth,mapheight,64,64, 128)

myclip = pi3d.clipPlane()

light = pi3d.createLight(0, 10,10,10, "", 0,100,0)
light.on()

#Create tree models
treeplane = pi3d.createPlane(4.0,5.0)

treemodel1 = pi3d.createMergeShape("baretree")
treemodel1.add(treeplane, 0,0,0)
treemodel1.add(treeplane, 0,0,0, 0,90,0)

treemodel2 = pi3d.createMergeShape("bushytree")
treemodel2.add(treeplane, 0,0,0)
treemodel2.add(treeplane, 0,0,0, 0,60,0)
treemodel2.add(treeplane, 0,0,0, 0,120,0)

#Scatter them on map using Merge shape's cluster function
mytrees1 = pi3d.createMergeShape("trees1")
mytrees1.cluster(treemodel1, mymap,0.0,0.0,200.0,200.0,30,"",8.0,3.0)
# (shape,elevmap,xpos,zpos,w,d,count,options,minscl,maxscl)
예제 #3
0
#ectex = pi3d.loadTexture("textures/SkyBox.png")
#myecube = pi3d.createEnvironmentCube(900.0,"HALFCROSS")

ectex=pi3d.loadECfiles("textures/ecubes","sbox",texs)
myecube = pi3d.createEnvironmentCube(900.0,"FACES")

# Create elevation map
mapwidth=1000.0
mapdepth=1000.0
mapheight=60.0
mountimg1 = texs.loadTexture("textures/mountains3_512.jpg")
mymap = pi3d.createElevationMapFromTexture("textures/mountainsHgt.jpg",mapwidth,mapdepth,mapheight,64,64) #testislands.jpg
 
#Create tree models	
treeplane = pi3d.createPlane(4.0,5.0)

treemodel1 = pi3d.createMergeShape("baretree")
treemodel1.add(treeplane, 0,0,0)
treemodel1.add(treeplane, 0,0,0, 0,90,0)

treemodel2 = pi3d.createMergeShape("bushytree")
treemodel2.add(treeplane, 0,0,0)
treemodel2.add(treeplane, 0,0,0, 0,60,0)
treemodel2.add(treeplane, 0,0,0, 0,120,0)

#Create grass model	
grassplane = pi3d.createPlane(1.0,0.3,"",0,-2,0)
grassmodel = pi3d.createMergeShape("grass")
grassmodel.add(grassplane, 0,0,0)
grassmodel.add(grassplane, 0,0,0, 0,60,0)
예제 #4
0
파일: Pong.py 프로젝트: becky1166/pi3d
display.setBackColour(0.4,0.8,0.8,1) # r,g,b,alpha

# Load textures
texs=pi3d.textures()
# Setting 2nd param to True renders 'True' Blending
# (this can be changed later to 'False' with 'rockimg2.blend = False')
groundimg = texs.loadTexture("textures/pong2.jpg")
monstimg = texs.loadTexture("textures/pong3.png")
# environment cube
ectex = texs.loadTexture("textures/ecubes/skybox_stormydays.jpg")
myecube = pi3d.createEnvironmentCube(900.0,"CROSS")
#ball
radius = 1
ball = pi3d.createSphere(radius,12,12,0.0,"sphere",-4,2,-7)
#monster
monster = pi3d.createPlane(5.0, 5.0, "monster", 0,0,0, 0,0,0)
# Create elevation map
mapwidth=50.0                              
mapdepth=50.0
maphalf=23.0
mapheight=20.0
#set smooth to give proper normals
mymap = pi3d.createElevationMapFromTexture("textures/pong.jpg",mapwidth,mapdepth,mapheight,64,64,2,"sub",0,0,0, smooth=True)
# lighting. The default light is a point light but I have made the position method capable of creating
# a directional light and this is what I do inside the loop. If you want a torch you don't need to move it about
light = pi3d.createLight(0, 2, 2, 1, "", 1,2,3, 0.1,0.1,0.2) #yellowish 'torch' or 'sun' with low level blueish ambient
light.position(1,2,3,0) # set to directional light by settin position with 0 fourth parameter
light.on()

#avatar camera
rot=0.0
예제 #5
0
# Create elevation map
mapwidth=1000.0
mapdepth=1000.0
mapheight=60.0
landimg = texs.loadTexture("textures/stonygrass.jpg")
#surface1 = pi3d.loadTextureAlpha("textures/gravel3.png")
mymap = pi3d.createElevationMapFromTexture("textures/mountainsHgt.jpg",mapwidth,mapdepth,mapheight,64,64,10.0) #testislands.jpg
#mymap2 = pi3d.createElevationMapFromTexture("textures/mountainsHgt.jpg",mapwidth,mapdepth,mapheight,64,64, 128)

myclip = pi3d.clipPlane()

light = pi3d.createLight(0, 10,10,10, "", 0,100,0)
light.on()

#Create tree models
treeplane = pi3d.createPlane(4.0,5.0)

treemodel1 = pi3d.createMergeShape("baretree")
treemodel1.add(treeplane, 0,0,0)
treemodel1.add(treeplane, 0,0,0, 0,90,0)

treemodel2 = pi3d.createMergeShape("bushytree")
treemodel2.add(treeplane, 0,0,0)
treemodel2.add(treeplane, 0,0,0, 0,60,0)
treemodel2.add(treeplane, 0,0,0, 0,120,0)

#Scatter them on map using Merge shape's cluster function
mytrees1 = pi3d.createMergeShape("trees1")
mytrees1.cluster(treemodel1, mymap,0.0,0.0,200.0,200.0,30,"",8.0,3.0)
# (shape,elevmap,xpos,zpos,w,d,count,options,minscl,maxscl)
예제 #6
0
#myecube = pi3d.createEnvironmentCube(900.0,"HALFCROSS")

ectex = pi3d.loadECfiles("textures/ecubes", "sbox", texs)
myecube = pi3d.createEnvironmentCube(900.0, "FACES")

# Create elevation map
mapwidth = 1000.0
mapdepth = 1000.0
mapheight = 60.0
mountimg1 = texs.loadTexture("textures/mountains3_512.jpg")
mymap = pi3d.createElevationMapFromTexture("textures/mountainsHgt.jpg",
                                           mapwidth, mapdepth, mapheight, 64,
                                           64)  #testislands.jpg

#Create tree models
treeplane = pi3d.createPlane(4.0, 5.0)

treemodel1 = pi3d.createMergeShape("baretree")
treemodel1.add(treeplane, 0, 0, 0)
treemodel1.add(treeplane, 0, 0, 0, 0, 90, 0)

treemodel2 = pi3d.createMergeShape("bushytree")
treemodel2.add(treeplane, 0, 0, 0)
treemodel2.add(treeplane, 0, 0, 0, 0, 60, 0)
treemodel2.add(treeplane, 0, 0, 0, 0, 120, 0)

#Create grass model
grassplane = pi3d.createPlane(1.0, 0.3, "", 0, -2, 0)
grassmodel = pi3d.createMergeShape("grass")
grassmodel.add(grassplane, 0, 0, 0)
grassmodel.add(grassplane, 0, 0, 0, 0, 60, 0)