Ejemplo n.º 1
0
Archivo: Draw.py Proyecto: JamesR1/pi3d
def string(font, string, x, y, z, rot, sclx, scly):
  opengles.glNormalPointer(GL_BYTE, 0, RECT_NORMALS)
  Utility.texture_min_mag()
  opengles.glEnableClientState(GL_TEXTURE_COORD_ARRAY)
  opengles.glBindTexture(GL_TEXTURE_2D,font.tex)
  opengles.glEnable(GL_TEXTURE_2D)

  opengles.glDisable(GL_DEPTH_TEST)
  opengles.glDisable(GL_CULL_FACE)
  opengles.glEnable(GL_BLEND)
  opengles.glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA)

  mtrx =(c_float * 16)()
  opengles.glGetFloatv(GL_MODELVIEW_MATRIX,ctypes.byref(mtrx))
  Utility.translatef(x, y, z)
  Utility.rotatef(rot, 0, 0, 1)
  Utility.scalef(sclx, scly, 1)

  for c in range(0,len(string)):
    v = ord(string[c])-32
    w, h, texc, verts = font.chr[v]
    if v > 0:
      opengles.glVertexPointer(3, GL_FLOAT, 0,verts)
      opengles.glTexCoordPointer(2, GL_FLOAT,0,texc)
      opengles.glDrawElements( GL_TRIANGLES, 6, GL_UNSIGNED_BYTE, RECT_TRIANGLES)
    Utility.translatef(w, 0, 0)

  opengles.glLoadMatrixf(mtrx)
  opengles.glDisable(GL_TEXTURE_2D)
  opengles.glDisable(GL_BLEND)
  opengles.glEnable(GL_DEPTH_TEST)
  opengles.glEnable(GL_CULL_FACE)
Ejemplo n.º 2
0
  def transform(self):
    Utility.translatef(self.x - self.cx, self.y - self.cy, self.z - self.cz)

    # TODO: why the reverse order?
    Utility.rotatef(self.rotz, 0, 0, 1)
    Utility.rotatef(self.roty, 0, 1, 0)
    Utility.rotatef(self.rotx, 1, 0, 0)
    Utility.scalef(self.sx, self.sy, self.sz)
    Utility.translatef(self.cx, self.cy, self.cz)
Ejemplo n.º 3
0
Archivo: Draw.py Proyecto: JamesR1/pi3d
def _draw(verts, tex, x, y, w, h, r, z):
  opengles.glNormalPointer(GL_BYTE, 0, RECT_NORMALS);
  opengles.glVertexPointer(3, GL_BYTE, 0, verts);
  Utility.load_identity()
  Utility.translatef(x, y, z)
  Utility.scalef(w, h, 1)
  if r:
    Utility.rotatef(r, 0, 0, 1)
  with Texture.Loader(tex,RECT_TEX_COORDS,GL_BYTE):
    opengles.glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_BYTE, RECT_TRIANGLES)
Ejemplo n.º 4
0
  def draw(self,tex, x, y, z):
    mtrx = (ctypes.c_float*16)()
    opengles.glGetFloatv(GL_MODELVIEW_MATRIX,ctypes.byref(mtrx))
    Utility.translatef(-x, -y, -z)
    Utility.texture_min_mag();
    opengles.glVertexPointer(3, GL_FLOAT, 0, self.vertices)
    opengles.glNormalPointer(GL_FLOAT, 0, self.normals)
    opengles.glEnableClientState(GL_TEXTURE_COORD_ARRAY)
    opengles.glDisable(GL_LIGHTING)
    opengles.glEnable(GL_TEXTURE_2D)

    if self.maptype=="FACES":
        opengles.glTexCoordPointer(2, GL_FLOAT, 0, self.tex_faces)
        opengles.glBindTexture(GL_TEXTURE_2D,tex[0].tex)
        opengles.glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_SHORT , self.indtop)

        Utility.texture_min_mag()
        opengles.glBindTexture(GL_TEXTURE_2D,tex[1].tex)
        opengles.glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_SHORT , self.indleft)

        Utility.texture_min_mag()
        opengles.glBindTexture(GL_TEXTURE_2D,tex[2].tex)
        opengles.glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_SHORT , self.indfront)

        Utility.texture_min_mag()
        opengles.glBindTexture(GL_TEXTURE_2D,tex[3].tex)
        opengles.glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_SHORT , self.indright)

        Utility.texture_min_mag()
        opengles.glBindTexture(GL_TEXTURE_2D,tex[4].tex)
        opengles.glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_SHORT , self.indback)
        if tex[5] >0:
          Utility.texture_min_mag()
          opengles.glBindTexture(GL_TEXTURE_2D,tex[5].tex)
          opengles.glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_SHORT , self.indbot)
    else:
      #load view matrix
      opengles.glTexCoordPointer(2, GL_FLOAT, 0, self.tex_coords)
      opengles.glBindTexture(GL_TEXTURE_2D,tex.tex)
      opengles.glDrawElements(GL_TRIANGLES, 36, GL_UNSIGNED_SHORT , self.indices)

    opengles.glEnable(GL_LIGHTING)
    opengles.glDisable(GL_TEXTURE_2D)
    #restore to previous matrix
    opengles.glLoadMatrixf(mtrx)
Ejemplo n.º 5
0
# 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")
    elif k==27:
      mykeys.close()
      texs.deleteAll()
      display.destroy()
      break
    else:
      print k
Ejemplo n.º 6
0
 def translate(self,x,y,z):
   # TODO: get rid of this.
   Utility.translatef(x, y, z)