Forum Groups
  All forums
    Help & Feedback
      Work in progress
      Finished Art
      Non-Max related

Maxunderground news unavailable

Sorting Face indexes according to a multi-material.
show user profile  Seyren
Alright, i'm having an issue i don't really know how to solve...

I'm coding my own exporter for a game engine i'm working on, and this is how the engine reads the textures from a multi-material mesh.

From Face 1 to 10 -> Use Texture 1
From Face 11 to 20 > Use Texture 2

Now the problem i have is that when i'm seting up a multi material, the face index is not sorted this way, leading up to:

From face 1 to 3 -> Use Texture 1
From Face 4 to 8 -> Use Texture 2
From Face 9 to 11 -> Use Texture 1

And so on, it repeats a lot of times, and this would not be practical for the engine if the mesh is too complex.

So my question is, is there any way to sort the vertex index or the face index in order to make all the faces from X to X have a corresponding material? I know it's kind of hard to ask for something like this, but i was wondering if a script or any feature would do this.

Thanks in advance :P
read 406 times
4/14/2016 7:34:04 PM (last edit: 4/14/2016 7:34:04 PM)
show user profile  Garp
Face indexing is dictated by the order in which the faces are created, not the material assignments.
You'd have to implement a secondary index and do the mapping through an array.

read 403 times
4/14/2016 8:41:05 PM (last edit: 4/14/2016 8:41:05 PM)
show user profile  Seyren
Do you think there could be an algorythim to recreate the mesh based of the material FACE ID's? that way it could solve the problem, a little bit costly maybe...
read 392 times
4/15/2016 1:27:56 AM (last edit: 4/15/2016 1:27:56 AM)
show user profile  Garp
I don't know what format you're exporting to but if the game engine determines the face indices by the ordering of their definitions, you just have to sort an array of indices by materialIDs. Once sorted, you would read the face definitions in the new order and export that.
Note that the definitions themselves do not change. Also don't forget to use the same ordering for whatever UV map(s) you're exporting, since there's a one-to-one correspondance between mesh faces and texture faces.

read 390 times
4/15/2016 1:58:24 AM (last edit: 4/15/2016 2:00:01 AM)
#Maxforums IRC
Open chat window