コード例 #1
0
            class DummyTkWin(object):
                def __init__(self):
                    self.tkKeyboard = Keyboard()
                    self.ev = ""
                    self.key = ""
                    self.winx, self.winy = 0, 0
                    self.width, self.height = 1920, 1180
                    self.event_list = []

                def update(self):
                    if PLATFORM == PLATFORM_WINDOWS or pi3d.USE_PYGAME:  #uses pygame UI
                        k = self.tkKeyboard.read()
                        if k == -1:
                            self.key = ""
                            self.ev = ""
                        else:
                            if k == 27:
                                self.key = "Escape"
                            else:
                                self.key = chr(k)
                            self.ev = "key"
                    else:
                        self.key = self.tkKeyboard.read_code()
                        if self.key == "":
                            self.ev = ""
                        else:
                            self.ev = "key"
コード例 #2
0
ファイル: Display.py プロジェクト: bpow/pi3d
      class DummyTkWin(object):
        def __init__(self):
          self.tkKeyboard = Keyboard()
          self.ev = ""
          self.key = ""
          self.winx, self.winy = 0, 0
          self.width, self.height = 1920, 1180
          self.event_list = []

        def update(self):
          if pi3d.PLATFORM == pi3d.PLATFORM_WINDOWS or pi3d.USE_PYGAME: #uses pygame UI
            k = self.tkKeyboard.read()
            if k == -1:
              self.key = ""
              self.ev = ""
            else:
              if k == 27:
                self.key = "Escape"
              else:
                self.key = chr(k)
              self.ev = "key"
          else:
            self.key = self.tkKeyboard.read_code()
            if self.key == "":
              self.ev = ""
            else:
              self.ev = "key"
コード例 #3
0
ファイル: TriceratopsModel.py プロジェクト: JamesR1/pi3d
# 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")
    elif k==27:
      mykeys.close()
      texs.deleteAll()
      display.destroy()
      break
    else:
      print k

  display.swapBuffers()
コード例 #4
0
ファイル: TriceratopsModel.py プロジェクト: akissu/pi3d
                x=0,
                y=-1,
                z=40,
                sx=0.005,
                sy=0.005,
                sz=0.005)
mymodel.set_shader(shader)

# Fetch key presses
mykeys = Keyboard()

while 1:
    DISPLAY.clear()

    mymodel.draw()
    mymodel.rotateIncZ(0.001)
    mymodel.rotateIncX(-0.00317543)
    mymodel.rotateIncY(0.11)

    k = mykeys.read()
    if k > -1:
        if k == 112: screenshot('Triceratops.jpg')
        elif k == 27:
            mykeys.close()
            DISPLAY.destroy()
            break
        else:
            print(k)

    DISPLAY.swap_buffers()
コード例 #5
0
ファイル: Clouds3d.py プロジェクト: JamesR1/pi3d
while True:

  display.clear()

  maxDepth = 0
  axDepthIndex = 0
  # this is easier to understand, the z position of each cloud is (only) held in cxyz[][2]
  # it stops the clouds appearing in front of nearer clouds!
  # first go through the clouds to find index of furthest away
  for i in range(len(cxyz)):
    cxyz[i][2] = (cxyz[i][2] - speed) % cloud_depth
    if (cxyz[i][2] > maxDepth):
      maxDepth = cxyz[i][2]
      maxDepthIndex = i

  # paint the clouds from background to foreground
  for i in range(maxDepthIndex, maxDepthIndex + cloudno):
    c = cxyz[i%cloudno]
    Draw.sprite(clouds[c[3]], c[0], c[1], -c[2], 8, 5)

  #Press ESCAPE to terminate
  if mykeys.read() == 27:
    mykeys.close()
    texs.deleteAll()
    display.destroy()
    break

  display.swapBuffers()
  time.sleep(0.01)
コード例 #6
0
# 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
    maxDepth = -100
    for i, cloud in enumerate(clouds):
        if cloud.z() > maxDepth:
            maxDepth = cloud.z()
            maxDepthIndex = i

    # paint the clouds from background to foreground
    # normally not the most efficient order but has to be done this way for low alpha
    for i in range(cloudno):
        cloud = clouds[(maxDepthIndex + i) % cloudno]
        cloud.draw()
        cloud.translateZ(-speed)
        if cloud.z() < -20.0:
            # send to back
            cloud.positionZ(cloud_depth)

    #Press ESCAPE to terminate
    if mykeys.read() == 27:
        mykeys.close()
        DISPLAY.destroy()
        break