Sign in to follow this  

Texture Coordinates

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

I believe this has to do with DirectX ;) I am loading .obj files to render with a vertex buffer and an index buffer (by using device-DrawIndexedPrimitive(...)). For example a cube has 8 vertices and 24 indices ( or so ) but the obj file from 3d studio writes 24 texture vertices. I know why and I know what its doing however my problem comes when I want to render my 'mesh' from DrawIndexedPrimitive with a custom vertex that defines (u,v) and (D3DFVF_TEX1) I dont have 24 vertices... I have 8. I am not exactly sure how to keep the right texturing if I dont use all 24 texture coordinates with 24 matching vertices. (I am trying to avoid filling the vertex buffer with duplicates) :( Lol I hope that made sense :D Btw the rest of the obj loader works perfectly I am just slightly confused on what to do with.. X more texture vertices for the number of vertices I have. (DirectX format is 1 textureVertex to one vertex) So basically I am looking for a way to use DrawIndexedPrimitive with the correct texture coordinates.. if possible. [Edited by - cistar on June 25, 2008 12:38:31 AM]

Share this post


Link to post
Share on other sites
There is no way around this, because texture coordinates make every vertex unique. At least if you want to render the cube with 6 different textures.

With texture atlases you would still have to duplicate the vertices, where the texture borders meet again.

h.

Share this post


Link to post
Share on other sites
Well I see the logic flaw between:

every tri in a mesh == defined by 3 individual vertices
(which allows individual tex coords)
and

every tri in a mesh == defined by 3 shared vertices
(which cannot have individual tex coords.. or tex coords at all-(at least not any that look good))

So this leads me to believe that there is no other way of doing it other than listing each vertex in the vertex buffer 3 times and drawing the primitive as an individual triangle.. (TRIANGLELIST or TRIANGLESTRIP)so how do you move a mesh vertex and keep the shape solid (moving the vertex doesnt create a hole) with texture coordinates... :( modeling programs seem to have figured it out :( lol

Share this post


Link to post
Share on other sites

Modelling programs indeed come to the rescue here. Typical game models are textured using 'unwrapped' UV maps (this looks like it explains things). These basically allow you to paint a texture for the complete model so it doesn't need duplicate vertices and can still use one set of texture coordinates. This may be a bit more work to set up on the modelling side, but it's gives modellers more control once it is set up and it saves programmers a lot of headaches to get working.

Hope this helps :)

Share this post


Link to post
Share on other sites

True. I guess it's safe to say though that a cube such as this is a bit of an exception to the typical mesh, where you'll likely want to have smooth normals. Not to be smug to be sure, just to clarify the logic flaw the OP thought to see.

Share this post


Link to post
Share on other sites

This topic is 3457 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this