Disabled actor rotation for speed
[flail.git] / wall.py
blob23cdcfce768a2284716018f1a4db9ec1c00c93af
1 from __future__ import division
2 from geom import line
3 from pyglet.gl import *
7 class wall (object):
9 def __init__ (self, seg = None, img = None):
10 self.bounce, self.friction, self.stiction = 0, 0, 0
11 self.seg, self.__seg, self.tex = seg or line (), None, img and img.texture
13 if self.tex:
14 try:
15 perp = seg.perp ().normed (self.tex.height)
16 self.__seg = line (seg.p1 - perp, seg.p2 - perp)
18 glBindTexture (GL_TEXTURE_2D, self.tex.id)
19 glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_BORDER)
20 except ZeroDivisionError:
21 pass
23 def render (self):
24 if self.__seg:
25 u = self.seg.length () / self.tex.width
26 glBindTexture (GL_TEXTURE_2D, self.tex.id)
27 glBegin (GL_TRIANGLE_STRIP)
28 glColor4d (1, 1, 1, 1)
30 glTexCoord2d (0, self.tex.tex_coords[10])
31 glVertex3d (self.seg.p1.x,
32 self.seg.p1.y,
33 self.seg.p1.z)
35 glTexCoord2d (u, self.tex.tex_coords[7])
36 glVertex3d (self.seg.p2.x,
37 self.seg.p2.y,
38 self.seg.p2.z)
40 glTexCoord2d (0, self.tex.tex_coords[1])
41 glVertex3d (self.__seg.p1.x,
42 self.__seg.p1.y,
43 self.__seg.p1.z)
45 glTexCoord2d (u, self.tex.tex_coords[4])
46 glVertex3d (self.__seg.p2.x,
47 self.__seg.p2.y,
48 self.__seg.p2.z)
50 glEnd ()