Jump to content
  • Advertisement
Sign in to follow this  
Garra

Assimp textures

This topic is 2611 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've been making a assimp model loader off and on and I'm currently at the point of adding textures to my models. I can loop through and get the names of the textures, but my problem comes in when I call D3DX10CreateShaderResourceViewFrom file. Most of the time I will need to handle multiple textures. So I believe I need to loop through, get all the texture names, then call D3DX10CreateShaderResourceViewFromFile for each of the textures and store them in a vector. My issue comes in when I'm drawing the model. Basically I'm collected all the data assimp collected from the model such as vertex data, put it all in a vertex structure, then call D3DX10CreateMesh and draw the model like below. When drawing I need to call SetResource, but how can I code my draw code so it knows which of the shader resource views to use?


void MeshLoader::RenderShader(ID3D10Device* device)
{
D3D10_TECHNIQUE_DESC techniqueDesc;
unsigned int i;

//set the input layout
device->IASetInputLayout(m_pBasicLayout);

m_pBasicTechnique->GetDesc(&techniqueDesc);

//go through each pass in the technique
for (i = 0; i < techniqueDesc.Passes; ++i)
{
m_pBasicTechnique->GetPassByIndex(i)->Apply(0);

//render the mesh
m_dxMesh->DrawSubset(0);
}
}

Share this post


Link to post
Share on other sites
Advertisement
Well I ran into another issue with SetResource. Basically I have the textures mapping to the model now and I'm drawing the model like the code below. The problem is both the mesh subsets (the dwarf and the axe) are using the dwarfs texture. I have them both in a vector, and in this case index 0 should be the axe and 1 should be the dwarf. I made a loop to loop through and set the resource for the particular subset, but it doesn't seem to be working.


void MeshLoader::RenderShader(ID3D10Device* device)
{
D3D10_TECHNIQUE_DESC techniqueDesc;
unsigned int i;

//set the input layout
device->IASetInputLayout(m_pBasicLayout);

m_pBasicTechnique->GetDesc(&techniqueDesc);

//go through each pass in the technique
for (i = 0; i < techniqueDesc.Passes; ++i)
{
m_pBasicTechnique->GetPassByIndex(i)->Apply(0);

for (int x = 0; x < m_numMeshes; ++x)
{
m_pTextureSR->SetResource(m_textureSRV[x]);
//render the mesh
m_dxMesh->DrawSubset(x);
}
}
}


assimptextures2.jpg

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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!