Draw lights for an editor

Started by
7 comments, last by polar01 14 years, 1 month ago
Hi, I'm currently working on a OpenGL editor and now I'm trying to display the lights on the scene. I use the "glutSolidSphere" to draw a simple sphere... the problem is that : - when I zoom... the sphere is growing too - how can I draw different kind of lights ? Directionals, spots etc... Thanks
--------------------------------------------------------------------------------Aurora Studio - PureLight - Animation & rendering software and API.http://www.polarlights.net
Advertisement
Does the mesh representing the light have to be depth tested?
Or you can just render it on top of the scene (if you have wire-frame representation, like in 3ds Max).
If the second, calculate the orientation of the light (get its rotation matrix), then render the wire-frame by resetting the modelview, and applying the same rotation. Use the same projection matrix, but probably you have to move the wire-frame away from the camera.

I hope that make sense.

For types of light, try to google "3ds Max Ligth" images, to get some ideas.
Try using an orthographic projection for the light's sphere rather than perspective. That way it will not change size when you get closer to it.
Alternatively you can try to ensure a constant distance between the camera and sphere. Choose a distance D. before rendering the sphere, calculate the displacement between the camera and sphere
dist_vec = lightpos - campos
dist = length(dist_vec).

Now you move the sphere away from the viewer
dist_to_move = D - dist;
move_vec = normalize(dist_vec) * dist_to_move;
glTranslate(move_vec.x, move_vec.y, move_vec.z);

Now you can draw the sphere

I'm not sure if this works, but give it a try. It should not change the apparent location in space, because you're moving it along the line of sight.
You're right...

The difficulty is that I have a gluLookAt... and I don't know the real camera position :-P
--------------------------------------------------------------------------------Aurora Studio - PureLight - Animation & rendering software and API.http://www.polarlights.net
Oups... it works now...

I just have to save my camera position somewhere :-)

Also, does someone know how I can draw

- Camera :

- Lights :

Some OpenGL code will be great :-P

Thanks for the help
--------------------------------------------------------------------------------Aurora Studio - PureLight - Animation & rendering software and API.http://www.polarlights.net
You will never get code. Seriously what are you expecting?
These are just a bunch of lines, either you can hard-code the drawing code, or you can use an 3D editor to make the meshes.

Oh my...
Its what I will do... just asking... sometimes peoples share their code... sometimes ;-)
--------------------------------------------------------------------------------Aurora Studio - PureLight - Animation & rendering software and API.http://www.polarlights.net
The problem is that your need is so specific and has to be integrated to your specific system, that there is a very little chance to find a "code", especially if they are models, not really "code". Try to look for models instead on turbosquid/wherever.
Okay... thanks for your help :-)
--------------------------------------------------------------------------------Aurora Studio - PureLight - Animation & rendering software and API.http://www.polarlights.net

This topic is closed to new replies.

Advertisement