[MDX] Lighting in the newest SDK update

Started by
5 comments, last by k00k 18 years, 8 months ago
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
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.
Hello.

I tried to use update(). It doesn't work. :(

ninjaindark
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().
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.
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.
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.

This topic is closed to new replies.

Advertisement