Jump to content
  • Advertisement
Sign in to follow this  
ninjaindark

[MDX] Lighting in the newest SDK update

This topic is 4842 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

Hello, I am playing with the Managed DirectX lighting. I found a piece of sample code on a MDX book:

device.Lights[0].Type = LightType.Point;
device.Lights[0].Position = new Vector3();
device.Lights[0].Diffuse = System.Drawing.Color.White;
device.Lights[0].Attenuation0 = 0.2f;
device.Lights[0].Range = 10000.0f;
device.Lights[0].Commit();
device.Lights[0].Enabled = true;


However, the Visual Studio .Net tells the that the Commit() member has no definition in the "Microsoft.DirectX.Direct3D.Light". Can anyone tell me if this function is deleted in the newest SDK? I am using the newest version (August 2005 Release). Thanks, ninjaindark

Share this post


Link to post
Share on other sites
Advertisement
There is no Commit() method in Light class in the newest SDK. Maybe the book uses some older SDK version? I think Commit() was replaced with Update() so try to use it instead.

Share this post


Link to post
Share on other sites
I'm about 80% sure that it is a redundant line of code that was abolished a few SDK revisions ago. Try just commenting out the line for now and see what happens. If my memory serves me correctly, setting the light's state to ENABLED acheives everything that was required of commit().

Share this post


Link to post
Share on other sites
Hi there ninjaindark,
how are you doing?

[The Problem]
You light doesn't want to update or light the objects in the scene?

[The list of Possible Solutions]
1. Check that the object you are drawing isn't in the position (0.0f, 0.0f, 0.0f) It will possibly not get lit since your light is in the same position
2. Check to make sure that your object has a material attached to it so that your light knows how to behave when it encounters the material associated with your object.
3. Pull your light back about 100 units and see if the object gets lit.

e.g. code in C#

window.D3DDevice.Lights[0].Type = LightType.Point;
window.D3DDevice.Lights[0].Position = new Vector3(0.0f, 0.0f, -100.0f);
window.D3DDevice.Lights[0].Diffuse = System.Drawing.Color.White;
window.D3DDevice.Lights[0].Attenuation0 = 0.1f;
window.D3DDevice.Lights[0].Range = 1000.0f;
window.D3DDevice.Lights[0].Enabled = true;



I hope this helps a bit.
Take care, keep cool.

Share this post


Link to post
Share on other sites
Quote:
Original post by ninjaindark
Hello,

I am playing with the Managed DirectX lighting.

I found a piece of sample code on a MDX book:

*** Source Snippet Removed ***

However, the Visual Studio .Net tells the that the Commit() member has no definition in the "Microsoft.DirectX.Direct3D.Light".

Can anyone tell me if this function is deleted in the newest SDK? I am using the newest version (August 2005 Release).

Thanks,

ninjaindark


This is from Tom Miller's old book. There's are new books about MDX that you should read because the core framework of mdx has been revised alot since it first showed.

Share this post


Link to post
Share on other sites
Just Remove the Commit(); line is it not needed to get your lighting to render. also Tom Miller is aware of it and i belive on his blog it also states to just comment the line out.

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!