Jump to content
  • Advertisement
Sign in to follow this  
Ildun

Why I cannot load the texture of a .X format object?

This topic is 3906 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 though when I export an object from 3DSMAX as a .X file, it will contain its texture as well? What should I do in order to load its texture? Here is my code( only the load mesh part ): D3DXLoadMeshFromX( TEXT("WoodTable.x"), D3DXMESH_SYSTEMMEM, d3ddev, NULL, &bufVoidMaterial, NULL, &numMaterials, &meshTable );

Share this post


Link to post
Share on other sites
Advertisement
The .X file only contains a reference to the texture. You have to load and manage the textures yourself in much the same way as normal rendering.

Examine the D3DXMATERIAL::pTextureFilename field.

hth
Jack

Share this post


Link to post
Share on other sites
I get my material in this way:

for( DWORD i = 0; i < numMaterials; i++ ) //loop through each subset
{
d3ddev->SetMaterial(&material); //set the material for the subset
meshTable->DrawSubset(i); //draw the subset
}

//retrieve the pointer to the buffer containing the material information

D3DXMATERIAL* tempMaterials = (D3DXMATERIAL*)bufVoidMaterial->GetBufferPointer();

//create a new material buffer for each material in the mesh
material = new D3DMATERIAL9[numMaterials];

for( DWORD i = 0; i < numMaterials; i++ ) //for each material...
{
material = tempMaterials.MatD3D; //get the material info
material.Ambient = material.Diffuse; //make ambient the same as diffuse
}

Where should I put the texture pointer?

Share this post


Link to post
Share on other sites
You don't put the pointer anywhere as such - you use it in a call to D3DXCreateTextureFromFile() (or similar functions) and then get an IDirect3DTexture9 interface you can configure on your device when you're doing the rendering. You'll need an array of them as you may get multiple textures per mesh depending on how many subsets/materials are in use.

hth
Jack

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!