Click to See Complete Forum and Search --> : Texture mapping a 64x64 mesh


Eggman002
February 25th, 2005, 10:27 PM
I am working with DirectX 9 using C#.

I have a mesh that has 64x64 vertices. I want to map a single texture so that instead of being tiled, the texture is stretched over the entire mesh. How do I do this? I can get the image to be tiled, but I can not get it to stretch over the mesh.

Thanks,
eggman

Elementer
February 26th, 2005, 06:07 AM
Hi,
I don't know how to achieve this with DX because I use OGL, I explain how OGL allow you to achieve this, you also can undestand with this example.

Suppose you have a texture 64x64, the lower left corner of texture is the coord (0.0, 0.0) and the upper right corner is coord (1.0, 1.0):

________ (1, 1)
|...........|
|...........|
|_______|
(0,0)

If you want the coord of middle of texture, you can specify coord (0.5, 0.5). You can specify what value you want in the range 0.0 -> 1.0, the value get the current position in the texture. Now, suppose you want to bind half bottom left part of texture into a quad, you can do this:

Texture (you want to apply only the lower left half part)
________ (1,1)
|...........|
|-----....|
|___|___|
(0,0)

Your texturemapped quad:

________ (1, 1)
|...........|
|...........|
|_______|
(0,0)

bind (0,0) to vertex (0, 0)
bind (0.5, 0) to vertex (1, 0)
bind (0.5, 0.5) to vertex (1, 1)
bind (0, 0.5) to vertex (0, 1)

Do you get it ? Maybe DX have a similiar manner to bind differets parts of a texture in different vertices...

Hope this help :)

Eggman002
February 26th, 2005, 09:27 AM
Yeah, the problem I am having is that I am not sure if Directx supports a feature like that. I am sure that it does, I just don't know what feature to look for. So far I am able to set Tu and Tv for each vertex, but then when I render the image it seems that causes it to use the portion of the texure from 0,0 to Tu,Tv. for each quad. The result is I still get a tiled image.

(0,0).........(Tu,0)
------------------
|----------------|
|----------------|
|----------------|
------------------
(0,TV)........(Tu,Tv)

What I want is it to tile from the prev. Tu,Tv to the new Tu,Tv.

(PrevTu,PrevTv).........(Tu,PrevTv)
---------------------------------
|-------------------------------|
|-------------------------------|
|-------------------------------|
|-------------------------------|
|-------------------------------|
---------------------------------
(Tv,PrevTu)...................(Tu,Tv)

Eggman

Elementer
February 26th, 2005, 06:12 PM
OK, I undestand, but I don't use D3D, I don't know as you what searching for..., so googling :D for texturing tutorials or similiar ;)

Cheers

Eggman002
February 26th, 2005, 11:32 PM
Tried googling. All I can find is how to texture map a simple quad. Nothing about meshes. :cry: