with reference to my earlier posting(http://www.opengl.org/discussion_boards/ubb/Forum2/HTML/010995.html),
1. can anybody tell me how to calculate normals for a circle?
2. Is it possible to move the light position along with view point?
3. I'm trying to create an effect like this - holding a searchlight(spotlight) in hand and moving into a dark tunnel.

I checked nehe's demo on lighting and specular lighting and i tried out in the same way. But there is no effect of lighting. if possible, will you guys tell me what sort of components(global ambient light or ambient and diffuse of LIGHT0 or GL_SPOT_DIRECTION or GL_SPOT_CUTOFF etc.) to get the above mentioned effect.

Many may thanks in advance
pl

known quantity - centre of the circle.

M/\dm/\n

12-11-2002, 04:55 AM

As far as I know circle was flat figure http://www.opengl.org/discussion_boards/ubb/biggrin.gif so the normal is in the same direction(s) (to both sides so you must choose one http://www.opengl.org/discussion_boards/ubb/smile.gif ) as normal from plane holding this circe. You can get the normals mathematicaly by using 3 points of cirle, creating 2 vectors from them & calculating cross product from those vectors http://www.opengl.org/discussion_boards/ubb/smile.gif

Gavin

12-11-2002, 05:29 AM

or do you mean normals extruding outward from the centre?

satan

12-11-2002, 05:50 AM

Originally posted by Gavin:
or do you mean normals extruding outward from the centre?

He wants the normals pointing inside for lighting a cylinder on the inside.
I tried to tell him how to do this in his original thread and I have no idea why he started this one.
Perhaps he does not like my answers http://www.opengl.org/discussion_boards/ubb/frown.gif

[This message has been edited by satan (edited 12-11-2002).]

Deiussum

12-11-2002, 06:30 AM

I think satan already gave you this basic formula, but calculating the normal for any given point on a circle is easy. You obviously know the center, and you need to know the point on the circle you need to calculate the normal for, or else how do you know what to pass to glVertex3f?

Anyway, say that vert is the vertex on the circle, and center is the center. You calculate the normals something like so:

This will calculate normals pointing in, to calculate normals pointing out, you simply reverse the order you subtract.

Nearly, I explained it for a circle at the origin and told him that the center is just an offset to this.
To complicated???
Perhaps I should not think that people starting OGL know vector math http://www.opengl.org/discussion_boards/ubb/wink.gif

12-16-2002, 04:23 PM

once again special apologies to SATAN.
since my pc crashed i couldn't respond.

I started this thread to ask the following question
2. Is it possible to move the light position along with view point?
but i mixed up and typed everthing.

sorry guys.

Actually i'm confused about how to specify normals because already i specified the normals in the way you guys said. But the lighting effect was different one.

x1,y1,z1-centre of circle1
x2,y2,z2-centre of circle2
ang1,ang2 - angle of the plane which holds the circles with respect to world cooordinates
r1,r2-radius of circles

method of drawing the tunnel
using centre points & radius, vertices of circles are calculated and they are joined by polygons

now my problem I can't get the lighting effect with shades and shininess of the surface

Hope everybody understood what my problem is.

pl

zeckensack

12-17-2002, 12:30 AM

1)Be extra careful if you seperate lighting setup from rendering. If you update your modelview/projection matrices, you may need to update your light position. Depends on what you want to accomplish.

Submitting a light position once and keeping it through matrix updates kind of makes your light 'attached to the camera'.

If you want your light position to be fixed relative to the scene, you'll have to respecify the light position each time after updating matrices, and before actually rendering the geometry.

2)My wild guess regarding your problem: Your sphere is centered around the origin. Your light is positioned at the origin. All normals point to the origin. Result? All surfaces get the exact same light intensity, thus no shades and lighting looks as if it doesn't work.

Try moving your light position around and see if it's getting better. You may also need to experiment with the light's falloff parameters, but try changing position first.

12-17-2002, 08:33 AM

Actually i'm moving my light along with camera position.

the object is a dark tunnel.

the effect i want is
.....
3. I'm trying to create an effect like this - holding a searchlight(spotlight) in hand and moving into a dark tunnel.

normals point away from light position

Deiussum

12-17-2002, 10:45 AM

I haven't taken a close look at your code yet, but I don't think you don't want all the normals to point away from your light source. If I understand correctly what you want, you want them all to point IN towards the center of the cylinder.

The Xs above represent the location of vertices on the top and bottom of the cylinder, the L represents the location of your Light, the center line being the path the light is moving. the lines coming off the Xs are the direction you want the normals pointing. Note they are pointing in TOWARDS THE CENTER LINE, NOT THE LIGHT.

Hope that helps somewhat.

Edit: Ugh. I hate how the code tags sometimes choose to use different font sizes in different spots.