# Mesh Lighting with .X format

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

## Recommended Posts

Hi all, I've been using Milkshape to do simple models like planets mapped with a material and texture. Then I tried to use the DirectX Model Viewer to view the model, everything is ok in place. I also noticed that the normals are there. Next, I throw them into my own code using some of D3DX libraries. However, with a Directional Light, the "planet" mesh still doesn't get lighted up. This also happened to some of my borrowed models as well. Please note that I've ensured that the light parameters are correct and that its range is far enough to hit the planet. But somehow, the planet doesn't get lighted up. I've spoken to some of my friends who had experience using .X format. They told me that there is a part of the file I have to remove. Does anyone have any idea with that? Please help... Thanks, Thrawn80

##### Share on other sites
Sometimes you have to delete stuff depending on the exporter but thats probably not your issue because I export from MilkShape and it works fine.

Try the usual stuff. Make sure that lighting is enabled. Make sure that your material's ambient and diffuse are not the same. Make sure that you have that specific light enabled.

Is it completely black? That could be a different problem. You could post your code so we can check it out.

##### Share on other sites
Hi Programmer101,

May I ask, why can't I put the same values for Ambient and Diffuse? Please forgive my ignorance but I'm still relatively a newbie in 3D meshes...

On the other hand, the code should be fine because there are some of the models that actually react to the light settings.

It's a directional light, so I don't think attenuation, phi and theta has anything to do with it. Perhaps I'm wrong also :)

Thanks,
Thrawn80

##### Share on other sites
Hello, Have you tryed calling this
Device->SetRenderState(D3DRS_NORMALIZENORMALS, true);

this will renormalize the normals may help next time send some code so we don't need to guess.

##### Share on other sites
Hi ankhd,

Thanks for that. I'm going to try it out. Actually I also don't know what code to paste since my code is already working for some of the models.

Which is y I don't mention abt the codes. More rather, I'm inclined to believe that it's the exporter's fault....

I'm using Milkshape, but the exported is DirectX (JT).. so there might be some things that I hav to add or remove from the .X file.

Perhaps if there is anyone who has insights on this can provide some help? Please advise.

Regards,
Thrawn80

##### Share on other sites
You can't use the same ambient and diffuse values because the color will never be lighter than the ambient color and never darker than the diffuse so by making them the same you eliminate your lighting range.

Again, I've never had to delete anything from my JT exported models.

##### Share on other sites
Hi all,

I've managed to resolve the problem.

Here's how -
...// the material description of the .x file (ORIGINAL)Material Material{    0.886275;0.886275;0.886275;1.000000;;    0.000000;    0.698039;0.698039;0.698039;;    0.147059;0.147059;0.147059;;    TextureFileName    {        "Blackstone.jpg";    }}

Noticed that 0.000000; ? that's actually the Power of the material. After going thru some DirectX documentations on materials, I've decided to try changing this value.

Material Material{    0.886275;0.886275;0.886275;1.000000;;    80.000000;    0.698039;0.698039;0.698039;;    0.147059;0.147059;0.147059;;    TextureFileName    {        "Blackstone.jpg";    }}

Now the power is at 80, the lighting works along with the specular lighting. And yes, there is no need to remove anything from exporter for Milkshape.

Please let me know if you think that there are any errors or discreptancies in my conclusion.

Thanks a lot !

Thrawn80

1. 1
Rutin
46
2. 2
3. 3
4. 4
5. 5
JoeJ
19

• 11
• 15
• 9
• 10
• 13
• ### Forum Statistics

• Total Topics
633004
• Total Posts
3009842
• ### Who's Online (See full list)

There are no registered users currently online

×