Archived

This topic is now archived and is closed to further replies.

FuzzyBunny

D3DXCreateBox texturing problems

Recommended Posts

Hi all, I have a mesh interface: LPD3DXMESH m_pMesh; Then i use the D3DX function D3DXCreateBox to create a box primitive, then render using m_pMesh->DrawSubset(0); everythng work ok, until i try to use textures, when i set a texture and do DrawSubset the texture flickers, and does appear in some places at all, so the whole thing looks really really messed up.. Any idea why? I set all the render states, I set the VertexShaderFVF to m_pMesh->GetFVF();, but the whole thing is messed up. I have my own CCube class with a Vetex Buffer, and I can render textured cubes no problem, but if I use the LPD3DXMESH and try to use textures, it doesn''t work.... please, any feedback is appreciated, and thanks in advance, ~Dima

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
did you try cloning the created mesh to a FVF that has texture coordinates?

i''m pretty sure that D3DXCreateBox and the other D3DX shape creating functions do not create vertex buffers with texture coordinates, or anything else for that matter, other than positioning information.

Share this post


Link to post
Share on other sites
hi, and thanks for the reply...

I tried cloning teh mesh using:

#define SHAPE_D3DFVF_CUSTOMVERTEX (D3DFVF_XYZ|D3DFVF_NORMAL|D3DFVF_TEX1)

pMesh->CloneMeshFVF(D3DXMESH_MANAGED, SHAPE_D3DFVF_CUSTOMVERTEX, m_pD3DDevice, &m_pMesh);

after cloning the texture does not appear at all. The flickering is gone and it''s just the material...

so Im guessing D3DX does not create texture coordinates for the shapes it creates???? Any way to make it automatically generate coords? am I missing something?

thanks for any help in advance!

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
quote:
Original post by FuzzyBunny
so Im guessing D3DX does not create texture coordinates for the shapes it creates???? Any way to make it automatically generate coords? am I missing something?

your guess is as good as mine but i imagine the UVs are either set to zeroes or are left as garbage from the memory''s previous allocation. i don''t think it would generate the UVs itself because that would imply knowledge of what type of texture mapping you''d want to use.

the article at http://www.mvps.org/directx/articles/spheremap.htm gives a good example of what i think you''ll need to do after the cloning. it covers sphere mapping but should give you enough to go on.

also, if you want to apply a different texture to each face you''ll need to find out if duplicate vertices were created, e.g., are there 8 or 24 vertices in the vertex buffer?

Share this post


Link to post
Share on other sites