djfroofy / Miru

Miru is a set of graphics extensions to pyglet enabling easier development of OpenGL-based applications in Python. Features include camera, lighting and advanced texture mapping abstractions. There is also support for loading Wavefront OBJ files.

Clone this repository (size: 7.2 MB): HTTPS / SSH
$ hg clone http://bitbucket.org/djfroofy/miru/
commit 203: 94c7af0a3cb5
parent 202: e141eae14c84
branch: default
-bump
dre...@gmail.com
23 months ago

Changed (Δ961 bytes):

raw changeset »

miru/camera.py (19 lines added, 0 lines removed)

miru/effects.py (1 lines added, 1 lines removed)

miru/tools/obj.py (12 lines added, 2 lines removed)

miru/track.py (15 lines added, 6 lines removed)

Up to file-list miru/camera.py:

@@ -423,6 +423,13 @@ class DirectionalLight(LightMixin, commo
423
423
        gl.glLightfv(lno, gl.GL_DIFFUSE, self.ldifs)
424
424
        gl.glLightfv(lno, gl.GL_AMBIENT, self.lambient)
425
425
426
    def clone(self):
427
        return DirectionalLight(ambient=tuple(self.ambient),
428
                specular=tuple(self.specular),
429
                diffuse=self.diffuse,
430
                pos=tuple(self.pos),
431
                angle=tuple(self.angle))
432
426
433
427
434
class PositionalLight(LightMixin, common.PositionalMixin):
428
435
    """A positinal light's pos is the actual position in 3D space coords.
@@ -534,6 +541,18 @@ class PositionalLight(LightMixin, common
534
541
    spot_dir = property(_getspotdir, _setspotdir)
535
542
    spot_exponent = property(_getspotexponent, _setspotexponent)
536
543
544
545
    def clone(self):
546
        return PositionalLight(
547
                pos=tuple(self.pos),
548
                angle=tuple(self.angle),
549
                diffuse=tuple(self.diffuse),
550
                ambient=tuple(self.ambient),
551
                kc=self.kc, kl=self.kl, kq=self.kq,
552
                spot_cutoff=self.spot_cutoff,
553
                spot_exponent=self.spot_exponent[0],
554
                spot_dir=tuple(self.spot_dir))
555
537
556
    def _setdebug(self, debug):
538
557
539
558
        try:

Up to file-list miru/effects.py:

@@ -70,7 +70,7 @@ class Reflection:
70
70
        if ls is None: ls = env.camera.lights
71
71
        self.lights = miru.camera.LightGroup()
72
72
        for l in ls:
73
            self.lights.append(l)
73
            self.lights.append(l.clone())
74
74
            l2 = self.lights[-1]
75
75
            p = (l2.pos.x, -l2.pos.y, l2.pos.z)
76
76
            l2.pos = tuple(p)

Up to file-list miru/tools/obj.py:

@@ -88,7 +88,14 @@ class ObjParser:
88
88
        self.materials = {}
89
89
        data = StringIO()
90
90
91
        for line in fh:
91
        def i_():
92
            n = 0
93
            while True:
94
                yield n
95
                n += 1
96
97
        it = i_()
98
        for (idx,line) in ((it.next(),l) for l in fh):
92
99
            data.write(line)
93
100
            if not line[:-1]:
94
101
                continue
@@ -98,7 +105,10 @@ class ObjParser:
98
105
            directive = tks[0]
99
106
            try:
100
107
                h = getattr(self, '_handle_%s' % directive)
101
                h(tks[1:])
108
                try:
109
                    h(tks[1:])
110
                except Exception, e:
111
                    pass
102
112
            except AttributeError:
103
113
                f = failure.Failure()
104
114
                f.printTraceback()

Up to file-list miru/track.py:

@@ -108,17 +108,26 @@ class SSCameraTrack(Track):
108
108
109
109
    Assumption - view vector is parallel with the z-axis of the worldi.
110
110
111
    @param camera: the tracker
112
    @type  camera: miru.camera.Camera
111
    @param camera: the tracker Camera
112
113
    @type  camera: C{miru.camera.Camera}
114
113
115
    @param tracked: the object tracked by the camera
114
    @type  tracked: miru.mesh.Object
116
117
    @type  tracked: C{miru.common.PositionalMixin}
118
115
119
    @param window: view window
116
    @type  window: pyglet.window.Window
120
121
    @type  window: C{pyglet.window.Window}
122
117
123
    @param zminmax: optional (minimum, maximum) distance (delta z) between tracker and 
118
124
                    tracked
119
    @type  zminmax: tuple
125
126
    @type  zminmax: C{tuple}
127
120
128
    @param edge: the edge factor in range [0,0.5] (default 0.2)
121
    @type  edge: float
129
130
    @type  edge: C{float}
122
131
123
132
    >>> from zope.interface.verify import verifyClass, verifyObject
124
133
    >>> verifyClass(ITrack, SSCameraTrack)