Jump to content
  • Advertisement

Archived

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

monkeyography

xfiles refuse ambient light

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

I can''t get ambient light to affect the xfiles I''m displaying in my scene. I set the ambient light like so: pd3dDevice->SetRenderState( D3DRS_AMBIENT, 0x00808080 ); I export out of Maya and the material in the xfile looks like so: Material file3SG { 0.800000;0.800000;0.800000;1.000000;; 0.000000; 0.000000;0.000000;0.000000;; 0.000000;0.000000;0.000000;; TextureFilename { "player01.bmp"; } } I''m basing my file loader on Sarmad''s skinned mesh tutorial available here on GameDev and the material loading process looks something like this:
  
// load the materials

D3DMATERIAL8 *aMaterial = new D3DMATERIAL8[dwMaterialCount];
SAFEPOINTER( aMaterial );
LPDIRECT3DTEXTURE8 *apD3DTexture = new LPDIRECT3DTEXTURE8[dwMaterialCount];
SAFEPOINTER( apD3DTexture );
ZeroMemory( apD3DTexture, dwMaterialCount * sizeof(void*) );

LPD3DXMATERIAL axmaterial = (LPD3DXMATERIAL)pmaterialsbuf->GetBufferPointer();

for( int i = 0; i < dwMaterialCount; i++ )
{
	aMaterial[i] = axmaterial[i].MatD3D;

	if( axmaterial[i].pTextureFilename != NULL )
	{
		// load the texture

		HRESULT result = D3DXCreateTextureFromFileEx( pd3ddevice,
			axmaterial[i].pTextureFilename, D3DX_DEFAULT, D3DX_DEFAULT,
			D3DX_DEFAULT, 0, D3DFMT_UNKNOWN, D3DPOOL_MANAGED, D3DX_DEFAULT, 
			D3DX_DEFAULT, 0, NULL, NULL, &apD3DTexture[i] );
		if( FAILED( result ) )
			throw new CFileException( axmaterial[i].pTextureFilename );
	}
	else
		apD3DTexture[i] = NULL;
}
  
any ideas? thanks in advance

Share this post


Link to post
Share on other sites
Advertisement
figured it out.

When ambient light is added to a scene it''s value is multiplied by the ambient color of each material to see how that material is lit. If the material''s ambient color is 0, then 0*x=0 every time.

Apparently, xfiles don''t even store Ambient color, they just store:
faceColor(rgba),
specularColor(rgba),
emissiveColor(rgba),
power(float),
textureFilename(string)

Since no real ambient is specified in the xfile, the material retrieved from the xfile has the default ambient value: 0

anyone else with this problem, just set the material''s ambient equal to its diffuse.

also, to anyone else messing with lighting and exported xfiles, normalizing your normals is a *really* good idea.

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!