Jump to content
  • Advertisement
Sign in to follow this  
polar01

OpenGL Draw lights for an editor

This topic is 3019 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
You're right...

The difficulty is that I have a gluLookAt... and I don't know the real camera position :-P

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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...

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!