rework addRing(); consider LBStruct.offset the offset when created

This commit is contained in:
Josh Holtrop 2011-10-12 12:45:15 -04:00
parent 2cab647bcb
commit 878b441742
2 changed files with 11 additions and 6 deletions

View File

@ -35,6 +35,12 @@ bool Tunnel::expose (GnomeScreensaver & gs)
m_last_ticks = gs.getTicks();
uint64_t ticks = gs.getTicks();
int elapsed = ticks - m_last_ticks;
m_offset += XLATE_RATE * elapsed;
while (m_offset - m_last_ring_offset > RING_LAYER_DIST)
{
m_last_ring_offset += RING_LAYER_DIST;
addRing(m_last_ring_offset);
}
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
@ -43,7 +49,7 @@ bool Tunnel::expose (GnomeScreensaver & gs)
it++)
{
glPushMatrix();
glTranslatef(0, m_offset + it->offset, 0);
glTranslatef(0, m_offset - it->offset, 0);
glRotatef(it->trot, 0, 1, 0);
glTranslatef(RING_RADIUS, 0, 0);
glRotatef(-90.0, 0, 0, 1);
@ -58,14 +64,14 @@ bool Tunnel::expose (GnomeScreensaver & gs)
return true;
}
void Tunnel::addRing()
void Tunnel::addRing(double offset)
{
for (int j = 0; j < N_LOGOS_PER_RING; j++)
{
float zrot = ((j + m_ring_rot_idx) & 0x3) * 90.0;
float trot = j * 360.0 / N_LOGOS_PER_RING;
LBStruct lbs = {
m_offset,
offset,
zrot,
trot,
{0, 0, 1}
@ -90,8 +96,7 @@ bool Tunnel::configure (GnomeScreensaver & gs)
for (int i = 0; i <= N_INITIAL_LAYERS; i++)
{
m_offset = (N_INITIAL_LAYERS - i) * RING_LAYER_DIST,
addRing();
addRing((i - N_INITIAL_LAYERS) * RING_LAYER_DIST);
}
m_offset = 0.0;

View File

@ -23,7 +23,7 @@ class Tunnel : public Mode
float spin_axis[3];
} LBStruct;
protected:
void addRing();
void addRing(double offset);
LogoBox m_logobox;
uint64_t m_last_ticks;
std::list<LBStruct> m_logos;