begin creating the ring

This commit is contained in:
Josh Holtrop 2011-10-12 12:26:00 -04:00
parent 8999fc9738
commit 07a2157fe6
2 changed files with 49 additions and 6 deletions

View File

@ -10,6 +10,13 @@
#include "Tunnel.h"
using namespace std;
#define N_LOGOS_PER_RING 12
#define RING_RADIUS 18
#define BREAKOFF_DIST 20
#define RING_LAYER_DIST 10
Tunnel::Tunnel()
{
m_last_ticks = 0;
@ -24,6 +31,21 @@ bool Tunnel::expose (GnomeScreensaver & gs)
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
for (list<LBStruct>::const_iterator it = m_logos.begin();
it != m_logos.end();
it++)
{
glPushMatrix();
glTranslatef(0, m_offset + it->offset + 50, 0);
glRotatef(it->trot, 0, 1, 0);
glTranslatef(RING_RADIUS, 0, 0);
glRotatef(-90.0, 0, 0, 1);
glRotatef(90.0, 1, 0, 0);
glRotatef(it->zrot, 0, 0, 1);
m_logobox.draw();
glPopMatrix();
}
return true;
}
@ -36,10 +58,26 @@ bool Tunnel::configure (GnomeScreensaver & gs)
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
gluLookAt(0, 0, 10, 0, 0, 0, 0, 1, 0);
gluLookAt(0, 0, 0, 0, 1, 0, 0, 0, 1);
glViewport(0, 0, gs.getWidth(), gs.getHeight());
for (int i = 0; i < 5; i++)
{
for (int j = 0; j < N_LOGOS_PER_RING; j++)
{
float zrot = ((j + i) & 0x3) * 90.0;
float trot = j * 360.0 / N_LOGOS_PER_RING;
LBStruct lbs = {
-i * RING_LAYER_DIST,
zrot,
trot,
{0, 0, 1}
};
m_logos.push_back(lbs);
}
}
return true;
}

View File

@ -2,6 +2,8 @@
#ifndef TUNNEL_H
#define TUNNEL_H
#include <list>
#include "LogoBox.h"
#include "Mode.h"
#include "GnomeScreensaver.h"
@ -14,14 +16,17 @@ class Tunnel : public Mode
bool expose (GnomeScreensaver & gs);
bool configure (GnomeScreensaver & gs);
bool update (GnomeScreensaver & gs);
typedef struct {
float offset;
float zrot;
float trot;
float spin_axis[3];
} LBStruct;
protected:
LogoBox m_logobox;
int m_num_monitors;
uint64_t m_last_ticks;
void initMonitorInfo();
void getRandomAxis(float (*axis)[3]);
uint32_t getRandomSwitchTime();
float getRandomSpeed();
std::list<LBStruct> m_logos;
float m_offset;
};
#endif /* TUNNEL_H */