updating distances for each logo each frame, rotating based on viewer position

git-svn-id: svn://anubis/dwscr/trunk@101 5bef9df8-b654-44bb-925b-0ff18baa8f8c
This commit is contained in:
josh 2008-11-13 17:27:59 +00:00
parent 17d3b1e154
commit 47c652a150

View File

@ -110,10 +110,13 @@ LightBounce::LightBounce(SSMain * _SSMain) : SSMode(_SSMain)
} }
y += box_stride; y += box_stride;
} }
glPushAttrib(GL_POLYGON_BIT); /* store CULL_FACE settings */
} }
LightBounce::~LightBounce() LightBounce::~LightBounce()
{ {
glPopAttrib();
int sz = m_boxes.size(); int sz = m_boxes.size();
for (int i = 0; i < sz; i++) for (int i = 0; i < sz; i++)
delete m_boxes[i]; delete m_boxes[i];
@ -127,14 +130,25 @@ void LightBounce::update()
int numMonitors = m_SSMain->getNumMonitors(); int numMonitors = m_SSMain->getNumMonitors();
int width = m_SSMain->getWidth(); int width = m_SSMain->getWidth();
int height = m_SSMain->getHeight(); int height = m_SSMain->getHeight();
/* update the viewer position */
double angle = m_elapsed/3700.0f;
double viewer_dist = SIZE * ZOOM;
float viewer_x = viewer_dist * cos(angle);
float viewer_z = viewer_dist * sin(angle);
float viewer_y = SIZE * ZOOM * 2.0 / 3.0;
for (int i = 0, sz = m_boxes.size(); i < sz; i++)
{
m_boxes[i]->updateDist(viewer_x, viewer_y, viewer_z);
}
for (int i = 0; i < numMonitors; i++) for (int i = 0; i < numMonitors; i++)
{ {
glViewport(i*width/numMonitors, 0, width/numMonitors, height); glViewport(i*width/numMonitors, 0, width/numMonitors, height);
glLoadIdentity(); glLoadIdentity();
gluLookAt(0, SIZE * ZOOM * 2.0 / 3.0, SIZE * ZOOM, 0, 0, 0, 0, 1, 0); gluLookAt(viewer_x, viewer_y, viewer_z, 0, 0, 0, 0, 1, 0);
glRotatef(m_elapsed/66.0f, 0, 1, 0); for (int i = 0, sz = m_boxes.size(); i < sz; i++)
int sz = m_boxes.size();
for (int i = 0; i < sz; i++)
{ {
m_boxes[i]->draw(); m_boxes[i]->draw();
} }