Problem loading texture uv coordinates from mesh

Started by
1 comment, last by arc4nis 17 years, 5 months ago
Hello I'm working on a space game in DX9, and now I'm trying to load mesh texture uv coordinates into my game, but something is wrong. I'm modelling my meshes in 3D Canvas Pro and then I export them in .x files. When I open the mesh with the DirectX Viewer it looks like this... Free Image Hosting at www.ImageShack.us ...but when I render it in my game: Free Image Hosting at www.ImageShack.us the code that I'm using to load a mesh (I want to load only the vertex data, textures and materials are added ingame):
D3DXLoadMeshFromX( "3d/asteroids/ceres.x", D3DXMESH_SYSTEMMEM, g_pd3dDevice, NULL, &g_pD3DXMB, NULL, NULL, &g_mCeres )
for rendering:
void RenderAsteroid()
{
	g_pd3dDevice->SetTexture( 0, g_tCeres );

	D3DXMatrixTranslation( &matTranslation, 20.0f, 20.0f, 10.0f );
	D3DXMatrixScaling( &matScalation, 10.0f, 10.0f, 10.0f );
	D3DXMatrixMultiply( &matWorld, &matScalation, &matTranslation ) ;

	g_pd3dDevice->SetTransform( D3DTS_WORLD, &matWorld );

    g_mCeres->DrawSubset(0);
}
What am I doing wrong ? Any help is welcome :)
Advertisement
The code looks correct to me. I'd guess theres something wrong with the texturecoords that's causing it to display differently than in DX Viewer.

I'd try setting the Sampler State's wrap mode to wrap:

mDevice->SetSamplerState(0, D3DSAMP_ADDRESSU, D3DTADDRESS_WRAP);
mDevice->SetSamplerState(0, D3DSAMP_ADDRESSV, D3DTADDRESS_WRAP);

Hope this helps :).
Sirob Yes.» - status: Work-O-Rama.
thx sirop, it works now! ^^

This topic is closed to new replies.

Advertisement