So I have a model of a light that I draw that is in the same place as the light. I first disable lighting, then draw the object, re-enable it then draw everything else. Simple right?

Well… my light model shows up at 50 or something tranparency, but I don’t have blending or anything enabled, nor is it colored with an alpha specified. Another weird thing is that I can’t use the select buffer to pick it, it simple is unpickable.

It gets stranger, when I enable lighting. My object shows up at no transparency and is pickable throught the select buffer…

Ummmmm… Help?

I need code

Originally posted by Michael Steinberg:

I need code

haha… I knew this would be a problem. Unfortuanitly most of it is in an all sorts of proprietary app so it’s tough.

Here’s the routine that draws the object though:

void C3DMaskPlot: rawLightObject()

{

glPushMatrix();

glLoadIdentity();

// Draw the light object

glDisable(GL_LIGHTING);

glRotatef(lightRot[0], 1.0, 0.0, 0.0);

glRotatef(lightRot[1], 0.0, 1.0, 0.0);

glRotatef(lightRot[2], 0.0, 0.0, 1.0);

glTranslatef(0, (sqrt(height*height+length*length+width*width)*0.95), 0);

if (showLight == true)

{

// Ok, draw it

glLoadName(666);

// Ack! Lights are tools of the devil.

GLdouble size = sqrt(width*width + length*length + height*height) * 0.05;

// The cone.

glBegin(GL_TRIANGLES);

for (GLfloat t = 0; t <= 2*3.141592654 - (0.1 * 3.141592654); t+=(0.1 * 3.141592654))
{
glColor3f(0.90,0.90,0.90);
glVertex3f(size*cos(t + (0.1 * 3.141592654)), 0, size

*sin(t + (0.1 * 3.141592654)));*

glColor3f(0.90,0.90,0.90);

glVertex3f(sizecos(t), 0, size

glColor3f(0.90,0.90,0.90);

glVertex3f(size

*sin(t));*

glColor3f(1,0.85,0.85);

glVertex3f(0,size,0);

}

glColor3f(0.90,0.90,0.90);

glVertex3f(sizecos(0), 0, size

glColor3f(1,0.85,0.85);

glVertex3f(0,size,0);

}

glColor3f(0.90,0.90,0.90);

glVertex3f(size

*sin(0));*

glColor3f(0.90,0.90,0.90);

glVertex3f(sizecos(0 - (0.1 * 3.141592654)), 0, size*sin(0 - (0.1 * 3.141592654)));

glColor3f(0.90,0.90,0.90);

glVertex3f(size

glColor3f(1,0.85,0.85);

glVertex3f(0,size,0);

glEnd();

// The Tube looking part.

glBegin(GL_QUADS);

for (GLfloat t = 0; t <= 2*3.141592654 - (0.1 * 3.141592654); t+=(0.1 * 3.141592654))

{

glColor3f(0.95,0.88,0.88);

glVertex3f((size/2.0)*cos(t), size + size*0.1, (size/2.0)*sin(t));

glColor3f(0.95,0.88,0.88);

glVertex3f((size/2.0)*cos(t + (0.1 * 3.141592654)), size + size*0.1, (size/2.0)*sin(t + (0.1 * 3.141592654)));

glColor3f(0.95,0.88,0.88);

glVertex3f((size/2.0)*cos(t + (0.1 * 3.141592654)), size/2.0, (size/2.0)*sin(t + (0.1 * 3.141592654)));

glColor3f(0.95,0.88,0.88);

glVertex3f((size/2.0)*cos(t), size/2.0, size*sin(t));

}

glColor3f(0.95,0.88,0.88);

glVertex3f((size/2.0)*cos(0 - (0.1 * 3.141592654)), size + size*0.1, (size/2.0)*sin(0 - (0.1 * 3.141592654)));

glColor3f(0.95,0.88,0.88);

glVertex3f((size/2.0)*cos(0), size + size*0.1, (size/2.0)*sin(0));

glColor3f(0.95,0.88,0.88);

glVertex3f((size/2.0)*cos(0), size/2.0, (size/2.0)*sin(0));

glColor3f(0.95,0.88,0.88);

glVertex3f((size/2.0)*cos(0 - (0.1 * 3.141592654)), size/2.0, (size/2.0)*sin(0 - (0.1 * 3.141592654)));

glEnd();

// The top of it.

glBegin(GL_TRIANGLES);

for (GLfloat t = 0; t <= 2*3.141592654 - (0.1 * 3.141592654); t+=(0.1 * 3.141592654))

{

glColor3f(1,0.85,0.85);

glVertex3f((size/2.0)*cos(t + (0.1 * 3.141592654)), size + size*0.1, (size/2.0)*sin(t + (0.1 * 3.141592654)));

glColor3f(1,0.85,0.85);

glVertex3f((size/2.0)*cos(t), size + size*0.1, (size/2.0)*sin(t));
glColor3f(1,0.85,0.85);
glVertex3f(0,size + size*0.1,0);

}

glColor3f(1,0.85,0.85);

glVertex3f((size/2.0)

*cos(0), size + size*0.1, (size/2.0)*sin(0));

glColor3f(1,0.85,0.85);

glVertex3f((size/2.0)

*cos(0 - (0.1 * 3.141592654)), size + size*0.1, (size/2.0)

*sin(0 - (0.1 * 3.141592654)));*

glColor3f(1,0.85,0.85);

glVertex3f(0,size + size0.1,0);

glColor3f(1,0.85,0.85);

glVertex3f(0,size + size

glEnd();

}

// Reset Matrix

glEnable(GL_LIGHTING);

// Now do the actual light

glLightfv(GL_LIGHT0, GL_POSITION, lightPos);

glPopMatrix();

}

Hmmm, other than that you don’t specify the matrix you’re working on here I don’t see anything. Could I have a look at the initialization code and the one to clear the screen?

Which lights did you enable after all?

Originally posted by Michael Steinberg:

Which lights did you enable after all?

Hmmm… I don’t know why this was affecting it. But I was using a translate in my projection matrix. And for some reason when drawn with lighting the piching worked, without it didn’t. So I removed the translate fromt he projection matrix and all is well in the universe again.

No transformations to the projections matrix. That kills lighting. Never!

Transformations only belong into the modelview matrix.