Example #1
0
class LightBeams:
    def __init__(self, n=512):
        self.texture = Texture("media/textures/flare3.png")
        #self.texture = Texture("media/textures/heart.tga")
        self.shader = Shader("media/shaders/beams.vert", fs=None, isFile=True)

        self.beams = []
        self.n = n

        for i in range(self.n):
            self.beams.append([
                random.random() * 10,
                random.random() * 10,
                random.random() * 10
            ])

        self.beamlistid = glGenLists(1)
        glNewList(self.beamlistid, GL_COMPILE)
        glBegin(GL_POINTS)
        for i in range(self.n):
            glVertex3f(self.beams[i][0], self.beams[i][1], self.beams[i][2])
        glEnd()
        glEndList()

        self.dt = 0

    def on_beat(self, beat):
        pass

    def update(self, dt):
        self.dt += dt

    def draw(self):
        #glColor4f(0.9,0.1,0.1,1)
        self.texture.bind()
        glEnable(GL_BLEND)
        glBlendFunc(GL_SRC_ALPHA, GL_ONE)

        glEnable(GL_POINT_SPRITE)
        glPointSize(60.0)
        glTexEnvi(GL_POINT_SPRITE, GL_COORD_REPLACE, GL_TRUE)
        #glPointParameterf(GL_POINT_FADE_THRESHOLD_SIZE, 60.0);
        #glPointParameterf(GL_POINT_SIZE_MIN, 30.0);
        #glPointParameterf(GL_POINT_SIZE_MAX, 40.0);

        glDepthMask(GL_FALSE)
        glPushMatrix()
        glTranslatef(-5, -5, -5)
        self.shader.bind()
        self.shader["time"] = float(self.dt)
        glCallList(self.beamlistid)
        self.shader.release()
        glPopMatrix()
        glDepthMask(GL_TRUE)
        glDisable(GL_POINT_SPRITE)
        glDisable(GL_BLEND)
        self.texture.release()
        glColor4f(1, 1, 1, 1)

        self.beat = False
Example #2
0
class Overlay:
	def __init__(self):
		self.quad = MeshQuad()
		self.texture = Texture("media/textures/border4.png")
		#self.texture = Texture("media/textures/flare.png")
		self.shader = Shader("media/shaders/overlay.vert", "media/shaders/overlay.frag", isFile=True)

	def on_beat(self, dt):
		pass

	def update(self, dt):
		pass

	def draw(self):
		glEnable(GL_BLEND)
		glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA)
		#glBlendFunc(GL_SRC_ALPHA, GL_ONE)
		#glDepthMask(GL_FALSE)
		#glDisable(GL_DEPTH_TEST)
		self.texture.bind()
		self.shader.bind()
		glPushMatrix()
		glLoadIdentity()
		self.quad.draw()
		glPopMatrix()
		self.shader.release()
		self.texture.release()
		#glEnable(GL_DEPTH_TEST)
		#glDepthMask(GL_TRUE)
		glDisable(GL_BLEND)
Example #3
0
class LightBeams:
	def __init__(self,n=512):
		self.texture = Texture("media/textures/flare3.png")
		#self.texture = Texture("media/textures/heart.tga")
		self.shader = Shader("media/shaders/beams.vert",fs=None,isFile=True)

		self.beams = []
		self.n = n

		for i in range(self.n):
			self.beams.append([random.random() * 10, random.random() * 10, random.random() * 10])

		self.beamlistid = glGenLists(1)
		glNewList(self.beamlistid, GL_COMPILE)
		glBegin(GL_POINTS)
		for i in range(self.n):
			glVertex3f(	self.beams[i][0],
						self.beams[i][1],
						self.beams[i][2] )
		glEnd()
		glEndList()

		self.dt = 0

	def on_beat(self, beat):
		pass

	def update(self, dt):
		self.dt += dt
		
	def draw(self):
		#glColor4f(0.9,0.1,0.1,1)
		self.texture.bind()
		glEnable(GL_BLEND)
		glBlendFunc(GL_SRC_ALPHA, GL_ONE)

		glEnable(GL_POINT_SPRITE)
		glPointSize(60.0)
		glTexEnvi(GL_POINT_SPRITE, GL_COORD_REPLACE, GL_TRUE);
		#glPointParameterf(GL_POINT_FADE_THRESHOLD_SIZE, 60.0);
		#glPointParameterf(GL_POINT_SIZE_MIN, 30.0);
		#glPointParameterf(GL_POINT_SIZE_MAX, 40.0);
		
		glDepthMask(GL_FALSE)
		glPushMatrix()
		glTranslatef(-5,-5,-5)
		self.shader.bind()
		self.shader["time"] = float(self.dt)
		glCallList(self.beamlistid)
		self.shader.release()
		glPopMatrix()
		glDepthMask(GL_TRUE)
		glDisable(GL_POINT_SPRITE)
		glDisable(GL_BLEND)
		self.texture.release()
		glColor4f(1,1,1,1)

		self.beat = False
Example #4
0
class PostProcess:
    def __init__(self, w=1024, h=1024):
        self.quad = MeshQuad()
        self.shader = Shader("media/shaders/postprocess.vert",
                             "media/shaders/postprocess.frag",
                             isFile=True)
        self.rt = RenderTarget(w, h, multisample=True)
        self.dt = 0
        self.mode = 0
        self.texture = Texture("media/textures/gradient.png")

    def on_beat(self, beat):
        pass

    def switch(self, n):
        self.mode = n

    def current(self):
        return self.mode

    def num(self):
        return 6

    def bind(self):
        if self.mode == 0:
            return

        self.rt.bind()

    def release(self):
        if self.mode == 0:
            return

        self.rt.release()

    def update(self, dt):
        self.dt += dt

    def draw(self):
        if self.mode == 0:
            return

        self.rt.texture.bind()
        self.shader.bind()
        self.shader["time"] = float(self.dt)
        self.shader["rt_w"] = float(self.rt.w)
        self.shader["rt_h"] = float(self.rt.h)
        self.shader["mode"] = float(self.mode)
        self.shader["texture2"] = int(1)
        self.texture.bind(1)
        self.quad.draw()
        self.texture.release()
        self.shader.release()
        self.rt.texture.release()
Example #5
0
class PostProcess:
	def __init__(self, w=1024, h=1024):
		self.quad = MeshQuad()
		self.shader = Shader("media/shaders/postprocess.vert", "media/shaders/postprocess.frag", isFile=True)
		self.rt = RenderTarget(w,h,multisample=True)
		self.dt = 0
		self.mode = 0
		self.texture = Texture("media/textures/gradient.png")

	def on_beat(self, beat):
		pass

	def switch(self, n):
		self.mode = n

	def current(self):
		return self.mode

	def num(self):
		return 6

	def bind(self):
		if self.mode == 0:
			return

		self.rt.bind()

	def release(self):
		if self.mode == 0:
			return

		self.rt.release()

	def update(self, dt):
		self.dt += dt

	def draw(self):
		if self.mode == 0:
			return

		self.rt.texture.bind()
		self.shader.bind()
		self.shader["time"] = float(self.dt)
		self.shader["rt_w"] = float(self.rt.w)
		self.shader["rt_h"] = float(self.rt.h)
		self.shader["mode"] = float(self.mode)
		self.shader["texture2"] = int(1)
		self.texture.bind(1)
		self.quad.draw()
		self.texture.release()
		self.shader.release()
		self.rt.texture.release()
Example #6
0
class FlowerGardens:
	def __init__(self, n=32, f=6):
		self.n = n # number of floating platforms (a.k.a gardens)
		self.f = f # maximum number of flowers per platform

		self.platforms = []
		self.flowers = []

		for i in range(self.n):
			nx = (random.random() * 5) - random.random() * 1
			ny = (random.random() * 5)
			nz = (random.random() * 5) - random.random() * 1
			self.platforms.append(MeshCube(0.1,0.02,0.1,tx=nx,ty=ny,tz=nz))
			self.flowers.extend(self.create_flowers(nx, ny+0.02, nz))

		self.flowertexture = Texture("media/textures/flare2.png")

		self.flowerlistid = glGenLists(1)
		glNewList(self.flowerlistid, GL_COMPILE)
		glColor4f(0.0,0.4,0.8,1)
		for f in self.flowers:
			i = 0
			glLineWidth(1.5)
			glBegin(GL_LINE_STRIP)
			for s in range(f['n']):
				glNormal3f(f['n'],float(i),float(f['d']))
				glVertex3f(f['x'],f['y']+(s*0.1),f['z'])
				i+=1
			glEnd()
		glColor4f(1,1,1,1)
		glEndList()

		self.flowerlistid2 = glGenLists(1)
		glNewList(self.flowerlistid2, GL_COMPILE)
		glColor4f(1,1,1,1)
		for f in self.flowers:
			i = 0
			glPointSize(20.0)
			glBegin(GL_POINTS)
			for s in range(f['n']):
				glNormal3f(f['n'],float(i),float(f['d']))
				glVertex3f(f['x'],f['y']+(s*0.1),f['z'])					
				i+=1
			glEnd()
		glEndList()

		self.platformshader = Shader("media/shaders/spherecubes.vert", "media/shaders/spherecubes.frag", isFile=True)
		self.flowershader = Shader("media/shaders/flowers.vert", None, isFile=True)

		self.dt = 0

	def create_flowers(self, x, y, z):
		flowers = []
		dx = x
		dy = y
		dz = z
		
		dn = random.random() * self.f
		while dn < 3:
			dn = random.random() * self.f

		d = random.random() - 0.5

		flowers.append({'x':dx-0.05,'y':dy,'z':dz-0.05,'n':int(dn),'d':d})

		dn = random.random() * self.f
		while dn < 3:
			dn = random.random() * self.f

		d = random.random() - 0.5

		flowers.append({'x':dx-0.05,'y':dy,'z':dz+0.05,'n':int(dn),'d':d})

		dn = random.random() * self.f
		while dn < 3:
			dn = random.random() * self.f

		d = random.random() - 0.5

		flowers.append({'x':dx,'y':dy,'z':dz,'n':int(dn),'d':d})
		
		dn = random.random() * self.f
		while dn < 3:
			dn = random.random() * self.f

		d = random.random() - 0.5

		flowers.append({'x':dx+0.05,'y':dy,'z':dz-0.05,'n':int(dn),'d':d})
		
		dn = random.random() * self.f
		while dn < 3:
			dn = random.random() * self.f

		d = random.random() - 0.5

		flowers.append({'x':dx+0.05,'y':dy,'z':dz+0.05,'n':int(dn),'d':d})

		return flowers

	def on_beat(self, beat):
		self.dt += (beat.confidence / 3)

	def update(self, dt):
		self.dt += dt

	def draw(self):
		glPushMatrix()
		glTranslatef(-2,-3,-2)

		self.platformshader.bind()
		self.platformshader["lightPos"] = [10,10,0]

		for p in self.platforms:
			p.draw()

		self.platformshader.release()

		self.flowershader.bind()
		self.flowershader["time"] = float(self.dt)

		glCallList(self.flowerlistid)
	
		glEnable(GL_POINT_SPRITE)
		glPointSize(50.0)
		glTexEnvi(GL_POINT_SPRITE, GL_COORD_REPLACE, GL_TRUE);

		glEnable(GL_BLEND)
		glBlendFunc(GL_SRC_ALPHA, GL_ONE)
		glDepthMask(GL_FALSE)
		self.flowertexture.bind()
		glCallList(self.flowerlistid2)
		self.flowertexture.release()
		glDepthMask(GL_TRUE)
		glDisable(GL_BLEND)
		glDisable(GL_POINT_SPRITE)

		self.flowershader.release()

		glPopMatrix()
Example #7
0
class FlowerGardens:
    def __init__(self, n=32, f=6):
        self.n = n  # number of floating platforms (a.k.a gardens)
        self.f = f  # maximum number of flowers per platform

        self.platforms = []
        self.flowers = []

        for i in range(self.n):
            nx = (random.random() * 5) - random.random() * 1
            ny = (random.random() * 5)
            nz = (random.random() * 5) - random.random() * 1
            self.platforms.append(MeshCube(0.1, 0.02, 0.1, tx=nx, ty=ny,
                                           tz=nz))
            self.flowers.extend(self.create_flowers(nx, ny + 0.02, nz))

        self.flowertexture = Texture("media/textures/flare2.png")

        self.flowerlistid = glGenLists(1)
        glNewList(self.flowerlistid, GL_COMPILE)
        glColor4f(0.0, 0.4, 0.8, 1)
        for f in self.flowers:
            i = 0
            glLineWidth(1.5)
            glBegin(GL_LINE_STRIP)
            for s in range(f['n']):
                glNormal3f(f['n'], float(i), float(f['d']))
                glVertex3f(f['x'], f['y'] + (s * 0.1), f['z'])
                i += 1
            glEnd()
        glColor4f(1, 1, 1, 1)
        glEndList()

        self.flowerlistid2 = glGenLists(1)
        glNewList(self.flowerlistid2, GL_COMPILE)
        glColor4f(1, 1, 1, 1)
        for f in self.flowers:
            i = 0
            glPointSize(20.0)
            glBegin(GL_POINTS)
            for s in range(f['n']):
                glNormal3f(f['n'], float(i), float(f['d']))
                glVertex3f(f['x'], f['y'] + (s * 0.1), f['z'])
                i += 1
            glEnd()
        glEndList()

        self.platformshader = Shader("media/shaders/spherecubes.vert",
                                     "media/shaders/spherecubes.frag",
                                     isFile=True)
        self.flowershader = Shader("media/shaders/flowers.vert",
                                   None,
                                   isFile=True)

        self.dt = 0

    def create_flowers(self, x, y, z):
        flowers = []
        dx = x
        dy = y
        dz = z

        dn = random.random() * self.f
        while dn < 3:
            dn = random.random() * self.f

        d = random.random() - 0.5

        flowers.append({
            'x': dx - 0.05,
            'y': dy,
            'z': dz - 0.05,
            'n': int(dn),
            'd': d
        })

        dn = random.random() * self.f
        while dn < 3:
            dn = random.random() * self.f

        d = random.random() - 0.5

        flowers.append({
            'x': dx - 0.05,
            'y': dy,
            'z': dz + 0.05,
            'n': int(dn),
            'd': d
        })

        dn = random.random() * self.f
        while dn < 3:
            dn = random.random() * self.f

        d = random.random() - 0.5

        flowers.append({'x': dx, 'y': dy, 'z': dz, 'n': int(dn), 'd': d})

        dn = random.random() * self.f
        while dn < 3:
            dn = random.random() * self.f

        d = random.random() - 0.5

        flowers.append({
            'x': dx + 0.05,
            'y': dy,
            'z': dz - 0.05,
            'n': int(dn),
            'd': d
        })

        dn = random.random() * self.f
        while dn < 3:
            dn = random.random() * self.f

        d = random.random() - 0.5

        flowers.append({
            'x': dx + 0.05,
            'y': dy,
            'z': dz + 0.05,
            'n': int(dn),
            'd': d
        })

        return flowers

    def on_beat(self, beat):
        self.dt += (beat.confidence / 3)

    def update(self, dt):
        self.dt += dt

    def draw(self):
        glPushMatrix()
        glTranslatef(-2, -3, -2)

        self.platformshader.bind()
        self.platformshader["lightPos"] = [10, 10, 0]

        for p in self.platforms:
            p.draw()

        self.platformshader.release()

        self.flowershader.bind()
        self.flowershader["time"] = float(self.dt)

        glCallList(self.flowerlistid)

        glEnable(GL_POINT_SPRITE)
        glPointSize(50.0)
        glTexEnvi(GL_POINT_SPRITE, GL_COORD_REPLACE, GL_TRUE)

        glEnable(GL_BLEND)
        glBlendFunc(GL_SRC_ALPHA, GL_ONE)
        glDepthMask(GL_FALSE)
        self.flowertexture.bind()
        glCallList(self.flowerlistid2)
        self.flowertexture.release()
        glDepthMask(GL_TRUE)
        glDisable(GL_BLEND)
        glDisable(GL_POINT_SPRITE)

        self.flowershader.release()

        glPopMatrix()