Sign in to follow this  
Raeldor

3ds max script texture export problem

Recommended Posts

Raeldor    254
I am trying to export my model using 3ds max maxscript, but I am finding that for a mapvert it can be attached to one OR MORE meshverts. This seems to go against what the documentation says. Does anyone know how I can find which meshvert belongs to a mapvert? Thanks

Share this post


Link to post
Share on other sites
bzroom    647


I dont know anything about the scripting language but it seems logical that you would think about it the other way around. While exporting your mesh points you'll have an index or pointer to the associated texture coordinate. Since a mesh point would only have 1 texture coordinate, where as the same texture coordinate could apply to many mesh points (per texture).

So consider if you would have asked:

Does anyone know how I can find which mapvert is associated with a meshvert?

Share this post


Link to post
Share on other sites
Teknofreek    331
Actually, that's not quite true. A mesh vertex in Max can have more than one texture coordinate. For that matter, it can have more than one normal, more than one vertex color, and so on. I don't have time to go into why, but here's what you need to know. The ONLY thing that has a one-to-one correlation is that for every mesh face, there is a matching map face. The indices of each face allows you to match them up.

So, what you need to do is loop through each mesh face and get the mesh vertices it uses. You can then get their position, normal, etc. Then, get each map face(one for each uv set), and get the map verts associated with that face. Now, for each triangle you will have three positions, normals, uv's, etc.

If you want to optimize the vertices, you can do so at the end. To do this, check to see if any verts have identical components(pos,normal,uv,etc) and then pull the duplicates out of the list and update your indices. I recommend that you DO NOT try to optimize your verts until the end...it will drive you mad if you do.

Good luck!

-John

Share this post


Link to post
Share on other sites
Raeldor    254
Quote:
Original post by Teknofreek
Actually, that's not quite true. A mesh vertex in Max can have more than one texture coordinate. For that matter, it can have more than one normal, more than one vertex color, and so on. I don't have time to go into why, but here's what you need to know. The ONLY thing that has a one-to-one correlation is that for every mesh face, there is a matching map face. The indices of each face allows you to match them up.

So, what you need to do is loop through each mesh face and get the mesh vertices it uses. You can then get their position, normal, etc. Then, get each map face(one for each uv set), and get the map verts associated with that face. Now, for each triangle you will have three positions, normals, uv's, etc.

If you want to optimize the vertices, you can do so at the end. To do this, check to see if any verts have identical components(pos,normal,uv,etc) and then pull the duplicates out of the list and update your indices. I recommend that you DO NOT try to optimize your verts until the end...it will drive you mad if you do.

Good luck!

-John


That's great info. Thanks for clearing up my confusion.

All the best.

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