XNA Creators Club Online
Page 1 of 1 (2 items)
Sort Posts: Previous Next

Texturing D3DX Meshs

Last post 04-30-2008 10:00 AM by Wessam Bahnassi. 1 replies.
  • 04-30-2008 7:25 AM

    Texturing D3DX Meshs

    Hello All

    I had an issue in making texturing for meshes created using d3dxCreate functions like D3DXCreateTeapot, D3DXCreateSphere and others, I had searched the internet and found every where that meshes that created using D3DX functions don’t have texture coordinates and i have to clone the mesh to another temp mesh and then trying to put the vertex coordinates for every vertex, and I couldn't able to find any code sample that can help

    and even i had posted this in another forum

    http://www.gamedev.net/community/forums/topic.asp?topic_id=492582

    But I am still have another two questions

    1-What if I had used an x file, can I able to change its original texturing

    2-What if I want to make my small modeling application, should I do the geometry by myself instead of using d3dx functions

    I don’t know!

     

     

  • 04-30-2008 10:00 AM In reply to

    Re: Texturing D3DX Meshs

    As has been mentioned in one of the replies to your question in Gamedev.net, there are two steps to add texturing to D3DX-generated meshes. The first one is of course cloning it to have a TexCoord2 component in addition to Position and Normal. The next step is filling the value of the new TexCoord2 component for each vertex, and here there are various approaches, each leading to different results.

    Here is an example why generating texcoords is not a single-solution problem. Imaging we have a cube, normally the way we imagine it to be textured is that the texture is shown completely on each of the cube's faces. But perhaps another person wants the top and bottom faces to actually only show the left half of the texture image, and the rest of the faces show the right half.  So it is really a question of how do you like your mesh to be textured... There are various procedural approaches that can be used as a start. Here is a link to spherical texture coordinates, which can look ok on a teapot:

    http://www.mvps.org/directx/articles/spheremap.htm

    One easy approach also is planar texture mapping, where you project a plane on your geometry. It can look like the image here:

    http://ar.wikipedia.org/wiki/%D8%B5%D9%88%D8%B1%D8%A9:Xsigator.jpg

    I hope this helps...

    Wessam Bahnassi
    Microsoft DirectX MVP
Page 1 of 1 (2 items) Previous Next