Updated LightBounce.cc to draw logos using the orb as a light source
still need to draw a better orb git-svn-id: svn://anubis/dwscr/trunk@113 5bef9df8-b654-44bb-925b-0ff18baa8f8c
This commit is contained in:
parent
15af488e98
commit
ae2f719bf3
@ -130,17 +130,28 @@ LightBounce::LightBounce(SSMain * _SSMain) : SSMode(_SSMain)
|
||||
m_orb_dir[1] = sin(theta) * sin(gamma);
|
||||
m_orb_dir[2] = cos(gamma);
|
||||
|
||||
/* Create the orb display list */
|
||||
// TODO: fix lighting
|
||||
// TODO: make it more of a "light" object and not a sphere
|
||||
m_orb_dl = glGenLists(1);
|
||||
glNewList(m_orb_dl, GL_COMPILE);
|
||||
GLfloat mat[] = {1, 1, 0.2, 0.8};
|
||||
glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, mat);
|
||||
GLUquadric * quad = gluNewQuadric();
|
||||
gluQuadricNormals(quad, GL_TRUE);
|
||||
gluSphere(quad, ORB_RADIUS, 16, 8);
|
||||
glPushAttrib(GL_LIGHTING_BIT);
|
||||
glPushMatrix();
|
||||
glLoadIdentity();
|
||||
GLfloat light_pos[] = {0, 0, 1, 0};
|
||||
glLightfv(GL_LIGHT0, GL_POSITION, light_pos);
|
||||
glPopMatrix();
|
||||
gluSphere(quad, ORB_RADIUS, 16, 8);
|
||||
glPopAttrib();
|
||||
glEndList();
|
||||
|
||||
glPushAttrib(GL_POLYGON_BIT); /* store CULL_FACE settings */
|
||||
glPushAttrib(GL_ENABLE_BIT); /* store current GL_BLEND setting */
|
||||
glPushAttrib(GL_LIGHTING_BIT); /* store current LIGHTING settings */
|
||||
glEnable(GL_BLEND);
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
|
||||
@ -154,6 +165,7 @@ LightBounce::LightBounce(SSMain * _SSMain) : SSMode(_SSMain)
|
||||
|
||||
LightBounce::~LightBounce()
|
||||
{
|
||||
glPopAttrib(); /* restore old LIGHTING settings */
|
||||
glPopAttrib(); /* restore old GL_BLEND setting */
|
||||
glPopAttrib(); /* restore old CULL_FACE settings */
|
||||
int sz = m_boxes.size();
|
||||
@ -234,6 +246,12 @@ void LightBounce::update()
|
||||
glViewport(i*width/numMonitors, 0, width/numMonitors, height);
|
||||
glLoadIdentity();
|
||||
gluLookAt(viewer_x, viewer_y, viewer_z, 0, 0, 0, 0, 1, 0);
|
||||
GLfloat light_pos[4];
|
||||
light_pos[0] = m_orb_pos[0];
|
||||
light_pos[1] = m_orb_pos[1];
|
||||
light_pos[2] = m_orb_pos[2];
|
||||
light_pos[3] = 1.0f;
|
||||
glLightfv(GL_LIGHT0, GL_POSITION, light_pos);
|
||||
for (int i = 0, sz = m_boxes.size(); i < sz; i++)
|
||||
{
|
||||
if (m_boxes[i]->getDist() < orbDist && !drewOrb)
|
||||
|
Loading…
x
Reference in New Issue
Block a user