Jump to content
  • Advertisement
Sign in to follow this  
Thrawn80

Mesh Lighting with .X format

This topic is 4057 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 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 this post


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


Link to post
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 :)

Please advise.

Thanks,
Thrawn80

Share this post


Link to post
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 this post


Link to post
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 this post


Link to post
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 this post


Link to post
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

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!