Jump to content
  • Advertisement
Sign in to follow this  
SONB

texture mapping on indexed primitives?

This topic is 4843 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! A long time I was trying to find a tutorial on how to map a texture on a primitive built with index buffer. All I could find was a note that there is a disadvantage of the index buffers, which can not allow us to map textures correctly. So, my first question: What are index buffers good for when I can't put a texture on my cube correctly? The second question: Is there a way to avoid this disadvantage? If so, pleeease share your ideas on it. Or should I build my cube with a vertex buffer only? What about more complex models? Thanx a lot in advance! SONB

Share this post


Link to post
Share on other sites
Advertisement
Quote:

All I could find was a note that there is a disadvantage of the index buffers, which can not allow us to map textures correctly.

This is absolute BS nonsense. What is the problem that would make this impossible? I cannot even answer your second question because I cannot think of any. The only issue is that some positions need to be repeated because two faces may use a vertex differently (i.e. with different texture coordinates) but this is easily fixed. See this recent thread.

Greetz,

Illco

Share this post


Link to post
Share on other sites
Well, this article http://www.gamedev.net/reference/articles/article1247.asp says:

Quote:
Note, you are not reusing the vertices as described in example three. This is because you need up to three texture coordinates per vertex and you only have specified the one.


So, what should I do, when I'm reusing the vertices?


Sorry, I'm just a newbie asking newbie-questions...



SONB

Share this post


Link to post
Share on other sites
I don't see why the author did it that way other then for the sake of writing the text more quickly. You can simply do that as you'd expect: define three texture coordinates per vertex and index the vertices... There is really not much to it.

Greetz,

Illco

Share this post


Link to post
Share on other sites
Thanx for your reply Illco!

I defined three coordinates for each vertex, changed my vertex array and FVF flags like this:

#define D3DFVF_CUSTOM (D3DFVF_XYZ | D3DFVF_TEX3)

typedef struct
{
FLOAT x, y, z;
FLOAT u1, v1;
FLOAT u2, v2;
FLOAT u3, v3;
} CUSTOMVERTEX;

Now how can I tell the app to use the right coordinates? I just want to map the same texture onto each side of my cube.

SONB

Share this post


Link to post
Share on other sites
Ok perhaps I wrote a bit confusingly but for a cube you do not need three texture coordinates per vertex. What the author of the tutorial was trying to do, I don't know, but he/she thought it require three texture coordinates. For a cube we do not.

Although there are only eight positions (corner points) they are all used three times with at least different normals. So we need 24 vertices. The normals should point in the direction of the side and the texture coordinates should run from (0,0) to (1,1) accross a side.

I don't know whatever vertex you had before but it is probably fine for this. The right values for a cube you can find on the net.

Greetz,

Illco

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!