Sign in to follow this  
disanti

3DS Max Plugin, exporting incorrect UVs.

Recommended Posts

disanti    174
Hello! I've just about finished my 3DS Max Exporter plugin for my 3d engine but there is only one problem left... The UV coordinates are not exported properly. From what I know, the coordinates are supposed to be between 1.0f and -1.0f. The exported UVs range from 3.0f to -3.0f. When I load the mesh into my game, the UVs display really weird texture patterns and stretches. Why does 3ds max have to be so weird with its number systems? Is there anyway I can fix this? I'm using Freexporter as a template for my exporter. If you would like the source code I can email it to you. I don't have a website right now. Thanks~ John DiSanti

Share this post


Link to post
Share on other sites
Viquel    122
UV normally range between [0-1] but can be far more (less). In this case the texture is repeated, or border color is used, or anything else. It depends of what you set in your 3D API.

Here the code from my exporter.

// i range from 0 to mesh->getNumFaces();
// j range from 0 to 3 for each face
DWORD tIndex = mesh->tvFace[i].getTVert(j);
float u = mesh->tVerts[tIndex].x;
float v = 1.f - mesh->tVerts[tIndex].y;

Hope that help.
Good luck.

Share this post


Link to post
Share on other sites
disanti    174
Ok, I tried your code and it isn't working out for me. :(

Here is how I applied it:

BOOL CExport::ReadMeshTVerts(Mesh *mesh)
{
int i;

int nTVertices = mesh->getNumTVerts();
if (nTVertices <= 0)
return FALSE;

int nTFaces = mesh->getNumFaces();

// Inform the user we are dumping the channel #1 used for texture mapping
UserBeginMeshChannel(1, nTVertices, nTFaces);

// Find the corresponding texture face for each mesh face
for (i = 0; i < nTFaces; i++)
{
for(int j = 0; j < 3; j++)
{
DWORD tIndex = mesh->tvFace[i].getTVert(j);
User3dTextureVertex(mesh->tVerts[tIndex], tIndex);
}
}

UserEndMeshChannel();

return TRUE;
}




User3dTextureVertex:

// Called when found a 3d texture vertex
void CExport::User3dTextureVertex(UVVert tVertex, int vertexNumber)
{
ipwfile.uv[vertexNumber] = new ipwuv;
ipwfile.uv[vertexNumber]->u = tVertex.x;
ipwfile.uv[vertexNumber]->v = 1.0f - tVertex.y;
}




Thanks~ John DiSanti

Edit: Forgot to say that I'm not noticing a difference with the texture coords.

Share this post


Link to post
Share on other sites
Viquel    122
Hum... that's quite strange. Can you try with a simple quad and tell me the result that you have for your vertices (coords, normal and UV)?

Also have you tried that "mesh->getNumTVerts ();" give you a value ?

Good luck.

Share this post


Link to post
Share on other sites

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