示例#1
0
display = Display()
display.create3D(50,50,display.max_width-100,display.max_height-100)   	# x,y,width,height
display.setBackColour(0.2,0.4,0.6,1)    # r,g,b,alpha

# load model_loadmodel
texs = Textures()
mymodel = Model("models/Triceratops/Triceratops.egg",texs,"Triceratops", 0,-1,0, -90,0,0, .005,.005,.005)

# Fetch key presses
mykeys = Keyboard()

# mastrix and rotate variables
rot=0

#create a light
mylight = Light(0,1,1,1,"",10,10,0)
mylight.on()

while 1:
  display.clear()

  Utility.load_identity()
  Utility.translatef(0,0, -40)
  Utility.rotatef(rot, 0, 1, 0)
  rot += 3

  mymodel.draw()

  k = mykeys.read()
  if k >-1:
    if k==112: display.screenshot("Triceratops.jpg")
示例#2
0
display.create3D(100,100,800,600, 0.5, 800.0, 60.0)  # x,y,width,height,near,far,aspect
display.setBackColour(0.4,0.8,0.8,1)      # r,g,b,alpha

# Load textures
texs = Textures()
tree2img = texs.loadTexture("textures/tree2.png")
tree1img = texs.loadTexture("textures/tree1.png")
grassimg = texs.loadTexture("textures/grass.png")
hb2img = texs.loadTexture("textures/hornbeam2.png")

#myecube = EnvironmentCube(900.0,"HALFCROSS")

ectex=loadECfiles("textures/ecubes","sbox",texs)
myecube = EnvironmentCube(900.0,"FACES")

light = Light(0, 10,10,10, "", 0,100,0)
light.on()

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

#Create tree models
treeplane = Plane(4.0,5.0)

treemodel1 = MergeShape("baretree")
treemodel1.add(treeplane, 0,0,0)
treemodel1.add(treeplane, 0,0,0, 0,90,0)
示例#3
0
avhgt = 2.0
xm=0.0
zm=0.0
ym= -(mymap.calcHeight(xm,zm)+avhgt)

# Fetch key presses
mykeys = Keyboard()
mymouse = Mouse()
mymouse.start()
mtrx = Matrix()

omx=mymouse.x
omy=mymouse.y

myfog = Fog(0.002,(0.3,0.8,0.6,0.5))
mylight = Light(0,1,1,1,"",10,10,10, .9,.7,.6)

# Display scene and rotate cuboid
while 1:
  display.clear()

  mtrx.identity()
  #tilt can be used as a means to prevent the view from going under the landscape!
  if tilt<-1: sf=1.0/-tilt
  else: sf=1.0
  mtrx.translate(0,-10*sf-5.0,-40*sf)   #zoom camera out so we can see our robot
  mtrx.rotate(tilt, 0, 0)		#Robot still affected by scene tilt

  #draw robot
  mylight.on()
  robot.drawAll(metalimg)
示例#4
0
文件: Pong.py 项目: JamesR1/pi3d
radius = 1.0
ball = Sphere(radius,12,12,0.0,"sphere",-4,8,-7)
#monster
monster = Plane(5.0, 5.0, "monster", 0,0,0, 0,0,0)

# Create elevation map
mapwidth=50.0
mapdepth=50.0
maphalf=22.0
mapheight=40.0
#set smooth to give proper normals the bouncing won't work properly without and it doesn't look as good
mymap = ElevationMap("textures/pong.jpg",mapwidth,mapdepth,mapheight,32,32,4,"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 = Light(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 setting position with 0 fourth parameter
light.on()

#avatar camera
rot=0.0
tilt=0.0
avhgt = 2.0
xm=0.0
zm=0.0
ym=mapheight
lastX0=0.0
lastZ0=0.0

arialFont = Font("AR_CENA","#dd00aa")   #load AR_CENA font and set the font colour to 'raspberry'
score = [0,0]
示例#5
0
文件: Amazing.py 项目: JamesR1/pi3d
  rArr.append(random.random()*45) # front faces approximately towards the sun (found by trial and error)
for g in shed.vGroup:
  thisAbbGp = MergeShape("shed")
  for i in range(len(xArr)):
    thisAbbGp.add(shed.vGroup[g], xArr[i], yArr[i], zArr[i], 0, rArr[i], 0)
  shedgp[g] = thisAbbGp

#monster
monst = TCone()
mDx,mDy,mDz = 0.1,0,0.2
mSx,mSy,mSz = -5, mymap.calcHeight(-5,5)+1, 5
gravity = 0.02

# 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 = Light(0, 4, 4, 2, "", 0,1,-2, 0.1,0.1,0.2) #yellowish 'torch' or 'sun' (could be blueish ambient with different env cube)
light.on()

#screenshot number key P for screenshots
scshots = 1

#energy counter
hp = 25

#missile
missile = Missile(50,50)

#avatar camera NB this isn't really moving as an object in the scene - it's staying still and used to move everything else
#relative to it. So -xm, -ym, -zm all need to be used for calcualtions of real object relative to the camera!
camera = Matrix()
rot=0.0