Skip to main content
gamedev.net
🔒 Locked

Problem setting the material

Started by Brobanx Nov 18, 2001 at 12:54 PM 0 replies 250+ views
Original Post
Brobanx
Brobanx
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:
  

device->BeginScene();
SetMaterial(&material); //material is an already filled pointer


//drawing routines below


device->EndScene();
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.
S1CA
S1CA
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
www.creative-asylum.com
Simon O'Connor | Technical Director (Newcastle) Lockwood Publishing | LinkedIn | Personal site

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.