Question on DirectX tutorial 6 (meshes)

Started by
3 comments, last by Mr Kickass 18 years, 9 months ago
In the tutorial, the verticies are loaded into a ID3DXMESH object. OK. Then, the part that I don't understand is why the textures are loaded into an array of textures... Why an array of textures instead of just one IDIRECT3DTEXTURE9 entity? Question 2: If a mesh isn't authored to have a 2nd texture, could I still load a 2nd texture onto the mesh by calling D3DXCreateTextureFromFile() a second time that specifies a different array for the 2nd set of textures?
Advertisement
Actualy there are number of materials in .x file
and for each material, you set the texture which you load form
TextureLoader.fromFile(..) method.
Instead of setTexture method in loop, try setTexture method outside
the loop. I havent tried this..but i think it will give the same
result(not in all cases)

In response of ur Q2. I think it will override ur first texture.
The bettr approach is to set (tu, tv) coordinates.
Question 1: Why an array of textures instead of just one IDIRECT3DTEXTURE9 entity?

Question 2: If a mesh isn't authored to have a 2nd texture, could I still load a 2nd texture onto the mesh by calling D3DXCreateTextureFromFile() a second time that specifies a different array for the 2nd set of textures?

Both questions nearly has the same answer which is that you are allowed to have a number of textures associated with a single mesh (entity), and is set using IDirect3DDevice9::SetTexture();
I hope this helps a bit.
So tiger.x probably doesn't have texture coordinates, as I should set some???
How does the first texture get displayed then? Or is that part of the reason they are loaded by pieces onto each triangle?

I don't see the 2nd texture overrriding the first because the 2nd texture will simply be a normal map - I will then send both the normal map texture and diffuse map texture to shaders.

I am just not understanding why directX is splitting the textures up into pieces, and how texture coordinates are getting associated with positions on the texture...
OH I didn't see that 2nd response before I replied. Yes that helps very much. I see you can associate 2 textures to 2 different samplers in the pipeline just by doing something like

setTexture(0, tex0);
setTexture(1, tex1);

And a pointer (array) to a texture represents 1 entire texture.

I am starting to understand. Thanks.

This topic is closed to new replies.

Advertisement