Jump to content
  • Advertisement
Sign in to follow this  
rajesh_nest

Texture coordinate generation

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

Suppose, I have a mesh file with vertices and indices. Now I need to generate texture coordinates, inorder to texture map the mesh. ( My texture is a jpeg image). My question, how to generate texture coordinates?. Are there any standard techniques? Regards and Thanks in advance

Share this post


Link to post
Share on other sites
Advertisement
the standard method is to open up the mesh in a modelling program (theres a few)
and then manually assign the texture coordinates.
i.e. theres no button that saiz assign texture coordinates to this model (aside from simple shapes)

Share this post


Link to post
Share on other sites

Thanks sir.

Will the automatic texture generation specified in opengl Redbook will be of any help.

I need to develop some algorithm for generating the coordinates. Will it be possible?


Share this post


Link to post
Share on other sites
You can project a texture onto a mesh by generating the UV coordinates by running the vertex position through 2 plane equations. This is one of the techniques that is described in the red book.

Another technique is box mapping (akin to cubemapping but all 6 faces are the one texture indexed using 2d coordinates instead of 3d normals), another is sphere mapping. Cylinder mapping is another. It all depends on what sort of shape you are trying to map to.

If its something as complex as a human, then you are going to need the texture coordinates created in an art package.

Share this post


Link to post
Share on other sites
What about the following code. Here I am trying to find maximum(xmax,ymax and minimum(xmin,ymin) of the entire vertex set and then,normalize using the vertex values for computing texture coordinates (u,v).


GetMaxMinXYofVertices(pVertices,xmax,xmin,ymax,ymin,noofVertices);
for(int uiIdx=0; uiIdx<m_noofVertices;uiIdx++)
{
//computing the u coordinate
pVertices[uiIdx].U =(m_pVertices[uiIdx].flX - xmax)/(xmax-xmin);
//computing the v coordinate
pVertices[uiIdx].V =(m_pVertices[uiIdx].flY - ymax)/(ymax-ymin);
}


Will this work? Please correct if I am wrong.I am developing a Mesh viewer. I need to dynamically texture map the loaded mesh.

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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!