Skip to content

Commit

Permalink
Stages are now 100% functional and stable again. Have fun!
Browse files Browse the repository at this point in the history
  • Loading branch information
erodozer committed Nov 25, 2010
1 parent f899133 commit 4efb854
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 40 deletions.
46 changes: 23 additions & 23 deletions data/themes/MegaLight V4/stage.ini
Expand Up @@ -12,21 +12,21 @@ angle = 0.0
texture = stage_lights1.png
xres = 256
yres = 128
xpos = -0.65
ypos = -0.8
xpos = 0.65
ypos = 0.8

[layer3]
texture = stage_lights2.png
xres = 256
yres = 128
xpos = 0.65
ypos = -0.8
ypos = 0.8

[layer4]
texture = stage_drums.png
xres = 256
yres = 256
xpos = -0.7
xpos = 0.7
ypos = 0.0

[layer4:fx1]
Expand All @@ -39,7 +39,7 @@ ymagnitude = 0.01
texture = stage_bassdrum.png
xres = 128
yres = 128
xpos = -0.65
xpos = 0.65
ypos = 0.13

[layer5:fx1]
Expand Down Expand Up @@ -67,7 +67,7 @@ texture = stage_speaker_cones.png
xres = 256
yres = 256
xpos = 0.67
ypos = -0.03
ypos = 0.03

[layer7:fx1]
type = scale
Expand All @@ -79,14 +79,14 @@ ymagnitude = 0.07
texture = stage_audience1.png
xres = 256
yres = 256
xpos = -0.8
xpos = 0.8
ypos = 0.4

[layer8:fx1]
type = wiggle
trigger = beat
xmagnitude = 0.02
ymagnitude = -0.04
ymagnitude = 0.04
frequency = 0.5

[layer9]
Expand All @@ -100,16 +100,16 @@ ypos = 0.4
type = wiggle
trigger = beat
xmagnitude = 0.01
ymagnitude = -0.03
ymagnitude = 0.03
frequency = 1.0
delay = .25

[layer10]
texture = stage_light.png
xres = 256
yres = 256
xpos = -0.87
ypos = -0.75
xpos = 0.87
ypos = 0.75
xscale = 3.0
yscale = 3.0
src_blending = src_alpha
Expand All @@ -133,11 +133,11 @@ period = 75
texture = stage_light.png
xres = 256
yres = 256
xpos = -0.69
ypos = -0.8
xpos = 0.69
ypos = 0.8
xscale = 3.0
yscale = 3.0
angle = -12.0
angle = 12.0
src_blending = src_alpha
dst_blending = one
foreground = 1
Expand All @@ -152,18 +152,18 @@ intensity = 0.7
type = rotate
trigger = miss
profile = sinstep
angle = -10
angle = 10
period = 100

[layer12]
texture = stage_light.png
xres = 256
yres = 256
xpos = -0.48
ypos = -0.83
xpos = 0.48
ypos = 0.83
xscale = 3.0
yscale = 3.0
angle = -16.0
angle = 16.0
src_blending = src_alpha
dst_blending = one
foreground = 1
Expand All @@ -186,7 +186,7 @@ texture = stage_light.png
xres = 256
yres = 256
xpos = 0.83
ypos = -0.75
ypos = 0.75
xscale = 3.0
yscale = 3.0
src_blending = src_alpha
Expand All @@ -211,7 +211,7 @@ texture = stage_light.png
xres = 256
yres = 256
xpos = 0.64
ypos = -0.84
ypos = 0.84
xscale = 3.0
yscale = 3.0
angle = 12.0
Expand All @@ -229,15 +229,15 @@ intensity = 0.7
type = rotate
trigger = miss
profile = sinstep
angle = -5
angle = 5
period = 200

[layer15]
texture = stage_light.png
xres = 256
yres = 256
xpos = 0.46
ypos = -0.9
ypos = 0.9
xscale = 3.0
yscale = 3.0
angle = 19.0
Expand All @@ -254,5 +254,5 @@ intensity = 0.7
[layer15:fx2]
type = rotate
trigger = miss
angle = -5
angle = 5
period = 150
38 changes: 21 additions & 17 deletions src/Stage.py
Expand Up @@ -63,6 +63,7 @@ def __init__(self, stage, drawing):
self.color = (1.0, 1.0, 1.0, 1.0)
self.srcBlending = GL_SRC_ALPHA
self.dstBlending = GL_ONE_MINUS_SRC_ALPHA
self.transforms = [(1,1), (1,1), 1, (1,1,1,1)]
self.effects = []

def render(self, visibility):
Expand All @@ -71,26 +72,28 @@ def render(self, visibility):
@param visibility: Floating point visibility factor (1 = opaque, 0 = invisibile)
"""
w, h, = self.stage.engine.view.geometry[2:4]
w, h = self.stage.engine.view.geometry[2:4]
v = 1.0 - visibility ** 2

color = self.color
coord = [self.position[0] * w / 2, -self.position[1] * h / 2]

#coordinates are positioned with (0,0) being in the middle of the screen
coord = (w/2 + self.position[0] * w/2, h/2 - self.position[1] * h/2)
if v > .01:
color = (self.color[0], self.color[1], self.color[2], visibility)
if self.position[0] < -.25:
coord[0] *= -v * w
elif self.position[0] > .25:
coord[0] *= v * w
scale = [self.scale[0], -self.scale[1]]
scale = (self.scale[0], -self.scale[1])
rot = self.angle

self.stage.engine.drawImage(self.drawing, scale, coord, rot, color)


self.transforms = [scale, coord, rot, color]
# Blend in all the effects
for effect in self.effects:
effect.apply()

glBlendFunc(self.srcBlending, self.dstBlending)
self.stage.engine.drawImage(self.drawing, self.transforms[0], self.transforms[1],
self.transforms[2], self.transforms[3])
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA)

class Effect(object):
"""
An animationn effect that can be attached to a Layer.
Expand Down Expand Up @@ -197,7 +200,7 @@ def apply(self):
t = self.trigger()
t = self.ambient + self.contrast * t
c = self.getNoteColor(self.stage.averageNotes[self.lightNumber])
self.layer.color = (c[0] * t, c[1] * t, c[2] * t, self.intensity)
self.layer.transforms[3] = (c[0] * t, c[1] * t, c[2] * t, self.intensity)

class RotateEffect(Effect):
def __init__(self, layer, options):
Expand All @@ -209,7 +212,7 @@ def apply(self):
return

t = self.trigger()
self.layer.drawing.setAngle(t * self.angle)
self.layer.transforms[2] = t*self.angle

class WiggleEffect(Effect):
def __init__(self, layer, options):
Expand All @@ -224,7 +227,7 @@ def apply(self):
w, h = self.stage.engine.view.geometry[2:4]
p = t * 2 * math.pi * self.freq
s, c = t * math.sin(p), t * math.cos(p)
self.layer.drawing.setPosition(self.xmag * w * s, self.ymag * h * c)
self.layer.transforms[1] = (self.xmag * w * s, self.ymag * h * c)

class ScaleEffect(Effect):
def __init__(self, layer, options):
Expand All @@ -234,7 +237,7 @@ def __init__(self, layer, options):

def apply(self):
t = self.trigger()
self.layer.drawing.setScale(1.0 + self.xmag * t, 1.0 + self.ymag * t)
self.layer.transforms[0] = (1.0 + self.xmag * t, -1.0 + self.ymag * t)

class Stage(object):
def __init__(self, guitarScene, configFileName):
Expand Down Expand Up @@ -608,9 +611,10 @@ def run(self, pos, period):
self.triggerBeat(pos, beat)

def renderLayers(self, layers, visibility):
with self.engine.view.orthogonalProjection(normalize = True):
for layer in layers:
layer.render(visibility)
if self.mode != 3:
with self.engine.view.orthogonalProjection(normalize = True):
for layer in layers:
layer.render(visibility)

def render(self, visibility):
if self.mode != 3:
Expand Down

0 comments on commit 4efb854

Please sign in to comment.