Ejemplo n.º 1
0
 def setImage(self, name): #, texCoord=[(0, 0), (1, 0), (1, 1), (0, 1)]):
     """ sets shape's texture
     """
     self.texID = engine.loadTexture(name) # class method
Ejemplo n.º 2
0
 def __init__(self, evsys, updater, track):
     self.track = track
     f = open("models/harimau")
     l = f.readline()[:-1]
     if not "faces" in l:
         print "errror"
     faclen = int(l.split(" ")[1])
     l = f.readline()[:-1]
     if not "verts" in l:
         print "errror"
     vertlen = int(l.split(" ")[1])
     self.texref = []
     self.faces = []
     self.verts = []
     for i in xrange(faclen):
         ltex = f.readline()[:-1].split(" ")[0].strip()
         ldat = f.readline()[:-1].split("|")
         verts = ldat[0].split(" ")[:-1]
         uvs = ldat[1].split(" ")
         normal = f.readline()[:-1].split(" ")
         face = Face()
         face.v = [int(v) for v in verts]
         face.normal = [float(v) for v in normal]
         tmuvs = [float(uv) for uv in uvs]
         face.uvs[0] = tmuvs[0], tmuvs[1]
         face.uvs[1] = tmuvs[2], tmuvs[3]
         face.uvs[2] = tmuvs[4], tmuvs[5]
         if ltex not in self.texref:
             self.texref.append(ltex)
         face.tex = self.texref.index(ltex)
         self.faces.append(face)
     for i in xrange(vertlen):
         normal = f.readline()[:-1].split(" ")
         vert = [float(v) for v in normal]
         self.verts.append(vert)
     self.texglref = []
     for fname in self.texref:
         self.texglref.append(en.loadTexture("textures/" + fname))
     evsys.signal("keydown_left").Connect(bind(self.startMove, 0, -1, 0.8))
     evsys.signal("keyup_left").Connect(bind(self.stopMove, 0, -1, 0.8))
     evsys.signal("keydown_right").Connect(bind(self.startMove, 0, 1, -0.8))
     evsys.signal("keyup_right").Connect(bind(self.stopMove, 0, 1, -0.8))
     evsys.signal("keydown_up").Connect(bind(self.startMove, 1, 0, 0))
     evsys.signal("keyup_up").Connect(bind(self.stopMove, 1, 0, 0))
     evsys.signal("keydown_down").Connect(bind(self.startMove, -1, 0, 0))
     evsys.signal("keyup_down").Connect(bind(self.stopMove, -1, 0, 0))
     evsys.signal("keydown_pageup").Connect(bind(self.startMove, 0, 0, 1))
     evsys.signal("keyup_pageup").Connect(bind(self.stopMove, 0, 0, 1))
     evsys.signal("keydown_pagedown").Connect(bind(self.startMove, 0, 0, -1))
     evsys.signal("keyup_pagedown").Connect(bind(self.stopMove, 0, 0, -1))
     evsys.signal("keydown_x").Connect(bind(self.setForward, True))
     evsys.signal("keyup_x").Connect(bind(self.setForward, False))
     updater.Connect(self.draw, 6000)
     self.rot = en.Vector(0,0,0)
     self.osc = en.OpenSoundControl()
     self.osc.connect("localhost", 9002)
     self.move = True
     self.moverot = en.Vector(0)
     self.movebody = physics.Body()
     self.rotbody = physics.Body()
     self.m = en.Matrix()
     self.forward = False
     self.upv = Vector(0,1,0)
Ejemplo n.º 3
0
    def die(self):
        self.v.die = True

LightPosition  = [0.0, 10.0, 2.0, 1.0]
LightAmbient = [0.5, 0.5, 0.5, 1.0]
LightDiffuse = [1.0, 1.0, 1.0, 1.0]
glLightfv( GL_LIGHT1, GL_AMBIENT, LightAmbient )
glLightfv( GL_LIGHT1, GL_DIFFUSE, LightDiffuse )
glLightfv( GL_LIGHT1, GL_POSITION, LightPosition )
glEnable( GL_LIGHT1 )

#evsys = EventSystem()
evsys = ev.EventSystem()
evsys.runOSCServer(7779)

tex = en.loadTexture("textures/thefuture.png")
updater = signals.Signal()
tr = track.Track(updater, tex)
vid = Video(updater)
s = harimau.Ship(evsys, updater, tr)
cam = Camera(evsys, updater, s)
#cube.Cube(updater, tex, s)

finish = False
def stopLoop(p):
    global finish
    finish = True
evsys.signal("keydown_escape").Connect(stopLoop)

while not finish:
    try:
Ejemplo n.º 4
0
 def setImage(self, name):  #, texCoord=[(0, 0), (1, 0), (1, 1), (0, 1)]):
     """ sets shape's texture
     """
     self.texID = engine.loadTexture(name)  # class method