Jump to content
  • Advertisement
Sign in to follow this  
catalin_pin

OpenGL Problem with matrix stacks and lighting

This topic is 4556 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 trying to build my own 3D engine using D3D9 and I'm having a problem involving matrix stacks and lights. I want to make a light stay at a fixed location in my world, but it moves as I move :(( ... If I don't use a matrix stack I achieve this effect, but as soon as I switch back to the matrix stack the light moves along with me :(. I found some explanations at www.opengl.org about matrix stacks and lights but the rules do not seem to aply to D3D as I can't notice any difference. I've searched the net and found nothing envolving matrix stacks and lights under D3D. Does anyone have any experience with this topic?! Please help. I don't want code ... only an idee will do ... at least the mathematical explanation for matrix stacks and light positions ... I'll try to understand myself ... but I need somekind of a starting point ... than k u :) EDIT: Better subject lines will help you as well as us. As stated in the forum guidelines

Share this post


Link to post
Share on other sites
Advertisement
Wow, you've posted in three different forums.
If you haven't had time to read the Forums FAQ it's a good idea to take a look (the rules section is a must).

As for your problem, judging by your description my guess is you have to multiply the matrix of your light position with camera matrix. Think of light as of any other object in your scene.



Share this post


Link to post
Share on other sites
I don't work with DirectX really, but I saw your thread in the openGL section. so here goes.

First of all, IIRC, direct X organizes their matrix arrays differently. OpenGL matrixes are tipped on their side (or vice versa, I can't recall) and that may be the source of confusion about your matrices.

second of all, if you don't specify normals for objects in your scene, it can appear that the light is moving. At least I've had that experience in the past. But I don't know if that's the problem you're having :O

Share this post


Link to post
Share on other sites
I am writing now to thank those few who tried to answer my question :) ... And I have to say that I may have to explain it again ... I am having problems with my objects when I use ID3DXMAtrixStack instead of normal transformation ussage. If I use the transformations as they are normally used it works fine :) ... but I'm trying to use ID3DXMatrixStack as it implies an optimization technique and it doesn't work :( ... It seems that I have to take a pen and a piece of papaer and try to understand what goes on in there :O ...

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!