Skip to main content
GameDev.net gamedev.net
🔒 Locked

draw a line

Started by McZ Jan 24, 2006 at 9:55 AM 1 replies 1.1k views
Original Post
McZ
McZ
I'm trying to draw a line, so I can see position and direction of my lightsource. so this how I draw the line

glDisable(GL_LIGHTING);
glBegin(GL_LINES);
	glColor3f(0,0.9f,0);
	glVertex3fv( Math3D::CVertex3f(0,0,0) );
	glColor3f(0,0.2f,0);
	glVertex3fv( (Math3D::CVertex3f(0,0,0) + (pLight->m_Direction*100)) );
glEnd();
glEnable(GL_LIGHTING);

so I have the light at position 0,0,0 and the direction is pointing somewhere from 0,0,0 so I want to draw a line with the lengt of 100 units but the problem is that the end of the line will follow the camera when I move the camera the end of the line follows but not the start why? why doesn't it stay at it's position (0,0,100 if lightdir is 0,0,1) when the start position of the line is at the same location even if I move the camera around. I tried quickly with a light at another position and that line doesn't follow the camera.
dweeb
dweeb
Unless you translate your line nothing should move if your direction is constant.

Could you post a screenshot or a link to your application.

Could it be clipping which makes the line appear to move?
______ohh well what the heck lets try it?
McZ
McZ
I do like this no more no less
glClear(...);glLoadIdentity();glMultMatrixf( camera->getMatrix() );glDisable(GL_LIGHTING);glBegin(GL_LINES);	glColor3f(0,0.9f,0);	glVertex3fv( Math3D::CVertex3f(0,0,0) );	glColor3f(0,0.2f,0);	glVertex3fv( (Math3D::CVertex3f(0,0,0) + (pLight->m_Direction*100)) );glEnd();glEnable(GL_LIGHTING);// enable light...// draw the rest of the scene...


the direction of the light is Always the same because the light never moves. it works if the light position is other than 0,0,0

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.