Jump to content
  • Advertisement
Sign in to follow this  

Max SDK (Export all faces to .txt file)

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

Hello. I have some problem: I can`t to get position(x,y,z) of faces:confused: How to get it? I do: ofstream pathfile; pathfile.open("C:\\123.txt"); for (i = 0; i < TObj->mesh.numFaces; i++) { pathfile<<&TObj->mesh.faces.v[0]; pathfile<<&TObj->mesh.faces.v[1]; pathfile<<&TObj->mesh.faces.v[2]; } pathfile.close();

Share this post

Link to post
Share on other sites
I don't know the SDK at all but I am learning Maxscript and I'm pretty sure the interface will be similar.

A face won't have an XYZ value. A face has 3 indices (integers). These integers are the indexes into the vertex array.
These might be represented as XYZ on the face object (not sure but seems more likely that it would be something like face._0, face._1 and face._2 or similar (unless the SDK represents a face as a single Vector3 type object).

Anyway, what you are outputting there are the vertex indexes. If you want the XYZ positions for each vertex of each face then do something like this.

ofstream pathfile;
for (i = 0; i < TObj->mesh.numFaces; i++)




Actual syntax may be different but that's the general idea. Hope this helps.


Share this post

Link to post
Share on other sites

face do not have any pos information
All the pos infomation are in the vertex data,
the face in Max only have the index infomation about the vertex and the visible infomation about the edge,so if you wanted export these infomation just like this:

TriObject * tri = NULL;
tri = (TriObject *) obj->ConvertToType(0, Class_ID(TRIOBJ_CLASS_ID, 0));
Mesh * mesh = &(tri->GetMesh());
::fprintf(m_fileStream, "BEGIN MESH NumVerts:<%d> NumFaces:<%d>\n",mesh->getNumVerts(),mesh->getNumFaces());

// Export the vertices
for (i = 0; i < mesh->getNumVerts(); i++)
vert = tm * mesh->verts;
::fprintf(m_fileStream, " vertex %d:<%f,%f,%f>\n", i, vert.x, vert.y, vert.z);

// export faces
for (i = 0; i < mesh->getNumFaces(); i++)
::fprintf(m_fileStream, " face %d -- verts:<%d,%d,%d> edgevis:<%d,%d,%d> smoothgrp:<0x%x> matid:<%d>\n", i,
mesh->faces.getEdgeVis(0) ? 1 : 0,
mesh->faces.getEdgeVis(1) ? 1 : 0,
mesh->faces.getEdgeVis(2) ? 1 : 0,

this is not all the code for export vertex and face,
i hope this can help you.

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!