Jump to content
  • Advertisement


This topic is now archived and is closed to further replies.


Problem setting the material

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

Ok I''ve got my program to load .ms3d models nice and dandy, but when they are untextured they are NOT drawn with their material, it''s very baffling... My code for setting the material looks something like this:

SetMaterial(&material); //material is an already filled pointer

//drawing routines below

device->Present(NULL, NULL, NULL, NULL);

the material is pointer already loaded from the .ms3d model, and i''ve verified that this works, and even when i manually make an all red material (diffuse, ambient, and specular), it fails to show this on screen, still using the default white material. I checked that SetMaterial returns D3D_OK, but it still uses the default WHITE. For the love of me, I can''t figure out why it''s doing that. Any help would be appreciated.

Share this post

Link to post
Share on other sites
1. Materials don''t do anything on their own. They''re part of the D3D lighting engine. When lighting is enabled, for each light in the scene, the influence of that light on each vertex is calculated. This influence is then multiplied by the material.
If you''re not intending on using any lights, you still need lighting enabled, and you''d be best putting the colour in the AMBIENT part of the material and then setting the AMBIENT renderstate to 0xFFFFFF (1.0, 1.0, 1.0).

2. The settings you''ve set for the texture pipeline affect where colours come from before they''re applied to polygons. This allows you to perform various maths on a combination of textures, diffuse vertex colour, specular vertex colour, constant colour etc. These are set with SetTextureStageState().

I suggest you read the "Lights and Materials" section of the docs to see how materials and lights interact in the fixed function pipeline. Also the "Textures -> Texture Blending" section to see how the fixed function texture cascade works.

Simon O''''Connor
Creative Asylum Ltd

Share this post

Link to post
Share on other sites

  • 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!