Sign in to follow this  

texture automatically wraps the whole mesh?

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

Quote:
Original post by Anddos
no in 3dsmax its just got 1 polygon side filled with it
not the whole box as you can see in the dx viewer..
I can see that. The question is whether your *own* renderer is correctly applying it to just one face?

Share this post


Link to post
Share on other sites
It looks like you're not applying the materials to the specified sub-meshes found in the .x file. It's probably just applying the first material's texture for all sub-meshes rather than deciding which sub-meshes use which materials.
This might happen if you're combining all sub-meshes into a single mesh.

Share this post


Link to post
Share on other sites
AFAIK the .x format can't support multiple vertex formats. So if you assign UV to one face of something the rest will probably get some default UVs. If you assign the texture and draw the model it will texture over the whole thing.
.

Share this post


Link to post
Share on other sites
can you help me with this code


HR(BoxEffect->SetTexture(gTex,mTex)); //wood.bmp //texture sampler1
HR(BoxEffect->SetTexture(gTex2,mTex2)); //planks.bmp //texture sampler2
HR(BoxEffect->SetTechnique(BoxTech));

HR(BoxEffect->Begin(&numPasses, 0));
HR(BoxEffect->BeginPass(0));
for(DWORD i = 0; i < numMaterials; i++) // loop through each subset
{
Mesh->DrawSubset(i); // draw the subset
}
HR(BoxEffect->EndPass());
HR(BoxEffect->End());

Share this post


Link to post
Share on other sites
You have to move your apply texture code into the loop.




HR(BoxEffect->SetTechnique(BoxTech));



HR(BoxEffect->Begin(&numPasses, 0));

HR(BoxEffect->BeginPass(0));

for(DWORD i = 0; i < numMaterials; i++) { // loop through each subset
HR(BoxEffect->SetTexture(gTex,mTex)); //wood.bmp //texture sampler1

HR(BoxEffect->SetTexture(gTex2,mTex2)); //planks.bmp //texture sampler2
Mesh->DrawSubset(i); // draw the subset

}

HR(BoxEffect->EndPass());

HR(BoxEffect->End());



The code will not work for models with multiple textures. You can see why if you look at the fact you only set the first texture once before the loop, then you are drawing the rest of the submeshes using the same texture. You have to have different textures as well. The above code is not correct, but it should give you an idea of why your previous code was not working.

Make sure to load the other textures, then place them in the loop, like I did above.

Share this post


Link to post
Share on other sites
@smasherprog:
Quote:
The above code is not correct

You're right. If you want to set effect variables inside the loop, you also need effect->CommitChanges().

@Anddos: Can you post the shader?

Also, it may not be necessary in your specific case, but for correctness, you should loop on the passes also.

In any case, you code should like more like:

for(DWORD i=0; i<numMaterials; i++)
{
effect->SetTexture(gTex,textureForThisSubset); // may be NULL if no texture
effect->CommitChanges();
mesh->DrawSubset(i);
}

Share this post


Link to post
Share on other sites

This topic is 2588 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this