Archived

This topic is now archived and is closed to further replies.

3dsmax export plugin - How on earth do i...

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

..get out the texture mapping coordinates correctly? I''ve written a plugin based on the .ASE exporter sample, since all i do is format the output, so it suits the XML specification. Now, the problem is, that i want to output OpenGL-suitable data, that is vertex coordinates, vertex normals, index array and texture mapping coordinates. Vertices, normals and the index array exports and renders fine, but then i''m stuck: 3dsmax seems to use different data structures to define texture mapping coordinates. it uses T(exture?)Vertices and TFaces. Problem: there are always more TVertices than geometry vertices. How can that be? What am i missing here? (the documentation is kinda bad imho, and i couldn''t find any in-depth information on how max handles texture projection). How can i get one (correct!) texture coordinate per vertex?

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
> Problem: there are always more TVertices than geometry vertices

Of course there are. geometric vertices can be shared among faces, but Tvertices can have seams, depends on how you apply UVW mapping. It''s esp. visible with the UVW/box modifier, here you''ll get a lot more tvertices than geometric ones.

Share this post


Link to post
Share on other sites
I see. Ok, then, how could one serve this data to OpenGL via Vertex Arrays? All i know so far is that you need an array of geometry vertices, normals and texture coordinates. How do i supply the 3dsmax data to opengl then?

Share this post


Link to post
Share on other sites
I''m not sure with *.max files, I export legacy *.3ds files and ream them,
but maybe it''s handled same way there:
I read vertex arrays out of a *.3ds file, and then there are indices, which I read.
There are 3 indices for every triangle, with which you can get the 3
corresponding vertices out of the vertex array.
From that data, I create all triangles, with their own vertices,
and then delete the 3ds'' vertex and index arrays.

Well, I used this only for test levels with my engine.
I''m not (yet ;-) that familar with OGL, is there a way to give vertex arrays and
indices to ogl, like in d3d? dunno...


Share this post


Link to post
Share on other sites
  

int MyExporter::AddVertex(VERTEX insVertex)
{


for(int i=0; i<m_VertCount; i++)
{

if( (m_VertList[i].x == insVertex.x) &&
(m_VertList[i].y == insVertex.y) &&
(m_VertList[i].z == insVertex.z) &&
(m_VertList[i].tu == insVertex.tu) &&
(m_VertList[i].tv == insVertex.tv) ) return i;

}

m_VertList[m_VertCount] = insVertex;
m_VertCount++;

return (m_VertCount - 1);

}

///////////////////////////////////////////

void MyExporter::Export(TriObject *oe, Vert3ds *verts, Face3ds *faces)
{
Mesh mesh = oe->GetMesh();
m_VertCount = 0;

m_VertList = (VERTEX *)malloc( (mesh.getNumTVerts()+1)
* sizeof(VERTEX));
m_FaceList = (Face3ds *)malloc( (mesh.getNumFaces()+1)
* sizeof(Face3ds));

for (int i = 0; i < mesh.getNumFaces(); i++)
{
Face face = mesh.faces[i];
TVFace tvFace = mesh.tvFace[i];

for (int k = 0; k < 3; k++)
{
VERTEX curVertex;

UVVert tVert = mesh.tVerts[tvFace.t[k]];
Point3 vert = mesh.verts[face.v[k]];

curVertex.x = vert.x;
curVertex.y = vert.y;
curVertex.z = vert.z;
curVertex.tu = tVert.x;
curVertex.tv = tVert.y;

m_FaceList[i].vNum[k] = AddVertex(curVertex);
}

...



}




Note that Face and TFace have the sam length - build a vert using the Position from mesh.verts[face.v[k]] and the texcoords from UVVert tVert = mesh.tVerts[tvFace[i].t[k]] ( i is the number of the face and k is the number of the face edge 1-3 ) and check if the vert was created before, if not add it to the vertlist.





Share this post


Link to post
Share on other sites