Notifications
Clear all
[Closed] How get texture uv's
Jan 09, 2012 8:17 pm
As i said in the title i want to make an exporter using 3ds max sdk and i wonder how i get textures uv’s ?
2 Replies
Jan 09, 2012 8:17 pm
here’s some code from a plugin I’m developing.
for (int f = 0; f < mesh->numFaces; f++)
{
pTVFace = mesh->tvFace[f];
Face face = mesh->faces[f];
if (mesh->getNumTVerts() !=0)
{
TVFace tvFace = mesh->tvFace[f];
fprintf(file,"<f a=\"%i\" b=\"%i\" c=\"%i\" uv_a=\"%i\" uv_b=\"%i\" uv_c=\"%i\"/>
",
face.v[0], face.v[1], face.v[2],
tvFace.t[0], tvFace.t[1], tvFace.t[2]);
}
else
{
fprintf(file,"<f a=\"%i\" b=\"%i\" c=\"%i\"/>
",face.v[0],face.v[1],face.v[2]);
}
}
here is another sample, probably easier to understand:
for(int f = 0; f < numFaces; ++f)
{
for(int v = 0; v < 3; ++v)
{
TVFace* tvface = &mesh->tvFace[f];
Point3 uv = mesh->getTVert(tvface->getTVert(v));
fprintf(file, "<texCoord x=\"%f\" y=\"%f\" />
", uv.x, uv.y);
}
}
what you do is to loop through all texture vertices, or get the texture face and go through it’s vertices.
Jan 09, 2012 8:17 pm
you could also have a look at the IGame wrapper in the SDK, it provides a “broader” set of mesh access functions.
there’s an example of typical usage in this thread
http://forums.cgsociety.org/showthread.php?f=98&t=1024221&page=2&pp=15