Texture coordinate generation

Started by
3 comments, last by rajesh_nest 14 years, 11 months ago
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
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)

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?


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.
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.

This topic is closed to new replies.

Advertisement