3DS Max Plugin, exporting incorrect UVs.
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
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.getTVert(j);
float u = mesh->tVerts[tIndex].x;
float v = 1.f - mesh->tVerts[tIndex].y;
Hope that help.
Good luck.
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.getTVert(j);
float u = mesh->tVerts[tIndex].x;
float v = 1.f - mesh->tVerts[tIndex].y;
Hope that help.
Good luck.
Ok, I tried your code and it isn't working out for me. :(
Here is how I applied it:
User3dTextureVertex:
Thanks~ John DiSanti
Edit: Forgot to say that I'm not noticing a difference with the texture coords.
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.getTVert(j); User3dTextureVertex(mesh->tVerts[tIndex], tIndex); } } UserEndMeshChannel(); return TRUE;}
User3dTextureVertex:
// Called when found a 3d texture vertexvoid 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.
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.
Also have you tried that "mesh->getNumTVerts ();" give you a value ?
Good luck.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement