Ejemplo n.º 1
0
  def draw(self, texID=None, n=None):
    # TODO: shadows Shape.draw.
    if self.exf != 'egg' and self.exf != 'obj':
      return

    # From loaderEgg.draw, probably added by paddy gaunt 15 June 2012
    texToUse = None
    if texID != None:
      texToUse = texID
    elif n != None:
      n = n % (len(self.textureList))
      i = 0
      for t in self.textureList:
        if i == n:
          texToUse = self.textureList[t].texID
          break
        i += 1

    mtrx = Matrix()
    mtrx.push()
    self.transform()
    for g in self.vGroup:
      opengles.glShadeModel(GL_SMOOTH)
      opengles.glVertexPointer( 3, GL_FLOAT, 0, self.vGroup[g].vertices);
      opengles.glNormalPointer( GL_FLOAT, 0, self.vGroup[g].normals);

      texture = texToUse or self.vGroup[g].texID
      with Texture.Loader(texture, self.vGroup[g].tex_coords):
        #TODO enable material colours as well as textures from images
        material = self.vGroup[g].material
        if material:
          #opengles.glMaterialfv(GL_FRONT, GL_DIFFUSE, material);
          opengles.glEnableClientState(GL_COLOR_ARRAY)
          opengles.glColorPointer(4, GL_UNSIGNED_BYTE, 0, material);

        opengles.glDrawElements(GL_TRIANGLES, self.vGroup[g].indicesLen,
                                GL_UNSIGNED_SHORT, self.vGroup[g].indices)


        opengles.glShadeModel(GL_FLAT)
    mtrx.pop()

    for c in self.childModel:
      relx, rely, relz = c.x, c.y, c.z
      relrotx, relroty, relrotz = c.rotx, c.roty, c.rotz
      rval = rotate_vec(self.rotx, self.roty, self.rotz, (c.x, c.y, c.z))
      c.x, c.y, c.z = self.x + rval[0], self.y + rval[1], self.z + rval[2]
      c.rotx, c.roty, c.rotz = (self.rotx + c.rotx, self.roty + c.roty,
                                self.rotz + c.rotz)
      c.draw() #should texture override be passed down to children?
      c.x, c.y, c.z = relx, rely, relz
      c.rotx, c.roty, c.rotz = relrotx, relroty, relrotz
Ejemplo n.º 2
0
#         (shape,elevmap,xpos,zpos,w,d,count,options,minscl,maxscl)


#screenshot number
scshots = 1

#avatar camera
rot=0.0
tilt=0.0
avhgt = 2.0
xm=0.0
zm=0.0
ym= -(mymap.calcHeight(xm,zm)+avhgt)

# setup matrices
mtrx = Matrix()

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

omx=mymouse.x
omy=mymouse.y

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

  mtrx.identity()
  mtrx.rotate(tilt, 0, 0)
Ejemplo n.º 3
0
# Setup display and initialise pi3d
display = Display()
display.create3D(100,100,1200,900)    # x,y,width,height
display.setBackColour(0.2,0.4,0.6,1)      # r,g,b,alpha

texs = Textures()

# load model_loadmodel
mymodel = Model("models/teapot.obj",texs ,"teapot", 0,-1.0,0)

# Fetch key presses
mykeys = Keyboard()

# setup matrices
mtrx = Matrix()

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

while 1:
  display.clear()

  mtrx.identity()
  mtrx.translate(0,2,-5)

  mymodel.draw()
  mymodel.rotateIncY(1.0)
  mymodel.rotateIncX(1.3)
Ejemplo n.º 4
0
# Setup display and initialise pi3d
display = Display()
display.create3D(100,100,1200,900)    # x,y,width,height
display.setBackColour(0.2,0.4,0.6,1)      # r,g,b,alpha

texs = Textures()

# load model_loadmodel
mymodel = Model("models/teapot.egg",texs ,"teapot", 0,-1,0)

# Fetch key presses
mykeys = Keyboard()

# setup matrices
mtrx = Matrix()

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

while 1:
  display.clear()

  mtrx.identity()
  mtrx.translate(0,0,-10)

  mymodel.draw()
  mymodel.rotateIncY(3.0)

  k = mykeys.read()
Ejemplo n.º 5
0
  myecube = EnvironmentCube(900.0,"HALFCROSS")
elif box==2:
  ectex=loadECfiles("textures/ecubes","sbox_interstellar",texs)
  myecube = EnvironmentCube(900.0,"FACES")
else:
  ectex=loadECfiles("textures/ecubes","skybox_hall",texs)
  myecube = EnvironmentCube(900.0,"FACES")

rot=0.0
tilt=0.0

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

omx = mymouse.x
omy = mymouse.y

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

  mtrx.identity()
  mtrx.rotate(tilt, 0, 0)
  mtrx.rotate(0, rot, 0)
  #Utility.translatef(xm, ym, zm)

  myecube.draw(ectex, 0.0, 0.0, 0.0)
Ejemplo n.º 6
0
Archivo: Pong.py Proyecto: JamesR1/pi3d
dsx, dsy, dsz = 0.2, 0.0, -0.1
gravity = 0.02
#monster loc and speed
rx, ry, rz = 0, 0, -maphalf
drx, dry, drz = 0, 0, 0
max_speed = 0.2

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

omx=mymouse.x
omy=mymouse.y

camera = Matrix()

while True:
  display.clear()

  camera.identity()
  camera.translate(xm,-2+ym-mapheight,-maphalf-2.5)

  myecube.draw(ectex,xm,ym,zm)
  mymap.draw(groundimg)

  #monster movement
  drx = sx - rx
  if abs(drx) > max_speed: drx = drx/abs(drx) * max_speed
  dry = sy - ry
  if abs(dry) > max_speed: dry = dry/abs(dry) * max_speed
Ejemplo n.º 7
0
station.add(scorrid, 0,0,20, 90,90,0)
station.add(scorrid, 0,0,-20, 90,90,0)

#avatar camera
rot=0.0
tilt=0.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
Ejemplo n.º 8
0
mymouse.start()

#screenshot number
scshots = 1

#avatar camera
rot=0.0
tilt=0.0
avhgt = 2.0
xm=0.0
zm=0.0
ym= -avhgt

#create a light
mylight = Light(0,1,1,1,"",0,200,200,0.4,0.4,0.4)
mtrx=Matrix()

omx=mymouse.x
omy=mymouse.y

while 1:
  display.clear()

  mtrx.identity()
  mtrx.rotate(tilt, rot, 0)
  mtrx.translate(xm,ym,zm)
  mtrx.push()
  mtrx.rotate(0, 180, 0)
  myecube.draw(ectex,xm,ym,zm)
  mtrx.pop()
Ejemplo n.º 9
0
# 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
tilt=0.0
avhgt = 2.0
xm=0.0
zm=0.0
ym= -(mymap.calcHeight(xm,zm)+avhgt)
lastX0=0.0
lastZ0=0.0

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

omx=mymouse.x