Jump to content
  • Advertisement
Sign in to follow this  
Dean1988

Texturing a Mesh - Tiling? (Managed dx9)

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

Hi guys, I'm using vb.net and Managed DirectX 9 I've made a mesh of a terrain, and i've put a texture on it, but as expected it's being stretched across the entire mesh, i would rather it tiled X amount of times to fit onto the mesh. If you get my drift? If it can fit on there 5 fives, and at the moment it only draws it once, i would like it to draw it 5 times, all next to eachother. Cheers guys Dean

Share this post


Link to post
Share on other sites
Advertisement
You are referring to this concept. Unfortunately, I haven't touched DirectX for quite a long time, and I forgot the details. Also, I don't know if it's quite the same in Managed DirectX.

Share this post


Link to post
Share on other sites
I have never touched the VB.NET but in c++ what you do is to set the texture coordinates on every vertex to a value between (0, 0) and (1,1), this four the x an y axis of the coordinates..

This is how i do it on c++

// Vertex declaration
struct vertexD3D
{
float x, y, z; // Position of the vertex
float uv, uy; // These are the texture coordinates of the vertex
};


Then you set the values you want for every vertex when you create the vertex buffer- this is how i do it.


for (int x = 0; x < MAP_SIZE x++; )
{
for (int y = 0; y < MAP_SIZE y++;)
{
pVertexData[x + y * (MAP_ZIZE + 1)].x = (float)ix;
pVertexData[x + y * (MAP_ZIZE + 1)].y = (float)iy;
pVertexData[x + y * (MAP_ZIZE + 1)].z = (float)pHeightMap[((y)*MAP_SIZE)+x];
pVertexData[x + y * (MAP_ZIZE + 1)].uv = (float)(x); // Here you scale the texture coordinate to what you need
pVertexData[x + y * (MAP_ZIZE + 1)].uy = (float)(y); // Here you scale the texture coordinate to what you need
}
}

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!